mutation.go 1.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/apikey"
  14. "wechat-api/ent/batchmsg"
  15. "wechat-api/ent/category"
  16. "wechat-api/ent/chatrecords"
  17. "wechat-api/ent/chatsession"
  18. "wechat-api/ent/compapiasynctask"
  19. "wechat-api/ent/contact"
  20. "wechat-api/ent/contactfield"
  21. "wechat-api/ent/contactfieldtemplate"
  22. "wechat-api/ent/creditbalance"
  23. "wechat-api/ent/creditusage"
  24. "wechat-api/ent/custom_types"
  25. "wechat-api/ent/employee"
  26. "wechat-api/ent/employeeconfig"
  27. "wechat-api/ent/label"
  28. "wechat-api/ent/labellog"
  29. "wechat-api/ent/labelrelationship"
  30. "wechat-api/ent/labeltagging"
  31. "wechat-api/ent/message"
  32. "wechat-api/ent/messagerecords"
  33. "wechat-api/ent/msg"
  34. "wechat-api/ent/payrecharge"
  35. "wechat-api/ent/predicate"
  36. "wechat-api/ent/server"
  37. "wechat-api/ent/sopnode"
  38. "wechat-api/ent/sopstage"
  39. "wechat-api/ent/soptask"
  40. "wechat-api/ent/token"
  41. "wechat-api/ent/tutorial"
  42. "wechat-api/ent/usagedetail"
  43. "wechat-api/ent/usagestatisticday"
  44. "wechat-api/ent/usagestatistichour"
  45. "wechat-api/ent/usagestatisticmonth"
  46. "wechat-api/ent/usagetotal"
  47. "wechat-api/ent/whatsapp"
  48. "wechat-api/ent/whatsappchannel"
  49. "wechat-api/ent/workexperience"
  50. "wechat-api/ent/wpchatroom"
  51. "wechat-api/ent/wpchatroommember"
  52. "wechat-api/ent/wx"
  53. "wechat-api/ent/wxcard"
  54. "wechat-api/ent/wxcarduser"
  55. "wechat-api/ent/wxcardvisit"
  56. "wechat-api/ent/xunji"
  57. "wechat-api/ent/xunjiservice"
  58. "entgo.io/ent"
  59. "entgo.io/ent/dialect/sql"
  60. )
  61. const (
  62. // Operation types.
  63. OpCreate = ent.OpCreate
  64. OpDelete = ent.OpDelete
  65. OpDeleteOne = ent.OpDeleteOne
  66. OpUpdate = ent.OpUpdate
  67. OpUpdateOne = ent.OpUpdateOne
  68. // Node types.
  69. TypeAgent = "Agent"
  70. TypeAgentBase = "AgentBase"
  71. TypeAliyunAvatar = "AliyunAvatar"
  72. TypeAllocAgent = "AllocAgent"
  73. TypeApiKey = "ApiKey"
  74. TypeBatchMsg = "BatchMsg"
  75. TypeCategory = "Category"
  76. TypeChatRecords = "ChatRecords"
  77. TypeChatSession = "ChatSession"
  78. TypeCompapiAsynctask = "CompapiAsynctask"
  79. TypeContact = "Contact"
  80. TypeContactField = "ContactField"
  81. TypeContactFieldTemplate = "ContactFieldTemplate"
  82. TypeCreditBalance = "CreditBalance"
  83. TypeCreditUsage = "CreditUsage"
  84. TypeEmployee = "Employee"
  85. TypeEmployeeConfig = "EmployeeConfig"
  86. TypeLabel = "Label"
  87. TypeLabelLog = "LabelLog"
  88. TypeLabelRelationship = "LabelRelationship"
  89. TypeLabelTagging = "LabelTagging"
  90. TypeMessage = "Message"
  91. TypeMessageRecords = "MessageRecords"
  92. TypeMsg = "Msg"
  93. TypePayRecharge = "PayRecharge"
  94. TypeServer = "Server"
  95. TypeSopNode = "SopNode"
  96. TypeSopStage = "SopStage"
  97. TypeSopTask = "SopTask"
  98. TypeToken = "Token"
  99. TypeTutorial = "Tutorial"
  100. TypeUsageDetail = "UsageDetail"
  101. TypeUsageStatisticDay = "UsageStatisticDay"
  102. TypeUsageStatisticHour = "UsageStatisticHour"
  103. TypeUsageStatisticMonth = "UsageStatisticMonth"
  104. TypeUsageTotal = "UsageTotal"
  105. TypeWhatsapp = "Whatsapp"
  106. TypeWhatsappChannel = "WhatsappChannel"
  107. TypeWorkExperience = "WorkExperience"
  108. TypeWpChatroom = "WpChatroom"
  109. TypeWpChatroomMember = "WpChatroomMember"
  110. TypeWx = "Wx"
  111. TypeWxCard = "WxCard"
  112. TypeWxCardUser = "WxCardUser"
  113. TypeWxCardVisit = "WxCardVisit"
  114. TypeXunji = "Xunji"
  115. TypeXunjiService = "XunjiService"
  116. )
  117. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  118. type AgentMutation struct {
  119. config
  120. op Op
  121. typ string
  122. id *uint64
  123. created_at *time.Time
  124. updated_at *time.Time
  125. deleted_at *time.Time
  126. name *string
  127. role *string
  128. status *int
  129. addstatus *int
  130. background *string
  131. examples *string
  132. organization_id *uint64
  133. addorganization_id *int64
  134. dataset_id *string
  135. collection_id *string
  136. model *string
  137. api_base *string
  138. api_key *string
  139. _type *int
  140. add_type *int
  141. clearedFields map[string]struct{}
  142. wx_agent map[uint64]struct{}
  143. removedwx_agent map[uint64]struct{}
  144. clearedwx_agent bool
  145. token_agent map[uint64]struct{}
  146. removedtoken_agent map[uint64]struct{}
  147. clearedtoken_agent bool
  148. wa_agent map[uint64]struct{}
  149. removedwa_agent map[uint64]struct{}
  150. clearedwa_agent bool
  151. xjs_agent map[uint64]struct{}
  152. removedxjs_agent map[uint64]struct{}
  153. clearedxjs_agent bool
  154. key_agent map[uint64]struct{}
  155. removedkey_agent map[uint64]struct{}
  156. clearedkey_agent bool
  157. done bool
  158. oldValue func(context.Context) (*Agent, error)
  159. predicates []predicate.Agent
  160. }
  161. var _ ent.Mutation = (*AgentMutation)(nil)
  162. // agentOption allows management of the mutation configuration using functional options.
  163. type agentOption func(*AgentMutation)
  164. // newAgentMutation creates new mutation for the Agent entity.
  165. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  166. m := &AgentMutation{
  167. config: c,
  168. op: op,
  169. typ: TypeAgent,
  170. clearedFields: make(map[string]struct{}),
  171. }
  172. for _, opt := range opts {
  173. opt(m)
  174. }
  175. return m
  176. }
  177. // withAgentID sets the ID field of the mutation.
  178. func withAgentID(id uint64) agentOption {
  179. return func(m *AgentMutation) {
  180. var (
  181. err error
  182. once sync.Once
  183. value *Agent
  184. )
  185. m.oldValue = func(ctx context.Context) (*Agent, error) {
  186. once.Do(func() {
  187. if m.done {
  188. err = errors.New("querying old values post mutation is not allowed")
  189. } else {
  190. value, err = m.Client().Agent.Get(ctx, id)
  191. }
  192. })
  193. return value, err
  194. }
  195. m.id = &id
  196. }
  197. }
  198. // withAgent sets the old Agent of the mutation.
  199. func withAgent(node *Agent) agentOption {
  200. return func(m *AgentMutation) {
  201. m.oldValue = func(context.Context) (*Agent, error) {
  202. return node, nil
  203. }
  204. m.id = &node.ID
  205. }
  206. }
  207. // Client returns a new `ent.Client` from the mutation. If the mutation was
  208. // executed in a transaction (ent.Tx), a transactional client is returned.
  209. func (m AgentMutation) Client() *Client {
  210. client := &Client{config: m.config}
  211. client.init()
  212. return client
  213. }
  214. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  215. // it returns an error otherwise.
  216. func (m AgentMutation) Tx() (*Tx, error) {
  217. if _, ok := m.driver.(*txDriver); !ok {
  218. return nil, errors.New("ent: mutation is not running in a transaction")
  219. }
  220. tx := &Tx{config: m.config}
  221. tx.init()
  222. return tx, nil
  223. }
  224. // SetID sets the value of the id field. Note that this
  225. // operation is only accepted on creation of Agent entities.
  226. func (m *AgentMutation) SetID(id uint64) {
  227. m.id = &id
  228. }
  229. // ID returns the ID value in the mutation. Note that the ID is only available
  230. // if it was provided to the builder or after it was returned from the database.
  231. func (m *AgentMutation) ID() (id uint64, exists bool) {
  232. if m.id == nil {
  233. return
  234. }
  235. return *m.id, true
  236. }
  237. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  238. // That means, if the mutation is applied within a transaction with an isolation level such
  239. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  240. // or updated by the mutation.
  241. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  242. switch {
  243. case m.op.Is(OpUpdateOne | OpDeleteOne):
  244. id, exists := m.ID()
  245. if exists {
  246. return []uint64{id}, nil
  247. }
  248. fallthrough
  249. case m.op.Is(OpUpdate | OpDelete):
  250. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  251. default:
  252. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  253. }
  254. }
  255. // SetCreatedAt sets the "created_at" field.
  256. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  257. m.created_at = &t
  258. }
  259. // CreatedAt returns the value of the "created_at" field in the mutation.
  260. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  261. v := m.created_at
  262. if v == nil {
  263. return
  264. }
  265. return *v, true
  266. }
  267. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  268. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  270. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  271. if !m.op.Is(OpUpdateOne) {
  272. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  273. }
  274. if m.id == nil || m.oldValue == nil {
  275. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  276. }
  277. oldValue, err := m.oldValue(ctx)
  278. if err != nil {
  279. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  280. }
  281. return oldValue.CreatedAt, nil
  282. }
  283. // ResetCreatedAt resets all changes to the "created_at" field.
  284. func (m *AgentMutation) ResetCreatedAt() {
  285. m.created_at = nil
  286. }
  287. // SetUpdatedAt sets the "updated_at" field.
  288. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  289. m.updated_at = &t
  290. }
  291. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  292. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  293. v := m.updated_at
  294. if v == nil {
  295. return
  296. }
  297. return *v, true
  298. }
  299. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  300. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  302. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  303. if !m.op.Is(OpUpdateOne) {
  304. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  305. }
  306. if m.id == nil || m.oldValue == nil {
  307. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  308. }
  309. oldValue, err := m.oldValue(ctx)
  310. if err != nil {
  311. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  312. }
  313. return oldValue.UpdatedAt, nil
  314. }
  315. // ResetUpdatedAt resets all changes to the "updated_at" field.
  316. func (m *AgentMutation) ResetUpdatedAt() {
  317. m.updated_at = nil
  318. }
  319. // SetDeletedAt sets the "deleted_at" field.
  320. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  321. m.deleted_at = &t
  322. }
  323. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  324. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  325. v := m.deleted_at
  326. if v == nil {
  327. return
  328. }
  329. return *v, true
  330. }
  331. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  332. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  334. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  335. if !m.op.Is(OpUpdateOne) {
  336. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  337. }
  338. if m.id == nil || m.oldValue == nil {
  339. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  340. }
  341. oldValue, err := m.oldValue(ctx)
  342. if err != nil {
  343. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  344. }
  345. return oldValue.DeletedAt, nil
  346. }
  347. // ClearDeletedAt clears the value of the "deleted_at" field.
  348. func (m *AgentMutation) ClearDeletedAt() {
  349. m.deleted_at = nil
  350. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  351. }
  352. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  353. func (m *AgentMutation) DeletedAtCleared() bool {
  354. _, ok := m.clearedFields[agent.FieldDeletedAt]
  355. return ok
  356. }
  357. // ResetDeletedAt resets all changes to the "deleted_at" field.
  358. func (m *AgentMutation) ResetDeletedAt() {
  359. m.deleted_at = nil
  360. delete(m.clearedFields, agent.FieldDeletedAt)
  361. }
  362. // SetName sets the "name" field.
  363. func (m *AgentMutation) SetName(s string) {
  364. m.name = &s
  365. }
  366. // Name returns the value of the "name" field in the mutation.
  367. func (m *AgentMutation) Name() (r string, exists bool) {
  368. v := m.name
  369. if v == nil {
  370. return
  371. }
  372. return *v, true
  373. }
  374. // OldName returns the old "name" field's value of the Agent entity.
  375. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  377. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  378. if !m.op.Is(OpUpdateOne) {
  379. return v, errors.New("OldName is only allowed on UpdateOne operations")
  380. }
  381. if m.id == nil || m.oldValue == nil {
  382. return v, errors.New("OldName requires an ID field in the mutation")
  383. }
  384. oldValue, err := m.oldValue(ctx)
  385. if err != nil {
  386. return v, fmt.Errorf("querying old value for OldName: %w", err)
  387. }
  388. return oldValue.Name, nil
  389. }
  390. // ResetName resets all changes to the "name" field.
  391. func (m *AgentMutation) ResetName() {
  392. m.name = nil
  393. }
  394. // SetRole sets the "role" field.
  395. func (m *AgentMutation) SetRole(s string) {
  396. m.role = &s
  397. }
  398. // Role returns the value of the "role" field in the mutation.
  399. func (m *AgentMutation) Role() (r string, exists bool) {
  400. v := m.role
  401. if v == nil {
  402. return
  403. }
  404. return *v, true
  405. }
  406. // OldRole returns the old "role" field's value of the Agent entity.
  407. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  409. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  410. if !m.op.Is(OpUpdateOne) {
  411. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  412. }
  413. if m.id == nil || m.oldValue == nil {
  414. return v, errors.New("OldRole requires an ID field in the mutation")
  415. }
  416. oldValue, err := m.oldValue(ctx)
  417. if err != nil {
  418. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  419. }
  420. return oldValue.Role, nil
  421. }
  422. // ClearRole clears the value of the "role" field.
  423. func (m *AgentMutation) ClearRole() {
  424. m.role = nil
  425. m.clearedFields[agent.FieldRole] = struct{}{}
  426. }
  427. // RoleCleared returns if the "role" field was cleared in this mutation.
  428. func (m *AgentMutation) RoleCleared() bool {
  429. _, ok := m.clearedFields[agent.FieldRole]
  430. return ok
  431. }
  432. // ResetRole resets all changes to the "role" field.
  433. func (m *AgentMutation) ResetRole() {
  434. m.role = nil
  435. delete(m.clearedFields, agent.FieldRole)
  436. }
  437. // SetStatus sets the "status" field.
  438. func (m *AgentMutation) SetStatus(i int) {
  439. m.status = &i
  440. m.addstatus = nil
  441. }
  442. // Status returns the value of the "status" field in the mutation.
  443. func (m *AgentMutation) Status() (r int, exists bool) {
  444. v := m.status
  445. if v == nil {
  446. return
  447. }
  448. return *v, true
  449. }
  450. // OldStatus returns the old "status" field's value of the Agent entity.
  451. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  453. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  454. if !m.op.Is(OpUpdateOne) {
  455. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  456. }
  457. if m.id == nil || m.oldValue == nil {
  458. return v, errors.New("OldStatus requires an ID field in the mutation")
  459. }
  460. oldValue, err := m.oldValue(ctx)
  461. if err != nil {
  462. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  463. }
  464. return oldValue.Status, nil
  465. }
  466. // AddStatus adds i to the "status" field.
  467. func (m *AgentMutation) AddStatus(i int) {
  468. if m.addstatus != nil {
  469. *m.addstatus += i
  470. } else {
  471. m.addstatus = &i
  472. }
  473. }
  474. // AddedStatus returns the value that was added to the "status" field in this mutation.
  475. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  476. v := m.addstatus
  477. if v == nil {
  478. return
  479. }
  480. return *v, true
  481. }
  482. // ClearStatus clears the value of the "status" field.
  483. func (m *AgentMutation) ClearStatus() {
  484. m.status = nil
  485. m.addstatus = nil
  486. m.clearedFields[agent.FieldStatus] = struct{}{}
  487. }
  488. // StatusCleared returns if the "status" field was cleared in this mutation.
  489. func (m *AgentMutation) StatusCleared() bool {
  490. _, ok := m.clearedFields[agent.FieldStatus]
  491. return ok
  492. }
  493. // ResetStatus resets all changes to the "status" field.
  494. func (m *AgentMutation) ResetStatus() {
  495. m.status = nil
  496. m.addstatus = nil
  497. delete(m.clearedFields, agent.FieldStatus)
  498. }
  499. // SetBackground sets the "background" field.
  500. func (m *AgentMutation) SetBackground(s string) {
  501. m.background = &s
  502. }
  503. // Background returns the value of the "background" field in the mutation.
  504. func (m *AgentMutation) Background() (r string, exists bool) {
  505. v := m.background
  506. if v == nil {
  507. return
  508. }
  509. return *v, true
  510. }
  511. // OldBackground returns the old "background" field's value of the Agent entity.
  512. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  514. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  515. if !m.op.Is(OpUpdateOne) {
  516. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  517. }
  518. if m.id == nil || m.oldValue == nil {
  519. return v, errors.New("OldBackground requires an ID field in the mutation")
  520. }
  521. oldValue, err := m.oldValue(ctx)
  522. if err != nil {
  523. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  524. }
  525. return oldValue.Background, nil
  526. }
  527. // ClearBackground clears the value of the "background" field.
  528. func (m *AgentMutation) ClearBackground() {
  529. m.background = nil
  530. m.clearedFields[agent.FieldBackground] = struct{}{}
  531. }
  532. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  533. func (m *AgentMutation) BackgroundCleared() bool {
  534. _, ok := m.clearedFields[agent.FieldBackground]
  535. return ok
  536. }
  537. // ResetBackground resets all changes to the "background" field.
  538. func (m *AgentMutation) ResetBackground() {
  539. m.background = nil
  540. delete(m.clearedFields, agent.FieldBackground)
  541. }
  542. // SetExamples sets the "examples" field.
  543. func (m *AgentMutation) SetExamples(s string) {
  544. m.examples = &s
  545. }
  546. // Examples returns the value of the "examples" field in the mutation.
  547. func (m *AgentMutation) Examples() (r string, exists bool) {
  548. v := m.examples
  549. if v == nil {
  550. return
  551. }
  552. return *v, true
  553. }
  554. // OldExamples returns the old "examples" field's value of the Agent entity.
  555. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  557. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  558. if !m.op.Is(OpUpdateOne) {
  559. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  560. }
  561. if m.id == nil || m.oldValue == nil {
  562. return v, errors.New("OldExamples requires an ID field in the mutation")
  563. }
  564. oldValue, err := m.oldValue(ctx)
  565. if err != nil {
  566. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  567. }
  568. return oldValue.Examples, nil
  569. }
  570. // ClearExamples clears the value of the "examples" field.
  571. func (m *AgentMutation) ClearExamples() {
  572. m.examples = nil
  573. m.clearedFields[agent.FieldExamples] = struct{}{}
  574. }
  575. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  576. func (m *AgentMutation) ExamplesCleared() bool {
  577. _, ok := m.clearedFields[agent.FieldExamples]
  578. return ok
  579. }
  580. // ResetExamples resets all changes to the "examples" field.
  581. func (m *AgentMutation) ResetExamples() {
  582. m.examples = nil
  583. delete(m.clearedFields, agent.FieldExamples)
  584. }
  585. // SetOrganizationID sets the "organization_id" field.
  586. func (m *AgentMutation) SetOrganizationID(u uint64) {
  587. m.organization_id = &u
  588. m.addorganization_id = nil
  589. }
  590. // OrganizationID returns the value of the "organization_id" field in the mutation.
  591. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  592. v := m.organization_id
  593. if v == nil {
  594. return
  595. }
  596. return *v, true
  597. }
  598. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  599. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  601. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  602. if !m.op.Is(OpUpdateOne) {
  603. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  604. }
  605. if m.id == nil || m.oldValue == nil {
  606. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  607. }
  608. oldValue, err := m.oldValue(ctx)
  609. if err != nil {
  610. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  611. }
  612. return oldValue.OrganizationID, nil
  613. }
  614. // AddOrganizationID adds u to the "organization_id" field.
  615. func (m *AgentMutation) AddOrganizationID(u int64) {
  616. if m.addorganization_id != nil {
  617. *m.addorganization_id += u
  618. } else {
  619. m.addorganization_id = &u
  620. }
  621. }
  622. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  623. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  624. v := m.addorganization_id
  625. if v == nil {
  626. return
  627. }
  628. return *v, true
  629. }
  630. // ResetOrganizationID resets all changes to the "organization_id" field.
  631. func (m *AgentMutation) ResetOrganizationID() {
  632. m.organization_id = nil
  633. m.addorganization_id = nil
  634. }
  635. // SetDatasetID sets the "dataset_id" field.
  636. func (m *AgentMutation) SetDatasetID(s string) {
  637. m.dataset_id = &s
  638. }
  639. // DatasetID returns the value of the "dataset_id" field in the mutation.
  640. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  641. v := m.dataset_id
  642. if v == nil {
  643. return
  644. }
  645. return *v, true
  646. }
  647. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  648. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  650. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  651. if !m.op.Is(OpUpdateOne) {
  652. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  653. }
  654. if m.id == nil || m.oldValue == nil {
  655. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  656. }
  657. oldValue, err := m.oldValue(ctx)
  658. if err != nil {
  659. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  660. }
  661. return oldValue.DatasetID, nil
  662. }
  663. // ResetDatasetID resets all changes to the "dataset_id" field.
  664. func (m *AgentMutation) ResetDatasetID() {
  665. m.dataset_id = nil
  666. }
  667. // SetCollectionID sets the "collection_id" field.
  668. func (m *AgentMutation) SetCollectionID(s string) {
  669. m.collection_id = &s
  670. }
  671. // CollectionID returns the value of the "collection_id" field in the mutation.
  672. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  673. v := m.collection_id
  674. if v == nil {
  675. return
  676. }
  677. return *v, true
  678. }
  679. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  680. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  682. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  683. if !m.op.Is(OpUpdateOne) {
  684. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  685. }
  686. if m.id == nil || m.oldValue == nil {
  687. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  688. }
  689. oldValue, err := m.oldValue(ctx)
  690. if err != nil {
  691. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  692. }
  693. return oldValue.CollectionID, nil
  694. }
  695. // ResetCollectionID resets all changes to the "collection_id" field.
  696. func (m *AgentMutation) ResetCollectionID() {
  697. m.collection_id = nil
  698. }
  699. // SetModel sets the "model" field.
  700. func (m *AgentMutation) SetModel(s string) {
  701. m.model = &s
  702. }
  703. // Model returns the value of the "model" field in the mutation.
  704. func (m *AgentMutation) Model() (r string, exists bool) {
  705. v := m.model
  706. if v == nil {
  707. return
  708. }
  709. return *v, true
  710. }
  711. // OldModel returns the old "model" field's value of the Agent entity.
  712. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  714. func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
  715. if !m.op.Is(OpUpdateOne) {
  716. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  717. }
  718. if m.id == nil || m.oldValue == nil {
  719. return v, errors.New("OldModel requires an ID field in the mutation")
  720. }
  721. oldValue, err := m.oldValue(ctx)
  722. if err != nil {
  723. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  724. }
  725. return oldValue.Model, nil
  726. }
  727. // ClearModel clears the value of the "model" field.
  728. func (m *AgentMutation) ClearModel() {
  729. m.model = nil
  730. m.clearedFields[agent.FieldModel] = struct{}{}
  731. }
  732. // ModelCleared returns if the "model" field was cleared in this mutation.
  733. func (m *AgentMutation) ModelCleared() bool {
  734. _, ok := m.clearedFields[agent.FieldModel]
  735. return ok
  736. }
  737. // ResetModel resets all changes to the "model" field.
  738. func (m *AgentMutation) ResetModel() {
  739. m.model = nil
  740. delete(m.clearedFields, agent.FieldModel)
  741. }
  742. // SetAPIBase sets the "api_base" field.
  743. func (m *AgentMutation) SetAPIBase(s string) {
  744. m.api_base = &s
  745. }
  746. // APIBase returns the value of the "api_base" field in the mutation.
  747. func (m *AgentMutation) APIBase() (r string, exists bool) {
  748. v := m.api_base
  749. if v == nil {
  750. return
  751. }
  752. return *v, true
  753. }
  754. // OldAPIBase returns the old "api_base" field's value of the Agent entity.
  755. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  757. func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  758. if !m.op.Is(OpUpdateOne) {
  759. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  760. }
  761. if m.id == nil || m.oldValue == nil {
  762. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  763. }
  764. oldValue, err := m.oldValue(ctx)
  765. if err != nil {
  766. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  767. }
  768. return oldValue.APIBase, nil
  769. }
  770. // ClearAPIBase clears the value of the "api_base" field.
  771. func (m *AgentMutation) ClearAPIBase() {
  772. m.api_base = nil
  773. m.clearedFields[agent.FieldAPIBase] = struct{}{}
  774. }
  775. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  776. func (m *AgentMutation) APIBaseCleared() bool {
  777. _, ok := m.clearedFields[agent.FieldAPIBase]
  778. return ok
  779. }
  780. // ResetAPIBase resets all changes to the "api_base" field.
  781. func (m *AgentMutation) ResetAPIBase() {
  782. m.api_base = nil
  783. delete(m.clearedFields, agent.FieldAPIBase)
  784. }
  785. // SetAPIKey sets the "api_key" field.
  786. func (m *AgentMutation) SetAPIKey(s string) {
  787. m.api_key = &s
  788. }
  789. // APIKey returns the value of the "api_key" field in the mutation.
  790. func (m *AgentMutation) APIKey() (r string, exists bool) {
  791. v := m.api_key
  792. if v == nil {
  793. return
  794. }
  795. return *v, true
  796. }
  797. // OldAPIKey returns the old "api_key" field's value of the Agent entity.
  798. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  800. func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  801. if !m.op.Is(OpUpdateOne) {
  802. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  803. }
  804. if m.id == nil || m.oldValue == nil {
  805. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  806. }
  807. oldValue, err := m.oldValue(ctx)
  808. if err != nil {
  809. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  810. }
  811. return oldValue.APIKey, nil
  812. }
  813. // ClearAPIKey clears the value of the "api_key" field.
  814. func (m *AgentMutation) ClearAPIKey() {
  815. m.api_key = nil
  816. m.clearedFields[agent.FieldAPIKey] = struct{}{}
  817. }
  818. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  819. func (m *AgentMutation) APIKeyCleared() bool {
  820. _, ok := m.clearedFields[agent.FieldAPIKey]
  821. return ok
  822. }
  823. // ResetAPIKey resets all changes to the "api_key" field.
  824. func (m *AgentMutation) ResetAPIKey() {
  825. m.api_key = nil
  826. delete(m.clearedFields, agent.FieldAPIKey)
  827. }
  828. // SetType sets the "type" field.
  829. func (m *AgentMutation) SetType(i int) {
  830. m._type = &i
  831. m.add_type = nil
  832. }
  833. // GetType returns the value of the "type" field in the mutation.
  834. func (m *AgentMutation) GetType() (r int, exists bool) {
  835. v := m._type
  836. if v == nil {
  837. return
  838. }
  839. return *v, true
  840. }
  841. // OldType returns the old "type" field's value of the Agent entity.
  842. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  844. func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
  845. if !m.op.Is(OpUpdateOne) {
  846. return v, errors.New("OldType is only allowed on UpdateOne operations")
  847. }
  848. if m.id == nil || m.oldValue == nil {
  849. return v, errors.New("OldType requires an ID field in the mutation")
  850. }
  851. oldValue, err := m.oldValue(ctx)
  852. if err != nil {
  853. return v, fmt.Errorf("querying old value for OldType: %w", err)
  854. }
  855. return oldValue.Type, nil
  856. }
  857. // AddType adds i to the "type" field.
  858. func (m *AgentMutation) AddType(i int) {
  859. if m.add_type != nil {
  860. *m.add_type += i
  861. } else {
  862. m.add_type = &i
  863. }
  864. }
  865. // AddedType returns the value that was added to the "type" field in this mutation.
  866. func (m *AgentMutation) AddedType() (r int, exists bool) {
  867. v := m.add_type
  868. if v == nil {
  869. return
  870. }
  871. return *v, true
  872. }
  873. // ClearType clears the value of the "type" field.
  874. func (m *AgentMutation) ClearType() {
  875. m._type = nil
  876. m.add_type = nil
  877. m.clearedFields[agent.FieldType] = struct{}{}
  878. }
  879. // TypeCleared returns if the "type" field was cleared in this mutation.
  880. func (m *AgentMutation) TypeCleared() bool {
  881. _, ok := m.clearedFields[agent.FieldType]
  882. return ok
  883. }
  884. // ResetType resets all changes to the "type" field.
  885. func (m *AgentMutation) ResetType() {
  886. m._type = nil
  887. m.add_type = nil
  888. delete(m.clearedFields, agent.FieldType)
  889. }
  890. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  891. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  892. if m.wx_agent == nil {
  893. m.wx_agent = make(map[uint64]struct{})
  894. }
  895. for i := range ids {
  896. m.wx_agent[ids[i]] = struct{}{}
  897. }
  898. }
  899. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  900. func (m *AgentMutation) ClearWxAgent() {
  901. m.clearedwx_agent = true
  902. }
  903. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  904. func (m *AgentMutation) WxAgentCleared() bool {
  905. return m.clearedwx_agent
  906. }
  907. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  908. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  909. if m.removedwx_agent == nil {
  910. m.removedwx_agent = make(map[uint64]struct{})
  911. }
  912. for i := range ids {
  913. delete(m.wx_agent, ids[i])
  914. m.removedwx_agent[ids[i]] = struct{}{}
  915. }
  916. }
  917. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  918. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  919. for id := range m.removedwx_agent {
  920. ids = append(ids, id)
  921. }
  922. return
  923. }
  924. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  925. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  926. for id := range m.wx_agent {
  927. ids = append(ids, id)
  928. }
  929. return
  930. }
  931. // ResetWxAgent resets all changes to the "wx_agent" edge.
  932. func (m *AgentMutation) ResetWxAgent() {
  933. m.wx_agent = nil
  934. m.clearedwx_agent = false
  935. m.removedwx_agent = nil
  936. }
  937. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  938. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  939. if m.token_agent == nil {
  940. m.token_agent = make(map[uint64]struct{})
  941. }
  942. for i := range ids {
  943. m.token_agent[ids[i]] = struct{}{}
  944. }
  945. }
  946. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  947. func (m *AgentMutation) ClearTokenAgent() {
  948. m.clearedtoken_agent = true
  949. }
  950. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  951. func (m *AgentMutation) TokenAgentCleared() bool {
  952. return m.clearedtoken_agent
  953. }
  954. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  955. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  956. if m.removedtoken_agent == nil {
  957. m.removedtoken_agent = make(map[uint64]struct{})
  958. }
  959. for i := range ids {
  960. delete(m.token_agent, ids[i])
  961. m.removedtoken_agent[ids[i]] = struct{}{}
  962. }
  963. }
  964. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  965. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  966. for id := range m.removedtoken_agent {
  967. ids = append(ids, id)
  968. }
  969. return
  970. }
  971. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  972. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  973. for id := range m.token_agent {
  974. ids = append(ids, id)
  975. }
  976. return
  977. }
  978. // ResetTokenAgent resets all changes to the "token_agent" edge.
  979. func (m *AgentMutation) ResetTokenAgent() {
  980. m.token_agent = nil
  981. m.clearedtoken_agent = false
  982. m.removedtoken_agent = nil
  983. }
  984. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  985. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  986. if m.wa_agent == nil {
  987. m.wa_agent = make(map[uint64]struct{})
  988. }
  989. for i := range ids {
  990. m.wa_agent[ids[i]] = struct{}{}
  991. }
  992. }
  993. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  994. func (m *AgentMutation) ClearWaAgent() {
  995. m.clearedwa_agent = true
  996. }
  997. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  998. func (m *AgentMutation) WaAgentCleared() bool {
  999. return m.clearedwa_agent
  1000. }
  1001. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  1002. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  1003. if m.removedwa_agent == nil {
  1004. m.removedwa_agent = make(map[uint64]struct{})
  1005. }
  1006. for i := range ids {
  1007. delete(m.wa_agent, ids[i])
  1008. m.removedwa_agent[ids[i]] = struct{}{}
  1009. }
  1010. }
  1011. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  1012. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  1013. for id := range m.removedwa_agent {
  1014. ids = append(ids, id)
  1015. }
  1016. return
  1017. }
  1018. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  1019. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  1020. for id := range m.wa_agent {
  1021. ids = append(ids, id)
  1022. }
  1023. return
  1024. }
  1025. // ResetWaAgent resets all changes to the "wa_agent" edge.
  1026. func (m *AgentMutation) ResetWaAgent() {
  1027. m.wa_agent = nil
  1028. m.clearedwa_agent = false
  1029. m.removedwa_agent = nil
  1030. }
  1031. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  1032. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  1033. if m.xjs_agent == nil {
  1034. m.xjs_agent = make(map[uint64]struct{})
  1035. }
  1036. for i := range ids {
  1037. m.xjs_agent[ids[i]] = struct{}{}
  1038. }
  1039. }
  1040. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  1041. func (m *AgentMutation) ClearXjsAgent() {
  1042. m.clearedxjs_agent = true
  1043. }
  1044. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  1045. func (m *AgentMutation) XjsAgentCleared() bool {
  1046. return m.clearedxjs_agent
  1047. }
  1048. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  1049. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  1050. if m.removedxjs_agent == nil {
  1051. m.removedxjs_agent = make(map[uint64]struct{})
  1052. }
  1053. for i := range ids {
  1054. delete(m.xjs_agent, ids[i])
  1055. m.removedxjs_agent[ids[i]] = struct{}{}
  1056. }
  1057. }
  1058. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  1059. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  1060. for id := range m.removedxjs_agent {
  1061. ids = append(ids, id)
  1062. }
  1063. return
  1064. }
  1065. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  1066. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  1067. for id := range m.xjs_agent {
  1068. ids = append(ids, id)
  1069. }
  1070. return
  1071. }
  1072. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  1073. func (m *AgentMutation) ResetXjsAgent() {
  1074. m.xjs_agent = nil
  1075. m.clearedxjs_agent = false
  1076. m.removedxjs_agent = nil
  1077. }
  1078. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  1079. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  1080. if m.key_agent == nil {
  1081. m.key_agent = make(map[uint64]struct{})
  1082. }
  1083. for i := range ids {
  1084. m.key_agent[ids[i]] = struct{}{}
  1085. }
  1086. }
  1087. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  1088. func (m *AgentMutation) ClearKeyAgent() {
  1089. m.clearedkey_agent = true
  1090. }
  1091. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  1092. func (m *AgentMutation) KeyAgentCleared() bool {
  1093. return m.clearedkey_agent
  1094. }
  1095. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  1096. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  1097. if m.removedkey_agent == nil {
  1098. m.removedkey_agent = make(map[uint64]struct{})
  1099. }
  1100. for i := range ids {
  1101. delete(m.key_agent, ids[i])
  1102. m.removedkey_agent[ids[i]] = struct{}{}
  1103. }
  1104. }
  1105. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  1106. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  1107. for id := range m.removedkey_agent {
  1108. ids = append(ids, id)
  1109. }
  1110. return
  1111. }
  1112. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  1113. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  1114. for id := range m.key_agent {
  1115. ids = append(ids, id)
  1116. }
  1117. return
  1118. }
  1119. // ResetKeyAgent resets all changes to the "key_agent" edge.
  1120. func (m *AgentMutation) ResetKeyAgent() {
  1121. m.key_agent = nil
  1122. m.clearedkey_agent = false
  1123. m.removedkey_agent = nil
  1124. }
  1125. // Where appends a list predicates to the AgentMutation builder.
  1126. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  1127. m.predicates = append(m.predicates, ps...)
  1128. }
  1129. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  1130. // users can use type-assertion to append predicates that do not depend on any generated package.
  1131. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  1132. p := make([]predicate.Agent, len(ps))
  1133. for i := range ps {
  1134. p[i] = ps[i]
  1135. }
  1136. m.Where(p...)
  1137. }
  1138. // Op returns the operation name.
  1139. func (m *AgentMutation) Op() Op {
  1140. return m.op
  1141. }
  1142. // SetOp allows setting the mutation operation.
  1143. func (m *AgentMutation) SetOp(op Op) {
  1144. m.op = op
  1145. }
  1146. // Type returns the node type of this mutation (Agent).
  1147. func (m *AgentMutation) Type() string {
  1148. return m.typ
  1149. }
  1150. // Fields returns all fields that were changed during this mutation. Note that in
  1151. // order to get all numeric fields that were incremented/decremented, call
  1152. // AddedFields().
  1153. func (m *AgentMutation) Fields() []string {
  1154. fields := make([]string, 0, 15)
  1155. if m.created_at != nil {
  1156. fields = append(fields, agent.FieldCreatedAt)
  1157. }
  1158. if m.updated_at != nil {
  1159. fields = append(fields, agent.FieldUpdatedAt)
  1160. }
  1161. if m.deleted_at != nil {
  1162. fields = append(fields, agent.FieldDeletedAt)
  1163. }
  1164. if m.name != nil {
  1165. fields = append(fields, agent.FieldName)
  1166. }
  1167. if m.role != nil {
  1168. fields = append(fields, agent.FieldRole)
  1169. }
  1170. if m.status != nil {
  1171. fields = append(fields, agent.FieldStatus)
  1172. }
  1173. if m.background != nil {
  1174. fields = append(fields, agent.FieldBackground)
  1175. }
  1176. if m.examples != nil {
  1177. fields = append(fields, agent.FieldExamples)
  1178. }
  1179. if m.organization_id != nil {
  1180. fields = append(fields, agent.FieldOrganizationID)
  1181. }
  1182. if m.dataset_id != nil {
  1183. fields = append(fields, agent.FieldDatasetID)
  1184. }
  1185. if m.collection_id != nil {
  1186. fields = append(fields, agent.FieldCollectionID)
  1187. }
  1188. if m.model != nil {
  1189. fields = append(fields, agent.FieldModel)
  1190. }
  1191. if m.api_base != nil {
  1192. fields = append(fields, agent.FieldAPIBase)
  1193. }
  1194. if m.api_key != nil {
  1195. fields = append(fields, agent.FieldAPIKey)
  1196. }
  1197. if m._type != nil {
  1198. fields = append(fields, agent.FieldType)
  1199. }
  1200. return fields
  1201. }
  1202. // Field returns the value of a field with the given name. The second boolean
  1203. // return value indicates that this field was not set, or was not defined in the
  1204. // schema.
  1205. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  1206. switch name {
  1207. case agent.FieldCreatedAt:
  1208. return m.CreatedAt()
  1209. case agent.FieldUpdatedAt:
  1210. return m.UpdatedAt()
  1211. case agent.FieldDeletedAt:
  1212. return m.DeletedAt()
  1213. case agent.FieldName:
  1214. return m.Name()
  1215. case agent.FieldRole:
  1216. return m.Role()
  1217. case agent.FieldStatus:
  1218. return m.Status()
  1219. case agent.FieldBackground:
  1220. return m.Background()
  1221. case agent.FieldExamples:
  1222. return m.Examples()
  1223. case agent.FieldOrganizationID:
  1224. return m.OrganizationID()
  1225. case agent.FieldDatasetID:
  1226. return m.DatasetID()
  1227. case agent.FieldCollectionID:
  1228. return m.CollectionID()
  1229. case agent.FieldModel:
  1230. return m.Model()
  1231. case agent.FieldAPIBase:
  1232. return m.APIBase()
  1233. case agent.FieldAPIKey:
  1234. return m.APIKey()
  1235. case agent.FieldType:
  1236. return m.GetType()
  1237. }
  1238. return nil, false
  1239. }
  1240. // OldField returns the old value of the field from the database. An error is
  1241. // returned if the mutation operation is not UpdateOne, or the query to the
  1242. // database failed.
  1243. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1244. switch name {
  1245. case agent.FieldCreatedAt:
  1246. return m.OldCreatedAt(ctx)
  1247. case agent.FieldUpdatedAt:
  1248. return m.OldUpdatedAt(ctx)
  1249. case agent.FieldDeletedAt:
  1250. return m.OldDeletedAt(ctx)
  1251. case agent.FieldName:
  1252. return m.OldName(ctx)
  1253. case agent.FieldRole:
  1254. return m.OldRole(ctx)
  1255. case agent.FieldStatus:
  1256. return m.OldStatus(ctx)
  1257. case agent.FieldBackground:
  1258. return m.OldBackground(ctx)
  1259. case agent.FieldExamples:
  1260. return m.OldExamples(ctx)
  1261. case agent.FieldOrganizationID:
  1262. return m.OldOrganizationID(ctx)
  1263. case agent.FieldDatasetID:
  1264. return m.OldDatasetID(ctx)
  1265. case agent.FieldCollectionID:
  1266. return m.OldCollectionID(ctx)
  1267. case agent.FieldModel:
  1268. return m.OldModel(ctx)
  1269. case agent.FieldAPIBase:
  1270. return m.OldAPIBase(ctx)
  1271. case agent.FieldAPIKey:
  1272. return m.OldAPIKey(ctx)
  1273. case agent.FieldType:
  1274. return m.OldType(ctx)
  1275. }
  1276. return nil, fmt.Errorf("unknown Agent field %s", name)
  1277. }
  1278. // SetField sets the value of a field with the given name. It returns an error if
  1279. // the field is not defined in the schema, or if the type mismatched the field
  1280. // type.
  1281. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1282. switch name {
  1283. case agent.FieldCreatedAt:
  1284. v, ok := value.(time.Time)
  1285. if !ok {
  1286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1287. }
  1288. m.SetCreatedAt(v)
  1289. return nil
  1290. case agent.FieldUpdatedAt:
  1291. v, ok := value.(time.Time)
  1292. if !ok {
  1293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1294. }
  1295. m.SetUpdatedAt(v)
  1296. return nil
  1297. case agent.FieldDeletedAt:
  1298. v, ok := value.(time.Time)
  1299. if !ok {
  1300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1301. }
  1302. m.SetDeletedAt(v)
  1303. return nil
  1304. case agent.FieldName:
  1305. v, ok := value.(string)
  1306. if !ok {
  1307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1308. }
  1309. m.SetName(v)
  1310. return nil
  1311. case agent.FieldRole:
  1312. v, ok := value.(string)
  1313. if !ok {
  1314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1315. }
  1316. m.SetRole(v)
  1317. return nil
  1318. case agent.FieldStatus:
  1319. v, ok := value.(int)
  1320. if !ok {
  1321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1322. }
  1323. m.SetStatus(v)
  1324. return nil
  1325. case agent.FieldBackground:
  1326. v, ok := value.(string)
  1327. if !ok {
  1328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1329. }
  1330. m.SetBackground(v)
  1331. return nil
  1332. case agent.FieldExamples:
  1333. v, ok := value.(string)
  1334. if !ok {
  1335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1336. }
  1337. m.SetExamples(v)
  1338. return nil
  1339. case agent.FieldOrganizationID:
  1340. v, ok := value.(uint64)
  1341. if !ok {
  1342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1343. }
  1344. m.SetOrganizationID(v)
  1345. return nil
  1346. case agent.FieldDatasetID:
  1347. v, ok := value.(string)
  1348. if !ok {
  1349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1350. }
  1351. m.SetDatasetID(v)
  1352. return nil
  1353. case agent.FieldCollectionID:
  1354. v, ok := value.(string)
  1355. if !ok {
  1356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1357. }
  1358. m.SetCollectionID(v)
  1359. return nil
  1360. case agent.FieldModel:
  1361. v, ok := value.(string)
  1362. if !ok {
  1363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1364. }
  1365. m.SetModel(v)
  1366. return nil
  1367. case agent.FieldAPIBase:
  1368. v, ok := value.(string)
  1369. if !ok {
  1370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1371. }
  1372. m.SetAPIBase(v)
  1373. return nil
  1374. case agent.FieldAPIKey:
  1375. v, ok := value.(string)
  1376. if !ok {
  1377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1378. }
  1379. m.SetAPIKey(v)
  1380. return nil
  1381. case agent.FieldType:
  1382. v, ok := value.(int)
  1383. if !ok {
  1384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1385. }
  1386. m.SetType(v)
  1387. return nil
  1388. }
  1389. return fmt.Errorf("unknown Agent field %s", name)
  1390. }
  1391. // AddedFields returns all numeric fields that were incremented/decremented during
  1392. // this mutation.
  1393. func (m *AgentMutation) AddedFields() []string {
  1394. var fields []string
  1395. if m.addstatus != nil {
  1396. fields = append(fields, agent.FieldStatus)
  1397. }
  1398. if m.addorganization_id != nil {
  1399. fields = append(fields, agent.FieldOrganizationID)
  1400. }
  1401. if m.add_type != nil {
  1402. fields = append(fields, agent.FieldType)
  1403. }
  1404. return fields
  1405. }
  1406. // AddedField returns the numeric value that was incremented/decremented on a field
  1407. // with the given name. The second boolean return value indicates that this field
  1408. // was not set, or was not defined in the schema.
  1409. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1410. switch name {
  1411. case agent.FieldStatus:
  1412. return m.AddedStatus()
  1413. case agent.FieldOrganizationID:
  1414. return m.AddedOrganizationID()
  1415. case agent.FieldType:
  1416. return m.AddedType()
  1417. }
  1418. return nil, false
  1419. }
  1420. // AddField adds the value to the field with the given name. It returns an error if
  1421. // the field is not defined in the schema, or if the type mismatched the field
  1422. // type.
  1423. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1424. switch name {
  1425. case agent.FieldStatus:
  1426. v, ok := value.(int)
  1427. if !ok {
  1428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1429. }
  1430. m.AddStatus(v)
  1431. return nil
  1432. case agent.FieldOrganizationID:
  1433. v, ok := value.(int64)
  1434. if !ok {
  1435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1436. }
  1437. m.AddOrganizationID(v)
  1438. return nil
  1439. case agent.FieldType:
  1440. v, ok := value.(int)
  1441. if !ok {
  1442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1443. }
  1444. m.AddType(v)
  1445. return nil
  1446. }
  1447. return fmt.Errorf("unknown Agent numeric field %s", name)
  1448. }
  1449. // ClearedFields returns all nullable fields that were cleared during this
  1450. // mutation.
  1451. func (m *AgentMutation) ClearedFields() []string {
  1452. var fields []string
  1453. if m.FieldCleared(agent.FieldDeletedAt) {
  1454. fields = append(fields, agent.FieldDeletedAt)
  1455. }
  1456. if m.FieldCleared(agent.FieldRole) {
  1457. fields = append(fields, agent.FieldRole)
  1458. }
  1459. if m.FieldCleared(agent.FieldStatus) {
  1460. fields = append(fields, agent.FieldStatus)
  1461. }
  1462. if m.FieldCleared(agent.FieldBackground) {
  1463. fields = append(fields, agent.FieldBackground)
  1464. }
  1465. if m.FieldCleared(agent.FieldExamples) {
  1466. fields = append(fields, agent.FieldExamples)
  1467. }
  1468. if m.FieldCleared(agent.FieldModel) {
  1469. fields = append(fields, agent.FieldModel)
  1470. }
  1471. if m.FieldCleared(agent.FieldAPIBase) {
  1472. fields = append(fields, agent.FieldAPIBase)
  1473. }
  1474. if m.FieldCleared(agent.FieldAPIKey) {
  1475. fields = append(fields, agent.FieldAPIKey)
  1476. }
  1477. if m.FieldCleared(agent.FieldType) {
  1478. fields = append(fields, agent.FieldType)
  1479. }
  1480. return fields
  1481. }
  1482. // FieldCleared returns a boolean indicating if a field with the given name was
  1483. // cleared in this mutation.
  1484. func (m *AgentMutation) FieldCleared(name string) bool {
  1485. _, ok := m.clearedFields[name]
  1486. return ok
  1487. }
  1488. // ClearField clears the value of the field with the given name. It returns an
  1489. // error if the field is not defined in the schema.
  1490. func (m *AgentMutation) ClearField(name string) error {
  1491. switch name {
  1492. case agent.FieldDeletedAt:
  1493. m.ClearDeletedAt()
  1494. return nil
  1495. case agent.FieldRole:
  1496. m.ClearRole()
  1497. return nil
  1498. case agent.FieldStatus:
  1499. m.ClearStatus()
  1500. return nil
  1501. case agent.FieldBackground:
  1502. m.ClearBackground()
  1503. return nil
  1504. case agent.FieldExamples:
  1505. m.ClearExamples()
  1506. return nil
  1507. case agent.FieldModel:
  1508. m.ClearModel()
  1509. return nil
  1510. case agent.FieldAPIBase:
  1511. m.ClearAPIBase()
  1512. return nil
  1513. case agent.FieldAPIKey:
  1514. m.ClearAPIKey()
  1515. return nil
  1516. case agent.FieldType:
  1517. m.ClearType()
  1518. return nil
  1519. }
  1520. return fmt.Errorf("unknown Agent nullable field %s", name)
  1521. }
  1522. // ResetField resets all changes in the mutation for the field with the given name.
  1523. // It returns an error if the field is not defined in the schema.
  1524. func (m *AgentMutation) ResetField(name string) error {
  1525. switch name {
  1526. case agent.FieldCreatedAt:
  1527. m.ResetCreatedAt()
  1528. return nil
  1529. case agent.FieldUpdatedAt:
  1530. m.ResetUpdatedAt()
  1531. return nil
  1532. case agent.FieldDeletedAt:
  1533. m.ResetDeletedAt()
  1534. return nil
  1535. case agent.FieldName:
  1536. m.ResetName()
  1537. return nil
  1538. case agent.FieldRole:
  1539. m.ResetRole()
  1540. return nil
  1541. case agent.FieldStatus:
  1542. m.ResetStatus()
  1543. return nil
  1544. case agent.FieldBackground:
  1545. m.ResetBackground()
  1546. return nil
  1547. case agent.FieldExamples:
  1548. m.ResetExamples()
  1549. return nil
  1550. case agent.FieldOrganizationID:
  1551. m.ResetOrganizationID()
  1552. return nil
  1553. case agent.FieldDatasetID:
  1554. m.ResetDatasetID()
  1555. return nil
  1556. case agent.FieldCollectionID:
  1557. m.ResetCollectionID()
  1558. return nil
  1559. case agent.FieldModel:
  1560. m.ResetModel()
  1561. return nil
  1562. case agent.FieldAPIBase:
  1563. m.ResetAPIBase()
  1564. return nil
  1565. case agent.FieldAPIKey:
  1566. m.ResetAPIKey()
  1567. return nil
  1568. case agent.FieldType:
  1569. m.ResetType()
  1570. return nil
  1571. }
  1572. return fmt.Errorf("unknown Agent field %s", name)
  1573. }
  1574. // AddedEdges returns all edge names that were set/added in this mutation.
  1575. func (m *AgentMutation) AddedEdges() []string {
  1576. edges := make([]string, 0, 5)
  1577. if m.wx_agent != nil {
  1578. edges = append(edges, agent.EdgeWxAgent)
  1579. }
  1580. if m.token_agent != nil {
  1581. edges = append(edges, agent.EdgeTokenAgent)
  1582. }
  1583. if m.wa_agent != nil {
  1584. edges = append(edges, agent.EdgeWaAgent)
  1585. }
  1586. if m.xjs_agent != nil {
  1587. edges = append(edges, agent.EdgeXjsAgent)
  1588. }
  1589. if m.key_agent != nil {
  1590. edges = append(edges, agent.EdgeKeyAgent)
  1591. }
  1592. return edges
  1593. }
  1594. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1595. // name in this mutation.
  1596. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1597. switch name {
  1598. case agent.EdgeWxAgent:
  1599. ids := make([]ent.Value, 0, len(m.wx_agent))
  1600. for id := range m.wx_agent {
  1601. ids = append(ids, id)
  1602. }
  1603. return ids
  1604. case agent.EdgeTokenAgent:
  1605. ids := make([]ent.Value, 0, len(m.token_agent))
  1606. for id := range m.token_agent {
  1607. ids = append(ids, id)
  1608. }
  1609. return ids
  1610. case agent.EdgeWaAgent:
  1611. ids := make([]ent.Value, 0, len(m.wa_agent))
  1612. for id := range m.wa_agent {
  1613. ids = append(ids, id)
  1614. }
  1615. return ids
  1616. case agent.EdgeXjsAgent:
  1617. ids := make([]ent.Value, 0, len(m.xjs_agent))
  1618. for id := range m.xjs_agent {
  1619. ids = append(ids, id)
  1620. }
  1621. return ids
  1622. case agent.EdgeKeyAgent:
  1623. ids := make([]ent.Value, 0, len(m.key_agent))
  1624. for id := range m.key_agent {
  1625. ids = append(ids, id)
  1626. }
  1627. return ids
  1628. }
  1629. return nil
  1630. }
  1631. // RemovedEdges returns all edge names that were removed in this mutation.
  1632. func (m *AgentMutation) RemovedEdges() []string {
  1633. edges := make([]string, 0, 5)
  1634. if m.removedwx_agent != nil {
  1635. edges = append(edges, agent.EdgeWxAgent)
  1636. }
  1637. if m.removedtoken_agent != nil {
  1638. edges = append(edges, agent.EdgeTokenAgent)
  1639. }
  1640. if m.removedwa_agent != nil {
  1641. edges = append(edges, agent.EdgeWaAgent)
  1642. }
  1643. if m.removedxjs_agent != nil {
  1644. edges = append(edges, agent.EdgeXjsAgent)
  1645. }
  1646. if m.removedkey_agent != nil {
  1647. edges = append(edges, agent.EdgeKeyAgent)
  1648. }
  1649. return edges
  1650. }
  1651. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1652. // the given name in this mutation.
  1653. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1654. switch name {
  1655. case agent.EdgeWxAgent:
  1656. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1657. for id := range m.removedwx_agent {
  1658. ids = append(ids, id)
  1659. }
  1660. return ids
  1661. case agent.EdgeTokenAgent:
  1662. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1663. for id := range m.removedtoken_agent {
  1664. ids = append(ids, id)
  1665. }
  1666. return ids
  1667. case agent.EdgeWaAgent:
  1668. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1669. for id := range m.removedwa_agent {
  1670. ids = append(ids, id)
  1671. }
  1672. return ids
  1673. case agent.EdgeXjsAgent:
  1674. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  1675. for id := range m.removedxjs_agent {
  1676. ids = append(ids, id)
  1677. }
  1678. return ids
  1679. case agent.EdgeKeyAgent:
  1680. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1681. for id := range m.removedkey_agent {
  1682. ids = append(ids, id)
  1683. }
  1684. return ids
  1685. }
  1686. return nil
  1687. }
  1688. // ClearedEdges returns all edge names that were cleared in this mutation.
  1689. func (m *AgentMutation) ClearedEdges() []string {
  1690. edges := make([]string, 0, 5)
  1691. if m.clearedwx_agent {
  1692. edges = append(edges, agent.EdgeWxAgent)
  1693. }
  1694. if m.clearedtoken_agent {
  1695. edges = append(edges, agent.EdgeTokenAgent)
  1696. }
  1697. if m.clearedwa_agent {
  1698. edges = append(edges, agent.EdgeWaAgent)
  1699. }
  1700. if m.clearedxjs_agent {
  1701. edges = append(edges, agent.EdgeXjsAgent)
  1702. }
  1703. if m.clearedkey_agent {
  1704. edges = append(edges, agent.EdgeKeyAgent)
  1705. }
  1706. return edges
  1707. }
  1708. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1709. // was cleared in this mutation.
  1710. func (m *AgentMutation) EdgeCleared(name string) bool {
  1711. switch name {
  1712. case agent.EdgeWxAgent:
  1713. return m.clearedwx_agent
  1714. case agent.EdgeTokenAgent:
  1715. return m.clearedtoken_agent
  1716. case agent.EdgeWaAgent:
  1717. return m.clearedwa_agent
  1718. case agent.EdgeXjsAgent:
  1719. return m.clearedxjs_agent
  1720. case agent.EdgeKeyAgent:
  1721. return m.clearedkey_agent
  1722. }
  1723. return false
  1724. }
  1725. // ClearEdge clears the value of the edge with the given name. It returns an error
  1726. // if that edge is not defined in the schema.
  1727. func (m *AgentMutation) ClearEdge(name string) error {
  1728. switch name {
  1729. }
  1730. return fmt.Errorf("unknown Agent unique edge %s", name)
  1731. }
  1732. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1733. // It returns an error if the edge is not defined in the schema.
  1734. func (m *AgentMutation) ResetEdge(name string) error {
  1735. switch name {
  1736. case agent.EdgeWxAgent:
  1737. m.ResetWxAgent()
  1738. return nil
  1739. case agent.EdgeTokenAgent:
  1740. m.ResetTokenAgent()
  1741. return nil
  1742. case agent.EdgeWaAgent:
  1743. m.ResetWaAgent()
  1744. return nil
  1745. case agent.EdgeXjsAgent:
  1746. m.ResetXjsAgent()
  1747. return nil
  1748. case agent.EdgeKeyAgent:
  1749. m.ResetKeyAgent()
  1750. return nil
  1751. }
  1752. return fmt.Errorf("unknown Agent edge %s", name)
  1753. }
  1754. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1755. type AgentBaseMutation struct {
  1756. config
  1757. op Op
  1758. typ string
  1759. id *string
  1760. q *string
  1761. a *string
  1762. chunk_index *uint64
  1763. addchunk_index *int64
  1764. indexes *[]string
  1765. appendindexes []string
  1766. dataset_id *string
  1767. collection_id *string
  1768. source_name *string
  1769. can_write *[]bool
  1770. appendcan_write []bool
  1771. is_owner *[]bool
  1772. appendis_owner []bool
  1773. clearedFields map[string]struct{}
  1774. wx_agent map[uint64]struct{}
  1775. removedwx_agent map[uint64]struct{}
  1776. clearedwx_agent bool
  1777. done bool
  1778. oldValue func(context.Context) (*AgentBase, error)
  1779. predicates []predicate.AgentBase
  1780. }
  1781. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1782. // agentbaseOption allows management of the mutation configuration using functional options.
  1783. type agentbaseOption func(*AgentBaseMutation)
  1784. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1785. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1786. m := &AgentBaseMutation{
  1787. config: c,
  1788. op: op,
  1789. typ: TypeAgentBase,
  1790. clearedFields: make(map[string]struct{}),
  1791. }
  1792. for _, opt := range opts {
  1793. opt(m)
  1794. }
  1795. return m
  1796. }
  1797. // withAgentBaseID sets the ID field of the mutation.
  1798. func withAgentBaseID(id string) agentbaseOption {
  1799. return func(m *AgentBaseMutation) {
  1800. var (
  1801. err error
  1802. once sync.Once
  1803. value *AgentBase
  1804. )
  1805. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1806. once.Do(func() {
  1807. if m.done {
  1808. err = errors.New("querying old values post mutation is not allowed")
  1809. } else {
  1810. value, err = m.Client().AgentBase.Get(ctx, id)
  1811. }
  1812. })
  1813. return value, err
  1814. }
  1815. m.id = &id
  1816. }
  1817. }
  1818. // withAgentBase sets the old AgentBase of the mutation.
  1819. func withAgentBase(node *AgentBase) agentbaseOption {
  1820. return func(m *AgentBaseMutation) {
  1821. m.oldValue = func(context.Context) (*AgentBase, error) {
  1822. return node, nil
  1823. }
  1824. m.id = &node.ID
  1825. }
  1826. }
  1827. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1828. // executed in a transaction (ent.Tx), a transactional client is returned.
  1829. func (m AgentBaseMutation) Client() *Client {
  1830. client := &Client{config: m.config}
  1831. client.init()
  1832. return client
  1833. }
  1834. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1835. // it returns an error otherwise.
  1836. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1837. if _, ok := m.driver.(*txDriver); !ok {
  1838. return nil, errors.New("ent: mutation is not running in a transaction")
  1839. }
  1840. tx := &Tx{config: m.config}
  1841. tx.init()
  1842. return tx, nil
  1843. }
  1844. // SetID sets the value of the id field. Note that this
  1845. // operation is only accepted on creation of AgentBase entities.
  1846. func (m *AgentBaseMutation) SetID(id string) {
  1847. m.id = &id
  1848. }
  1849. // ID returns the ID value in the mutation. Note that the ID is only available
  1850. // if it was provided to the builder or after it was returned from the database.
  1851. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1852. if m.id == nil {
  1853. return
  1854. }
  1855. return *m.id, true
  1856. }
  1857. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1858. // That means, if the mutation is applied within a transaction with an isolation level such
  1859. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1860. // or updated by the mutation.
  1861. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1862. switch {
  1863. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1864. id, exists := m.ID()
  1865. if exists {
  1866. return []string{id}, nil
  1867. }
  1868. fallthrough
  1869. case m.op.Is(OpUpdate | OpDelete):
  1870. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1871. default:
  1872. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1873. }
  1874. }
  1875. // SetQ sets the "q" field.
  1876. func (m *AgentBaseMutation) SetQ(s string) {
  1877. m.q = &s
  1878. }
  1879. // Q returns the value of the "q" field in the mutation.
  1880. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1881. v := m.q
  1882. if v == nil {
  1883. return
  1884. }
  1885. return *v, true
  1886. }
  1887. // OldQ returns the old "q" field's value of the AgentBase entity.
  1888. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1890. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1891. if !m.op.Is(OpUpdateOne) {
  1892. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1893. }
  1894. if m.id == nil || m.oldValue == nil {
  1895. return v, errors.New("OldQ requires an ID field in the mutation")
  1896. }
  1897. oldValue, err := m.oldValue(ctx)
  1898. if err != nil {
  1899. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1900. }
  1901. return oldValue.Q, nil
  1902. }
  1903. // ClearQ clears the value of the "q" field.
  1904. func (m *AgentBaseMutation) ClearQ() {
  1905. m.q = nil
  1906. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1907. }
  1908. // QCleared returns if the "q" field was cleared in this mutation.
  1909. func (m *AgentBaseMutation) QCleared() bool {
  1910. _, ok := m.clearedFields[agentbase.FieldQ]
  1911. return ok
  1912. }
  1913. // ResetQ resets all changes to the "q" field.
  1914. func (m *AgentBaseMutation) ResetQ() {
  1915. m.q = nil
  1916. delete(m.clearedFields, agentbase.FieldQ)
  1917. }
  1918. // SetA sets the "a" field.
  1919. func (m *AgentBaseMutation) SetA(s string) {
  1920. m.a = &s
  1921. }
  1922. // A returns the value of the "a" field in the mutation.
  1923. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1924. v := m.a
  1925. if v == nil {
  1926. return
  1927. }
  1928. return *v, true
  1929. }
  1930. // OldA returns the old "a" field's value of the AgentBase entity.
  1931. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1933. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1934. if !m.op.Is(OpUpdateOne) {
  1935. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1936. }
  1937. if m.id == nil || m.oldValue == nil {
  1938. return v, errors.New("OldA requires an ID field in the mutation")
  1939. }
  1940. oldValue, err := m.oldValue(ctx)
  1941. if err != nil {
  1942. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1943. }
  1944. return oldValue.A, nil
  1945. }
  1946. // ClearA clears the value of the "a" field.
  1947. func (m *AgentBaseMutation) ClearA() {
  1948. m.a = nil
  1949. m.clearedFields[agentbase.FieldA] = struct{}{}
  1950. }
  1951. // ACleared returns if the "a" field was cleared in this mutation.
  1952. func (m *AgentBaseMutation) ACleared() bool {
  1953. _, ok := m.clearedFields[agentbase.FieldA]
  1954. return ok
  1955. }
  1956. // ResetA resets all changes to the "a" field.
  1957. func (m *AgentBaseMutation) ResetA() {
  1958. m.a = nil
  1959. delete(m.clearedFields, agentbase.FieldA)
  1960. }
  1961. // SetChunkIndex sets the "chunk_index" field.
  1962. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1963. m.chunk_index = &u
  1964. m.addchunk_index = nil
  1965. }
  1966. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1967. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1968. v := m.chunk_index
  1969. if v == nil {
  1970. return
  1971. }
  1972. return *v, true
  1973. }
  1974. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1975. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1977. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1978. if !m.op.Is(OpUpdateOne) {
  1979. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1980. }
  1981. if m.id == nil || m.oldValue == nil {
  1982. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1983. }
  1984. oldValue, err := m.oldValue(ctx)
  1985. if err != nil {
  1986. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1987. }
  1988. return oldValue.ChunkIndex, nil
  1989. }
  1990. // AddChunkIndex adds u to the "chunk_index" field.
  1991. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1992. if m.addchunk_index != nil {
  1993. *m.addchunk_index += u
  1994. } else {
  1995. m.addchunk_index = &u
  1996. }
  1997. }
  1998. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1999. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  2000. v := m.addchunk_index
  2001. if v == nil {
  2002. return
  2003. }
  2004. return *v, true
  2005. }
  2006. // ResetChunkIndex resets all changes to the "chunk_index" field.
  2007. func (m *AgentBaseMutation) ResetChunkIndex() {
  2008. m.chunk_index = nil
  2009. m.addchunk_index = nil
  2010. }
  2011. // SetIndexes sets the "indexes" field.
  2012. func (m *AgentBaseMutation) SetIndexes(s []string) {
  2013. m.indexes = &s
  2014. m.appendindexes = nil
  2015. }
  2016. // Indexes returns the value of the "indexes" field in the mutation.
  2017. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  2018. v := m.indexes
  2019. if v == nil {
  2020. return
  2021. }
  2022. return *v, true
  2023. }
  2024. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  2025. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2027. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  2028. if !m.op.Is(OpUpdateOne) {
  2029. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  2030. }
  2031. if m.id == nil || m.oldValue == nil {
  2032. return v, errors.New("OldIndexes requires an ID field in the mutation")
  2033. }
  2034. oldValue, err := m.oldValue(ctx)
  2035. if err != nil {
  2036. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  2037. }
  2038. return oldValue.Indexes, nil
  2039. }
  2040. // AppendIndexes adds s to the "indexes" field.
  2041. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  2042. m.appendindexes = append(m.appendindexes, s...)
  2043. }
  2044. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  2045. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  2046. if len(m.appendindexes) == 0 {
  2047. return nil, false
  2048. }
  2049. return m.appendindexes, true
  2050. }
  2051. // ClearIndexes clears the value of the "indexes" field.
  2052. func (m *AgentBaseMutation) ClearIndexes() {
  2053. m.indexes = nil
  2054. m.appendindexes = nil
  2055. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  2056. }
  2057. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  2058. func (m *AgentBaseMutation) IndexesCleared() bool {
  2059. _, ok := m.clearedFields[agentbase.FieldIndexes]
  2060. return ok
  2061. }
  2062. // ResetIndexes resets all changes to the "indexes" field.
  2063. func (m *AgentBaseMutation) ResetIndexes() {
  2064. m.indexes = nil
  2065. m.appendindexes = nil
  2066. delete(m.clearedFields, agentbase.FieldIndexes)
  2067. }
  2068. // SetDatasetID sets the "dataset_id" field.
  2069. func (m *AgentBaseMutation) SetDatasetID(s string) {
  2070. m.dataset_id = &s
  2071. }
  2072. // DatasetID returns the value of the "dataset_id" field in the mutation.
  2073. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  2074. v := m.dataset_id
  2075. if v == nil {
  2076. return
  2077. }
  2078. return *v, true
  2079. }
  2080. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  2081. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2083. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  2084. if !m.op.Is(OpUpdateOne) {
  2085. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  2086. }
  2087. if m.id == nil || m.oldValue == nil {
  2088. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  2089. }
  2090. oldValue, err := m.oldValue(ctx)
  2091. if err != nil {
  2092. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  2093. }
  2094. return oldValue.DatasetID, nil
  2095. }
  2096. // ClearDatasetID clears the value of the "dataset_id" field.
  2097. func (m *AgentBaseMutation) ClearDatasetID() {
  2098. m.dataset_id = nil
  2099. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  2100. }
  2101. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  2102. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  2103. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  2104. return ok
  2105. }
  2106. // ResetDatasetID resets all changes to the "dataset_id" field.
  2107. func (m *AgentBaseMutation) ResetDatasetID() {
  2108. m.dataset_id = nil
  2109. delete(m.clearedFields, agentbase.FieldDatasetID)
  2110. }
  2111. // SetCollectionID sets the "collection_id" field.
  2112. func (m *AgentBaseMutation) SetCollectionID(s string) {
  2113. m.collection_id = &s
  2114. }
  2115. // CollectionID returns the value of the "collection_id" field in the mutation.
  2116. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  2117. v := m.collection_id
  2118. if v == nil {
  2119. return
  2120. }
  2121. return *v, true
  2122. }
  2123. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  2124. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2126. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  2127. if !m.op.Is(OpUpdateOne) {
  2128. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  2129. }
  2130. if m.id == nil || m.oldValue == nil {
  2131. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  2132. }
  2133. oldValue, err := m.oldValue(ctx)
  2134. if err != nil {
  2135. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  2136. }
  2137. return oldValue.CollectionID, nil
  2138. }
  2139. // ClearCollectionID clears the value of the "collection_id" field.
  2140. func (m *AgentBaseMutation) ClearCollectionID() {
  2141. m.collection_id = nil
  2142. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  2143. }
  2144. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  2145. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  2146. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  2147. return ok
  2148. }
  2149. // ResetCollectionID resets all changes to the "collection_id" field.
  2150. func (m *AgentBaseMutation) ResetCollectionID() {
  2151. m.collection_id = nil
  2152. delete(m.clearedFields, agentbase.FieldCollectionID)
  2153. }
  2154. // SetSourceName sets the "source_name" field.
  2155. func (m *AgentBaseMutation) SetSourceName(s string) {
  2156. m.source_name = &s
  2157. }
  2158. // SourceName returns the value of the "source_name" field in the mutation.
  2159. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  2160. v := m.source_name
  2161. if v == nil {
  2162. return
  2163. }
  2164. return *v, true
  2165. }
  2166. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  2167. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2169. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  2170. if !m.op.Is(OpUpdateOne) {
  2171. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  2172. }
  2173. if m.id == nil || m.oldValue == nil {
  2174. return v, errors.New("OldSourceName requires an ID field in the mutation")
  2175. }
  2176. oldValue, err := m.oldValue(ctx)
  2177. if err != nil {
  2178. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  2179. }
  2180. return oldValue.SourceName, nil
  2181. }
  2182. // ClearSourceName clears the value of the "source_name" field.
  2183. func (m *AgentBaseMutation) ClearSourceName() {
  2184. m.source_name = nil
  2185. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  2186. }
  2187. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  2188. func (m *AgentBaseMutation) SourceNameCleared() bool {
  2189. _, ok := m.clearedFields[agentbase.FieldSourceName]
  2190. return ok
  2191. }
  2192. // ResetSourceName resets all changes to the "source_name" field.
  2193. func (m *AgentBaseMutation) ResetSourceName() {
  2194. m.source_name = nil
  2195. delete(m.clearedFields, agentbase.FieldSourceName)
  2196. }
  2197. // SetCanWrite sets the "can_write" field.
  2198. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  2199. m.can_write = &b
  2200. m.appendcan_write = nil
  2201. }
  2202. // CanWrite returns the value of the "can_write" field in the mutation.
  2203. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  2204. v := m.can_write
  2205. if v == nil {
  2206. return
  2207. }
  2208. return *v, true
  2209. }
  2210. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  2211. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2213. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  2214. if !m.op.Is(OpUpdateOne) {
  2215. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  2216. }
  2217. if m.id == nil || m.oldValue == nil {
  2218. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  2219. }
  2220. oldValue, err := m.oldValue(ctx)
  2221. if err != nil {
  2222. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  2223. }
  2224. return oldValue.CanWrite, nil
  2225. }
  2226. // AppendCanWrite adds b to the "can_write" field.
  2227. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  2228. m.appendcan_write = append(m.appendcan_write, b...)
  2229. }
  2230. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  2231. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  2232. if len(m.appendcan_write) == 0 {
  2233. return nil, false
  2234. }
  2235. return m.appendcan_write, true
  2236. }
  2237. // ClearCanWrite clears the value of the "can_write" field.
  2238. func (m *AgentBaseMutation) ClearCanWrite() {
  2239. m.can_write = nil
  2240. m.appendcan_write = nil
  2241. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  2242. }
  2243. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  2244. func (m *AgentBaseMutation) CanWriteCleared() bool {
  2245. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  2246. return ok
  2247. }
  2248. // ResetCanWrite resets all changes to the "can_write" field.
  2249. func (m *AgentBaseMutation) ResetCanWrite() {
  2250. m.can_write = nil
  2251. m.appendcan_write = nil
  2252. delete(m.clearedFields, agentbase.FieldCanWrite)
  2253. }
  2254. // SetIsOwner sets the "is_owner" field.
  2255. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  2256. m.is_owner = &b
  2257. m.appendis_owner = nil
  2258. }
  2259. // IsOwner returns the value of the "is_owner" field in the mutation.
  2260. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  2261. v := m.is_owner
  2262. if v == nil {
  2263. return
  2264. }
  2265. return *v, true
  2266. }
  2267. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  2268. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2270. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  2271. if !m.op.Is(OpUpdateOne) {
  2272. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  2273. }
  2274. if m.id == nil || m.oldValue == nil {
  2275. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  2276. }
  2277. oldValue, err := m.oldValue(ctx)
  2278. if err != nil {
  2279. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  2280. }
  2281. return oldValue.IsOwner, nil
  2282. }
  2283. // AppendIsOwner adds b to the "is_owner" field.
  2284. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  2285. m.appendis_owner = append(m.appendis_owner, b...)
  2286. }
  2287. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  2288. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  2289. if len(m.appendis_owner) == 0 {
  2290. return nil, false
  2291. }
  2292. return m.appendis_owner, true
  2293. }
  2294. // ClearIsOwner clears the value of the "is_owner" field.
  2295. func (m *AgentBaseMutation) ClearIsOwner() {
  2296. m.is_owner = nil
  2297. m.appendis_owner = nil
  2298. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  2299. }
  2300. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  2301. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  2302. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  2303. return ok
  2304. }
  2305. // ResetIsOwner resets all changes to the "is_owner" field.
  2306. func (m *AgentBaseMutation) ResetIsOwner() {
  2307. m.is_owner = nil
  2308. m.appendis_owner = nil
  2309. delete(m.clearedFields, agentbase.FieldIsOwner)
  2310. }
  2311. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  2312. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  2313. if m.wx_agent == nil {
  2314. m.wx_agent = make(map[uint64]struct{})
  2315. }
  2316. for i := range ids {
  2317. m.wx_agent[ids[i]] = struct{}{}
  2318. }
  2319. }
  2320. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  2321. func (m *AgentBaseMutation) ClearWxAgent() {
  2322. m.clearedwx_agent = true
  2323. }
  2324. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2325. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2326. return m.clearedwx_agent
  2327. }
  2328. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2329. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2330. if m.removedwx_agent == nil {
  2331. m.removedwx_agent = make(map[uint64]struct{})
  2332. }
  2333. for i := range ids {
  2334. delete(m.wx_agent, ids[i])
  2335. m.removedwx_agent[ids[i]] = struct{}{}
  2336. }
  2337. }
  2338. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2339. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2340. for id := range m.removedwx_agent {
  2341. ids = append(ids, id)
  2342. }
  2343. return
  2344. }
  2345. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2346. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2347. for id := range m.wx_agent {
  2348. ids = append(ids, id)
  2349. }
  2350. return
  2351. }
  2352. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2353. func (m *AgentBaseMutation) ResetWxAgent() {
  2354. m.wx_agent = nil
  2355. m.clearedwx_agent = false
  2356. m.removedwx_agent = nil
  2357. }
  2358. // Where appends a list predicates to the AgentBaseMutation builder.
  2359. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2360. m.predicates = append(m.predicates, ps...)
  2361. }
  2362. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2363. // users can use type-assertion to append predicates that do not depend on any generated package.
  2364. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2365. p := make([]predicate.AgentBase, len(ps))
  2366. for i := range ps {
  2367. p[i] = ps[i]
  2368. }
  2369. m.Where(p...)
  2370. }
  2371. // Op returns the operation name.
  2372. func (m *AgentBaseMutation) Op() Op {
  2373. return m.op
  2374. }
  2375. // SetOp allows setting the mutation operation.
  2376. func (m *AgentBaseMutation) SetOp(op Op) {
  2377. m.op = op
  2378. }
  2379. // Type returns the node type of this mutation (AgentBase).
  2380. func (m *AgentBaseMutation) Type() string {
  2381. return m.typ
  2382. }
  2383. // Fields returns all fields that were changed during this mutation. Note that in
  2384. // order to get all numeric fields that were incremented/decremented, call
  2385. // AddedFields().
  2386. func (m *AgentBaseMutation) Fields() []string {
  2387. fields := make([]string, 0, 9)
  2388. if m.q != nil {
  2389. fields = append(fields, agentbase.FieldQ)
  2390. }
  2391. if m.a != nil {
  2392. fields = append(fields, agentbase.FieldA)
  2393. }
  2394. if m.chunk_index != nil {
  2395. fields = append(fields, agentbase.FieldChunkIndex)
  2396. }
  2397. if m.indexes != nil {
  2398. fields = append(fields, agentbase.FieldIndexes)
  2399. }
  2400. if m.dataset_id != nil {
  2401. fields = append(fields, agentbase.FieldDatasetID)
  2402. }
  2403. if m.collection_id != nil {
  2404. fields = append(fields, agentbase.FieldCollectionID)
  2405. }
  2406. if m.source_name != nil {
  2407. fields = append(fields, agentbase.FieldSourceName)
  2408. }
  2409. if m.can_write != nil {
  2410. fields = append(fields, agentbase.FieldCanWrite)
  2411. }
  2412. if m.is_owner != nil {
  2413. fields = append(fields, agentbase.FieldIsOwner)
  2414. }
  2415. return fields
  2416. }
  2417. // Field returns the value of a field with the given name. The second boolean
  2418. // return value indicates that this field was not set, or was not defined in the
  2419. // schema.
  2420. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2421. switch name {
  2422. case agentbase.FieldQ:
  2423. return m.Q()
  2424. case agentbase.FieldA:
  2425. return m.A()
  2426. case agentbase.FieldChunkIndex:
  2427. return m.ChunkIndex()
  2428. case agentbase.FieldIndexes:
  2429. return m.Indexes()
  2430. case agentbase.FieldDatasetID:
  2431. return m.DatasetID()
  2432. case agentbase.FieldCollectionID:
  2433. return m.CollectionID()
  2434. case agentbase.FieldSourceName:
  2435. return m.SourceName()
  2436. case agentbase.FieldCanWrite:
  2437. return m.CanWrite()
  2438. case agentbase.FieldIsOwner:
  2439. return m.IsOwner()
  2440. }
  2441. return nil, false
  2442. }
  2443. // OldField returns the old value of the field from the database. An error is
  2444. // returned if the mutation operation is not UpdateOne, or the query to the
  2445. // database failed.
  2446. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2447. switch name {
  2448. case agentbase.FieldQ:
  2449. return m.OldQ(ctx)
  2450. case agentbase.FieldA:
  2451. return m.OldA(ctx)
  2452. case agentbase.FieldChunkIndex:
  2453. return m.OldChunkIndex(ctx)
  2454. case agentbase.FieldIndexes:
  2455. return m.OldIndexes(ctx)
  2456. case agentbase.FieldDatasetID:
  2457. return m.OldDatasetID(ctx)
  2458. case agentbase.FieldCollectionID:
  2459. return m.OldCollectionID(ctx)
  2460. case agentbase.FieldSourceName:
  2461. return m.OldSourceName(ctx)
  2462. case agentbase.FieldCanWrite:
  2463. return m.OldCanWrite(ctx)
  2464. case agentbase.FieldIsOwner:
  2465. return m.OldIsOwner(ctx)
  2466. }
  2467. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2468. }
  2469. // SetField sets the value of a field with the given name. It returns an error if
  2470. // the field is not defined in the schema, or if the type mismatched the field
  2471. // type.
  2472. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2473. switch name {
  2474. case agentbase.FieldQ:
  2475. v, ok := value.(string)
  2476. if !ok {
  2477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2478. }
  2479. m.SetQ(v)
  2480. return nil
  2481. case agentbase.FieldA:
  2482. v, ok := value.(string)
  2483. if !ok {
  2484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2485. }
  2486. m.SetA(v)
  2487. return nil
  2488. case agentbase.FieldChunkIndex:
  2489. v, ok := value.(uint64)
  2490. if !ok {
  2491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2492. }
  2493. m.SetChunkIndex(v)
  2494. return nil
  2495. case agentbase.FieldIndexes:
  2496. v, ok := value.([]string)
  2497. if !ok {
  2498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2499. }
  2500. m.SetIndexes(v)
  2501. return nil
  2502. case agentbase.FieldDatasetID:
  2503. v, ok := value.(string)
  2504. if !ok {
  2505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2506. }
  2507. m.SetDatasetID(v)
  2508. return nil
  2509. case agentbase.FieldCollectionID:
  2510. v, ok := value.(string)
  2511. if !ok {
  2512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2513. }
  2514. m.SetCollectionID(v)
  2515. return nil
  2516. case agentbase.FieldSourceName:
  2517. v, ok := value.(string)
  2518. if !ok {
  2519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2520. }
  2521. m.SetSourceName(v)
  2522. return nil
  2523. case agentbase.FieldCanWrite:
  2524. v, ok := value.([]bool)
  2525. if !ok {
  2526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2527. }
  2528. m.SetCanWrite(v)
  2529. return nil
  2530. case agentbase.FieldIsOwner:
  2531. v, ok := value.([]bool)
  2532. if !ok {
  2533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2534. }
  2535. m.SetIsOwner(v)
  2536. return nil
  2537. }
  2538. return fmt.Errorf("unknown AgentBase field %s", name)
  2539. }
  2540. // AddedFields returns all numeric fields that were incremented/decremented during
  2541. // this mutation.
  2542. func (m *AgentBaseMutation) AddedFields() []string {
  2543. var fields []string
  2544. if m.addchunk_index != nil {
  2545. fields = append(fields, agentbase.FieldChunkIndex)
  2546. }
  2547. return fields
  2548. }
  2549. // AddedField returns the numeric value that was incremented/decremented on a field
  2550. // with the given name. The second boolean return value indicates that this field
  2551. // was not set, or was not defined in the schema.
  2552. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2553. switch name {
  2554. case agentbase.FieldChunkIndex:
  2555. return m.AddedChunkIndex()
  2556. }
  2557. return nil, false
  2558. }
  2559. // AddField adds the value to the field with the given name. It returns an error if
  2560. // the field is not defined in the schema, or if the type mismatched the field
  2561. // type.
  2562. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2563. switch name {
  2564. case agentbase.FieldChunkIndex:
  2565. v, ok := value.(int64)
  2566. if !ok {
  2567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2568. }
  2569. m.AddChunkIndex(v)
  2570. return nil
  2571. }
  2572. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2573. }
  2574. // ClearedFields returns all nullable fields that were cleared during this
  2575. // mutation.
  2576. func (m *AgentBaseMutation) ClearedFields() []string {
  2577. var fields []string
  2578. if m.FieldCleared(agentbase.FieldQ) {
  2579. fields = append(fields, agentbase.FieldQ)
  2580. }
  2581. if m.FieldCleared(agentbase.FieldA) {
  2582. fields = append(fields, agentbase.FieldA)
  2583. }
  2584. if m.FieldCleared(agentbase.FieldIndexes) {
  2585. fields = append(fields, agentbase.FieldIndexes)
  2586. }
  2587. if m.FieldCleared(agentbase.FieldDatasetID) {
  2588. fields = append(fields, agentbase.FieldDatasetID)
  2589. }
  2590. if m.FieldCleared(agentbase.FieldCollectionID) {
  2591. fields = append(fields, agentbase.FieldCollectionID)
  2592. }
  2593. if m.FieldCleared(agentbase.FieldSourceName) {
  2594. fields = append(fields, agentbase.FieldSourceName)
  2595. }
  2596. if m.FieldCleared(agentbase.FieldCanWrite) {
  2597. fields = append(fields, agentbase.FieldCanWrite)
  2598. }
  2599. if m.FieldCleared(agentbase.FieldIsOwner) {
  2600. fields = append(fields, agentbase.FieldIsOwner)
  2601. }
  2602. return fields
  2603. }
  2604. // FieldCleared returns a boolean indicating if a field with the given name was
  2605. // cleared in this mutation.
  2606. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2607. _, ok := m.clearedFields[name]
  2608. return ok
  2609. }
  2610. // ClearField clears the value of the field with the given name. It returns an
  2611. // error if the field is not defined in the schema.
  2612. func (m *AgentBaseMutation) ClearField(name string) error {
  2613. switch name {
  2614. case agentbase.FieldQ:
  2615. m.ClearQ()
  2616. return nil
  2617. case agentbase.FieldA:
  2618. m.ClearA()
  2619. return nil
  2620. case agentbase.FieldIndexes:
  2621. m.ClearIndexes()
  2622. return nil
  2623. case agentbase.FieldDatasetID:
  2624. m.ClearDatasetID()
  2625. return nil
  2626. case agentbase.FieldCollectionID:
  2627. m.ClearCollectionID()
  2628. return nil
  2629. case agentbase.FieldSourceName:
  2630. m.ClearSourceName()
  2631. return nil
  2632. case agentbase.FieldCanWrite:
  2633. m.ClearCanWrite()
  2634. return nil
  2635. case agentbase.FieldIsOwner:
  2636. m.ClearIsOwner()
  2637. return nil
  2638. }
  2639. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2640. }
  2641. // ResetField resets all changes in the mutation for the field with the given name.
  2642. // It returns an error if the field is not defined in the schema.
  2643. func (m *AgentBaseMutation) ResetField(name string) error {
  2644. switch name {
  2645. case agentbase.FieldQ:
  2646. m.ResetQ()
  2647. return nil
  2648. case agentbase.FieldA:
  2649. m.ResetA()
  2650. return nil
  2651. case agentbase.FieldChunkIndex:
  2652. m.ResetChunkIndex()
  2653. return nil
  2654. case agentbase.FieldIndexes:
  2655. m.ResetIndexes()
  2656. return nil
  2657. case agentbase.FieldDatasetID:
  2658. m.ResetDatasetID()
  2659. return nil
  2660. case agentbase.FieldCollectionID:
  2661. m.ResetCollectionID()
  2662. return nil
  2663. case agentbase.FieldSourceName:
  2664. m.ResetSourceName()
  2665. return nil
  2666. case agentbase.FieldCanWrite:
  2667. m.ResetCanWrite()
  2668. return nil
  2669. case agentbase.FieldIsOwner:
  2670. m.ResetIsOwner()
  2671. return nil
  2672. }
  2673. return fmt.Errorf("unknown AgentBase field %s", name)
  2674. }
  2675. // AddedEdges returns all edge names that were set/added in this mutation.
  2676. func (m *AgentBaseMutation) AddedEdges() []string {
  2677. edges := make([]string, 0, 1)
  2678. if m.wx_agent != nil {
  2679. edges = append(edges, agentbase.EdgeWxAgent)
  2680. }
  2681. return edges
  2682. }
  2683. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2684. // name in this mutation.
  2685. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2686. switch name {
  2687. case agentbase.EdgeWxAgent:
  2688. ids := make([]ent.Value, 0, len(m.wx_agent))
  2689. for id := range m.wx_agent {
  2690. ids = append(ids, id)
  2691. }
  2692. return ids
  2693. }
  2694. return nil
  2695. }
  2696. // RemovedEdges returns all edge names that were removed in this mutation.
  2697. func (m *AgentBaseMutation) RemovedEdges() []string {
  2698. edges := make([]string, 0, 1)
  2699. if m.removedwx_agent != nil {
  2700. edges = append(edges, agentbase.EdgeWxAgent)
  2701. }
  2702. return edges
  2703. }
  2704. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2705. // the given name in this mutation.
  2706. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2707. switch name {
  2708. case agentbase.EdgeWxAgent:
  2709. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2710. for id := range m.removedwx_agent {
  2711. ids = append(ids, id)
  2712. }
  2713. return ids
  2714. }
  2715. return nil
  2716. }
  2717. // ClearedEdges returns all edge names that were cleared in this mutation.
  2718. func (m *AgentBaseMutation) ClearedEdges() []string {
  2719. edges := make([]string, 0, 1)
  2720. if m.clearedwx_agent {
  2721. edges = append(edges, agentbase.EdgeWxAgent)
  2722. }
  2723. return edges
  2724. }
  2725. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2726. // was cleared in this mutation.
  2727. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2728. switch name {
  2729. case agentbase.EdgeWxAgent:
  2730. return m.clearedwx_agent
  2731. }
  2732. return false
  2733. }
  2734. // ClearEdge clears the value of the edge with the given name. It returns an error
  2735. // if that edge is not defined in the schema.
  2736. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2737. switch name {
  2738. }
  2739. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2740. }
  2741. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2742. // It returns an error if the edge is not defined in the schema.
  2743. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2744. switch name {
  2745. case agentbase.EdgeWxAgent:
  2746. m.ResetWxAgent()
  2747. return nil
  2748. }
  2749. return fmt.Errorf("unknown AgentBase edge %s", name)
  2750. }
  2751. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2752. type AliyunAvatarMutation struct {
  2753. config
  2754. op Op
  2755. typ string
  2756. id *uint64
  2757. created_at *time.Time
  2758. updated_at *time.Time
  2759. deleted_at *time.Time
  2760. user_id *uint64
  2761. adduser_id *int64
  2762. biz_id *string
  2763. access_key_id *string
  2764. access_key_secret *string
  2765. app_id *string
  2766. tenant_id *uint64
  2767. addtenant_id *int64
  2768. response *string
  2769. token *string
  2770. session_id *string
  2771. clearedFields map[string]struct{}
  2772. done bool
  2773. oldValue func(context.Context) (*AliyunAvatar, error)
  2774. predicates []predicate.AliyunAvatar
  2775. }
  2776. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2777. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2778. type aliyunavatarOption func(*AliyunAvatarMutation)
  2779. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2780. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2781. m := &AliyunAvatarMutation{
  2782. config: c,
  2783. op: op,
  2784. typ: TypeAliyunAvatar,
  2785. clearedFields: make(map[string]struct{}),
  2786. }
  2787. for _, opt := range opts {
  2788. opt(m)
  2789. }
  2790. return m
  2791. }
  2792. // withAliyunAvatarID sets the ID field of the mutation.
  2793. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2794. return func(m *AliyunAvatarMutation) {
  2795. var (
  2796. err error
  2797. once sync.Once
  2798. value *AliyunAvatar
  2799. )
  2800. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2801. once.Do(func() {
  2802. if m.done {
  2803. err = errors.New("querying old values post mutation is not allowed")
  2804. } else {
  2805. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2806. }
  2807. })
  2808. return value, err
  2809. }
  2810. m.id = &id
  2811. }
  2812. }
  2813. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2814. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2815. return func(m *AliyunAvatarMutation) {
  2816. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2817. return node, nil
  2818. }
  2819. m.id = &node.ID
  2820. }
  2821. }
  2822. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2823. // executed in a transaction (ent.Tx), a transactional client is returned.
  2824. func (m AliyunAvatarMutation) Client() *Client {
  2825. client := &Client{config: m.config}
  2826. client.init()
  2827. return client
  2828. }
  2829. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2830. // it returns an error otherwise.
  2831. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2832. if _, ok := m.driver.(*txDriver); !ok {
  2833. return nil, errors.New("ent: mutation is not running in a transaction")
  2834. }
  2835. tx := &Tx{config: m.config}
  2836. tx.init()
  2837. return tx, nil
  2838. }
  2839. // SetID sets the value of the id field. Note that this
  2840. // operation is only accepted on creation of AliyunAvatar entities.
  2841. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2842. m.id = &id
  2843. }
  2844. // ID returns the ID value in the mutation. Note that the ID is only available
  2845. // if it was provided to the builder or after it was returned from the database.
  2846. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2847. if m.id == nil {
  2848. return
  2849. }
  2850. return *m.id, true
  2851. }
  2852. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2853. // That means, if the mutation is applied within a transaction with an isolation level such
  2854. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2855. // or updated by the mutation.
  2856. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2857. switch {
  2858. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2859. id, exists := m.ID()
  2860. if exists {
  2861. return []uint64{id}, nil
  2862. }
  2863. fallthrough
  2864. case m.op.Is(OpUpdate | OpDelete):
  2865. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2866. default:
  2867. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2868. }
  2869. }
  2870. // SetCreatedAt sets the "created_at" field.
  2871. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2872. m.created_at = &t
  2873. }
  2874. // CreatedAt returns the value of the "created_at" field in the mutation.
  2875. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2876. v := m.created_at
  2877. if v == nil {
  2878. return
  2879. }
  2880. return *v, true
  2881. }
  2882. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2883. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2885. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2886. if !m.op.Is(OpUpdateOne) {
  2887. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2888. }
  2889. if m.id == nil || m.oldValue == nil {
  2890. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2891. }
  2892. oldValue, err := m.oldValue(ctx)
  2893. if err != nil {
  2894. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2895. }
  2896. return oldValue.CreatedAt, nil
  2897. }
  2898. // ResetCreatedAt resets all changes to the "created_at" field.
  2899. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2900. m.created_at = nil
  2901. }
  2902. // SetUpdatedAt sets the "updated_at" field.
  2903. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2904. m.updated_at = &t
  2905. }
  2906. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2907. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2908. v := m.updated_at
  2909. if v == nil {
  2910. return
  2911. }
  2912. return *v, true
  2913. }
  2914. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2915. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2917. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2918. if !m.op.Is(OpUpdateOne) {
  2919. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2920. }
  2921. if m.id == nil || m.oldValue == nil {
  2922. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2923. }
  2924. oldValue, err := m.oldValue(ctx)
  2925. if err != nil {
  2926. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2927. }
  2928. return oldValue.UpdatedAt, nil
  2929. }
  2930. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2931. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2932. m.updated_at = nil
  2933. }
  2934. // SetDeletedAt sets the "deleted_at" field.
  2935. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2936. m.deleted_at = &t
  2937. }
  2938. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2939. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2940. v := m.deleted_at
  2941. if v == nil {
  2942. return
  2943. }
  2944. return *v, true
  2945. }
  2946. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2947. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2949. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2950. if !m.op.Is(OpUpdateOne) {
  2951. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2952. }
  2953. if m.id == nil || m.oldValue == nil {
  2954. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2955. }
  2956. oldValue, err := m.oldValue(ctx)
  2957. if err != nil {
  2958. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2959. }
  2960. return oldValue.DeletedAt, nil
  2961. }
  2962. // ClearDeletedAt clears the value of the "deleted_at" field.
  2963. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2964. m.deleted_at = nil
  2965. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2966. }
  2967. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2968. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2969. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2970. return ok
  2971. }
  2972. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2973. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2974. m.deleted_at = nil
  2975. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2976. }
  2977. // SetUserID sets the "user_id" field.
  2978. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2979. m.user_id = &u
  2980. m.adduser_id = nil
  2981. }
  2982. // UserID returns the value of the "user_id" field in the mutation.
  2983. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2984. v := m.user_id
  2985. if v == nil {
  2986. return
  2987. }
  2988. return *v, true
  2989. }
  2990. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2991. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2993. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2994. if !m.op.Is(OpUpdateOne) {
  2995. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2996. }
  2997. if m.id == nil || m.oldValue == nil {
  2998. return v, errors.New("OldUserID requires an ID field in the mutation")
  2999. }
  3000. oldValue, err := m.oldValue(ctx)
  3001. if err != nil {
  3002. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3003. }
  3004. return oldValue.UserID, nil
  3005. }
  3006. // AddUserID adds u to the "user_id" field.
  3007. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  3008. if m.adduser_id != nil {
  3009. *m.adduser_id += u
  3010. } else {
  3011. m.adduser_id = &u
  3012. }
  3013. }
  3014. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  3015. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  3016. v := m.adduser_id
  3017. if v == nil {
  3018. return
  3019. }
  3020. return *v, true
  3021. }
  3022. // ResetUserID resets all changes to the "user_id" field.
  3023. func (m *AliyunAvatarMutation) ResetUserID() {
  3024. m.user_id = nil
  3025. m.adduser_id = nil
  3026. }
  3027. // SetBizID sets the "biz_id" field.
  3028. func (m *AliyunAvatarMutation) SetBizID(s string) {
  3029. m.biz_id = &s
  3030. }
  3031. // BizID returns the value of the "biz_id" field in the mutation.
  3032. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  3033. v := m.biz_id
  3034. if v == nil {
  3035. return
  3036. }
  3037. return *v, true
  3038. }
  3039. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  3040. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3042. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  3043. if !m.op.Is(OpUpdateOne) {
  3044. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  3045. }
  3046. if m.id == nil || m.oldValue == nil {
  3047. return v, errors.New("OldBizID requires an ID field in the mutation")
  3048. }
  3049. oldValue, err := m.oldValue(ctx)
  3050. if err != nil {
  3051. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  3052. }
  3053. return oldValue.BizID, nil
  3054. }
  3055. // ResetBizID resets all changes to the "biz_id" field.
  3056. func (m *AliyunAvatarMutation) ResetBizID() {
  3057. m.biz_id = nil
  3058. }
  3059. // SetAccessKeyID sets the "access_key_id" field.
  3060. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  3061. m.access_key_id = &s
  3062. }
  3063. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  3064. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  3065. v := m.access_key_id
  3066. if v == nil {
  3067. return
  3068. }
  3069. return *v, true
  3070. }
  3071. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  3072. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3074. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  3075. if !m.op.Is(OpUpdateOne) {
  3076. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  3077. }
  3078. if m.id == nil || m.oldValue == nil {
  3079. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  3080. }
  3081. oldValue, err := m.oldValue(ctx)
  3082. if err != nil {
  3083. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  3084. }
  3085. return oldValue.AccessKeyID, nil
  3086. }
  3087. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  3088. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  3089. m.access_key_id = nil
  3090. }
  3091. // SetAccessKeySecret sets the "access_key_secret" field.
  3092. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  3093. m.access_key_secret = &s
  3094. }
  3095. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  3096. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  3097. v := m.access_key_secret
  3098. if v == nil {
  3099. return
  3100. }
  3101. return *v, true
  3102. }
  3103. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  3104. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3106. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  3107. if !m.op.Is(OpUpdateOne) {
  3108. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  3109. }
  3110. if m.id == nil || m.oldValue == nil {
  3111. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  3112. }
  3113. oldValue, err := m.oldValue(ctx)
  3114. if err != nil {
  3115. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  3116. }
  3117. return oldValue.AccessKeySecret, nil
  3118. }
  3119. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  3120. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  3121. m.access_key_secret = nil
  3122. }
  3123. // SetAppID sets the "app_id" field.
  3124. func (m *AliyunAvatarMutation) SetAppID(s string) {
  3125. m.app_id = &s
  3126. }
  3127. // AppID returns the value of the "app_id" field in the mutation.
  3128. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  3129. v := m.app_id
  3130. if v == nil {
  3131. return
  3132. }
  3133. return *v, true
  3134. }
  3135. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  3136. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3138. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  3139. if !m.op.Is(OpUpdateOne) {
  3140. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  3141. }
  3142. if m.id == nil || m.oldValue == nil {
  3143. return v, errors.New("OldAppID requires an ID field in the mutation")
  3144. }
  3145. oldValue, err := m.oldValue(ctx)
  3146. if err != nil {
  3147. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  3148. }
  3149. return oldValue.AppID, nil
  3150. }
  3151. // ClearAppID clears the value of the "app_id" field.
  3152. func (m *AliyunAvatarMutation) ClearAppID() {
  3153. m.app_id = nil
  3154. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  3155. }
  3156. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  3157. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  3158. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  3159. return ok
  3160. }
  3161. // ResetAppID resets all changes to the "app_id" field.
  3162. func (m *AliyunAvatarMutation) ResetAppID() {
  3163. m.app_id = nil
  3164. delete(m.clearedFields, aliyunavatar.FieldAppID)
  3165. }
  3166. // SetTenantID sets the "tenant_id" field.
  3167. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  3168. m.tenant_id = &u
  3169. m.addtenant_id = nil
  3170. }
  3171. // TenantID returns the value of the "tenant_id" field in the mutation.
  3172. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  3173. v := m.tenant_id
  3174. if v == nil {
  3175. return
  3176. }
  3177. return *v, true
  3178. }
  3179. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  3180. // If the AliyunAvatar 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 *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  3183. if !m.op.Is(OpUpdateOne) {
  3184. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  3185. }
  3186. if m.id == nil || m.oldValue == nil {
  3187. return v, errors.New("OldTenantID 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 OldTenantID: %w", err)
  3192. }
  3193. return oldValue.TenantID, nil
  3194. }
  3195. // AddTenantID adds u to the "tenant_id" field.
  3196. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  3197. if m.addtenant_id != nil {
  3198. *m.addtenant_id += u
  3199. } else {
  3200. m.addtenant_id = &u
  3201. }
  3202. }
  3203. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  3204. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  3205. v := m.addtenant_id
  3206. if v == nil {
  3207. return
  3208. }
  3209. return *v, true
  3210. }
  3211. // ResetTenantID resets all changes to the "tenant_id" field.
  3212. func (m *AliyunAvatarMutation) ResetTenantID() {
  3213. m.tenant_id = nil
  3214. m.addtenant_id = nil
  3215. }
  3216. // SetResponse sets the "response" field.
  3217. func (m *AliyunAvatarMutation) SetResponse(s string) {
  3218. m.response = &s
  3219. }
  3220. // Response returns the value of the "response" field in the mutation.
  3221. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  3222. v := m.response
  3223. if v == nil {
  3224. return
  3225. }
  3226. return *v, true
  3227. }
  3228. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  3229. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3231. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  3232. if !m.op.Is(OpUpdateOne) {
  3233. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  3234. }
  3235. if m.id == nil || m.oldValue == nil {
  3236. return v, errors.New("OldResponse requires an ID field in the mutation")
  3237. }
  3238. oldValue, err := m.oldValue(ctx)
  3239. if err != nil {
  3240. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  3241. }
  3242. return oldValue.Response, nil
  3243. }
  3244. // ResetResponse resets all changes to the "response" field.
  3245. func (m *AliyunAvatarMutation) ResetResponse() {
  3246. m.response = nil
  3247. }
  3248. // SetToken sets the "token" field.
  3249. func (m *AliyunAvatarMutation) SetToken(s string) {
  3250. m.token = &s
  3251. }
  3252. // Token returns the value of the "token" field in the mutation.
  3253. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  3254. v := m.token
  3255. if v == nil {
  3256. return
  3257. }
  3258. return *v, true
  3259. }
  3260. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  3261. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3263. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  3264. if !m.op.Is(OpUpdateOne) {
  3265. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  3266. }
  3267. if m.id == nil || m.oldValue == nil {
  3268. return v, errors.New("OldToken requires an ID field in the mutation")
  3269. }
  3270. oldValue, err := m.oldValue(ctx)
  3271. if err != nil {
  3272. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  3273. }
  3274. return oldValue.Token, nil
  3275. }
  3276. // ResetToken resets all changes to the "token" field.
  3277. func (m *AliyunAvatarMutation) ResetToken() {
  3278. m.token = nil
  3279. }
  3280. // SetSessionID sets the "session_id" field.
  3281. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  3282. m.session_id = &s
  3283. }
  3284. // SessionID returns the value of the "session_id" field in the mutation.
  3285. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  3286. v := m.session_id
  3287. if v == nil {
  3288. return
  3289. }
  3290. return *v, true
  3291. }
  3292. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  3293. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3295. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  3296. if !m.op.Is(OpUpdateOne) {
  3297. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  3298. }
  3299. if m.id == nil || m.oldValue == nil {
  3300. return v, errors.New("OldSessionID requires an ID field in the mutation")
  3301. }
  3302. oldValue, err := m.oldValue(ctx)
  3303. if err != nil {
  3304. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  3305. }
  3306. return oldValue.SessionID, nil
  3307. }
  3308. // ResetSessionID resets all changes to the "session_id" field.
  3309. func (m *AliyunAvatarMutation) ResetSessionID() {
  3310. m.session_id = nil
  3311. }
  3312. // Where appends a list predicates to the AliyunAvatarMutation builder.
  3313. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  3314. m.predicates = append(m.predicates, ps...)
  3315. }
  3316. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  3317. // users can use type-assertion to append predicates that do not depend on any generated package.
  3318. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  3319. p := make([]predicate.AliyunAvatar, len(ps))
  3320. for i := range ps {
  3321. p[i] = ps[i]
  3322. }
  3323. m.Where(p...)
  3324. }
  3325. // Op returns the operation name.
  3326. func (m *AliyunAvatarMutation) Op() Op {
  3327. return m.op
  3328. }
  3329. // SetOp allows setting the mutation operation.
  3330. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3331. m.op = op
  3332. }
  3333. // Type returns the node type of this mutation (AliyunAvatar).
  3334. func (m *AliyunAvatarMutation) Type() string {
  3335. return m.typ
  3336. }
  3337. // Fields returns all fields that were changed during this mutation. Note that in
  3338. // order to get all numeric fields that were incremented/decremented, call
  3339. // AddedFields().
  3340. func (m *AliyunAvatarMutation) Fields() []string {
  3341. fields := make([]string, 0, 12)
  3342. if m.created_at != nil {
  3343. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3344. }
  3345. if m.updated_at != nil {
  3346. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3347. }
  3348. if m.deleted_at != nil {
  3349. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3350. }
  3351. if m.user_id != nil {
  3352. fields = append(fields, aliyunavatar.FieldUserID)
  3353. }
  3354. if m.biz_id != nil {
  3355. fields = append(fields, aliyunavatar.FieldBizID)
  3356. }
  3357. if m.access_key_id != nil {
  3358. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3359. }
  3360. if m.access_key_secret != nil {
  3361. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3362. }
  3363. if m.app_id != nil {
  3364. fields = append(fields, aliyunavatar.FieldAppID)
  3365. }
  3366. if m.tenant_id != nil {
  3367. fields = append(fields, aliyunavatar.FieldTenantID)
  3368. }
  3369. if m.response != nil {
  3370. fields = append(fields, aliyunavatar.FieldResponse)
  3371. }
  3372. if m.token != nil {
  3373. fields = append(fields, aliyunavatar.FieldToken)
  3374. }
  3375. if m.session_id != nil {
  3376. fields = append(fields, aliyunavatar.FieldSessionID)
  3377. }
  3378. return fields
  3379. }
  3380. // Field returns the value of a field with the given name. The second boolean
  3381. // return value indicates that this field was not set, or was not defined in the
  3382. // schema.
  3383. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3384. switch name {
  3385. case aliyunavatar.FieldCreatedAt:
  3386. return m.CreatedAt()
  3387. case aliyunavatar.FieldUpdatedAt:
  3388. return m.UpdatedAt()
  3389. case aliyunavatar.FieldDeletedAt:
  3390. return m.DeletedAt()
  3391. case aliyunavatar.FieldUserID:
  3392. return m.UserID()
  3393. case aliyunavatar.FieldBizID:
  3394. return m.BizID()
  3395. case aliyunavatar.FieldAccessKeyID:
  3396. return m.AccessKeyID()
  3397. case aliyunavatar.FieldAccessKeySecret:
  3398. return m.AccessKeySecret()
  3399. case aliyunavatar.FieldAppID:
  3400. return m.AppID()
  3401. case aliyunavatar.FieldTenantID:
  3402. return m.TenantID()
  3403. case aliyunavatar.FieldResponse:
  3404. return m.Response()
  3405. case aliyunavatar.FieldToken:
  3406. return m.Token()
  3407. case aliyunavatar.FieldSessionID:
  3408. return m.SessionID()
  3409. }
  3410. return nil, false
  3411. }
  3412. // OldField returns the old value of the field from the database. An error is
  3413. // returned if the mutation operation is not UpdateOne, or the query to the
  3414. // database failed.
  3415. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3416. switch name {
  3417. case aliyunavatar.FieldCreatedAt:
  3418. return m.OldCreatedAt(ctx)
  3419. case aliyunavatar.FieldUpdatedAt:
  3420. return m.OldUpdatedAt(ctx)
  3421. case aliyunavatar.FieldDeletedAt:
  3422. return m.OldDeletedAt(ctx)
  3423. case aliyunavatar.FieldUserID:
  3424. return m.OldUserID(ctx)
  3425. case aliyunavatar.FieldBizID:
  3426. return m.OldBizID(ctx)
  3427. case aliyunavatar.FieldAccessKeyID:
  3428. return m.OldAccessKeyID(ctx)
  3429. case aliyunavatar.FieldAccessKeySecret:
  3430. return m.OldAccessKeySecret(ctx)
  3431. case aliyunavatar.FieldAppID:
  3432. return m.OldAppID(ctx)
  3433. case aliyunavatar.FieldTenantID:
  3434. return m.OldTenantID(ctx)
  3435. case aliyunavatar.FieldResponse:
  3436. return m.OldResponse(ctx)
  3437. case aliyunavatar.FieldToken:
  3438. return m.OldToken(ctx)
  3439. case aliyunavatar.FieldSessionID:
  3440. return m.OldSessionID(ctx)
  3441. }
  3442. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3443. }
  3444. // SetField sets the value of a field with the given name. It returns an error if
  3445. // the field is not defined in the schema, or if the type mismatched the field
  3446. // type.
  3447. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3448. switch name {
  3449. case aliyunavatar.FieldCreatedAt:
  3450. v, ok := value.(time.Time)
  3451. if !ok {
  3452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3453. }
  3454. m.SetCreatedAt(v)
  3455. return nil
  3456. case aliyunavatar.FieldUpdatedAt:
  3457. v, ok := value.(time.Time)
  3458. if !ok {
  3459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3460. }
  3461. m.SetUpdatedAt(v)
  3462. return nil
  3463. case aliyunavatar.FieldDeletedAt:
  3464. v, ok := value.(time.Time)
  3465. if !ok {
  3466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3467. }
  3468. m.SetDeletedAt(v)
  3469. return nil
  3470. case aliyunavatar.FieldUserID:
  3471. v, ok := value.(uint64)
  3472. if !ok {
  3473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3474. }
  3475. m.SetUserID(v)
  3476. return nil
  3477. case aliyunavatar.FieldBizID:
  3478. v, ok := value.(string)
  3479. if !ok {
  3480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3481. }
  3482. m.SetBizID(v)
  3483. return nil
  3484. case aliyunavatar.FieldAccessKeyID:
  3485. v, ok := value.(string)
  3486. if !ok {
  3487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3488. }
  3489. m.SetAccessKeyID(v)
  3490. return nil
  3491. case aliyunavatar.FieldAccessKeySecret:
  3492. v, ok := value.(string)
  3493. if !ok {
  3494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3495. }
  3496. m.SetAccessKeySecret(v)
  3497. return nil
  3498. case aliyunavatar.FieldAppID:
  3499. v, ok := value.(string)
  3500. if !ok {
  3501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3502. }
  3503. m.SetAppID(v)
  3504. return nil
  3505. case aliyunavatar.FieldTenantID:
  3506. v, ok := value.(uint64)
  3507. if !ok {
  3508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3509. }
  3510. m.SetTenantID(v)
  3511. return nil
  3512. case aliyunavatar.FieldResponse:
  3513. v, ok := value.(string)
  3514. if !ok {
  3515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3516. }
  3517. m.SetResponse(v)
  3518. return nil
  3519. case aliyunavatar.FieldToken:
  3520. v, ok := value.(string)
  3521. if !ok {
  3522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3523. }
  3524. m.SetToken(v)
  3525. return nil
  3526. case aliyunavatar.FieldSessionID:
  3527. v, ok := value.(string)
  3528. if !ok {
  3529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3530. }
  3531. m.SetSessionID(v)
  3532. return nil
  3533. }
  3534. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3535. }
  3536. // AddedFields returns all numeric fields that were incremented/decremented during
  3537. // this mutation.
  3538. func (m *AliyunAvatarMutation) AddedFields() []string {
  3539. var fields []string
  3540. if m.adduser_id != nil {
  3541. fields = append(fields, aliyunavatar.FieldUserID)
  3542. }
  3543. if m.addtenant_id != nil {
  3544. fields = append(fields, aliyunavatar.FieldTenantID)
  3545. }
  3546. return fields
  3547. }
  3548. // AddedField returns the numeric value that was incremented/decremented on a field
  3549. // with the given name. The second boolean return value indicates that this field
  3550. // was not set, or was not defined in the schema.
  3551. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3552. switch name {
  3553. case aliyunavatar.FieldUserID:
  3554. return m.AddedUserID()
  3555. case aliyunavatar.FieldTenantID:
  3556. return m.AddedTenantID()
  3557. }
  3558. return nil, false
  3559. }
  3560. // AddField adds the value to the field with the given name. It returns an error if
  3561. // the field is not defined in the schema, or if the type mismatched the field
  3562. // type.
  3563. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3564. switch name {
  3565. case aliyunavatar.FieldUserID:
  3566. v, ok := value.(int64)
  3567. if !ok {
  3568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3569. }
  3570. m.AddUserID(v)
  3571. return nil
  3572. case aliyunavatar.FieldTenantID:
  3573. v, ok := value.(int64)
  3574. if !ok {
  3575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3576. }
  3577. m.AddTenantID(v)
  3578. return nil
  3579. }
  3580. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3581. }
  3582. // ClearedFields returns all nullable fields that were cleared during this
  3583. // mutation.
  3584. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3585. var fields []string
  3586. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3587. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3588. }
  3589. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3590. fields = append(fields, aliyunavatar.FieldAppID)
  3591. }
  3592. return fields
  3593. }
  3594. // FieldCleared returns a boolean indicating if a field with the given name was
  3595. // cleared in this mutation.
  3596. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3597. _, ok := m.clearedFields[name]
  3598. return ok
  3599. }
  3600. // ClearField clears the value of the field with the given name. It returns an
  3601. // error if the field is not defined in the schema.
  3602. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3603. switch name {
  3604. case aliyunavatar.FieldDeletedAt:
  3605. m.ClearDeletedAt()
  3606. return nil
  3607. case aliyunavatar.FieldAppID:
  3608. m.ClearAppID()
  3609. return nil
  3610. }
  3611. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3612. }
  3613. // ResetField resets all changes in the mutation for the field with the given name.
  3614. // It returns an error if the field is not defined in the schema.
  3615. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3616. switch name {
  3617. case aliyunavatar.FieldCreatedAt:
  3618. m.ResetCreatedAt()
  3619. return nil
  3620. case aliyunavatar.FieldUpdatedAt:
  3621. m.ResetUpdatedAt()
  3622. return nil
  3623. case aliyunavatar.FieldDeletedAt:
  3624. m.ResetDeletedAt()
  3625. return nil
  3626. case aliyunavatar.FieldUserID:
  3627. m.ResetUserID()
  3628. return nil
  3629. case aliyunavatar.FieldBizID:
  3630. m.ResetBizID()
  3631. return nil
  3632. case aliyunavatar.FieldAccessKeyID:
  3633. m.ResetAccessKeyID()
  3634. return nil
  3635. case aliyunavatar.FieldAccessKeySecret:
  3636. m.ResetAccessKeySecret()
  3637. return nil
  3638. case aliyunavatar.FieldAppID:
  3639. m.ResetAppID()
  3640. return nil
  3641. case aliyunavatar.FieldTenantID:
  3642. m.ResetTenantID()
  3643. return nil
  3644. case aliyunavatar.FieldResponse:
  3645. m.ResetResponse()
  3646. return nil
  3647. case aliyunavatar.FieldToken:
  3648. m.ResetToken()
  3649. return nil
  3650. case aliyunavatar.FieldSessionID:
  3651. m.ResetSessionID()
  3652. return nil
  3653. }
  3654. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3655. }
  3656. // AddedEdges returns all edge names that were set/added in this mutation.
  3657. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3658. edges := make([]string, 0, 0)
  3659. return edges
  3660. }
  3661. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3662. // name in this mutation.
  3663. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3664. return nil
  3665. }
  3666. // RemovedEdges returns all edge names that were removed in this mutation.
  3667. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3668. edges := make([]string, 0, 0)
  3669. return edges
  3670. }
  3671. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3672. // the given name in this mutation.
  3673. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3674. return nil
  3675. }
  3676. // ClearedEdges returns all edge names that were cleared in this mutation.
  3677. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3678. edges := make([]string, 0, 0)
  3679. return edges
  3680. }
  3681. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3682. // was cleared in this mutation.
  3683. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3684. return false
  3685. }
  3686. // ClearEdge clears the value of the edge with the given name. It returns an error
  3687. // if that edge is not defined in the schema.
  3688. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3689. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3690. }
  3691. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3692. // It returns an error if the edge is not defined in the schema.
  3693. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3694. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3695. }
  3696. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3697. type AllocAgentMutation struct {
  3698. config
  3699. op Op
  3700. typ string
  3701. id *uint64
  3702. created_at *time.Time
  3703. updated_at *time.Time
  3704. deleted_at *time.Time
  3705. user_id *string
  3706. organization_id *uint64
  3707. addorganization_id *int64
  3708. agents *[]uint64
  3709. appendagents []uint64
  3710. status *int
  3711. addstatus *int
  3712. clearedFields map[string]struct{}
  3713. done bool
  3714. oldValue func(context.Context) (*AllocAgent, error)
  3715. predicates []predicate.AllocAgent
  3716. }
  3717. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3718. // allocagentOption allows management of the mutation configuration using functional options.
  3719. type allocagentOption func(*AllocAgentMutation)
  3720. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3721. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3722. m := &AllocAgentMutation{
  3723. config: c,
  3724. op: op,
  3725. typ: TypeAllocAgent,
  3726. clearedFields: make(map[string]struct{}),
  3727. }
  3728. for _, opt := range opts {
  3729. opt(m)
  3730. }
  3731. return m
  3732. }
  3733. // withAllocAgentID sets the ID field of the mutation.
  3734. func withAllocAgentID(id uint64) allocagentOption {
  3735. return func(m *AllocAgentMutation) {
  3736. var (
  3737. err error
  3738. once sync.Once
  3739. value *AllocAgent
  3740. )
  3741. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3742. once.Do(func() {
  3743. if m.done {
  3744. err = errors.New("querying old values post mutation is not allowed")
  3745. } else {
  3746. value, err = m.Client().AllocAgent.Get(ctx, id)
  3747. }
  3748. })
  3749. return value, err
  3750. }
  3751. m.id = &id
  3752. }
  3753. }
  3754. // withAllocAgent sets the old AllocAgent of the mutation.
  3755. func withAllocAgent(node *AllocAgent) allocagentOption {
  3756. return func(m *AllocAgentMutation) {
  3757. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3758. return node, nil
  3759. }
  3760. m.id = &node.ID
  3761. }
  3762. }
  3763. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3764. // executed in a transaction (ent.Tx), a transactional client is returned.
  3765. func (m AllocAgentMutation) Client() *Client {
  3766. client := &Client{config: m.config}
  3767. client.init()
  3768. return client
  3769. }
  3770. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3771. // it returns an error otherwise.
  3772. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3773. if _, ok := m.driver.(*txDriver); !ok {
  3774. return nil, errors.New("ent: mutation is not running in a transaction")
  3775. }
  3776. tx := &Tx{config: m.config}
  3777. tx.init()
  3778. return tx, nil
  3779. }
  3780. // SetID sets the value of the id field. Note that this
  3781. // operation is only accepted on creation of AllocAgent entities.
  3782. func (m *AllocAgentMutation) SetID(id uint64) {
  3783. m.id = &id
  3784. }
  3785. // ID returns the ID value in the mutation. Note that the ID is only available
  3786. // if it was provided to the builder or after it was returned from the database.
  3787. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3788. if m.id == nil {
  3789. return
  3790. }
  3791. return *m.id, true
  3792. }
  3793. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3794. // That means, if the mutation is applied within a transaction with an isolation level such
  3795. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3796. // or updated by the mutation.
  3797. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3798. switch {
  3799. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3800. id, exists := m.ID()
  3801. if exists {
  3802. return []uint64{id}, nil
  3803. }
  3804. fallthrough
  3805. case m.op.Is(OpUpdate | OpDelete):
  3806. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3807. default:
  3808. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3809. }
  3810. }
  3811. // SetCreatedAt sets the "created_at" field.
  3812. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3813. m.created_at = &t
  3814. }
  3815. // CreatedAt returns the value of the "created_at" field in the mutation.
  3816. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3817. v := m.created_at
  3818. if v == nil {
  3819. return
  3820. }
  3821. return *v, true
  3822. }
  3823. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3824. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3826. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3827. if !m.op.Is(OpUpdateOne) {
  3828. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3829. }
  3830. if m.id == nil || m.oldValue == nil {
  3831. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3832. }
  3833. oldValue, err := m.oldValue(ctx)
  3834. if err != nil {
  3835. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3836. }
  3837. return oldValue.CreatedAt, nil
  3838. }
  3839. // ResetCreatedAt resets all changes to the "created_at" field.
  3840. func (m *AllocAgentMutation) ResetCreatedAt() {
  3841. m.created_at = nil
  3842. }
  3843. // SetUpdatedAt sets the "updated_at" field.
  3844. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3845. m.updated_at = &t
  3846. }
  3847. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3848. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3849. v := m.updated_at
  3850. if v == nil {
  3851. return
  3852. }
  3853. return *v, true
  3854. }
  3855. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3856. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3858. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3859. if !m.op.Is(OpUpdateOne) {
  3860. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3861. }
  3862. if m.id == nil || m.oldValue == nil {
  3863. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3864. }
  3865. oldValue, err := m.oldValue(ctx)
  3866. if err != nil {
  3867. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3868. }
  3869. return oldValue.UpdatedAt, nil
  3870. }
  3871. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3872. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3873. m.updated_at = nil
  3874. }
  3875. // SetDeletedAt sets the "deleted_at" field.
  3876. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3877. m.deleted_at = &t
  3878. }
  3879. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3880. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3881. v := m.deleted_at
  3882. if v == nil {
  3883. return
  3884. }
  3885. return *v, true
  3886. }
  3887. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3888. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3890. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3891. if !m.op.Is(OpUpdateOne) {
  3892. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3893. }
  3894. if m.id == nil || m.oldValue == nil {
  3895. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3896. }
  3897. oldValue, err := m.oldValue(ctx)
  3898. if err != nil {
  3899. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3900. }
  3901. return oldValue.DeletedAt, nil
  3902. }
  3903. // ClearDeletedAt clears the value of the "deleted_at" field.
  3904. func (m *AllocAgentMutation) ClearDeletedAt() {
  3905. m.deleted_at = nil
  3906. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3907. }
  3908. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3909. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3910. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3911. return ok
  3912. }
  3913. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3914. func (m *AllocAgentMutation) ResetDeletedAt() {
  3915. m.deleted_at = nil
  3916. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3917. }
  3918. // SetUserID sets the "user_id" field.
  3919. func (m *AllocAgentMutation) SetUserID(s string) {
  3920. m.user_id = &s
  3921. }
  3922. // UserID returns the value of the "user_id" field in the mutation.
  3923. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3924. v := m.user_id
  3925. if v == nil {
  3926. return
  3927. }
  3928. return *v, true
  3929. }
  3930. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3931. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3933. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3934. if !m.op.Is(OpUpdateOne) {
  3935. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3936. }
  3937. if m.id == nil || m.oldValue == nil {
  3938. return v, errors.New("OldUserID requires an ID field in the mutation")
  3939. }
  3940. oldValue, err := m.oldValue(ctx)
  3941. if err != nil {
  3942. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3943. }
  3944. return oldValue.UserID, nil
  3945. }
  3946. // ClearUserID clears the value of the "user_id" field.
  3947. func (m *AllocAgentMutation) ClearUserID() {
  3948. m.user_id = nil
  3949. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3950. }
  3951. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3952. func (m *AllocAgentMutation) UserIDCleared() bool {
  3953. _, ok := m.clearedFields[allocagent.FieldUserID]
  3954. return ok
  3955. }
  3956. // ResetUserID resets all changes to the "user_id" field.
  3957. func (m *AllocAgentMutation) ResetUserID() {
  3958. m.user_id = nil
  3959. delete(m.clearedFields, allocagent.FieldUserID)
  3960. }
  3961. // SetOrganizationID sets the "organization_id" field.
  3962. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3963. m.organization_id = &u
  3964. m.addorganization_id = nil
  3965. }
  3966. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3967. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3968. v := m.organization_id
  3969. if v == nil {
  3970. return
  3971. }
  3972. return *v, true
  3973. }
  3974. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3975. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3977. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3978. if !m.op.Is(OpUpdateOne) {
  3979. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3980. }
  3981. if m.id == nil || m.oldValue == nil {
  3982. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3983. }
  3984. oldValue, err := m.oldValue(ctx)
  3985. if err != nil {
  3986. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3987. }
  3988. return oldValue.OrganizationID, nil
  3989. }
  3990. // AddOrganizationID adds u to the "organization_id" field.
  3991. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3992. if m.addorganization_id != nil {
  3993. *m.addorganization_id += u
  3994. } else {
  3995. m.addorganization_id = &u
  3996. }
  3997. }
  3998. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3999. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  4000. v := m.addorganization_id
  4001. if v == nil {
  4002. return
  4003. }
  4004. return *v, true
  4005. }
  4006. // ClearOrganizationID clears the value of the "organization_id" field.
  4007. func (m *AllocAgentMutation) ClearOrganizationID() {
  4008. m.organization_id = nil
  4009. m.addorganization_id = nil
  4010. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  4011. }
  4012. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4013. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  4014. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  4015. return ok
  4016. }
  4017. // ResetOrganizationID resets all changes to the "organization_id" field.
  4018. func (m *AllocAgentMutation) ResetOrganizationID() {
  4019. m.organization_id = nil
  4020. m.addorganization_id = nil
  4021. delete(m.clearedFields, allocagent.FieldOrganizationID)
  4022. }
  4023. // SetAgents sets the "agents" field.
  4024. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  4025. m.agents = &u
  4026. m.appendagents = nil
  4027. }
  4028. // Agents returns the value of the "agents" field in the mutation.
  4029. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  4030. v := m.agents
  4031. if v == nil {
  4032. return
  4033. }
  4034. return *v, true
  4035. }
  4036. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  4037. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4039. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  4040. if !m.op.Is(OpUpdateOne) {
  4041. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  4042. }
  4043. if m.id == nil || m.oldValue == nil {
  4044. return v, errors.New("OldAgents requires an ID field in the mutation")
  4045. }
  4046. oldValue, err := m.oldValue(ctx)
  4047. if err != nil {
  4048. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  4049. }
  4050. return oldValue.Agents, nil
  4051. }
  4052. // AppendAgents adds u to the "agents" field.
  4053. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  4054. m.appendagents = append(m.appendagents, u...)
  4055. }
  4056. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  4057. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  4058. if len(m.appendagents) == 0 {
  4059. return nil, false
  4060. }
  4061. return m.appendagents, true
  4062. }
  4063. // ResetAgents resets all changes to the "agents" field.
  4064. func (m *AllocAgentMutation) ResetAgents() {
  4065. m.agents = nil
  4066. m.appendagents = nil
  4067. }
  4068. // SetStatus sets the "status" field.
  4069. func (m *AllocAgentMutation) SetStatus(i int) {
  4070. m.status = &i
  4071. m.addstatus = nil
  4072. }
  4073. // Status returns the value of the "status" field in the mutation.
  4074. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  4075. v := m.status
  4076. if v == nil {
  4077. return
  4078. }
  4079. return *v, true
  4080. }
  4081. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  4082. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4084. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  4085. if !m.op.Is(OpUpdateOne) {
  4086. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4087. }
  4088. if m.id == nil || m.oldValue == nil {
  4089. return v, errors.New("OldStatus requires an ID field in the mutation")
  4090. }
  4091. oldValue, err := m.oldValue(ctx)
  4092. if err != nil {
  4093. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4094. }
  4095. return oldValue.Status, nil
  4096. }
  4097. // AddStatus adds i to the "status" field.
  4098. func (m *AllocAgentMutation) AddStatus(i int) {
  4099. if m.addstatus != nil {
  4100. *m.addstatus += i
  4101. } else {
  4102. m.addstatus = &i
  4103. }
  4104. }
  4105. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4106. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  4107. v := m.addstatus
  4108. if v == nil {
  4109. return
  4110. }
  4111. return *v, true
  4112. }
  4113. // ClearStatus clears the value of the "status" field.
  4114. func (m *AllocAgentMutation) ClearStatus() {
  4115. m.status = nil
  4116. m.addstatus = nil
  4117. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  4118. }
  4119. // StatusCleared returns if the "status" field was cleared in this mutation.
  4120. func (m *AllocAgentMutation) StatusCleared() bool {
  4121. _, ok := m.clearedFields[allocagent.FieldStatus]
  4122. return ok
  4123. }
  4124. // ResetStatus resets all changes to the "status" field.
  4125. func (m *AllocAgentMutation) ResetStatus() {
  4126. m.status = nil
  4127. m.addstatus = nil
  4128. delete(m.clearedFields, allocagent.FieldStatus)
  4129. }
  4130. // Where appends a list predicates to the AllocAgentMutation builder.
  4131. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  4132. m.predicates = append(m.predicates, ps...)
  4133. }
  4134. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  4135. // users can use type-assertion to append predicates that do not depend on any generated package.
  4136. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  4137. p := make([]predicate.AllocAgent, len(ps))
  4138. for i := range ps {
  4139. p[i] = ps[i]
  4140. }
  4141. m.Where(p...)
  4142. }
  4143. // Op returns the operation name.
  4144. func (m *AllocAgentMutation) Op() Op {
  4145. return m.op
  4146. }
  4147. // SetOp allows setting the mutation operation.
  4148. func (m *AllocAgentMutation) SetOp(op Op) {
  4149. m.op = op
  4150. }
  4151. // Type returns the node type of this mutation (AllocAgent).
  4152. func (m *AllocAgentMutation) Type() string {
  4153. return m.typ
  4154. }
  4155. // Fields returns all fields that were changed during this mutation. Note that in
  4156. // order to get all numeric fields that were incremented/decremented, call
  4157. // AddedFields().
  4158. func (m *AllocAgentMutation) Fields() []string {
  4159. fields := make([]string, 0, 7)
  4160. if m.created_at != nil {
  4161. fields = append(fields, allocagent.FieldCreatedAt)
  4162. }
  4163. if m.updated_at != nil {
  4164. fields = append(fields, allocagent.FieldUpdatedAt)
  4165. }
  4166. if m.deleted_at != nil {
  4167. fields = append(fields, allocagent.FieldDeletedAt)
  4168. }
  4169. if m.user_id != nil {
  4170. fields = append(fields, allocagent.FieldUserID)
  4171. }
  4172. if m.organization_id != nil {
  4173. fields = append(fields, allocagent.FieldOrganizationID)
  4174. }
  4175. if m.agents != nil {
  4176. fields = append(fields, allocagent.FieldAgents)
  4177. }
  4178. if m.status != nil {
  4179. fields = append(fields, allocagent.FieldStatus)
  4180. }
  4181. return fields
  4182. }
  4183. // Field returns the value of a field with the given name. The second boolean
  4184. // return value indicates that this field was not set, or was not defined in the
  4185. // schema.
  4186. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  4187. switch name {
  4188. case allocagent.FieldCreatedAt:
  4189. return m.CreatedAt()
  4190. case allocagent.FieldUpdatedAt:
  4191. return m.UpdatedAt()
  4192. case allocagent.FieldDeletedAt:
  4193. return m.DeletedAt()
  4194. case allocagent.FieldUserID:
  4195. return m.UserID()
  4196. case allocagent.FieldOrganizationID:
  4197. return m.OrganizationID()
  4198. case allocagent.FieldAgents:
  4199. return m.Agents()
  4200. case allocagent.FieldStatus:
  4201. return m.Status()
  4202. }
  4203. return nil, false
  4204. }
  4205. // OldField returns the old value of the field from the database. An error is
  4206. // returned if the mutation operation is not UpdateOne, or the query to the
  4207. // database failed.
  4208. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4209. switch name {
  4210. case allocagent.FieldCreatedAt:
  4211. return m.OldCreatedAt(ctx)
  4212. case allocagent.FieldUpdatedAt:
  4213. return m.OldUpdatedAt(ctx)
  4214. case allocagent.FieldDeletedAt:
  4215. return m.OldDeletedAt(ctx)
  4216. case allocagent.FieldUserID:
  4217. return m.OldUserID(ctx)
  4218. case allocagent.FieldOrganizationID:
  4219. return m.OldOrganizationID(ctx)
  4220. case allocagent.FieldAgents:
  4221. return m.OldAgents(ctx)
  4222. case allocagent.FieldStatus:
  4223. return m.OldStatus(ctx)
  4224. }
  4225. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  4226. }
  4227. // SetField sets the value of a field with the given name. It returns an error if
  4228. // the field is not defined in the schema, or if the type mismatched the field
  4229. // type.
  4230. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  4231. switch name {
  4232. case allocagent.FieldCreatedAt:
  4233. v, ok := value.(time.Time)
  4234. if !ok {
  4235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4236. }
  4237. m.SetCreatedAt(v)
  4238. return nil
  4239. case allocagent.FieldUpdatedAt:
  4240. v, ok := value.(time.Time)
  4241. if !ok {
  4242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4243. }
  4244. m.SetUpdatedAt(v)
  4245. return nil
  4246. case allocagent.FieldDeletedAt:
  4247. v, ok := value.(time.Time)
  4248. if !ok {
  4249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4250. }
  4251. m.SetDeletedAt(v)
  4252. return nil
  4253. case allocagent.FieldUserID:
  4254. v, ok := value.(string)
  4255. if !ok {
  4256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4257. }
  4258. m.SetUserID(v)
  4259. return nil
  4260. case allocagent.FieldOrganizationID:
  4261. v, ok := value.(uint64)
  4262. if !ok {
  4263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4264. }
  4265. m.SetOrganizationID(v)
  4266. return nil
  4267. case allocagent.FieldAgents:
  4268. v, ok := value.([]uint64)
  4269. if !ok {
  4270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4271. }
  4272. m.SetAgents(v)
  4273. return nil
  4274. case allocagent.FieldStatus:
  4275. v, ok := value.(int)
  4276. if !ok {
  4277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4278. }
  4279. m.SetStatus(v)
  4280. return nil
  4281. }
  4282. return fmt.Errorf("unknown AllocAgent field %s", name)
  4283. }
  4284. // AddedFields returns all numeric fields that were incremented/decremented during
  4285. // this mutation.
  4286. func (m *AllocAgentMutation) AddedFields() []string {
  4287. var fields []string
  4288. if m.addorganization_id != nil {
  4289. fields = append(fields, allocagent.FieldOrganizationID)
  4290. }
  4291. if m.addstatus != nil {
  4292. fields = append(fields, allocagent.FieldStatus)
  4293. }
  4294. return fields
  4295. }
  4296. // AddedField returns the numeric value that was incremented/decremented on a field
  4297. // with the given name. The second boolean return value indicates that this field
  4298. // was not set, or was not defined in the schema.
  4299. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  4300. switch name {
  4301. case allocagent.FieldOrganizationID:
  4302. return m.AddedOrganizationID()
  4303. case allocagent.FieldStatus:
  4304. return m.AddedStatus()
  4305. }
  4306. return nil, false
  4307. }
  4308. // AddField adds the value to the field with the given name. It returns an error if
  4309. // the field is not defined in the schema, or if the type mismatched the field
  4310. // type.
  4311. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  4312. switch name {
  4313. case allocagent.FieldOrganizationID:
  4314. v, ok := value.(int64)
  4315. if !ok {
  4316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4317. }
  4318. m.AddOrganizationID(v)
  4319. return nil
  4320. case allocagent.FieldStatus:
  4321. v, ok := value.(int)
  4322. if !ok {
  4323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4324. }
  4325. m.AddStatus(v)
  4326. return nil
  4327. }
  4328. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4329. }
  4330. // ClearedFields returns all nullable fields that were cleared during this
  4331. // mutation.
  4332. func (m *AllocAgentMutation) ClearedFields() []string {
  4333. var fields []string
  4334. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4335. fields = append(fields, allocagent.FieldDeletedAt)
  4336. }
  4337. if m.FieldCleared(allocagent.FieldUserID) {
  4338. fields = append(fields, allocagent.FieldUserID)
  4339. }
  4340. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4341. fields = append(fields, allocagent.FieldOrganizationID)
  4342. }
  4343. if m.FieldCleared(allocagent.FieldStatus) {
  4344. fields = append(fields, allocagent.FieldStatus)
  4345. }
  4346. return fields
  4347. }
  4348. // FieldCleared returns a boolean indicating if a field with the given name was
  4349. // cleared in this mutation.
  4350. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4351. _, ok := m.clearedFields[name]
  4352. return ok
  4353. }
  4354. // ClearField clears the value of the field with the given name. It returns an
  4355. // error if the field is not defined in the schema.
  4356. func (m *AllocAgentMutation) ClearField(name string) error {
  4357. switch name {
  4358. case allocagent.FieldDeletedAt:
  4359. m.ClearDeletedAt()
  4360. return nil
  4361. case allocagent.FieldUserID:
  4362. m.ClearUserID()
  4363. return nil
  4364. case allocagent.FieldOrganizationID:
  4365. m.ClearOrganizationID()
  4366. return nil
  4367. case allocagent.FieldStatus:
  4368. m.ClearStatus()
  4369. return nil
  4370. }
  4371. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4372. }
  4373. // ResetField resets all changes in the mutation for the field with the given name.
  4374. // It returns an error if the field is not defined in the schema.
  4375. func (m *AllocAgentMutation) ResetField(name string) error {
  4376. switch name {
  4377. case allocagent.FieldCreatedAt:
  4378. m.ResetCreatedAt()
  4379. return nil
  4380. case allocagent.FieldUpdatedAt:
  4381. m.ResetUpdatedAt()
  4382. return nil
  4383. case allocagent.FieldDeletedAt:
  4384. m.ResetDeletedAt()
  4385. return nil
  4386. case allocagent.FieldUserID:
  4387. m.ResetUserID()
  4388. return nil
  4389. case allocagent.FieldOrganizationID:
  4390. m.ResetOrganizationID()
  4391. return nil
  4392. case allocagent.FieldAgents:
  4393. m.ResetAgents()
  4394. return nil
  4395. case allocagent.FieldStatus:
  4396. m.ResetStatus()
  4397. return nil
  4398. }
  4399. return fmt.Errorf("unknown AllocAgent field %s", name)
  4400. }
  4401. // AddedEdges returns all edge names that were set/added in this mutation.
  4402. func (m *AllocAgentMutation) AddedEdges() []string {
  4403. edges := make([]string, 0, 0)
  4404. return edges
  4405. }
  4406. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4407. // name in this mutation.
  4408. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4409. return nil
  4410. }
  4411. // RemovedEdges returns all edge names that were removed in this mutation.
  4412. func (m *AllocAgentMutation) RemovedEdges() []string {
  4413. edges := make([]string, 0, 0)
  4414. return edges
  4415. }
  4416. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4417. // the given name in this mutation.
  4418. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4419. return nil
  4420. }
  4421. // ClearedEdges returns all edge names that were cleared in this mutation.
  4422. func (m *AllocAgentMutation) ClearedEdges() []string {
  4423. edges := make([]string, 0, 0)
  4424. return edges
  4425. }
  4426. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4427. // was cleared in this mutation.
  4428. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4429. return false
  4430. }
  4431. // ClearEdge clears the value of the edge with the given name. It returns an error
  4432. // if that edge is not defined in the schema.
  4433. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4434. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4435. }
  4436. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4437. // It returns an error if the edge is not defined in the schema.
  4438. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4439. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4440. }
  4441. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4442. type ApiKeyMutation struct {
  4443. config
  4444. op Op
  4445. typ string
  4446. id *uint64
  4447. created_at *time.Time
  4448. updated_at *time.Time
  4449. deleted_at *time.Time
  4450. title *string
  4451. key *string
  4452. organization_id *uint64
  4453. addorganization_id *int64
  4454. custom_agent_base *string
  4455. custom_agent_key *string
  4456. openai_base *string
  4457. openai_key *string
  4458. clearedFields map[string]struct{}
  4459. agent *uint64
  4460. clearedagent bool
  4461. done bool
  4462. oldValue func(context.Context) (*ApiKey, error)
  4463. predicates []predicate.ApiKey
  4464. }
  4465. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4466. // apikeyOption allows management of the mutation configuration using functional options.
  4467. type apikeyOption func(*ApiKeyMutation)
  4468. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4469. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4470. m := &ApiKeyMutation{
  4471. config: c,
  4472. op: op,
  4473. typ: TypeApiKey,
  4474. clearedFields: make(map[string]struct{}),
  4475. }
  4476. for _, opt := range opts {
  4477. opt(m)
  4478. }
  4479. return m
  4480. }
  4481. // withApiKeyID sets the ID field of the mutation.
  4482. func withApiKeyID(id uint64) apikeyOption {
  4483. return func(m *ApiKeyMutation) {
  4484. var (
  4485. err error
  4486. once sync.Once
  4487. value *ApiKey
  4488. )
  4489. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4490. once.Do(func() {
  4491. if m.done {
  4492. err = errors.New("querying old values post mutation is not allowed")
  4493. } else {
  4494. value, err = m.Client().ApiKey.Get(ctx, id)
  4495. }
  4496. })
  4497. return value, err
  4498. }
  4499. m.id = &id
  4500. }
  4501. }
  4502. // withApiKey sets the old ApiKey of the mutation.
  4503. func withApiKey(node *ApiKey) apikeyOption {
  4504. return func(m *ApiKeyMutation) {
  4505. m.oldValue = func(context.Context) (*ApiKey, error) {
  4506. return node, nil
  4507. }
  4508. m.id = &node.ID
  4509. }
  4510. }
  4511. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4512. // executed in a transaction (ent.Tx), a transactional client is returned.
  4513. func (m ApiKeyMutation) Client() *Client {
  4514. client := &Client{config: m.config}
  4515. client.init()
  4516. return client
  4517. }
  4518. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4519. // it returns an error otherwise.
  4520. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4521. if _, ok := m.driver.(*txDriver); !ok {
  4522. return nil, errors.New("ent: mutation is not running in a transaction")
  4523. }
  4524. tx := &Tx{config: m.config}
  4525. tx.init()
  4526. return tx, nil
  4527. }
  4528. // SetID sets the value of the id field. Note that this
  4529. // operation is only accepted on creation of ApiKey entities.
  4530. func (m *ApiKeyMutation) SetID(id uint64) {
  4531. m.id = &id
  4532. }
  4533. // ID returns the ID value in the mutation. Note that the ID is only available
  4534. // if it was provided to the builder or after it was returned from the database.
  4535. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4536. if m.id == nil {
  4537. return
  4538. }
  4539. return *m.id, true
  4540. }
  4541. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4542. // That means, if the mutation is applied within a transaction with an isolation level such
  4543. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4544. // or updated by the mutation.
  4545. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4546. switch {
  4547. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4548. id, exists := m.ID()
  4549. if exists {
  4550. return []uint64{id}, nil
  4551. }
  4552. fallthrough
  4553. case m.op.Is(OpUpdate | OpDelete):
  4554. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4555. default:
  4556. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4557. }
  4558. }
  4559. // SetCreatedAt sets the "created_at" field.
  4560. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4561. m.created_at = &t
  4562. }
  4563. // CreatedAt returns the value of the "created_at" field in the mutation.
  4564. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4565. v := m.created_at
  4566. if v == nil {
  4567. return
  4568. }
  4569. return *v, true
  4570. }
  4571. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4572. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4574. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4575. if !m.op.Is(OpUpdateOne) {
  4576. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4577. }
  4578. if m.id == nil || m.oldValue == nil {
  4579. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4580. }
  4581. oldValue, err := m.oldValue(ctx)
  4582. if err != nil {
  4583. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4584. }
  4585. return oldValue.CreatedAt, nil
  4586. }
  4587. // ResetCreatedAt resets all changes to the "created_at" field.
  4588. func (m *ApiKeyMutation) ResetCreatedAt() {
  4589. m.created_at = nil
  4590. }
  4591. // SetUpdatedAt sets the "updated_at" field.
  4592. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4593. m.updated_at = &t
  4594. }
  4595. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4596. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4597. v := m.updated_at
  4598. if v == nil {
  4599. return
  4600. }
  4601. return *v, true
  4602. }
  4603. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4604. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4606. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4607. if !m.op.Is(OpUpdateOne) {
  4608. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4609. }
  4610. if m.id == nil || m.oldValue == nil {
  4611. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4612. }
  4613. oldValue, err := m.oldValue(ctx)
  4614. if err != nil {
  4615. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4616. }
  4617. return oldValue.UpdatedAt, nil
  4618. }
  4619. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4620. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4621. m.updated_at = nil
  4622. }
  4623. // SetDeletedAt sets the "deleted_at" field.
  4624. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4625. m.deleted_at = &t
  4626. }
  4627. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4628. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4629. v := m.deleted_at
  4630. if v == nil {
  4631. return
  4632. }
  4633. return *v, true
  4634. }
  4635. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4636. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4638. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4639. if !m.op.Is(OpUpdateOne) {
  4640. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4641. }
  4642. if m.id == nil || m.oldValue == nil {
  4643. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4644. }
  4645. oldValue, err := m.oldValue(ctx)
  4646. if err != nil {
  4647. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4648. }
  4649. return oldValue.DeletedAt, nil
  4650. }
  4651. // ClearDeletedAt clears the value of the "deleted_at" field.
  4652. func (m *ApiKeyMutation) ClearDeletedAt() {
  4653. m.deleted_at = nil
  4654. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4655. }
  4656. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4657. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4658. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4659. return ok
  4660. }
  4661. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4662. func (m *ApiKeyMutation) ResetDeletedAt() {
  4663. m.deleted_at = nil
  4664. delete(m.clearedFields, apikey.FieldDeletedAt)
  4665. }
  4666. // SetTitle sets the "title" field.
  4667. func (m *ApiKeyMutation) SetTitle(s string) {
  4668. m.title = &s
  4669. }
  4670. // Title returns the value of the "title" field in the mutation.
  4671. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4672. v := m.title
  4673. if v == nil {
  4674. return
  4675. }
  4676. return *v, true
  4677. }
  4678. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4679. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4681. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4682. if !m.op.Is(OpUpdateOne) {
  4683. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4684. }
  4685. if m.id == nil || m.oldValue == nil {
  4686. return v, errors.New("OldTitle requires an ID field in the mutation")
  4687. }
  4688. oldValue, err := m.oldValue(ctx)
  4689. if err != nil {
  4690. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4691. }
  4692. return oldValue.Title, nil
  4693. }
  4694. // ClearTitle clears the value of the "title" field.
  4695. func (m *ApiKeyMutation) ClearTitle() {
  4696. m.title = nil
  4697. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4698. }
  4699. // TitleCleared returns if the "title" field was cleared in this mutation.
  4700. func (m *ApiKeyMutation) TitleCleared() bool {
  4701. _, ok := m.clearedFields[apikey.FieldTitle]
  4702. return ok
  4703. }
  4704. // ResetTitle resets all changes to the "title" field.
  4705. func (m *ApiKeyMutation) ResetTitle() {
  4706. m.title = nil
  4707. delete(m.clearedFields, apikey.FieldTitle)
  4708. }
  4709. // SetKey sets the "key" field.
  4710. func (m *ApiKeyMutation) SetKey(s string) {
  4711. m.key = &s
  4712. }
  4713. // Key returns the value of the "key" field in the mutation.
  4714. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4715. v := m.key
  4716. if v == nil {
  4717. return
  4718. }
  4719. return *v, true
  4720. }
  4721. // OldKey returns the old "key" field's value of the ApiKey entity.
  4722. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4724. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4725. if !m.op.Is(OpUpdateOne) {
  4726. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4727. }
  4728. if m.id == nil || m.oldValue == nil {
  4729. return v, errors.New("OldKey requires an ID field in the mutation")
  4730. }
  4731. oldValue, err := m.oldValue(ctx)
  4732. if err != nil {
  4733. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4734. }
  4735. return oldValue.Key, nil
  4736. }
  4737. // ClearKey clears the value of the "key" field.
  4738. func (m *ApiKeyMutation) ClearKey() {
  4739. m.key = nil
  4740. m.clearedFields[apikey.FieldKey] = struct{}{}
  4741. }
  4742. // KeyCleared returns if the "key" field was cleared in this mutation.
  4743. func (m *ApiKeyMutation) KeyCleared() bool {
  4744. _, ok := m.clearedFields[apikey.FieldKey]
  4745. return ok
  4746. }
  4747. // ResetKey resets all changes to the "key" field.
  4748. func (m *ApiKeyMutation) ResetKey() {
  4749. m.key = nil
  4750. delete(m.clearedFields, apikey.FieldKey)
  4751. }
  4752. // SetOrganizationID sets the "organization_id" field.
  4753. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4754. m.organization_id = &u
  4755. m.addorganization_id = nil
  4756. }
  4757. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4758. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4759. v := m.organization_id
  4760. if v == nil {
  4761. return
  4762. }
  4763. return *v, true
  4764. }
  4765. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4766. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4768. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4769. if !m.op.Is(OpUpdateOne) {
  4770. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4771. }
  4772. if m.id == nil || m.oldValue == nil {
  4773. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4774. }
  4775. oldValue, err := m.oldValue(ctx)
  4776. if err != nil {
  4777. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4778. }
  4779. return oldValue.OrganizationID, nil
  4780. }
  4781. // AddOrganizationID adds u to the "organization_id" field.
  4782. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4783. if m.addorganization_id != nil {
  4784. *m.addorganization_id += u
  4785. } else {
  4786. m.addorganization_id = &u
  4787. }
  4788. }
  4789. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4790. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4791. v := m.addorganization_id
  4792. if v == nil {
  4793. return
  4794. }
  4795. return *v, true
  4796. }
  4797. // ResetOrganizationID resets all changes to the "organization_id" field.
  4798. func (m *ApiKeyMutation) ResetOrganizationID() {
  4799. m.organization_id = nil
  4800. m.addorganization_id = nil
  4801. }
  4802. // SetAgentID sets the "agent_id" field.
  4803. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4804. m.agent = &u
  4805. }
  4806. // AgentID returns the value of the "agent_id" field in the mutation.
  4807. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4808. v := m.agent
  4809. if v == nil {
  4810. return
  4811. }
  4812. return *v, true
  4813. }
  4814. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4815. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4817. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4818. if !m.op.Is(OpUpdateOne) {
  4819. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4820. }
  4821. if m.id == nil || m.oldValue == nil {
  4822. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4823. }
  4824. oldValue, err := m.oldValue(ctx)
  4825. if err != nil {
  4826. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4827. }
  4828. return oldValue.AgentID, nil
  4829. }
  4830. // ResetAgentID resets all changes to the "agent_id" field.
  4831. func (m *ApiKeyMutation) ResetAgentID() {
  4832. m.agent = nil
  4833. }
  4834. // SetCustomAgentBase sets the "custom_agent_base" field.
  4835. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4836. m.custom_agent_base = &s
  4837. }
  4838. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4839. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4840. v := m.custom_agent_base
  4841. if v == nil {
  4842. return
  4843. }
  4844. return *v, true
  4845. }
  4846. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4847. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4849. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4850. if !m.op.Is(OpUpdateOne) {
  4851. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4852. }
  4853. if m.id == nil || m.oldValue == nil {
  4854. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4855. }
  4856. oldValue, err := m.oldValue(ctx)
  4857. if err != nil {
  4858. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4859. }
  4860. return oldValue.CustomAgentBase, nil
  4861. }
  4862. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4863. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4864. m.custom_agent_base = nil
  4865. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4866. }
  4867. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4868. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4869. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4870. return ok
  4871. }
  4872. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4873. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4874. m.custom_agent_base = nil
  4875. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4876. }
  4877. // SetCustomAgentKey sets the "custom_agent_key" field.
  4878. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4879. m.custom_agent_key = &s
  4880. }
  4881. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4882. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4883. v := m.custom_agent_key
  4884. if v == nil {
  4885. return
  4886. }
  4887. return *v, true
  4888. }
  4889. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4890. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4892. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4893. if !m.op.Is(OpUpdateOne) {
  4894. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4895. }
  4896. if m.id == nil || m.oldValue == nil {
  4897. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4898. }
  4899. oldValue, err := m.oldValue(ctx)
  4900. if err != nil {
  4901. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4902. }
  4903. return oldValue.CustomAgentKey, nil
  4904. }
  4905. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4906. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4907. m.custom_agent_key = nil
  4908. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4909. }
  4910. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4911. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4912. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4913. return ok
  4914. }
  4915. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4916. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4917. m.custom_agent_key = nil
  4918. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4919. }
  4920. // SetOpenaiBase sets the "openai_base" field.
  4921. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4922. m.openai_base = &s
  4923. }
  4924. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4925. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4926. v := m.openai_base
  4927. if v == nil {
  4928. return
  4929. }
  4930. return *v, true
  4931. }
  4932. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4933. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4935. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4936. if !m.op.Is(OpUpdateOne) {
  4937. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4938. }
  4939. if m.id == nil || m.oldValue == nil {
  4940. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4941. }
  4942. oldValue, err := m.oldValue(ctx)
  4943. if err != nil {
  4944. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4945. }
  4946. return oldValue.OpenaiBase, nil
  4947. }
  4948. // ClearOpenaiBase clears the value of the "openai_base" field.
  4949. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4950. m.openai_base = nil
  4951. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4952. }
  4953. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4954. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4955. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4956. return ok
  4957. }
  4958. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4959. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4960. m.openai_base = nil
  4961. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4962. }
  4963. // SetOpenaiKey sets the "openai_key" field.
  4964. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4965. m.openai_key = &s
  4966. }
  4967. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4968. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4969. v := m.openai_key
  4970. if v == nil {
  4971. return
  4972. }
  4973. return *v, true
  4974. }
  4975. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4976. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4978. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4979. if !m.op.Is(OpUpdateOne) {
  4980. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4981. }
  4982. if m.id == nil || m.oldValue == nil {
  4983. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4984. }
  4985. oldValue, err := m.oldValue(ctx)
  4986. if err != nil {
  4987. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4988. }
  4989. return oldValue.OpenaiKey, nil
  4990. }
  4991. // ClearOpenaiKey clears the value of the "openai_key" field.
  4992. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4993. m.openai_key = nil
  4994. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4995. }
  4996. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4997. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4998. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4999. return ok
  5000. }
  5001. // ResetOpenaiKey resets all changes to the "openai_key" field.
  5002. func (m *ApiKeyMutation) ResetOpenaiKey() {
  5003. m.openai_key = nil
  5004. delete(m.clearedFields, apikey.FieldOpenaiKey)
  5005. }
  5006. // ClearAgent clears the "agent" edge to the Agent entity.
  5007. func (m *ApiKeyMutation) ClearAgent() {
  5008. m.clearedagent = true
  5009. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  5010. }
  5011. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  5012. func (m *ApiKeyMutation) AgentCleared() bool {
  5013. return m.clearedagent
  5014. }
  5015. // AgentIDs returns the "agent" edge IDs in the mutation.
  5016. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5017. // AgentID instead. It exists only for internal usage by the builders.
  5018. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  5019. if id := m.agent; id != nil {
  5020. ids = append(ids, *id)
  5021. }
  5022. return
  5023. }
  5024. // ResetAgent resets all changes to the "agent" edge.
  5025. func (m *ApiKeyMutation) ResetAgent() {
  5026. m.agent = nil
  5027. m.clearedagent = false
  5028. }
  5029. // Where appends a list predicates to the ApiKeyMutation builder.
  5030. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  5031. m.predicates = append(m.predicates, ps...)
  5032. }
  5033. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  5034. // users can use type-assertion to append predicates that do not depend on any generated package.
  5035. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  5036. p := make([]predicate.ApiKey, len(ps))
  5037. for i := range ps {
  5038. p[i] = ps[i]
  5039. }
  5040. m.Where(p...)
  5041. }
  5042. // Op returns the operation name.
  5043. func (m *ApiKeyMutation) Op() Op {
  5044. return m.op
  5045. }
  5046. // SetOp allows setting the mutation operation.
  5047. func (m *ApiKeyMutation) SetOp(op Op) {
  5048. m.op = op
  5049. }
  5050. // Type returns the node type of this mutation (ApiKey).
  5051. func (m *ApiKeyMutation) Type() string {
  5052. return m.typ
  5053. }
  5054. // Fields returns all fields that were changed during this mutation. Note that in
  5055. // order to get all numeric fields that were incremented/decremented, call
  5056. // AddedFields().
  5057. func (m *ApiKeyMutation) Fields() []string {
  5058. fields := make([]string, 0, 11)
  5059. if m.created_at != nil {
  5060. fields = append(fields, apikey.FieldCreatedAt)
  5061. }
  5062. if m.updated_at != nil {
  5063. fields = append(fields, apikey.FieldUpdatedAt)
  5064. }
  5065. if m.deleted_at != nil {
  5066. fields = append(fields, apikey.FieldDeletedAt)
  5067. }
  5068. if m.title != nil {
  5069. fields = append(fields, apikey.FieldTitle)
  5070. }
  5071. if m.key != nil {
  5072. fields = append(fields, apikey.FieldKey)
  5073. }
  5074. if m.organization_id != nil {
  5075. fields = append(fields, apikey.FieldOrganizationID)
  5076. }
  5077. if m.agent != nil {
  5078. fields = append(fields, apikey.FieldAgentID)
  5079. }
  5080. if m.custom_agent_base != nil {
  5081. fields = append(fields, apikey.FieldCustomAgentBase)
  5082. }
  5083. if m.custom_agent_key != nil {
  5084. fields = append(fields, apikey.FieldCustomAgentKey)
  5085. }
  5086. if m.openai_base != nil {
  5087. fields = append(fields, apikey.FieldOpenaiBase)
  5088. }
  5089. if m.openai_key != nil {
  5090. fields = append(fields, apikey.FieldOpenaiKey)
  5091. }
  5092. return fields
  5093. }
  5094. // Field returns the value of a field with the given name. The second boolean
  5095. // return value indicates that this field was not set, or was not defined in the
  5096. // schema.
  5097. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  5098. switch name {
  5099. case apikey.FieldCreatedAt:
  5100. return m.CreatedAt()
  5101. case apikey.FieldUpdatedAt:
  5102. return m.UpdatedAt()
  5103. case apikey.FieldDeletedAt:
  5104. return m.DeletedAt()
  5105. case apikey.FieldTitle:
  5106. return m.Title()
  5107. case apikey.FieldKey:
  5108. return m.Key()
  5109. case apikey.FieldOrganizationID:
  5110. return m.OrganizationID()
  5111. case apikey.FieldAgentID:
  5112. return m.AgentID()
  5113. case apikey.FieldCustomAgentBase:
  5114. return m.CustomAgentBase()
  5115. case apikey.FieldCustomAgentKey:
  5116. return m.CustomAgentKey()
  5117. case apikey.FieldOpenaiBase:
  5118. return m.OpenaiBase()
  5119. case apikey.FieldOpenaiKey:
  5120. return m.OpenaiKey()
  5121. }
  5122. return nil, false
  5123. }
  5124. // OldField returns the old value of the field from the database. An error is
  5125. // returned if the mutation operation is not UpdateOne, or the query to the
  5126. // database failed.
  5127. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5128. switch name {
  5129. case apikey.FieldCreatedAt:
  5130. return m.OldCreatedAt(ctx)
  5131. case apikey.FieldUpdatedAt:
  5132. return m.OldUpdatedAt(ctx)
  5133. case apikey.FieldDeletedAt:
  5134. return m.OldDeletedAt(ctx)
  5135. case apikey.FieldTitle:
  5136. return m.OldTitle(ctx)
  5137. case apikey.FieldKey:
  5138. return m.OldKey(ctx)
  5139. case apikey.FieldOrganizationID:
  5140. return m.OldOrganizationID(ctx)
  5141. case apikey.FieldAgentID:
  5142. return m.OldAgentID(ctx)
  5143. case apikey.FieldCustomAgentBase:
  5144. return m.OldCustomAgentBase(ctx)
  5145. case apikey.FieldCustomAgentKey:
  5146. return m.OldCustomAgentKey(ctx)
  5147. case apikey.FieldOpenaiBase:
  5148. return m.OldOpenaiBase(ctx)
  5149. case apikey.FieldOpenaiKey:
  5150. return m.OldOpenaiKey(ctx)
  5151. }
  5152. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  5153. }
  5154. // SetField sets the value of a field with the given name. It returns an error if
  5155. // the field is not defined in the schema, or if the type mismatched the field
  5156. // type.
  5157. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  5158. switch name {
  5159. case apikey.FieldCreatedAt:
  5160. v, ok := value.(time.Time)
  5161. if !ok {
  5162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5163. }
  5164. m.SetCreatedAt(v)
  5165. return nil
  5166. case apikey.FieldUpdatedAt:
  5167. v, ok := value.(time.Time)
  5168. if !ok {
  5169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5170. }
  5171. m.SetUpdatedAt(v)
  5172. return nil
  5173. case apikey.FieldDeletedAt:
  5174. v, ok := value.(time.Time)
  5175. if !ok {
  5176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5177. }
  5178. m.SetDeletedAt(v)
  5179. return nil
  5180. case apikey.FieldTitle:
  5181. v, ok := value.(string)
  5182. if !ok {
  5183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5184. }
  5185. m.SetTitle(v)
  5186. return nil
  5187. case apikey.FieldKey:
  5188. v, ok := value.(string)
  5189. if !ok {
  5190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5191. }
  5192. m.SetKey(v)
  5193. return nil
  5194. case apikey.FieldOrganizationID:
  5195. v, ok := value.(uint64)
  5196. if !ok {
  5197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5198. }
  5199. m.SetOrganizationID(v)
  5200. return nil
  5201. case apikey.FieldAgentID:
  5202. v, ok := value.(uint64)
  5203. if !ok {
  5204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5205. }
  5206. m.SetAgentID(v)
  5207. return nil
  5208. case apikey.FieldCustomAgentBase:
  5209. v, ok := value.(string)
  5210. if !ok {
  5211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5212. }
  5213. m.SetCustomAgentBase(v)
  5214. return nil
  5215. case apikey.FieldCustomAgentKey:
  5216. v, ok := value.(string)
  5217. if !ok {
  5218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5219. }
  5220. m.SetCustomAgentKey(v)
  5221. return nil
  5222. case apikey.FieldOpenaiBase:
  5223. v, ok := value.(string)
  5224. if !ok {
  5225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5226. }
  5227. m.SetOpenaiBase(v)
  5228. return nil
  5229. case apikey.FieldOpenaiKey:
  5230. v, ok := value.(string)
  5231. if !ok {
  5232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5233. }
  5234. m.SetOpenaiKey(v)
  5235. return nil
  5236. }
  5237. return fmt.Errorf("unknown ApiKey field %s", name)
  5238. }
  5239. // AddedFields returns all numeric fields that were incremented/decremented during
  5240. // this mutation.
  5241. func (m *ApiKeyMutation) AddedFields() []string {
  5242. var fields []string
  5243. if m.addorganization_id != nil {
  5244. fields = append(fields, apikey.FieldOrganizationID)
  5245. }
  5246. return fields
  5247. }
  5248. // AddedField returns the numeric value that was incremented/decremented on a field
  5249. // with the given name. The second boolean return value indicates that this field
  5250. // was not set, or was not defined in the schema.
  5251. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  5252. switch name {
  5253. case apikey.FieldOrganizationID:
  5254. return m.AddedOrganizationID()
  5255. }
  5256. return nil, false
  5257. }
  5258. // AddField adds the value to the field with the given name. It returns an error if
  5259. // the field is not defined in the schema, or if the type mismatched the field
  5260. // type.
  5261. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  5262. switch name {
  5263. case apikey.FieldOrganizationID:
  5264. v, ok := value.(int64)
  5265. if !ok {
  5266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5267. }
  5268. m.AddOrganizationID(v)
  5269. return nil
  5270. }
  5271. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  5272. }
  5273. // ClearedFields returns all nullable fields that were cleared during this
  5274. // mutation.
  5275. func (m *ApiKeyMutation) ClearedFields() []string {
  5276. var fields []string
  5277. if m.FieldCleared(apikey.FieldDeletedAt) {
  5278. fields = append(fields, apikey.FieldDeletedAt)
  5279. }
  5280. if m.FieldCleared(apikey.FieldTitle) {
  5281. fields = append(fields, apikey.FieldTitle)
  5282. }
  5283. if m.FieldCleared(apikey.FieldKey) {
  5284. fields = append(fields, apikey.FieldKey)
  5285. }
  5286. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  5287. fields = append(fields, apikey.FieldCustomAgentBase)
  5288. }
  5289. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  5290. fields = append(fields, apikey.FieldCustomAgentKey)
  5291. }
  5292. if m.FieldCleared(apikey.FieldOpenaiBase) {
  5293. fields = append(fields, apikey.FieldOpenaiBase)
  5294. }
  5295. if m.FieldCleared(apikey.FieldOpenaiKey) {
  5296. fields = append(fields, apikey.FieldOpenaiKey)
  5297. }
  5298. return fields
  5299. }
  5300. // FieldCleared returns a boolean indicating if a field with the given name was
  5301. // cleared in this mutation.
  5302. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  5303. _, ok := m.clearedFields[name]
  5304. return ok
  5305. }
  5306. // ClearField clears the value of the field with the given name. It returns an
  5307. // error if the field is not defined in the schema.
  5308. func (m *ApiKeyMutation) ClearField(name string) error {
  5309. switch name {
  5310. case apikey.FieldDeletedAt:
  5311. m.ClearDeletedAt()
  5312. return nil
  5313. case apikey.FieldTitle:
  5314. m.ClearTitle()
  5315. return nil
  5316. case apikey.FieldKey:
  5317. m.ClearKey()
  5318. return nil
  5319. case apikey.FieldCustomAgentBase:
  5320. m.ClearCustomAgentBase()
  5321. return nil
  5322. case apikey.FieldCustomAgentKey:
  5323. m.ClearCustomAgentKey()
  5324. return nil
  5325. case apikey.FieldOpenaiBase:
  5326. m.ClearOpenaiBase()
  5327. return nil
  5328. case apikey.FieldOpenaiKey:
  5329. m.ClearOpenaiKey()
  5330. return nil
  5331. }
  5332. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5333. }
  5334. // ResetField resets all changes in the mutation for the field with the given name.
  5335. // It returns an error if the field is not defined in the schema.
  5336. func (m *ApiKeyMutation) ResetField(name string) error {
  5337. switch name {
  5338. case apikey.FieldCreatedAt:
  5339. m.ResetCreatedAt()
  5340. return nil
  5341. case apikey.FieldUpdatedAt:
  5342. m.ResetUpdatedAt()
  5343. return nil
  5344. case apikey.FieldDeletedAt:
  5345. m.ResetDeletedAt()
  5346. return nil
  5347. case apikey.FieldTitle:
  5348. m.ResetTitle()
  5349. return nil
  5350. case apikey.FieldKey:
  5351. m.ResetKey()
  5352. return nil
  5353. case apikey.FieldOrganizationID:
  5354. m.ResetOrganizationID()
  5355. return nil
  5356. case apikey.FieldAgentID:
  5357. m.ResetAgentID()
  5358. return nil
  5359. case apikey.FieldCustomAgentBase:
  5360. m.ResetCustomAgentBase()
  5361. return nil
  5362. case apikey.FieldCustomAgentKey:
  5363. m.ResetCustomAgentKey()
  5364. return nil
  5365. case apikey.FieldOpenaiBase:
  5366. m.ResetOpenaiBase()
  5367. return nil
  5368. case apikey.FieldOpenaiKey:
  5369. m.ResetOpenaiKey()
  5370. return nil
  5371. }
  5372. return fmt.Errorf("unknown ApiKey field %s", name)
  5373. }
  5374. // AddedEdges returns all edge names that were set/added in this mutation.
  5375. func (m *ApiKeyMutation) AddedEdges() []string {
  5376. edges := make([]string, 0, 1)
  5377. if m.agent != nil {
  5378. edges = append(edges, apikey.EdgeAgent)
  5379. }
  5380. return edges
  5381. }
  5382. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5383. // name in this mutation.
  5384. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5385. switch name {
  5386. case apikey.EdgeAgent:
  5387. if id := m.agent; id != nil {
  5388. return []ent.Value{*id}
  5389. }
  5390. }
  5391. return nil
  5392. }
  5393. // RemovedEdges returns all edge names that were removed in this mutation.
  5394. func (m *ApiKeyMutation) RemovedEdges() []string {
  5395. edges := make([]string, 0, 1)
  5396. return edges
  5397. }
  5398. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5399. // the given name in this mutation.
  5400. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5401. return nil
  5402. }
  5403. // ClearedEdges returns all edge names that were cleared in this mutation.
  5404. func (m *ApiKeyMutation) ClearedEdges() []string {
  5405. edges := make([]string, 0, 1)
  5406. if m.clearedagent {
  5407. edges = append(edges, apikey.EdgeAgent)
  5408. }
  5409. return edges
  5410. }
  5411. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5412. // was cleared in this mutation.
  5413. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5414. switch name {
  5415. case apikey.EdgeAgent:
  5416. return m.clearedagent
  5417. }
  5418. return false
  5419. }
  5420. // ClearEdge clears the value of the edge with the given name. It returns an error
  5421. // if that edge is not defined in the schema.
  5422. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5423. switch name {
  5424. case apikey.EdgeAgent:
  5425. m.ClearAgent()
  5426. return nil
  5427. }
  5428. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5429. }
  5430. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5431. // It returns an error if the edge is not defined in the schema.
  5432. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5433. switch name {
  5434. case apikey.EdgeAgent:
  5435. m.ResetAgent()
  5436. return nil
  5437. }
  5438. return fmt.Errorf("unknown ApiKey edge %s", name)
  5439. }
  5440. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5441. type BatchMsgMutation struct {
  5442. config
  5443. op Op
  5444. typ string
  5445. id *uint64
  5446. created_at *time.Time
  5447. updated_at *time.Time
  5448. deleted_at *time.Time
  5449. status *uint8
  5450. addstatus *int8
  5451. batch_no *string
  5452. task_name *string
  5453. fromwxid *string
  5454. msg *string
  5455. tag *string
  5456. tagids *string
  5457. total *int32
  5458. addtotal *int32
  5459. success *int32
  5460. addsuccess *int32
  5461. fail *int32
  5462. addfail *int32
  5463. start_time *time.Time
  5464. stop_time *time.Time
  5465. send_time *time.Time
  5466. _type *int32
  5467. add_type *int32
  5468. organization_id *uint64
  5469. addorganization_id *int64
  5470. ctype *uint64
  5471. addctype *int64
  5472. cc *string
  5473. phone *string
  5474. template_name *string
  5475. template_code *string
  5476. lang *string
  5477. clearedFields map[string]struct{}
  5478. done bool
  5479. oldValue func(context.Context) (*BatchMsg, error)
  5480. predicates []predicate.BatchMsg
  5481. }
  5482. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5483. // batchmsgOption allows management of the mutation configuration using functional options.
  5484. type batchmsgOption func(*BatchMsgMutation)
  5485. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5486. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5487. m := &BatchMsgMutation{
  5488. config: c,
  5489. op: op,
  5490. typ: TypeBatchMsg,
  5491. clearedFields: make(map[string]struct{}),
  5492. }
  5493. for _, opt := range opts {
  5494. opt(m)
  5495. }
  5496. return m
  5497. }
  5498. // withBatchMsgID sets the ID field of the mutation.
  5499. func withBatchMsgID(id uint64) batchmsgOption {
  5500. return func(m *BatchMsgMutation) {
  5501. var (
  5502. err error
  5503. once sync.Once
  5504. value *BatchMsg
  5505. )
  5506. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5507. once.Do(func() {
  5508. if m.done {
  5509. err = errors.New("querying old values post mutation is not allowed")
  5510. } else {
  5511. value, err = m.Client().BatchMsg.Get(ctx, id)
  5512. }
  5513. })
  5514. return value, err
  5515. }
  5516. m.id = &id
  5517. }
  5518. }
  5519. // withBatchMsg sets the old BatchMsg of the mutation.
  5520. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5521. return func(m *BatchMsgMutation) {
  5522. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5523. return node, nil
  5524. }
  5525. m.id = &node.ID
  5526. }
  5527. }
  5528. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5529. // executed in a transaction (ent.Tx), a transactional client is returned.
  5530. func (m BatchMsgMutation) Client() *Client {
  5531. client := &Client{config: m.config}
  5532. client.init()
  5533. return client
  5534. }
  5535. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5536. // it returns an error otherwise.
  5537. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5538. if _, ok := m.driver.(*txDriver); !ok {
  5539. return nil, errors.New("ent: mutation is not running in a transaction")
  5540. }
  5541. tx := &Tx{config: m.config}
  5542. tx.init()
  5543. return tx, nil
  5544. }
  5545. // SetID sets the value of the id field. Note that this
  5546. // operation is only accepted on creation of BatchMsg entities.
  5547. func (m *BatchMsgMutation) SetID(id uint64) {
  5548. m.id = &id
  5549. }
  5550. // ID returns the ID value in the mutation. Note that the ID is only available
  5551. // if it was provided to the builder or after it was returned from the database.
  5552. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5553. if m.id == nil {
  5554. return
  5555. }
  5556. return *m.id, true
  5557. }
  5558. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5559. // That means, if the mutation is applied within a transaction with an isolation level such
  5560. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5561. // or updated by the mutation.
  5562. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5563. switch {
  5564. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5565. id, exists := m.ID()
  5566. if exists {
  5567. return []uint64{id}, nil
  5568. }
  5569. fallthrough
  5570. case m.op.Is(OpUpdate | OpDelete):
  5571. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5572. default:
  5573. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5574. }
  5575. }
  5576. // SetCreatedAt sets the "created_at" field.
  5577. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5578. m.created_at = &t
  5579. }
  5580. // CreatedAt returns the value of the "created_at" field in the mutation.
  5581. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5582. v := m.created_at
  5583. if v == nil {
  5584. return
  5585. }
  5586. return *v, true
  5587. }
  5588. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5589. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5591. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5592. if !m.op.Is(OpUpdateOne) {
  5593. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5594. }
  5595. if m.id == nil || m.oldValue == nil {
  5596. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5597. }
  5598. oldValue, err := m.oldValue(ctx)
  5599. if err != nil {
  5600. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5601. }
  5602. return oldValue.CreatedAt, nil
  5603. }
  5604. // ResetCreatedAt resets all changes to the "created_at" field.
  5605. func (m *BatchMsgMutation) ResetCreatedAt() {
  5606. m.created_at = nil
  5607. }
  5608. // SetUpdatedAt sets the "updated_at" field.
  5609. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5610. m.updated_at = &t
  5611. }
  5612. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5613. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5614. v := m.updated_at
  5615. if v == nil {
  5616. return
  5617. }
  5618. return *v, true
  5619. }
  5620. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5621. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5623. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5624. if !m.op.Is(OpUpdateOne) {
  5625. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5626. }
  5627. if m.id == nil || m.oldValue == nil {
  5628. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5629. }
  5630. oldValue, err := m.oldValue(ctx)
  5631. if err != nil {
  5632. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5633. }
  5634. return oldValue.UpdatedAt, nil
  5635. }
  5636. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5637. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5638. m.updated_at = nil
  5639. }
  5640. // SetDeletedAt sets the "deleted_at" field.
  5641. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5642. m.deleted_at = &t
  5643. }
  5644. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5645. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5646. v := m.deleted_at
  5647. if v == nil {
  5648. return
  5649. }
  5650. return *v, true
  5651. }
  5652. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5653. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5655. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5656. if !m.op.Is(OpUpdateOne) {
  5657. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5658. }
  5659. if m.id == nil || m.oldValue == nil {
  5660. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5661. }
  5662. oldValue, err := m.oldValue(ctx)
  5663. if err != nil {
  5664. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5665. }
  5666. return oldValue.DeletedAt, nil
  5667. }
  5668. // ClearDeletedAt clears the value of the "deleted_at" field.
  5669. func (m *BatchMsgMutation) ClearDeletedAt() {
  5670. m.deleted_at = nil
  5671. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5672. }
  5673. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5674. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5675. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5676. return ok
  5677. }
  5678. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5679. func (m *BatchMsgMutation) ResetDeletedAt() {
  5680. m.deleted_at = nil
  5681. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5682. }
  5683. // SetStatus sets the "status" field.
  5684. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5685. m.status = &u
  5686. m.addstatus = nil
  5687. }
  5688. // Status returns the value of the "status" field in the mutation.
  5689. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5690. v := m.status
  5691. if v == nil {
  5692. return
  5693. }
  5694. return *v, true
  5695. }
  5696. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5697. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5699. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5700. if !m.op.Is(OpUpdateOne) {
  5701. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5702. }
  5703. if m.id == nil || m.oldValue == nil {
  5704. return v, errors.New("OldStatus requires an ID field in the mutation")
  5705. }
  5706. oldValue, err := m.oldValue(ctx)
  5707. if err != nil {
  5708. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5709. }
  5710. return oldValue.Status, nil
  5711. }
  5712. // AddStatus adds u to the "status" field.
  5713. func (m *BatchMsgMutation) AddStatus(u int8) {
  5714. if m.addstatus != nil {
  5715. *m.addstatus += u
  5716. } else {
  5717. m.addstatus = &u
  5718. }
  5719. }
  5720. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5721. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5722. v := m.addstatus
  5723. if v == nil {
  5724. return
  5725. }
  5726. return *v, true
  5727. }
  5728. // ClearStatus clears the value of the "status" field.
  5729. func (m *BatchMsgMutation) ClearStatus() {
  5730. m.status = nil
  5731. m.addstatus = nil
  5732. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5733. }
  5734. // StatusCleared returns if the "status" field was cleared in this mutation.
  5735. func (m *BatchMsgMutation) StatusCleared() bool {
  5736. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5737. return ok
  5738. }
  5739. // ResetStatus resets all changes to the "status" field.
  5740. func (m *BatchMsgMutation) ResetStatus() {
  5741. m.status = nil
  5742. m.addstatus = nil
  5743. delete(m.clearedFields, batchmsg.FieldStatus)
  5744. }
  5745. // SetBatchNo sets the "batch_no" field.
  5746. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5747. m.batch_no = &s
  5748. }
  5749. // BatchNo returns the value of the "batch_no" field in the mutation.
  5750. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5751. v := m.batch_no
  5752. if v == nil {
  5753. return
  5754. }
  5755. return *v, true
  5756. }
  5757. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5758. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5760. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5761. if !m.op.Is(OpUpdateOne) {
  5762. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5763. }
  5764. if m.id == nil || m.oldValue == nil {
  5765. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5766. }
  5767. oldValue, err := m.oldValue(ctx)
  5768. if err != nil {
  5769. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5770. }
  5771. return oldValue.BatchNo, nil
  5772. }
  5773. // ClearBatchNo clears the value of the "batch_no" field.
  5774. func (m *BatchMsgMutation) ClearBatchNo() {
  5775. m.batch_no = nil
  5776. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5777. }
  5778. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5779. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5780. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5781. return ok
  5782. }
  5783. // ResetBatchNo resets all changes to the "batch_no" field.
  5784. func (m *BatchMsgMutation) ResetBatchNo() {
  5785. m.batch_no = nil
  5786. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5787. }
  5788. // SetTaskName sets the "task_name" field.
  5789. func (m *BatchMsgMutation) SetTaskName(s string) {
  5790. m.task_name = &s
  5791. }
  5792. // TaskName returns the value of the "task_name" field in the mutation.
  5793. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5794. v := m.task_name
  5795. if v == nil {
  5796. return
  5797. }
  5798. return *v, true
  5799. }
  5800. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5801. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5803. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5804. if !m.op.Is(OpUpdateOne) {
  5805. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5806. }
  5807. if m.id == nil || m.oldValue == nil {
  5808. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5809. }
  5810. oldValue, err := m.oldValue(ctx)
  5811. if err != nil {
  5812. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5813. }
  5814. return oldValue.TaskName, nil
  5815. }
  5816. // ClearTaskName clears the value of the "task_name" field.
  5817. func (m *BatchMsgMutation) ClearTaskName() {
  5818. m.task_name = nil
  5819. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5820. }
  5821. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5822. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5823. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5824. return ok
  5825. }
  5826. // ResetTaskName resets all changes to the "task_name" field.
  5827. func (m *BatchMsgMutation) ResetTaskName() {
  5828. m.task_name = nil
  5829. delete(m.clearedFields, batchmsg.FieldTaskName)
  5830. }
  5831. // SetFromwxid sets the "fromwxid" field.
  5832. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5833. m.fromwxid = &s
  5834. }
  5835. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5836. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5837. v := m.fromwxid
  5838. if v == nil {
  5839. return
  5840. }
  5841. return *v, true
  5842. }
  5843. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5844. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5846. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5847. if !m.op.Is(OpUpdateOne) {
  5848. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5849. }
  5850. if m.id == nil || m.oldValue == nil {
  5851. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5852. }
  5853. oldValue, err := m.oldValue(ctx)
  5854. if err != nil {
  5855. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5856. }
  5857. return oldValue.Fromwxid, nil
  5858. }
  5859. // ClearFromwxid clears the value of the "fromwxid" field.
  5860. func (m *BatchMsgMutation) ClearFromwxid() {
  5861. m.fromwxid = nil
  5862. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5863. }
  5864. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5865. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5866. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5867. return ok
  5868. }
  5869. // ResetFromwxid resets all changes to the "fromwxid" field.
  5870. func (m *BatchMsgMutation) ResetFromwxid() {
  5871. m.fromwxid = nil
  5872. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5873. }
  5874. // SetMsg sets the "msg" field.
  5875. func (m *BatchMsgMutation) SetMsg(s string) {
  5876. m.msg = &s
  5877. }
  5878. // Msg returns the value of the "msg" field in the mutation.
  5879. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5880. v := m.msg
  5881. if v == nil {
  5882. return
  5883. }
  5884. return *v, true
  5885. }
  5886. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5887. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5889. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5890. if !m.op.Is(OpUpdateOne) {
  5891. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5892. }
  5893. if m.id == nil || m.oldValue == nil {
  5894. return v, errors.New("OldMsg requires an ID field in the mutation")
  5895. }
  5896. oldValue, err := m.oldValue(ctx)
  5897. if err != nil {
  5898. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5899. }
  5900. return oldValue.Msg, nil
  5901. }
  5902. // ClearMsg clears the value of the "msg" field.
  5903. func (m *BatchMsgMutation) ClearMsg() {
  5904. m.msg = nil
  5905. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5906. }
  5907. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5908. func (m *BatchMsgMutation) MsgCleared() bool {
  5909. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5910. return ok
  5911. }
  5912. // ResetMsg resets all changes to the "msg" field.
  5913. func (m *BatchMsgMutation) ResetMsg() {
  5914. m.msg = nil
  5915. delete(m.clearedFields, batchmsg.FieldMsg)
  5916. }
  5917. // SetTag sets the "tag" field.
  5918. func (m *BatchMsgMutation) SetTag(s string) {
  5919. m.tag = &s
  5920. }
  5921. // Tag returns the value of the "tag" field in the mutation.
  5922. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5923. v := m.tag
  5924. if v == nil {
  5925. return
  5926. }
  5927. return *v, true
  5928. }
  5929. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5930. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5932. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5933. if !m.op.Is(OpUpdateOne) {
  5934. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5935. }
  5936. if m.id == nil || m.oldValue == nil {
  5937. return v, errors.New("OldTag requires an ID field in the mutation")
  5938. }
  5939. oldValue, err := m.oldValue(ctx)
  5940. if err != nil {
  5941. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5942. }
  5943. return oldValue.Tag, nil
  5944. }
  5945. // ClearTag clears the value of the "tag" field.
  5946. func (m *BatchMsgMutation) ClearTag() {
  5947. m.tag = nil
  5948. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5949. }
  5950. // TagCleared returns if the "tag" field was cleared in this mutation.
  5951. func (m *BatchMsgMutation) TagCleared() bool {
  5952. _, ok := m.clearedFields[batchmsg.FieldTag]
  5953. return ok
  5954. }
  5955. // ResetTag resets all changes to the "tag" field.
  5956. func (m *BatchMsgMutation) ResetTag() {
  5957. m.tag = nil
  5958. delete(m.clearedFields, batchmsg.FieldTag)
  5959. }
  5960. // SetTagids sets the "tagids" field.
  5961. func (m *BatchMsgMutation) SetTagids(s string) {
  5962. m.tagids = &s
  5963. }
  5964. // Tagids returns the value of the "tagids" field in the mutation.
  5965. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5966. v := m.tagids
  5967. if v == nil {
  5968. return
  5969. }
  5970. return *v, true
  5971. }
  5972. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5973. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5975. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5976. if !m.op.Is(OpUpdateOne) {
  5977. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5978. }
  5979. if m.id == nil || m.oldValue == nil {
  5980. return v, errors.New("OldTagids requires an ID field in the mutation")
  5981. }
  5982. oldValue, err := m.oldValue(ctx)
  5983. if err != nil {
  5984. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5985. }
  5986. return oldValue.Tagids, nil
  5987. }
  5988. // ClearTagids clears the value of the "tagids" field.
  5989. func (m *BatchMsgMutation) ClearTagids() {
  5990. m.tagids = nil
  5991. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5992. }
  5993. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5994. func (m *BatchMsgMutation) TagidsCleared() bool {
  5995. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5996. return ok
  5997. }
  5998. // ResetTagids resets all changes to the "tagids" field.
  5999. func (m *BatchMsgMutation) ResetTagids() {
  6000. m.tagids = nil
  6001. delete(m.clearedFields, batchmsg.FieldTagids)
  6002. }
  6003. // SetTotal sets the "total" field.
  6004. func (m *BatchMsgMutation) SetTotal(i int32) {
  6005. m.total = &i
  6006. m.addtotal = nil
  6007. }
  6008. // Total returns the value of the "total" field in the mutation.
  6009. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  6010. v := m.total
  6011. if v == nil {
  6012. return
  6013. }
  6014. return *v, true
  6015. }
  6016. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  6017. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6019. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  6020. if !m.op.Is(OpUpdateOne) {
  6021. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  6022. }
  6023. if m.id == nil || m.oldValue == nil {
  6024. return v, errors.New("OldTotal requires an ID field in the mutation")
  6025. }
  6026. oldValue, err := m.oldValue(ctx)
  6027. if err != nil {
  6028. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  6029. }
  6030. return oldValue.Total, nil
  6031. }
  6032. // AddTotal adds i to the "total" field.
  6033. func (m *BatchMsgMutation) AddTotal(i int32) {
  6034. if m.addtotal != nil {
  6035. *m.addtotal += i
  6036. } else {
  6037. m.addtotal = &i
  6038. }
  6039. }
  6040. // AddedTotal returns the value that was added to the "total" field in this mutation.
  6041. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  6042. v := m.addtotal
  6043. if v == nil {
  6044. return
  6045. }
  6046. return *v, true
  6047. }
  6048. // ClearTotal clears the value of the "total" field.
  6049. func (m *BatchMsgMutation) ClearTotal() {
  6050. m.total = nil
  6051. m.addtotal = nil
  6052. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  6053. }
  6054. // TotalCleared returns if the "total" field was cleared in this mutation.
  6055. func (m *BatchMsgMutation) TotalCleared() bool {
  6056. _, ok := m.clearedFields[batchmsg.FieldTotal]
  6057. return ok
  6058. }
  6059. // ResetTotal resets all changes to the "total" field.
  6060. func (m *BatchMsgMutation) ResetTotal() {
  6061. m.total = nil
  6062. m.addtotal = nil
  6063. delete(m.clearedFields, batchmsg.FieldTotal)
  6064. }
  6065. // SetSuccess sets the "success" field.
  6066. func (m *BatchMsgMutation) SetSuccess(i int32) {
  6067. m.success = &i
  6068. m.addsuccess = nil
  6069. }
  6070. // Success returns the value of the "success" field in the mutation.
  6071. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  6072. v := m.success
  6073. if v == nil {
  6074. return
  6075. }
  6076. return *v, true
  6077. }
  6078. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  6079. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6081. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  6082. if !m.op.Is(OpUpdateOne) {
  6083. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  6084. }
  6085. if m.id == nil || m.oldValue == nil {
  6086. return v, errors.New("OldSuccess requires an ID field in the mutation")
  6087. }
  6088. oldValue, err := m.oldValue(ctx)
  6089. if err != nil {
  6090. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  6091. }
  6092. return oldValue.Success, nil
  6093. }
  6094. // AddSuccess adds i to the "success" field.
  6095. func (m *BatchMsgMutation) AddSuccess(i int32) {
  6096. if m.addsuccess != nil {
  6097. *m.addsuccess += i
  6098. } else {
  6099. m.addsuccess = &i
  6100. }
  6101. }
  6102. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  6103. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  6104. v := m.addsuccess
  6105. if v == nil {
  6106. return
  6107. }
  6108. return *v, true
  6109. }
  6110. // ClearSuccess clears the value of the "success" field.
  6111. func (m *BatchMsgMutation) ClearSuccess() {
  6112. m.success = nil
  6113. m.addsuccess = nil
  6114. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  6115. }
  6116. // SuccessCleared returns if the "success" field was cleared in this mutation.
  6117. func (m *BatchMsgMutation) SuccessCleared() bool {
  6118. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  6119. return ok
  6120. }
  6121. // ResetSuccess resets all changes to the "success" field.
  6122. func (m *BatchMsgMutation) ResetSuccess() {
  6123. m.success = nil
  6124. m.addsuccess = nil
  6125. delete(m.clearedFields, batchmsg.FieldSuccess)
  6126. }
  6127. // SetFail sets the "fail" field.
  6128. func (m *BatchMsgMutation) SetFail(i int32) {
  6129. m.fail = &i
  6130. m.addfail = nil
  6131. }
  6132. // Fail returns the value of the "fail" field in the mutation.
  6133. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  6134. v := m.fail
  6135. if v == nil {
  6136. return
  6137. }
  6138. return *v, true
  6139. }
  6140. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  6141. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6143. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  6144. if !m.op.Is(OpUpdateOne) {
  6145. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  6146. }
  6147. if m.id == nil || m.oldValue == nil {
  6148. return v, errors.New("OldFail requires an ID field in the mutation")
  6149. }
  6150. oldValue, err := m.oldValue(ctx)
  6151. if err != nil {
  6152. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  6153. }
  6154. return oldValue.Fail, nil
  6155. }
  6156. // AddFail adds i to the "fail" field.
  6157. func (m *BatchMsgMutation) AddFail(i int32) {
  6158. if m.addfail != nil {
  6159. *m.addfail += i
  6160. } else {
  6161. m.addfail = &i
  6162. }
  6163. }
  6164. // AddedFail returns the value that was added to the "fail" field in this mutation.
  6165. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  6166. v := m.addfail
  6167. if v == nil {
  6168. return
  6169. }
  6170. return *v, true
  6171. }
  6172. // ClearFail clears the value of the "fail" field.
  6173. func (m *BatchMsgMutation) ClearFail() {
  6174. m.fail = nil
  6175. m.addfail = nil
  6176. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  6177. }
  6178. // FailCleared returns if the "fail" field was cleared in this mutation.
  6179. func (m *BatchMsgMutation) FailCleared() bool {
  6180. _, ok := m.clearedFields[batchmsg.FieldFail]
  6181. return ok
  6182. }
  6183. // ResetFail resets all changes to the "fail" field.
  6184. func (m *BatchMsgMutation) ResetFail() {
  6185. m.fail = nil
  6186. m.addfail = nil
  6187. delete(m.clearedFields, batchmsg.FieldFail)
  6188. }
  6189. // SetStartTime sets the "start_time" field.
  6190. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  6191. m.start_time = &t
  6192. }
  6193. // StartTime returns the value of the "start_time" field in the mutation.
  6194. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  6195. v := m.start_time
  6196. if v == nil {
  6197. return
  6198. }
  6199. return *v, true
  6200. }
  6201. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  6202. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6204. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  6205. if !m.op.Is(OpUpdateOne) {
  6206. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  6207. }
  6208. if m.id == nil || m.oldValue == nil {
  6209. return v, errors.New("OldStartTime requires an ID field in the mutation")
  6210. }
  6211. oldValue, err := m.oldValue(ctx)
  6212. if err != nil {
  6213. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  6214. }
  6215. return oldValue.StartTime, nil
  6216. }
  6217. // ClearStartTime clears the value of the "start_time" field.
  6218. func (m *BatchMsgMutation) ClearStartTime() {
  6219. m.start_time = nil
  6220. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  6221. }
  6222. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  6223. func (m *BatchMsgMutation) StartTimeCleared() bool {
  6224. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  6225. return ok
  6226. }
  6227. // ResetStartTime resets all changes to the "start_time" field.
  6228. func (m *BatchMsgMutation) ResetStartTime() {
  6229. m.start_time = nil
  6230. delete(m.clearedFields, batchmsg.FieldStartTime)
  6231. }
  6232. // SetStopTime sets the "stop_time" field.
  6233. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  6234. m.stop_time = &t
  6235. }
  6236. // StopTime returns the value of the "stop_time" field in the mutation.
  6237. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  6238. v := m.stop_time
  6239. if v == nil {
  6240. return
  6241. }
  6242. return *v, true
  6243. }
  6244. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  6245. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6247. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  6248. if !m.op.Is(OpUpdateOne) {
  6249. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  6250. }
  6251. if m.id == nil || m.oldValue == nil {
  6252. return v, errors.New("OldStopTime requires an ID field in the mutation")
  6253. }
  6254. oldValue, err := m.oldValue(ctx)
  6255. if err != nil {
  6256. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  6257. }
  6258. return oldValue.StopTime, nil
  6259. }
  6260. // ClearStopTime clears the value of the "stop_time" field.
  6261. func (m *BatchMsgMutation) ClearStopTime() {
  6262. m.stop_time = nil
  6263. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  6264. }
  6265. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  6266. func (m *BatchMsgMutation) StopTimeCleared() bool {
  6267. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  6268. return ok
  6269. }
  6270. // ResetStopTime resets all changes to the "stop_time" field.
  6271. func (m *BatchMsgMutation) ResetStopTime() {
  6272. m.stop_time = nil
  6273. delete(m.clearedFields, batchmsg.FieldStopTime)
  6274. }
  6275. // SetSendTime sets the "send_time" field.
  6276. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  6277. m.send_time = &t
  6278. }
  6279. // SendTime returns the value of the "send_time" field in the mutation.
  6280. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  6281. v := m.send_time
  6282. if v == nil {
  6283. return
  6284. }
  6285. return *v, true
  6286. }
  6287. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  6288. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6290. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6291. if !m.op.Is(OpUpdateOne) {
  6292. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6293. }
  6294. if m.id == nil || m.oldValue == nil {
  6295. return v, errors.New("OldSendTime requires an ID field in the mutation")
  6296. }
  6297. oldValue, err := m.oldValue(ctx)
  6298. if err != nil {
  6299. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  6300. }
  6301. return oldValue.SendTime, nil
  6302. }
  6303. // ClearSendTime clears the value of the "send_time" field.
  6304. func (m *BatchMsgMutation) ClearSendTime() {
  6305. m.send_time = nil
  6306. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  6307. }
  6308. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6309. func (m *BatchMsgMutation) SendTimeCleared() bool {
  6310. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  6311. return ok
  6312. }
  6313. // ResetSendTime resets all changes to the "send_time" field.
  6314. func (m *BatchMsgMutation) ResetSendTime() {
  6315. m.send_time = nil
  6316. delete(m.clearedFields, batchmsg.FieldSendTime)
  6317. }
  6318. // SetType sets the "type" field.
  6319. func (m *BatchMsgMutation) SetType(i int32) {
  6320. m._type = &i
  6321. m.add_type = nil
  6322. }
  6323. // GetType returns the value of the "type" field in the mutation.
  6324. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6325. v := m._type
  6326. if v == nil {
  6327. return
  6328. }
  6329. return *v, true
  6330. }
  6331. // OldType returns the old "type" field's value of the BatchMsg entity.
  6332. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6334. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6335. if !m.op.Is(OpUpdateOne) {
  6336. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6337. }
  6338. if m.id == nil || m.oldValue == nil {
  6339. return v, errors.New("OldType requires an ID field in the mutation")
  6340. }
  6341. oldValue, err := m.oldValue(ctx)
  6342. if err != nil {
  6343. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6344. }
  6345. return oldValue.Type, nil
  6346. }
  6347. // AddType adds i to the "type" field.
  6348. func (m *BatchMsgMutation) AddType(i int32) {
  6349. if m.add_type != nil {
  6350. *m.add_type += i
  6351. } else {
  6352. m.add_type = &i
  6353. }
  6354. }
  6355. // AddedType returns the value that was added to the "type" field in this mutation.
  6356. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6357. v := m.add_type
  6358. if v == nil {
  6359. return
  6360. }
  6361. return *v, true
  6362. }
  6363. // ClearType clears the value of the "type" field.
  6364. func (m *BatchMsgMutation) ClearType() {
  6365. m._type = nil
  6366. m.add_type = nil
  6367. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6368. }
  6369. // TypeCleared returns if the "type" field was cleared in this mutation.
  6370. func (m *BatchMsgMutation) TypeCleared() bool {
  6371. _, ok := m.clearedFields[batchmsg.FieldType]
  6372. return ok
  6373. }
  6374. // ResetType resets all changes to the "type" field.
  6375. func (m *BatchMsgMutation) ResetType() {
  6376. m._type = nil
  6377. m.add_type = nil
  6378. delete(m.clearedFields, batchmsg.FieldType)
  6379. }
  6380. // SetOrganizationID sets the "organization_id" field.
  6381. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6382. m.organization_id = &u
  6383. m.addorganization_id = nil
  6384. }
  6385. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6386. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6387. v := m.organization_id
  6388. if v == nil {
  6389. return
  6390. }
  6391. return *v, true
  6392. }
  6393. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6394. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6396. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6397. if !m.op.Is(OpUpdateOne) {
  6398. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6399. }
  6400. if m.id == nil || m.oldValue == nil {
  6401. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6402. }
  6403. oldValue, err := m.oldValue(ctx)
  6404. if err != nil {
  6405. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6406. }
  6407. return oldValue.OrganizationID, nil
  6408. }
  6409. // AddOrganizationID adds u to the "organization_id" field.
  6410. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6411. if m.addorganization_id != nil {
  6412. *m.addorganization_id += u
  6413. } else {
  6414. m.addorganization_id = &u
  6415. }
  6416. }
  6417. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6418. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6419. v := m.addorganization_id
  6420. if v == nil {
  6421. return
  6422. }
  6423. return *v, true
  6424. }
  6425. // ResetOrganizationID resets all changes to the "organization_id" field.
  6426. func (m *BatchMsgMutation) ResetOrganizationID() {
  6427. m.organization_id = nil
  6428. m.addorganization_id = nil
  6429. }
  6430. // SetCtype sets the "ctype" field.
  6431. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6432. m.ctype = &u
  6433. m.addctype = nil
  6434. }
  6435. // Ctype returns the value of the "ctype" field in the mutation.
  6436. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6437. v := m.ctype
  6438. if v == nil {
  6439. return
  6440. }
  6441. return *v, true
  6442. }
  6443. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6444. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6446. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6447. if !m.op.Is(OpUpdateOne) {
  6448. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6449. }
  6450. if m.id == nil || m.oldValue == nil {
  6451. return v, errors.New("OldCtype requires an ID field in the mutation")
  6452. }
  6453. oldValue, err := m.oldValue(ctx)
  6454. if err != nil {
  6455. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6456. }
  6457. return oldValue.Ctype, nil
  6458. }
  6459. // AddCtype adds u to the "ctype" field.
  6460. func (m *BatchMsgMutation) AddCtype(u int64) {
  6461. if m.addctype != nil {
  6462. *m.addctype += u
  6463. } else {
  6464. m.addctype = &u
  6465. }
  6466. }
  6467. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6468. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6469. v := m.addctype
  6470. if v == nil {
  6471. return
  6472. }
  6473. return *v, true
  6474. }
  6475. // ResetCtype resets all changes to the "ctype" field.
  6476. func (m *BatchMsgMutation) ResetCtype() {
  6477. m.ctype = nil
  6478. m.addctype = nil
  6479. }
  6480. // SetCc sets the "cc" field.
  6481. func (m *BatchMsgMutation) SetCc(s string) {
  6482. m.cc = &s
  6483. }
  6484. // Cc returns the value of the "cc" field in the mutation.
  6485. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6486. v := m.cc
  6487. if v == nil {
  6488. return
  6489. }
  6490. return *v, true
  6491. }
  6492. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6493. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6495. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6496. if !m.op.Is(OpUpdateOne) {
  6497. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6498. }
  6499. if m.id == nil || m.oldValue == nil {
  6500. return v, errors.New("OldCc requires an ID field in the mutation")
  6501. }
  6502. oldValue, err := m.oldValue(ctx)
  6503. if err != nil {
  6504. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6505. }
  6506. return oldValue.Cc, nil
  6507. }
  6508. // ClearCc clears the value of the "cc" field.
  6509. func (m *BatchMsgMutation) ClearCc() {
  6510. m.cc = nil
  6511. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6512. }
  6513. // CcCleared returns if the "cc" field was cleared in this mutation.
  6514. func (m *BatchMsgMutation) CcCleared() bool {
  6515. _, ok := m.clearedFields[batchmsg.FieldCc]
  6516. return ok
  6517. }
  6518. // ResetCc resets all changes to the "cc" field.
  6519. func (m *BatchMsgMutation) ResetCc() {
  6520. m.cc = nil
  6521. delete(m.clearedFields, batchmsg.FieldCc)
  6522. }
  6523. // SetPhone sets the "phone" field.
  6524. func (m *BatchMsgMutation) SetPhone(s string) {
  6525. m.phone = &s
  6526. }
  6527. // Phone returns the value of the "phone" field in the mutation.
  6528. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6529. v := m.phone
  6530. if v == nil {
  6531. return
  6532. }
  6533. return *v, true
  6534. }
  6535. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6536. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6538. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6539. if !m.op.Is(OpUpdateOne) {
  6540. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6541. }
  6542. if m.id == nil || m.oldValue == nil {
  6543. return v, errors.New("OldPhone requires an ID field in the mutation")
  6544. }
  6545. oldValue, err := m.oldValue(ctx)
  6546. if err != nil {
  6547. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6548. }
  6549. return oldValue.Phone, nil
  6550. }
  6551. // ClearPhone clears the value of the "phone" field.
  6552. func (m *BatchMsgMutation) ClearPhone() {
  6553. m.phone = nil
  6554. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6555. }
  6556. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6557. func (m *BatchMsgMutation) PhoneCleared() bool {
  6558. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6559. return ok
  6560. }
  6561. // ResetPhone resets all changes to the "phone" field.
  6562. func (m *BatchMsgMutation) ResetPhone() {
  6563. m.phone = nil
  6564. delete(m.clearedFields, batchmsg.FieldPhone)
  6565. }
  6566. // SetTemplateName sets the "template_name" field.
  6567. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6568. m.template_name = &s
  6569. }
  6570. // TemplateName returns the value of the "template_name" field in the mutation.
  6571. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6572. v := m.template_name
  6573. if v == nil {
  6574. return
  6575. }
  6576. return *v, true
  6577. }
  6578. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6579. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6581. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6582. if !m.op.Is(OpUpdateOne) {
  6583. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6584. }
  6585. if m.id == nil || m.oldValue == nil {
  6586. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6587. }
  6588. oldValue, err := m.oldValue(ctx)
  6589. if err != nil {
  6590. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6591. }
  6592. return oldValue.TemplateName, nil
  6593. }
  6594. // ClearTemplateName clears the value of the "template_name" field.
  6595. func (m *BatchMsgMutation) ClearTemplateName() {
  6596. m.template_name = nil
  6597. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6598. }
  6599. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6600. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6601. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6602. return ok
  6603. }
  6604. // ResetTemplateName resets all changes to the "template_name" field.
  6605. func (m *BatchMsgMutation) ResetTemplateName() {
  6606. m.template_name = nil
  6607. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6608. }
  6609. // SetTemplateCode sets the "template_code" field.
  6610. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6611. m.template_code = &s
  6612. }
  6613. // TemplateCode returns the value of the "template_code" field in the mutation.
  6614. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6615. v := m.template_code
  6616. if v == nil {
  6617. return
  6618. }
  6619. return *v, true
  6620. }
  6621. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6622. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6624. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6625. if !m.op.Is(OpUpdateOne) {
  6626. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6627. }
  6628. if m.id == nil || m.oldValue == nil {
  6629. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6630. }
  6631. oldValue, err := m.oldValue(ctx)
  6632. if err != nil {
  6633. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6634. }
  6635. return oldValue.TemplateCode, nil
  6636. }
  6637. // ClearTemplateCode clears the value of the "template_code" field.
  6638. func (m *BatchMsgMutation) ClearTemplateCode() {
  6639. m.template_code = nil
  6640. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6641. }
  6642. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6643. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6644. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6645. return ok
  6646. }
  6647. // ResetTemplateCode resets all changes to the "template_code" field.
  6648. func (m *BatchMsgMutation) ResetTemplateCode() {
  6649. m.template_code = nil
  6650. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6651. }
  6652. // SetLang sets the "lang" field.
  6653. func (m *BatchMsgMutation) SetLang(s string) {
  6654. m.lang = &s
  6655. }
  6656. // Lang returns the value of the "lang" field in the mutation.
  6657. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6658. v := m.lang
  6659. if v == nil {
  6660. return
  6661. }
  6662. return *v, true
  6663. }
  6664. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6665. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6667. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6668. if !m.op.Is(OpUpdateOne) {
  6669. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6670. }
  6671. if m.id == nil || m.oldValue == nil {
  6672. return v, errors.New("OldLang requires an ID field in the mutation")
  6673. }
  6674. oldValue, err := m.oldValue(ctx)
  6675. if err != nil {
  6676. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6677. }
  6678. return oldValue.Lang, nil
  6679. }
  6680. // ClearLang clears the value of the "lang" field.
  6681. func (m *BatchMsgMutation) ClearLang() {
  6682. m.lang = nil
  6683. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6684. }
  6685. // LangCleared returns if the "lang" field was cleared in this mutation.
  6686. func (m *BatchMsgMutation) LangCleared() bool {
  6687. _, ok := m.clearedFields[batchmsg.FieldLang]
  6688. return ok
  6689. }
  6690. // ResetLang resets all changes to the "lang" field.
  6691. func (m *BatchMsgMutation) ResetLang() {
  6692. m.lang = nil
  6693. delete(m.clearedFields, batchmsg.FieldLang)
  6694. }
  6695. // Where appends a list predicates to the BatchMsgMutation builder.
  6696. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6697. m.predicates = append(m.predicates, ps...)
  6698. }
  6699. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6700. // users can use type-assertion to append predicates that do not depend on any generated package.
  6701. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6702. p := make([]predicate.BatchMsg, len(ps))
  6703. for i := range ps {
  6704. p[i] = ps[i]
  6705. }
  6706. m.Where(p...)
  6707. }
  6708. // Op returns the operation name.
  6709. func (m *BatchMsgMutation) Op() Op {
  6710. return m.op
  6711. }
  6712. // SetOp allows setting the mutation operation.
  6713. func (m *BatchMsgMutation) SetOp(op Op) {
  6714. m.op = op
  6715. }
  6716. // Type returns the node type of this mutation (BatchMsg).
  6717. func (m *BatchMsgMutation) Type() string {
  6718. return m.typ
  6719. }
  6720. // Fields returns all fields that were changed during this mutation. Note that in
  6721. // order to get all numeric fields that were incremented/decremented, call
  6722. // AddedFields().
  6723. func (m *BatchMsgMutation) Fields() []string {
  6724. fields := make([]string, 0, 24)
  6725. if m.created_at != nil {
  6726. fields = append(fields, batchmsg.FieldCreatedAt)
  6727. }
  6728. if m.updated_at != nil {
  6729. fields = append(fields, batchmsg.FieldUpdatedAt)
  6730. }
  6731. if m.deleted_at != nil {
  6732. fields = append(fields, batchmsg.FieldDeletedAt)
  6733. }
  6734. if m.status != nil {
  6735. fields = append(fields, batchmsg.FieldStatus)
  6736. }
  6737. if m.batch_no != nil {
  6738. fields = append(fields, batchmsg.FieldBatchNo)
  6739. }
  6740. if m.task_name != nil {
  6741. fields = append(fields, batchmsg.FieldTaskName)
  6742. }
  6743. if m.fromwxid != nil {
  6744. fields = append(fields, batchmsg.FieldFromwxid)
  6745. }
  6746. if m.msg != nil {
  6747. fields = append(fields, batchmsg.FieldMsg)
  6748. }
  6749. if m.tag != nil {
  6750. fields = append(fields, batchmsg.FieldTag)
  6751. }
  6752. if m.tagids != nil {
  6753. fields = append(fields, batchmsg.FieldTagids)
  6754. }
  6755. if m.total != nil {
  6756. fields = append(fields, batchmsg.FieldTotal)
  6757. }
  6758. if m.success != nil {
  6759. fields = append(fields, batchmsg.FieldSuccess)
  6760. }
  6761. if m.fail != nil {
  6762. fields = append(fields, batchmsg.FieldFail)
  6763. }
  6764. if m.start_time != nil {
  6765. fields = append(fields, batchmsg.FieldStartTime)
  6766. }
  6767. if m.stop_time != nil {
  6768. fields = append(fields, batchmsg.FieldStopTime)
  6769. }
  6770. if m.send_time != nil {
  6771. fields = append(fields, batchmsg.FieldSendTime)
  6772. }
  6773. if m._type != nil {
  6774. fields = append(fields, batchmsg.FieldType)
  6775. }
  6776. if m.organization_id != nil {
  6777. fields = append(fields, batchmsg.FieldOrganizationID)
  6778. }
  6779. if m.ctype != nil {
  6780. fields = append(fields, batchmsg.FieldCtype)
  6781. }
  6782. if m.cc != nil {
  6783. fields = append(fields, batchmsg.FieldCc)
  6784. }
  6785. if m.phone != nil {
  6786. fields = append(fields, batchmsg.FieldPhone)
  6787. }
  6788. if m.template_name != nil {
  6789. fields = append(fields, batchmsg.FieldTemplateName)
  6790. }
  6791. if m.template_code != nil {
  6792. fields = append(fields, batchmsg.FieldTemplateCode)
  6793. }
  6794. if m.lang != nil {
  6795. fields = append(fields, batchmsg.FieldLang)
  6796. }
  6797. return fields
  6798. }
  6799. // Field returns the value of a field with the given name. The second boolean
  6800. // return value indicates that this field was not set, or was not defined in the
  6801. // schema.
  6802. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6803. switch name {
  6804. case batchmsg.FieldCreatedAt:
  6805. return m.CreatedAt()
  6806. case batchmsg.FieldUpdatedAt:
  6807. return m.UpdatedAt()
  6808. case batchmsg.FieldDeletedAt:
  6809. return m.DeletedAt()
  6810. case batchmsg.FieldStatus:
  6811. return m.Status()
  6812. case batchmsg.FieldBatchNo:
  6813. return m.BatchNo()
  6814. case batchmsg.FieldTaskName:
  6815. return m.TaskName()
  6816. case batchmsg.FieldFromwxid:
  6817. return m.Fromwxid()
  6818. case batchmsg.FieldMsg:
  6819. return m.Msg()
  6820. case batchmsg.FieldTag:
  6821. return m.Tag()
  6822. case batchmsg.FieldTagids:
  6823. return m.Tagids()
  6824. case batchmsg.FieldTotal:
  6825. return m.Total()
  6826. case batchmsg.FieldSuccess:
  6827. return m.Success()
  6828. case batchmsg.FieldFail:
  6829. return m.Fail()
  6830. case batchmsg.FieldStartTime:
  6831. return m.StartTime()
  6832. case batchmsg.FieldStopTime:
  6833. return m.StopTime()
  6834. case batchmsg.FieldSendTime:
  6835. return m.SendTime()
  6836. case batchmsg.FieldType:
  6837. return m.GetType()
  6838. case batchmsg.FieldOrganizationID:
  6839. return m.OrganizationID()
  6840. case batchmsg.FieldCtype:
  6841. return m.Ctype()
  6842. case batchmsg.FieldCc:
  6843. return m.Cc()
  6844. case batchmsg.FieldPhone:
  6845. return m.Phone()
  6846. case batchmsg.FieldTemplateName:
  6847. return m.TemplateName()
  6848. case batchmsg.FieldTemplateCode:
  6849. return m.TemplateCode()
  6850. case batchmsg.FieldLang:
  6851. return m.Lang()
  6852. }
  6853. return nil, false
  6854. }
  6855. // OldField returns the old value of the field from the database. An error is
  6856. // returned if the mutation operation is not UpdateOne, or the query to the
  6857. // database failed.
  6858. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6859. switch name {
  6860. case batchmsg.FieldCreatedAt:
  6861. return m.OldCreatedAt(ctx)
  6862. case batchmsg.FieldUpdatedAt:
  6863. return m.OldUpdatedAt(ctx)
  6864. case batchmsg.FieldDeletedAt:
  6865. return m.OldDeletedAt(ctx)
  6866. case batchmsg.FieldStatus:
  6867. return m.OldStatus(ctx)
  6868. case batchmsg.FieldBatchNo:
  6869. return m.OldBatchNo(ctx)
  6870. case batchmsg.FieldTaskName:
  6871. return m.OldTaskName(ctx)
  6872. case batchmsg.FieldFromwxid:
  6873. return m.OldFromwxid(ctx)
  6874. case batchmsg.FieldMsg:
  6875. return m.OldMsg(ctx)
  6876. case batchmsg.FieldTag:
  6877. return m.OldTag(ctx)
  6878. case batchmsg.FieldTagids:
  6879. return m.OldTagids(ctx)
  6880. case batchmsg.FieldTotal:
  6881. return m.OldTotal(ctx)
  6882. case batchmsg.FieldSuccess:
  6883. return m.OldSuccess(ctx)
  6884. case batchmsg.FieldFail:
  6885. return m.OldFail(ctx)
  6886. case batchmsg.FieldStartTime:
  6887. return m.OldStartTime(ctx)
  6888. case batchmsg.FieldStopTime:
  6889. return m.OldStopTime(ctx)
  6890. case batchmsg.FieldSendTime:
  6891. return m.OldSendTime(ctx)
  6892. case batchmsg.FieldType:
  6893. return m.OldType(ctx)
  6894. case batchmsg.FieldOrganizationID:
  6895. return m.OldOrganizationID(ctx)
  6896. case batchmsg.FieldCtype:
  6897. return m.OldCtype(ctx)
  6898. case batchmsg.FieldCc:
  6899. return m.OldCc(ctx)
  6900. case batchmsg.FieldPhone:
  6901. return m.OldPhone(ctx)
  6902. case batchmsg.FieldTemplateName:
  6903. return m.OldTemplateName(ctx)
  6904. case batchmsg.FieldTemplateCode:
  6905. return m.OldTemplateCode(ctx)
  6906. case batchmsg.FieldLang:
  6907. return m.OldLang(ctx)
  6908. }
  6909. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6910. }
  6911. // SetField sets the value of a field with the given name. It returns an error if
  6912. // the field is not defined in the schema, or if the type mismatched the field
  6913. // type.
  6914. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6915. switch name {
  6916. case batchmsg.FieldCreatedAt:
  6917. v, ok := value.(time.Time)
  6918. if !ok {
  6919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6920. }
  6921. m.SetCreatedAt(v)
  6922. return nil
  6923. case batchmsg.FieldUpdatedAt:
  6924. v, ok := value.(time.Time)
  6925. if !ok {
  6926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6927. }
  6928. m.SetUpdatedAt(v)
  6929. return nil
  6930. case batchmsg.FieldDeletedAt:
  6931. v, ok := value.(time.Time)
  6932. if !ok {
  6933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6934. }
  6935. m.SetDeletedAt(v)
  6936. return nil
  6937. case batchmsg.FieldStatus:
  6938. v, ok := value.(uint8)
  6939. if !ok {
  6940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6941. }
  6942. m.SetStatus(v)
  6943. return nil
  6944. case batchmsg.FieldBatchNo:
  6945. v, ok := value.(string)
  6946. if !ok {
  6947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6948. }
  6949. m.SetBatchNo(v)
  6950. return nil
  6951. case batchmsg.FieldTaskName:
  6952. v, ok := value.(string)
  6953. if !ok {
  6954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6955. }
  6956. m.SetTaskName(v)
  6957. return nil
  6958. case batchmsg.FieldFromwxid:
  6959. v, ok := value.(string)
  6960. if !ok {
  6961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6962. }
  6963. m.SetFromwxid(v)
  6964. return nil
  6965. case batchmsg.FieldMsg:
  6966. v, ok := value.(string)
  6967. if !ok {
  6968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6969. }
  6970. m.SetMsg(v)
  6971. return nil
  6972. case batchmsg.FieldTag:
  6973. v, ok := value.(string)
  6974. if !ok {
  6975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6976. }
  6977. m.SetTag(v)
  6978. return nil
  6979. case batchmsg.FieldTagids:
  6980. v, ok := value.(string)
  6981. if !ok {
  6982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6983. }
  6984. m.SetTagids(v)
  6985. return nil
  6986. case batchmsg.FieldTotal:
  6987. v, ok := value.(int32)
  6988. if !ok {
  6989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6990. }
  6991. m.SetTotal(v)
  6992. return nil
  6993. case batchmsg.FieldSuccess:
  6994. v, ok := value.(int32)
  6995. if !ok {
  6996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6997. }
  6998. m.SetSuccess(v)
  6999. return nil
  7000. case batchmsg.FieldFail:
  7001. v, ok := value.(int32)
  7002. if !ok {
  7003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7004. }
  7005. m.SetFail(v)
  7006. return nil
  7007. case batchmsg.FieldStartTime:
  7008. v, ok := value.(time.Time)
  7009. if !ok {
  7010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7011. }
  7012. m.SetStartTime(v)
  7013. return nil
  7014. case batchmsg.FieldStopTime:
  7015. v, ok := value.(time.Time)
  7016. if !ok {
  7017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7018. }
  7019. m.SetStopTime(v)
  7020. return nil
  7021. case batchmsg.FieldSendTime:
  7022. v, ok := value.(time.Time)
  7023. if !ok {
  7024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7025. }
  7026. m.SetSendTime(v)
  7027. return nil
  7028. case batchmsg.FieldType:
  7029. v, ok := value.(int32)
  7030. if !ok {
  7031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7032. }
  7033. m.SetType(v)
  7034. return nil
  7035. case batchmsg.FieldOrganizationID:
  7036. v, ok := value.(uint64)
  7037. if !ok {
  7038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7039. }
  7040. m.SetOrganizationID(v)
  7041. return nil
  7042. case batchmsg.FieldCtype:
  7043. v, ok := value.(uint64)
  7044. if !ok {
  7045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7046. }
  7047. m.SetCtype(v)
  7048. return nil
  7049. case batchmsg.FieldCc:
  7050. v, ok := value.(string)
  7051. if !ok {
  7052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7053. }
  7054. m.SetCc(v)
  7055. return nil
  7056. case batchmsg.FieldPhone:
  7057. v, ok := value.(string)
  7058. if !ok {
  7059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7060. }
  7061. m.SetPhone(v)
  7062. return nil
  7063. case batchmsg.FieldTemplateName:
  7064. v, ok := value.(string)
  7065. if !ok {
  7066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7067. }
  7068. m.SetTemplateName(v)
  7069. return nil
  7070. case batchmsg.FieldTemplateCode:
  7071. v, ok := value.(string)
  7072. if !ok {
  7073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7074. }
  7075. m.SetTemplateCode(v)
  7076. return nil
  7077. case batchmsg.FieldLang:
  7078. v, ok := value.(string)
  7079. if !ok {
  7080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7081. }
  7082. m.SetLang(v)
  7083. return nil
  7084. }
  7085. return fmt.Errorf("unknown BatchMsg field %s", name)
  7086. }
  7087. // AddedFields returns all numeric fields that were incremented/decremented during
  7088. // this mutation.
  7089. func (m *BatchMsgMutation) AddedFields() []string {
  7090. var fields []string
  7091. if m.addstatus != nil {
  7092. fields = append(fields, batchmsg.FieldStatus)
  7093. }
  7094. if m.addtotal != nil {
  7095. fields = append(fields, batchmsg.FieldTotal)
  7096. }
  7097. if m.addsuccess != nil {
  7098. fields = append(fields, batchmsg.FieldSuccess)
  7099. }
  7100. if m.addfail != nil {
  7101. fields = append(fields, batchmsg.FieldFail)
  7102. }
  7103. if m.add_type != nil {
  7104. fields = append(fields, batchmsg.FieldType)
  7105. }
  7106. if m.addorganization_id != nil {
  7107. fields = append(fields, batchmsg.FieldOrganizationID)
  7108. }
  7109. if m.addctype != nil {
  7110. fields = append(fields, batchmsg.FieldCtype)
  7111. }
  7112. return fields
  7113. }
  7114. // AddedField returns the numeric value that was incremented/decremented on a field
  7115. // with the given name. The second boolean return value indicates that this field
  7116. // was not set, or was not defined in the schema.
  7117. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  7118. switch name {
  7119. case batchmsg.FieldStatus:
  7120. return m.AddedStatus()
  7121. case batchmsg.FieldTotal:
  7122. return m.AddedTotal()
  7123. case batchmsg.FieldSuccess:
  7124. return m.AddedSuccess()
  7125. case batchmsg.FieldFail:
  7126. return m.AddedFail()
  7127. case batchmsg.FieldType:
  7128. return m.AddedType()
  7129. case batchmsg.FieldOrganizationID:
  7130. return m.AddedOrganizationID()
  7131. case batchmsg.FieldCtype:
  7132. return m.AddedCtype()
  7133. }
  7134. return nil, false
  7135. }
  7136. // AddField adds the value to the field with the given name. It returns an error if
  7137. // the field is not defined in the schema, or if the type mismatched the field
  7138. // type.
  7139. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  7140. switch name {
  7141. case batchmsg.FieldStatus:
  7142. v, ok := value.(int8)
  7143. if !ok {
  7144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7145. }
  7146. m.AddStatus(v)
  7147. return nil
  7148. case batchmsg.FieldTotal:
  7149. v, ok := value.(int32)
  7150. if !ok {
  7151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7152. }
  7153. m.AddTotal(v)
  7154. return nil
  7155. case batchmsg.FieldSuccess:
  7156. v, ok := value.(int32)
  7157. if !ok {
  7158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7159. }
  7160. m.AddSuccess(v)
  7161. return nil
  7162. case batchmsg.FieldFail:
  7163. v, ok := value.(int32)
  7164. if !ok {
  7165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7166. }
  7167. m.AddFail(v)
  7168. return nil
  7169. case batchmsg.FieldType:
  7170. v, ok := value.(int32)
  7171. if !ok {
  7172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7173. }
  7174. m.AddType(v)
  7175. return nil
  7176. case batchmsg.FieldOrganizationID:
  7177. v, ok := value.(int64)
  7178. if !ok {
  7179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7180. }
  7181. m.AddOrganizationID(v)
  7182. return nil
  7183. case batchmsg.FieldCtype:
  7184. v, ok := value.(int64)
  7185. if !ok {
  7186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7187. }
  7188. m.AddCtype(v)
  7189. return nil
  7190. }
  7191. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  7192. }
  7193. // ClearedFields returns all nullable fields that were cleared during this
  7194. // mutation.
  7195. func (m *BatchMsgMutation) ClearedFields() []string {
  7196. var fields []string
  7197. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  7198. fields = append(fields, batchmsg.FieldDeletedAt)
  7199. }
  7200. if m.FieldCleared(batchmsg.FieldStatus) {
  7201. fields = append(fields, batchmsg.FieldStatus)
  7202. }
  7203. if m.FieldCleared(batchmsg.FieldBatchNo) {
  7204. fields = append(fields, batchmsg.FieldBatchNo)
  7205. }
  7206. if m.FieldCleared(batchmsg.FieldTaskName) {
  7207. fields = append(fields, batchmsg.FieldTaskName)
  7208. }
  7209. if m.FieldCleared(batchmsg.FieldFromwxid) {
  7210. fields = append(fields, batchmsg.FieldFromwxid)
  7211. }
  7212. if m.FieldCleared(batchmsg.FieldMsg) {
  7213. fields = append(fields, batchmsg.FieldMsg)
  7214. }
  7215. if m.FieldCleared(batchmsg.FieldTag) {
  7216. fields = append(fields, batchmsg.FieldTag)
  7217. }
  7218. if m.FieldCleared(batchmsg.FieldTagids) {
  7219. fields = append(fields, batchmsg.FieldTagids)
  7220. }
  7221. if m.FieldCleared(batchmsg.FieldTotal) {
  7222. fields = append(fields, batchmsg.FieldTotal)
  7223. }
  7224. if m.FieldCleared(batchmsg.FieldSuccess) {
  7225. fields = append(fields, batchmsg.FieldSuccess)
  7226. }
  7227. if m.FieldCleared(batchmsg.FieldFail) {
  7228. fields = append(fields, batchmsg.FieldFail)
  7229. }
  7230. if m.FieldCleared(batchmsg.FieldStartTime) {
  7231. fields = append(fields, batchmsg.FieldStartTime)
  7232. }
  7233. if m.FieldCleared(batchmsg.FieldStopTime) {
  7234. fields = append(fields, batchmsg.FieldStopTime)
  7235. }
  7236. if m.FieldCleared(batchmsg.FieldSendTime) {
  7237. fields = append(fields, batchmsg.FieldSendTime)
  7238. }
  7239. if m.FieldCleared(batchmsg.FieldType) {
  7240. fields = append(fields, batchmsg.FieldType)
  7241. }
  7242. if m.FieldCleared(batchmsg.FieldCc) {
  7243. fields = append(fields, batchmsg.FieldCc)
  7244. }
  7245. if m.FieldCleared(batchmsg.FieldPhone) {
  7246. fields = append(fields, batchmsg.FieldPhone)
  7247. }
  7248. if m.FieldCleared(batchmsg.FieldTemplateName) {
  7249. fields = append(fields, batchmsg.FieldTemplateName)
  7250. }
  7251. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  7252. fields = append(fields, batchmsg.FieldTemplateCode)
  7253. }
  7254. if m.FieldCleared(batchmsg.FieldLang) {
  7255. fields = append(fields, batchmsg.FieldLang)
  7256. }
  7257. return fields
  7258. }
  7259. // FieldCleared returns a boolean indicating if a field with the given name was
  7260. // cleared in this mutation.
  7261. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  7262. _, ok := m.clearedFields[name]
  7263. return ok
  7264. }
  7265. // ClearField clears the value of the field with the given name. It returns an
  7266. // error if the field is not defined in the schema.
  7267. func (m *BatchMsgMutation) ClearField(name string) error {
  7268. switch name {
  7269. case batchmsg.FieldDeletedAt:
  7270. m.ClearDeletedAt()
  7271. return nil
  7272. case batchmsg.FieldStatus:
  7273. m.ClearStatus()
  7274. return nil
  7275. case batchmsg.FieldBatchNo:
  7276. m.ClearBatchNo()
  7277. return nil
  7278. case batchmsg.FieldTaskName:
  7279. m.ClearTaskName()
  7280. return nil
  7281. case batchmsg.FieldFromwxid:
  7282. m.ClearFromwxid()
  7283. return nil
  7284. case batchmsg.FieldMsg:
  7285. m.ClearMsg()
  7286. return nil
  7287. case batchmsg.FieldTag:
  7288. m.ClearTag()
  7289. return nil
  7290. case batchmsg.FieldTagids:
  7291. m.ClearTagids()
  7292. return nil
  7293. case batchmsg.FieldTotal:
  7294. m.ClearTotal()
  7295. return nil
  7296. case batchmsg.FieldSuccess:
  7297. m.ClearSuccess()
  7298. return nil
  7299. case batchmsg.FieldFail:
  7300. m.ClearFail()
  7301. return nil
  7302. case batchmsg.FieldStartTime:
  7303. m.ClearStartTime()
  7304. return nil
  7305. case batchmsg.FieldStopTime:
  7306. m.ClearStopTime()
  7307. return nil
  7308. case batchmsg.FieldSendTime:
  7309. m.ClearSendTime()
  7310. return nil
  7311. case batchmsg.FieldType:
  7312. m.ClearType()
  7313. return nil
  7314. case batchmsg.FieldCc:
  7315. m.ClearCc()
  7316. return nil
  7317. case batchmsg.FieldPhone:
  7318. m.ClearPhone()
  7319. return nil
  7320. case batchmsg.FieldTemplateName:
  7321. m.ClearTemplateName()
  7322. return nil
  7323. case batchmsg.FieldTemplateCode:
  7324. m.ClearTemplateCode()
  7325. return nil
  7326. case batchmsg.FieldLang:
  7327. m.ClearLang()
  7328. return nil
  7329. }
  7330. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7331. }
  7332. // ResetField resets all changes in the mutation for the field with the given name.
  7333. // It returns an error if the field is not defined in the schema.
  7334. func (m *BatchMsgMutation) ResetField(name string) error {
  7335. switch name {
  7336. case batchmsg.FieldCreatedAt:
  7337. m.ResetCreatedAt()
  7338. return nil
  7339. case batchmsg.FieldUpdatedAt:
  7340. m.ResetUpdatedAt()
  7341. return nil
  7342. case batchmsg.FieldDeletedAt:
  7343. m.ResetDeletedAt()
  7344. return nil
  7345. case batchmsg.FieldStatus:
  7346. m.ResetStatus()
  7347. return nil
  7348. case batchmsg.FieldBatchNo:
  7349. m.ResetBatchNo()
  7350. return nil
  7351. case batchmsg.FieldTaskName:
  7352. m.ResetTaskName()
  7353. return nil
  7354. case batchmsg.FieldFromwxid:
  7355. m.ResetFromwxid()
  7356. return nil
  7357. case batchmsg.FieldMsg:
  7358. m.ResetMsg()
  7359. return nil
  7360. case batchmsg.FieldTag:
  7361. m.ResetTag()
  7362. return nil
  7363. case batchmsg.FieldTagids:
  7364. m.ResetTagids()
  7365. return nil
  7366. case batchmsg.FieldTotal:
  7367. m.ResetTotal()
  7368. return nil
  7369. case batchmsg.FieldSuccess:
  7370. m.ResetSuccess()
  7371. return nil
  7372. case batchmsg.FieldFail:
  7373. m.ResetFail()
  7374. return nil
  7375. case batchmsg.FieldStartTime:
  7376. m.ResetStartTime()
  7377. return nil
  7378. case batchmsg.FieldStopTime:
  7379. m.ResetStopTime()
  7380. return nil
  7381. case batchmsg.FieldSendTime:
  7382. m.ResetSendTime()
  7383. return nil
  7384. case batchmsg.FieldType:
  7385. m.ResetType()
  7386. return nil
  7387. case batchmsg.FieldOrganizationID:
  7388. m.ResetOrganizationID()
  7389. return nil
  7390. case batchmsg.FieldCtype:
  7391. m.ResetCtype()
  7392. return nil
  7393. case batchmsg.FieldCc:
  7394. m.ResetCc()
  7395. return nil
  7396. case batchmsg.FieldPhone:
  7397. m.ResetPhone()
  7398. return nil
  7399. case batchmsg.FieldTemplateName:
  7400. m.ResetTemplateName()
  7401. return nil
  7402. case batchmsg.FieldTemplateCode:
  7403. m.ResetTemplateCode()
  7404. return nil
  7405. case batchmsg.FieldLang:
  7406. m.ResetLang()
  7407. return nil
  7408. }
  7409. return fmt.Errorf("unknown BatchMsg field %s", name)
  7410. }
  7411. // AddedEdges returns all edge names that were set/added in this mutation.
  7412. func (m *BatchMsgMutation) AddedEdges() []string {
  7413. edges := make([]string, 0, 0)
  7414. return edges
  7415. }
  7416. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7417. // name in this mutation.
  7418. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7419. return nil
  7420. }
  7421. // RemovedEdges returns all edge names that were removed in this mutation.
  7422. func (m *BatchMsgMutation) RemovedEdges() []string {
  7423. edges := make([]string, 0, 0)
  7424. return edges
  7425. }
  7426. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7427. // the given name in this mutation.
  7428. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7429. return nil
  7430. }
  7431. // ClearedEdges returns all edge names that were cleared in this mutation.
  7432. func (m *BatchMsgMutation) ClearedEdges() []string {
  7433. edges := make([]string, 0, 0)
  7434. return edges
  7435. }
  7436. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7437. // was cleared in this mutation.
  7438. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7439. return false
  7440. }
  7441. // ClearEdge clears the value of the edge with the given name. It returns an error
  7442. // if that edge is not defined in the schema.
  7443. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7444. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7445. }
  7446. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7447. // It returns an error if the edge is not defined in the schema.
  7448. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7449. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7450. }
  7451. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7452. type CategoryMutation struct {
  7453. config
  7454. op Op
  7455. typ string
  7456. id *uint64
  7457. created_at *time.Time
  7458. updated_at *time.Time
  7459. deleted_at *time.Time
  7460. name *string
  7461. organization_id *uint64
  7462. addorganization_id *int64
  7463. clearedFields map[string]struct{}
  7464. done bool
  7465. oldValue func(context.Context) (*Category, error)
  7466. predicates []predicate.Category
  7467. }
  7468. var _ ent.Mutation = (*CategoryMutation)(nil)
  7469. // categoryOption allows management of the mutation configuration using functional options.
  7470. type categoryOption func(*CategoryMutation)
  7471. // newCategoryMutation creates new mutation for the Category entity.
  7472. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7473. m := &CategoryMutation{
  7474. config: c,
  7475. op: op,
  7476. typ: TypeCategory,
  7477. clearedFields: make(map[string]struct{}),
  7478. }
  7479. for _, opt := range opts {
  7480. opt(m)
  7481. }
  7482. return m
  7483. }
  7484. // withCategoryID sets the ID field of the mutation.
  7485. func withCategoryID(id uint64) categoryOption {
  7486. return func(m *CategoryMutation) {
  7487. var (
  7488. err error
  7489. once sync.Once
  7490. value *Category
  7491. )
  7492. m.oldValue = func(ctx context.Context) (*Category, error) {
  7493. once.Do(func() {
  7494. if m.done {
  7495. err = errors.New("querying old values post mutation is not allowed")
  7496. } else {
  7497. value, err = m.Client().Category.Get(ctx, id)
  7498. }
  7499. })
  7500. return value, err
  7501. }
  7502. m.id = &id
  7503. }
  7504. }
  7505. // withCategory sets the old Category of the mutation.
  7506. func withCategory(node *Category) categoryOption {
  7507. return func(m *CategoryMutation) {
  7508. m.oldValue = func(context.Context) (*Category, error) {
  7509. return node, nil
  7510. }
  7511. m.id = &node.ID
  7512. }
  7513. }
  7514. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7515. // executed in a transaction (ent.Tx), a transactional client is returned.
  7516. func (m CategoryMutation) Client() *Client {
  7517. client := &Client{config: m.config}
  7518. client.init()
  7519. return client
  7520. }
  7521. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7522. // it returns an error otherwise.
  7523. func (m CategoryMutation) Tx() (*Tx, error) {
  7524. if _, ok := m.driver.(*txDriver); !ok {
  7525. return nil, errors.New("ent: mutation is not running in a transaction")
  7526. }
  7527. tx := &Tx{config: m.config}
  7528. tx.init()
  7529. return tx, nil
  7530. }
  7531. // SetID sets the value of the id field. Note that this
  7532. // operation is only accepted on creation of Category entities.
  7533. func (m *CategoryMutation) SetID(id uint64) {
  7534. m.id = &id
  7535. }
  7536. // ID returns the ID value in the mutation. Note that the ID is only available
  7537. // if it was provided to the builder or after it was returned from the database.
  7538. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7539. if m.id == nil {
  7540. return
  7541. }
  7542. return *m.id, true
  7543. }
  7544. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7545. // That means, if the mutation is applied within a transaction with an isolation level such
  7546. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7547. // or updated by the mutation.
  7548. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7549. switch {
  7550. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7551. id, exists := m.ID()
  7552. if exists {
  7553. return []uint64{id}, nil
  7554. }
  7555. fallthrough
  7556. case m.op.Is(OpUpdate | OpDelete):
  7557. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7558. default:
  7559. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7560. }
  7561. }
  7562. // SetCreatedAt sets the "created_at" field.
  7563. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7564. m.created_at = &t
  7565. }
  7566. // CreatedAt returns the value of the "created_at" field in the mutation.
  7567. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7568. v := m.created_at
  7569. if v == nil {
  7570. return
  7571. }
  7572. return *v, true
  7573. }
  7574. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7575. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7577. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7578. if !m.op.Is(OpUpdateOne) {
  7579. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7580. }
  7581. if m.id == nil || m.oldValue == nil {
  7582. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7583. }
  7584. oldValue, err := m.oldValue(ctx)
  7585. if err != nil {
  7586. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7587. }
  7588. return oldValue.CreatedAt, nil
  7589. }
  7590. // ResetCreatedAt resets all changes to the "created_at" field.
  7591. func (m *CategoryMutation) ResetCreatedAt() {
  7592. m.created_at = nil
  7593. }
  7594. // SetUpdatedAt sets the "updated_at" field.
  7595. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7596. m.updated_at = &t
  7597. }
  7598. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7599. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7600. v := m.updated_at
  7601. if v == nil {
  7602. return
  7603. }
  7604. return *v, true
  7605. }
  7606. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7607. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7609. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7610. if !m.op.Is(OpUpdateOne) {
  7611. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7612. }
  7613. if m.id == nil || m.oldValue == nil {
  7614. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7615. }
  7616. oldValue, err := m.oldValue(ctx)
  7617. if err != nil {
  7618. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7619. }
  7620. return oldValue.UpdatedAt, nil
  7621. }
  7622. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7623. func (m *CategoryMutation) ResetUpdatedAt() {
  7624. m.updated_at = nil
  7625. }
  7626. // SetDeletedAt sets the "deleted_at" field.
  7627. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7628. m.deleted_at = &t
  7629. }
  7630. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7631. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7632. v := m.deleted_at
  7633. if v == nil {
  7634. return
  7635. }
  7636. return *v, true
  7637. }
  7638. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7639. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7641. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7642. if !m.op.Is(OpUpdateOne) {
  7643. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7644. }
  7645. if m.id == nil || m.oldValue == nil {
  7646. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7647. }
  7648. oldValue, err := m.oldValue(ctx)
  7649. if err != nil {
  7650. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7651. }
  7652. return oldValue.DeletedAt, nil
  7653. }
  7654. // ClearDeletedAt clears the value of the "deleted_at" field.
  7655. func (m *CategoryMutation) ClearDeletedAt() {
  7656. m.deleted_at = nil
  7657. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7658. }
  7659. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7660. func (m *CategoryMutation) DeletedAtCleared() bool {
  7661. _, ok := m.clearedFields[category.FieldDeletedAt]
  7662. return ok
  7663. }
  7664. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7665. func (m *CategoryMutation) ResetDeletedAt() {
  7666. m.deleted_at = nil
  7667. delete(m.clearedFields, category.FieldDeletedAt)
  7668. }
  7669. // SetName sets the "name" field.
  7670. func (m *CategoryMutation) SetName(s string) {
  7671. m.name = &s
  7672. }
  7673. // Name returns the value of the "name" field in the mutation.
  7674. func (m *CategoryMutation) Name() (r string, exists bool) {
  7675. v := m.name
  7676. if v == nil {
  7677. return
  7678. }
  7679. return *v, true
  7680. }
  7681. // OldName returns the old "name" field's value of the Category entity.
  7682. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7684. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7685. if !m.op.Is(OpUpdateOne) {
  7686. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7687. }
  7688. if m.id == nil || m.oldValue == nil {
  7689. return v, errors.New("OldName requires an ID field in the mutation")
  7690. }
  7691. oldValue, err := m.oldValue(ctx)
  7692. if err != nil {
  7693. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7694. }
  7695. return oldValue.Name, nil
  7696. }
  7697. // ResetName resets all changes to the "name" field.
  7698. func (m *CategoryMutation) ResetName() {
  7699. m.name = nil
  7700. }
  7701. // SetOrganizationID sets the "organization_id" field.
  7702. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7703. m.organization_id = &u
  7704. m.addorganization_id = nil
  7705. }
  7706. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7707. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7708. v := m.organization_id
  7709. if v == nil {
  7710. return
  7711. }
  7712. return *v, true
  7713. }
  7714. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7715. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7717. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7718. if !m.op.Is(OpUpdateOne) {
  7719. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7720. }
  7721. if m.id == nil || m.oldValue == nil {
  7722. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7723. }
  7724. oldValue, err := m.oldValue(ctx)
  7725. if err != nil {
  7726. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7727. }
  7728. return oldValue.OrganizationID, nil
  7729. }
  7730. // AddOrganizationID adds u to the "organization_id" field.
  7731. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7732. if m.addorganization_id != nil {
  7733. *m.addorganization_id += u
  7734. } else {
  7735. m.addorganization_id = &u
  7736. }
  7737. }
  7738. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7739. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7740. v := m.addorganization_id
  7741. if v == nil {
  7742. return
  7743. }
  7744. return *v, true
  7745. }
  7746. // ResetOrganizationID resets all changes to the "organization_id" field.
  7747. func (m *CategoryMutation) ResetOrganizationID() {
  7748. m.organization_id = nil
  7749. m.addorganization_id = nil
  7750. }
  7751. // Where appends a list predicates to the CategoryMutation builder.
  7752. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7753. m.predicates = append(m.predicates, ps...)
  7754. }
  7755. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7756. // users can use type-assertion to append predicates that do not depend on any generated package.
  7757. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7758. p := make([]predicate.Category, len(ps))
  7759. for i := range ps {
  7760. p[i] = ps[i]
  7761. }
  7762. m.Where(p...)
  7763. }
  7764. // Op returns the operation name.
  7765. func (m *CategoryMutation) Op() Op {
  7766. return m.op
  7767. }
  7768. // SetOp allows setting the mutation operation.
  7769. func (m *CategoryMutation) SetOp(op Op) {
  7770. m.op = op
  7771. }
  7772. // Type returns the node type of this mutation (Category).
  7773. func (m *CategoryMutation) Type() string {
  7774. return m.typ
  7775. }
  7776. // Fields returns all fields that were changed during this mutation. Note that in
  7777. // order to get all numeric fields that were incremented/decremented, call
  7778. // AddedFields().
  7779. func (m *CategoryMutation) Fields() []string {
  7780. fields := make([]string, 0, 5)
  7781. if m.created_at != nil {
  7782. fields = append(fields, category.FieldCreatedAt)
  7783. }
  7784. if m.updated_at != nil {
  7785. fields = append(fields, category.FieldUpdatedAt)
  7786. }
  7787. if m.deleted_at != nil {
  7788. fields = append(fields, category.FieldDeletedAt)
  7789. }
  7790. if m.name != nil {
  7791. fields = append(fields, category.FieldName)
  7792. }
  7793. if m.organization_id != nil {
  7794. fields = append(fields, category.FieldOrganizationID)
  7795. }
  7796. return fields
  7797. }
  7798. // Field returns the value of a field with the given name. The second boolean
  7799. // return value indicates that this field was not set, or was not defined in the
  7800. // schema.
  7801. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7802. switch name {
  7803. case category.FieldCreatedAt:
  7804. return m.CreatedAt()
  7805. case category.FieldUpdatedAt:
  7806. return m.UpdatedAt()
  7807. case category.FieldDeletedAt:
  7808. return m.DeletedAt()
  7809. case category.FieldName:
  7810. return m.Name()
  7811. case category.FieldOrganizationID:
  7812. return m.OrganizationID()
  7813. }
  7814. return nil, false
  7815. }
  7816. // OldField returns the old value of the field from the database. An error is
  7817. // returned if the mutation operation is not UpdateOne, or the query to the
  7818. // database failed.
  7819. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7820. switch name {
  7821. case category.FieldCreatedAt:
  7822. return m.OldCreatedAt(ctx)
  7823. case category.FieldUpdatedAt:
  7824. return m.OldUpdatedAt(ctx)
  7825. case category.FieldDeletedAt:
  7826. return m.OldDeletedAt(ctx)
  7827. case category.FieldName:
  7828. return m.OldName(ctx)
  7829. case category.FieldOrganizationID:
  7830. return m.OldOrganizationID(ctx)
  7831. }
  7832. return nil, fmt.Errorf("unknown Category field %s", name)
  7833. }
  7834. // SetField sets the value of a field with the given name. It returns an error if
  7835. // the field is not defined in the schema, or if the type mismatched the field
  7836. // type.
  7837. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7838. switch name {
  7839. case category.FieldCreatedAt:
  7840. v, ok := value.(time.Time)
  7841. if !ok {
  7842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7843. }
  7844. m.SetCreatedAt(v)
  7845. return nil
  7846. case category.FieldUpdatedAt:
  7847. v, ok := value.(time.Time)
  7848. if !ok {
  7849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7850. }
  7851. m.SetUpdatedAt(v)
  7852. return nil
  7853. case category.FieldDeletedAt:
  7854. v, ok := value.(time.Time)
  7855. if !ok {
  7856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7857. }
  7858. m.SetDeletedAt(v)
  7859. return nil
  7860. case category.FieldName:
  7861. v, ok := value.(string)
  7862. if !ok {
  7863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7864. }
  7865. m.SetName(v)
  7866. return nil
  7867. case category.FieldOrganizationID:
  7868. v, ok := value.(uint64)
  7869. if !ok {
  7870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7871. }
  7872. m.SetOrganizationID(v)
  7873. return nil
  7874. }
  7875. return fmt.Errorf("unknown Category field %s", name)
  7876. }
  7877. // AddedFields returns all numeric fields that were incremented/decremented during
  7878. // this mutation.
  7879. func (m *CategoryMutation) AddedFields() []string {
  7880. var fields []string
  7881. if m.addorganization_id != nil {
  7882. fields = append(fields, category.FieldOrganizationID)
  7883. }
  7884. return fields
  7885. }
  7886. // AddedField returns the numeric value that was incremented/decremented on a field
  7887. // with the given name. The second boolean return value indicates that this field
  7888. // was not set, or was not defined in the schema.
  7889. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7890. switch name {
  7891. case category.FieldOrganizationID:
  7892. return m.AddedOrganizationID()
  7893. }
  7894. return nil, false
  7895. }
  7896. // AddField adds the value to the field with the given name. It returns an error if
  7897. // the field is not defined in the schema, or if the type mismatched the field
  7898. // type.
  7899. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7900. switch name {
  7901. case category.FieldOrganizationID:
  7902. v, ok := value.(int64)
  7903. if !ok {
  7904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7905. }
  7906. m.AddOrganizationID(v)
  7907. return nil
  7908. }
  7909. return fmt.Errorf("unknown Category numeric field %s", name)
  7910. }
  7911. // ClearedFields returns all nullable fields that were cleared during this
  7912. // mutation.
  7913. func (m *CategoryMutation) ClearedFields() []string {
  7914. var fields []string
  7915. if m.FieldCleared(category.FieldDeletedAt) {
  7916. fields = append(fields, category.FieldDeletedAt)
  7917. }
  7918. return fields
  7919. }
  7920. // FieldCleared returns a boolean indicating if a field with the given name was
  7921. // cleared in this mutation.
  7922. func (m *CategoryMutation) FieldCleared(name string) bool {
  7923. _, ok := m.clearedFields[name]
  7924. return ok
  7925. }
  7926. // ClearField clears the value of the field with the given name. It returns an
  7927. // error if the field is not defined in the schema.
  7928. func (m *CategoryMutation) ClearField(name string) error {
  7929. switch name {
  7930. case category.FieldDeletedAt:
  7931. m.ClearDeletedAt()
  7932. return nil
  7933. }
  7934. return fmt.Errorf("unknown Category nullable field %s", name)
  7935. }
  7936. // ResetField resets all changes in the mutation for the field with the given name.
  7937. // It returns an error if the field is not defined in the schema.
  7938. func (m *CategoryMutation) ResetField(name string) error {
  7939. switch name {
  7940. case category.FieldCreatedAt:
  7941. m.ResetCreatedAt()
  7942. return nil
  7943. case category.FieldUpdatedAt:
  7944. m.ResetUpdatedAt()
  7945. return nil
  7946. case category.FieldDeletedAt:
  7947. m.ResetDeletedAt()
  7948. return nil
  7949. case category.FieldName:
  7950. m.ResetName()
  7951. return nil
  7952. case category.FieldOrganizationID:
  7953. m.ResetOrganizationID()
  7954. return nil
  7955. }
  7956. return fmt.Errorf("unknown Category field %s", name)
  7957. }
  7958. // AddedEdges returns all edge names that were set/added in this mutation.
  7959. func (m *CategoryMutation) AddedEdges() []string {
  7960. edges := make([]string, 0, 0)
  7961. return edges
  7962. }
  7963. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7964. // name in this mutation.
  7965. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7966. return nil
  7967. }
  7968. // RemovedEdges returns all edge names that were removed in this mutation.
  7969. func (m *CategoryMutation) RemovedEdges() []string {
  7970. edges := make([]string, 0, 0)
  7971. return edges
  7972. }
  7973. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7974. // the given name in this mutation.
  7975. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7976. return nil
  7977. }
  7978. // ClearedEdges returns all edge names that were cleared in this mutation.
  7979. func (m *CategoryMutation) ClearedEdges() []string {
  7980. edges := make([]string, 0, 0)
  7981. return edges
  7982. }
  7983. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7984. // was cleared in this mutation.
  7985. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7986. return false
  7987. }
  7988. // ClearEdge clears the value of the edge with the given name. It returns an error
  7989. // if that edge is not defined in the schema.
  7990. func (m *CategoryMutation) ClearEdge(name string) error {
  7991. return fmt.Errorf("unknown Category unique edge %s", name)
  7992. }
  7993. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7994. // It returns an error if the edge is not defined in the schema.
  7995. func (m *CategoryMutation) ResetEdge(name string) error {
  7996. return fmt.Errorf("unknown Category edge %s", name)
  7997. }
  7998. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7999. type ChatRecordsMutation struct {
  8000. config
  8001. op Op
  8002. typ string
  8003. id *uint64
  8004. created_at *time.Time
  8005. updated_at *time.Time
  8006. deleted_at *time.Time
  8007. content *string
  8008. content_type *uint8
  8009. addcontent_type *int8
  8010. session_id *uint64
  8011. addsession_id *int64
  8012. user_id *uint64
  8013. adduser_id *int64
  8014. bot_id *uint64
  8015. addbot_id *int64
  8016. bot_type *uint8
  8017. addbot_type *int8
  8018. clearedFields map[string]struct{}
  8019. done bool
  8020. oldValue func(context.Context) (*ChatRecords, error)
  8021. predicates []predicate.ChatRecords
  8022. }
  8023. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  8024. // chatrecordsOption allows management of the mutation configuration using functional options.
  8025. type chatrecordsOption func(*ChatRecordsMutation)
  8026. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  8027. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  8028. m := &ChatRecordsMutation{
  8029. config: c,
  8030. op: op,
  8031. typ: TypeChatRecords,
  8032. clearedFields: make(map[string]struct{}),
  8033. }
  8034. for _, opt := range opts {
  8035. opt(m)
  8036. }
  8037. return m
  8038. }
  8039. // withChatRecordsID sets the ID field of the mutation.
  8040. func withChatRecordsID(id uint64) chatrecordsOption {
  8041. return func(m *ChatRecordsMutation) {
  8042. var (
  8043. err error
  8044. once sync.Once
  8045. value *ChatRecords
  8046. )
  8047. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  8048. once.Do(func() {
  8049. if m.done {
  8050. err = errors.New("querying old values post mutation is not allowed")
  8051. } else {
  8052. value, err = m.Client().ChatRecords.Get(ctx, id)
  8053. }
  8054. })
  8055. return value, err
  8056. }
  8057. m.id = &id
  8058. }
  8059. }
  8060. // withChatRecords sets the old ChatRecords of the mutation.
  8061. func withChatRecords(node *ChatRecords) chatrecordsOption {
  8062. return func(m *ChatRecordsMutation) {
  8063. m.oldValue = func(context.Context) (*ChatRecords, error) {
  8064. return node, nil
  8065. }
  8066. m.id = &node.ID
  8067. }
  8068. }
  8069. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8070. // executed in a transaction (ent.Tx), a transactional client is returned.
  8071. func (m ChatRecordsMutation) Client() *Client {
  8072. client := &Client{config: m.config}
  8073. client.init()
  8074. return client
  8075. }
  8076. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8077. // it returns an error otherwise.
  8078. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  8079. if _, ok := m.driver.(*txDriver); !ok {
  8080. return nil, errors.New("ent: mutation is not running in a transaction")
  8081. }
  8082. tx := &Tx{config: m.config}
  8083. tx.init()
  8084. return tx, nil
  8085. }
  8086. // SetID sets the value of the id field. Note that this
  8087. // operation is only accepted on creation of ChatRecords entities.
  8088. func (m *ChatRecordsMutation) SetID(id uint64) {
  8089. m.id = &id
  8090. }
  8091. // ID returns the ID value in the mutation. Note that the ID is only available
  8092. // if it was provided to the builder or after it was returned from the database.
  8093. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  8094. if m.id == nil {
  8095. return
  8096. }
  8097. return *m.id, true
  8098. }
  8099. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8100. // That means, if the mutation is applied within a transaction with an isolation level such
  8101. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8102. // or updated by the mutation.
  8103. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  8104. switch {
  8105. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8106. id, exists := m.ID()
  8107. if exists {
  8108. return []uint64{id}, nil
  8109. }
  8110. fallthrough
  8111. case m.op.Is(OpUpdate | OpDelete):
  8112. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  8113. default:
  8114. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8115. }
  8116. }
  8117. // SetCreatedAt sets the "created_at" field.
  8118. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  8119. m.created_at = &t
  8120. }
  8121. // CreatedAt returns the value of the "created_at" field in the mutation.
  8122. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  8123. v := m.created_at
  8124. if v == nil {
  8125. return
  8126. }
  8127. return *v, true
  8128. }
  8129. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  8130. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8132. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8133. if !m.op.Is(OpUpdateOne) {
  8134. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8135. }
  8136. if m.id == nil || m.oldValue == nil {
  8137. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8138. }
  8139. oldValue, err := m.oldValue(ctx)
  8140. if err != nil {
  8141. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8142. }
  8143. return oldValue.CreatedAt, nil
  8144. }
  8145. // ResetCreatedAt resets all changes to the "created_at" field.
  8146. func (m *ChatRecordsMutation) ResetCreatedAt() {
  8147. m.created_at = nil
  8148. }
  8149. // SetUpdatedAt sets the "updated_at" field.
  8150. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  8151. m.updated_at = &t
  8152. }
  8153. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8154. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  8155. v := m.updated_at
  8156. if v == nil {
  8157. return
  8158. }
  8159. return *v, true
  8160. }
  8161. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  8162. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8164. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8165. if !m.op.Is(OpUpdateOne) {
  8166. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8167. }
  8168. if m.id == nil || m.oldValue == nil {
  8169. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8170. }
  8171. oldValue, err := m.oldValue(ctx)
  8172. if err != nil {
  8173. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8174. }
  8175. return oldValue.UpdatedAt, nil
  8176. }
  8177. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8178. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  8179. m.updated_at = nil
  8180. }
  8181. // SetDeletedAt sets the "deleted_at" field.
  8182. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  8183. m.deleted_at = &t
  8184. }
  8185. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8186. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  8187. v := m.deleted_at
  8188. if v == nil {
  8189. return
  8190. }
  8191. return *v, true
  8192. }
  8193. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  8194. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8196. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8197. if !m.op.Is(OpUpdateOne) {
  8198. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8199. }
  8200. if m.id == nil || m.oldValue == nil {
  8201. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8202. }
  8203. oldValue, err := m.oldValue(ctx)
  8204. if err != nil {
  8205. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8206. }
  8207. return oldValue.DeletedAt, nil
  8208. }
  8209. // ClearDeletedAt clears the value of the "deleted_at" field.
  8210. func (m *ChatRecordsMutation) ClearDeletedAt() {
  8211. m.deleted_at = nil
  8212. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  8213. }
  8214. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8215. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  8216. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  8217. return ok
  8218. }
  8219. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8220. func (m *ChatRecordsMutation) ResetDeletedAt() {
  8221. m.deleted_at = nil
  8222. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  8223. }
  8224. // SetContent sets the "content" field.
  8225. func (m *ChatRecordsMutation) SetContent(s string) {
  8226. m.content = &s
  8227. }
  8228. // Content returns the value of the "content" field in the mutation.
  8229. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  8230. v := m.content
  8231. if v == nil {
  8232. return
  8233. }
  8234. return *v, true
  8235. }
  8236. // OldContent returns the old "content" field's value of the ChatRecords entity.
  8237. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8239. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  8240. if !m.op.Is(OpUpdateOne) {
  8241. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8242. }
  8243. if m.id == nil || m.oldValue == nil {
  8244. return v, errors.New("OldContent requires an ID field in the mutation")
  8245. }
  8246. oldValue, err := m.oldValue(ctx)
  8247. if err != nil {
  8248. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8249. }
  8250. return oldValue.Content, nil
  8251. }
  8252. // ResetContent resets all changes to the "content" field.
  8253. func (m *ChatRecordsMutation) ResetContent() {
  8254. m.content = nil
  8255. }
  8256. // SetContentType sets the "content_type" field.
  8257. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  8258. m.content_type = &u
  8259. m.addcontent_type = nil
  8260. }
  8261. // ContentType returns the value of the "content_type" field in the mutation.
  8262. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  8263. v := m.content_type
  8264. if v == nil {
  8265. return
  8266. }
  8267. return *v, true
  8268. }
  8269. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  8270. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8272. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  8273. if !m.op.Is(OpUpdateOne) {
  8274. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8275. }
  8276. if m.id == nil || m.oldValue == nil {
  8277. return v, errors.New("OldContentType requires an ID field in the mutation")
  8278. }
  8279. oldValue, err := m.oldValue(ctx)
  8280. if err != nil {
  8281. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8282. }
  8283. return oldValue.ContentType, nil
  8284. }
  8285. // AddContentType adds u to the "content_type" field.
  8286. func (m *ChatRecordsMutation) AddContentType(u int8) {
  8287. if m.addcontent_type != nil {
  8288. *m.addcontent_type += u
  8289. } else {
  8290. m.addcontent_type = &u
  8291. }
  8292. }
  8293. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8294. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  8295. v := m.addcontent_type
  8296. if v == nil {
  8297. return
  8298. }
  8299. return *v, true
  8300. }
  8301. // ResetContentType resets all changes to the "content_type" field.
  8302. func (m *ChatRecordsMutation) ResetContentType() {
  8303. m.content_type = nil
  8304. m.addcontent_type = nil
  8305. }
  8306. // SetSessionID sets the "session_id" field.
  8307. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  8308. m.session_id = &u
  8309. m.addsession_id = nil
  8310. }
  8311. // SessionID returns the value of the "session_id" field in the mutation.
  8312. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  8313. v := m.session_id
  8314. if v == nil {
  8315. return
  8316. }
  8317. return *v, true
  8318. }
  8319. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  8320. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8322. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  8323. if !m.op.Is(OpUpdateOne) {
  8324. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8325. }
  8326. if m.id == nil || m.oldValue == nil {
  8327. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8328. }
  8329. oldValue, err := m.oldValue(ctx)
  8330. if err != nil {
  8331. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8332. }
  8333. return oldValue.SessionID, nil
  8334. }
  8335. // AddSessionID adds u to the "session_id" field.
  8336. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8337. if m.addsession_id != nil {
  8338. *m.addsession_id += u
  8339. } else {
  8340. m.addsession_id = &u
  8341. }
  8342. }
  8343. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8344. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8345. v := m.addsession_id
  8346. if v == nil {
  8347. return
  8348. }
  8349. return *v, true
  8350. }
  8351. // ResetSessionID resets all changes to the "session_id" field.
  8352. func (m *ChatRecordsMutation) ResetSessionID() {
  8353. m.session_id = nil
  8354. m.addsession_id = nil
  8355. }
  8356. // SetUserID sets the "user_id" field.
  8357. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8358. m.user_id = &u
  8359. m.adduser_id = nil
  8360. }
  8361. // UserID returns the value of the "user_id" field in the mutation.
  8362. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8363. v := m.user_id
  8364. if v == nil {
  8365. return
  8366. }
  8367. return *v, true
  8368. }
  8369. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8370. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8372. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8373. if !m.op.Is(OpUpdateOne) {
  8374. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8375. }
  8376. if m.id == nil || m.oldValue == nil {
  8377. return v, errors.New("OldUserID requires an ID field in the mutation")
  8378. }
  8379. oldValue, err := m.oldValue(ctx)
  8380. if err != nil {
  8381. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8382. }
  8383. return oldValue.UserID, nil
  8384. }
  8385. // AddUserID adds u to the "user_id" field.
  8386. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8387. if m.adduser_id != nil {
  8388. *m.adduser_id += u
  8389. } else {
  8390. m.adduser_id = &u
  8391. }
  8392. }
  8393. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8394. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8395. v := m.adduser_id
  8396. if v == nil {
  8397. return
  8398. }
  8399. return *v, true
  8400. }
  8401. // ResetUserID resets all changes to the "user_id" field.
  8402. func (m *ChatRecordsMutation) ResetUserID() {
  8403. m.user_id = nil
  8404. m.adduser_id = nil
  8405. }
  8406. // SetBotID sets the "bot_id" field.
  8407. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8408. m.bot_id = &u
  8409. m.addbot_id = nil
  8410. }
  8411. // BotID returns the value of the "bot_id" field in the mutation.
  8412. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8413. v := m.bot_id
  8414. if v == nil {
  8415. return
  8416. }
  8417. return *v, true
  8418. }
  8419. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8420. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8422. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8423. if !m.op.Is(OpUpdateOne) {
  8424. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8425. }
  8426. if m.id == nil || m.oldValue == nil {
  8427. return v, errors.New("OldBotID requires an ID field in the mutation")
  8428. }
  8429. oldValue, err := m.oldValue(ctx)
  8430. if err != nil {
  8431. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8432. }
  8433. return oldValue.BotID, nil
  8434. }
  8435. // AddBotID adds u to the "bot_id" field.
  8436. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8437. if m.addbot_id != nil {
  8438. *m.addbot_id += u
  8439. } else {
  8440. m.addbot_id = &u
  8441. }
  8442. }
  8443. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8444. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8445. v := m.addbot_id
  8446. if v == nil {
  8447. return
  8448. }
  8449. return *v, true
  8450. }
  8451. // ResetBotID resets all changes to the "bot_id" field.
  8452. func (m *ChatRecordsMutation) ResetBotID() {
  8453. m.bot_id = nil
  8454. m.addbot_id = nil
  8455. }
  8456. // SetBotType sets the "bot_type" field.
  8457. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8458. m.bot_type = &u
  8459. m.addbot_type = nil
  8460. }
  8461. // BotType returns the value of the "bot_type" field in the mutation.
  8462. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8463. v := m.bot_type
  8464. if v == nil {
  8465. return
  8466. }
  8467. return *v, true
  8468. }
  8469. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8470. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8472. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8473. if !m.op.Is(OpUpdateOne) {
  8474. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8475. }
  8476. if m.id == nil || m.oldValue == nil {
  8477. return v, errors.New("OldBotType requires an ID field in the mutation")
  8478. }
  8479. oldValue, err := m.oldValue(ctx)
  8480. if err != nil {
  8481. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8482. }
  8483. return oldValue.BotType, nil
  8484. }
  8485. // AddBotType adds u to the "bot_type" field.
  8486. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8487. if m.addbot_type != nil {
  8488. *m.addbot_type += u
  8489. } else {
  8490. m.addbot_type = &u
  8491. }
  8492. }
  8493. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8494. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8495. v := m.addbot_type
  8496. if v == nil {
  8497. return
  8498. }
  8499. return *v, true
  8500. }
  8501. // ResetBotType resets all changes to the "bot_type" field.
  8502. func (m *ChatRecordsMutation) ResetBotType() {
  8503. m.bot_type = nil
  8504. m.addbot_type = nil
  8505. }
  8506. // Where appends a list predicates to the ChatRecordsMutation builder.
  8507. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8508. m.predicates = append(m.predicates, ps...)
  8509. }
  8510. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8511. // users can use type-assertion to append predicates that do not depend on any generated package.
  8512. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8513. p := make([]predicate.ChatRecords, len(ps))
  8514. for i := range ps {
  8515. p[i] = ps[i]
  8516. }
  8517. m.Where(p...)
  8518. }
  8519. // Op returns the operation name.
  8520. func (m *ChatRecordsMutation) Op() Op {
  8521. return m.op
  8522. }
  8523. // SetOp allows setting the mutation operation.
  8524. func (m *ChatRecordsMutation) SetOp(op Op) {
  8525. m.op = op
  8526. }
  8527. // Type returns the node type of this mutation (ChatRecords).
  8528. func (m *ChatRecordsMutation) Type() string {
  8529. return m.typ
  8530. }
  8531. // Fields returns all fields that were changed during this mutation. Note that in
  8532. // order to get all numeric fields that were incremented/decremented, call
  8533. // AddedFields().
  8534. func (m *ChatRecordsMutation) Fields() []string {
  8535. fields := make([]string, 0, 9)
  8536. if m.created_at != nil {
  8537. fields = append(fields, chatrecords.FieldCreatedAt)
  8538. }
  8539. if m.updated_at != nil {
  8540. fields = append(fields, chatrecords.FieldUpdatedAt)
  8541. }
  8542. if m.deleted_at != nil {
  8543. fields = append(fields, chatrecords.FieldDeletedAt)
  8544. }
  8545. if m.content != nil {
  8546. fields = append(fields, chatrecords.FieldContent)
  8547. }
  8548. if m.content_type != nil {
  8549. fields = append(fields, chatrecords.FieldContentType)
  8550. }
  8551. if m.session_id != nil {
  8552. fields = append(fields, chatrecords.FieldSessionID)
  8553. }
  8554. if m.user_id != nil {
  8555. fields = append(fields, chatrecords.FieldUserID)
  8556. }
  8557. if m.bot_id != nil {
  8558. fields = append(fields, chatrecords.FieldBotID)
  8559. }
  8560. if m.bot_type != nil {
  8561. fields = append(fields, chatrecords.FieldBotType)
  8562. }
  8563. return fields
  8564. }
  8565. // Field returns the value of a field with the given name. The second boolean
  8566. // return value indicates that this field was not set, or was not defined in the
  8567. // schema.
  8568. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8569. switch name {
  8570. case chatrecords.FieldCreatedAt:
  8571. return m.CreatedAt()
  8572. case chatrecords.FieldUpdatedAt:
  8573. return m.UpdatedAt()
  8574. case chatrecords.FieldDeletedAt:
  8575. return m.DeletedAt()
  8576. case chatrecords.FieldContent:
  8577. return m.Content()
  8578. case chatrecords.FieldContentType:
  8579. return m.ContentType()
  8580. case chatrecords.FieldSessionID:
  8581. return m.SessionID()
  8582. case chatrecords.FieldUserID:
  8583. return m.UserID()
  8584. case chatrecords.FieldBotID:
  8585. return m.BotID()
  8586. case chatrecords.FieldBotType:
  8587. return m.BotType()
  8588. }
  8589. return nil, false
  8590. }
  8591. // OldField returns the old value of the field from the database. An error is
  8592. // returned if the mutation operation is not UpdateOne, or the query to the
  8593. // database failed.
  8594. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8595. switch name {
  8596. case chatrecords.FieldCreatedAt:
  8597. return m.OldCreatedAt(ctx)
  8598. case chatrecords.FieldUpdatedAt:
  8599. return m.OldUpdatedAt(ctx)
  8600. case chatrecords.FieldDeletedAt:
  8601. return m.OldDeletedAt(ctx)
  8602. case chatrecords.FieldContent:
  8603. return m.OldContent(ctx)
  8604. case chatrecords.FieldContentType:
  8605. return m.OldContentType(ctx)
  8606. case chatrecords.FieldSessionID:
  8607. return m.OldSessionID(ctx)
  8608. case chatrecords.FieldUserID:
  8609. return m.OldUserID(ctx)
  8610. case chatrecords.FieldBotID:
  8611. return m.OldBotID(ctx)
  8612. case chatrecords.FieldBotType:
  8613. return m.OldBotType(ctx)
  8614. }
  8615. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8616. }
  8617. // SetField sets the value of a field with the given name. It returns an error if
  8618. // the field is not defined in the schema, or if the type mismatched the field
  8619. // type.
  8620. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8621. switch name {
  8622. case chatrecords.FieldCreatedAt:
  8623. v, ok := value.(time.Time)
  8624. if !ok {
  8625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8626. }
  8627. m.SetCreatedAt(v)
  8628. return nil
  8629. case chatrecords.FieldUpdatedAt:
  8630. v, ok := value.(time.Time)
  8631. if !ok {
  8632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8633. }
  8634. m.SetUpdatedAt(v)
  8635. return nil
  8636. case chatrecords.FieldDeletedAt:
  8637. v, ok := value.(time.Time)
  8638. if !ok {
  8639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8640. }
  8641. m.SetDeletedAt(v)
  8642. return nil
  8643. case chatrecords.FieldContent:
  8644. v, ok := value.(string)
  8645. if !ok {
  8646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8647. }
  8648. m.SetContent(v)
  8649. return nil
  8650. case chatrecords.FieldContentType:
  8651. v, ok := value.(uint8)
  8652. if !ok {
  8653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8654. }
  8655. m.SetContentType(v)
  8656. return nil
  8657. case chatrecords.FieldSessionID:
  8658. v, ok := value.(uint64)
  8659. if !ok {
  8660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8661. }
  8662. m.SetSessionID(v)
  8663. return nil
  8664. case chatrecords.FieldUserID:
  8665. v, ok := value.(uint64)
  8666. if !ok {
  8667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8668. }
  8669. m.SetUserID(v)
  8670. return nil
  8671. case chatrecords.FieldBotID:
  8672. v, ok := value.(uint64)
  8673. if !ok {
  8674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8675. }
  8676. m.SetBotID(v)
  8677. return nil
  8678. case chatrecords.FieldBotType:
  8679. v, ok := value.(uint8)
  8680. if !ok {
  8681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8682. }
  8683. m.SetBotType(v)
  8684. return nil
  8685. }
  8686. return fmt.Errorf("unknown ChatRecords field %s", name)
  8687. }
  8688. // AddedFields returns all numeric fields that were incremented/decremented during
  8689. // this mutation.
  8690. func (m *ChatRecordsMutation) AddedFields() []string {
  8691. var fields []string
  8692. if m.addcontent_type != nil {
  8693. fields = append(fields, chatrecords.FieldContentType)
  8694. }
  8695. if m.addsession_id != nil {
  8696. fields = append(fields, chatrecords.FieldSessionID)
  8697. }
  8698. if m.adduser_id != nil {
  8699. fields = append(fields, chatrecords.FieldUserID)
  8700. }
  8701. if m.addbot_id != nil {
  8702. fields = append(fields, chatrecords.FieldBotID)
  8703. }
  8704. if m.addbot_type != nil {
  8705. fields = append(fields, chatrecords.FieldBotType)
  8706. }
  8707. return fields
  8708. }
  8709. // AddedField returns the numeric value that was incremented/decremented on a field
  8710. // with the given name. The second boolean return value indicates that this field
  8711. // was not set, or was not defined in the schema.
  8712. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8713. switch name {
  8714. case chatrecords.FieldContentType:
  8715. return m.AddedContentType()
  8716. case chatrecords.FieldSessionID:
  8717. return m.AddedSessionID()
  8718. case chatrecords.FieldUserID:
  8719. return m.AddedUserID()
  8720. case chatrecords.FieldBotID:
  8721. return m.AddedBotID()
  8722. case chatrecords.FieldBotType:
  8723. return m.AddedBotType()
  8724. }
  8725. return nil, false
  8726. }
  8727. // AddField adds the value to the field with the given name. It returns an error if
  8728. // the field is not defined in the schema, or if the type mismatched the field
  8729. // type.
  8730. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8731. switch name {
  8732. case chatrecords.FieldContentType:
  8733. v, ok := value.(int8)
  8734. if !ok {
  8735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8736. }
  8737. m.AddContentType(v)
  8738. return nil
  8739. case chatrecords.FieldSessionID:
  8740. v, ok := value.(int64)
  8741. if !ok {
  8742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8743. }
  8744. m.AddSessionID(v)
  8745. return nil
  8746. case chatrecords.FieldUserID:
  8747. v, ok := value.(int64)
  8748. if !ok {
  8749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8750. }
  8751. m.AddUserID(v)
  8752. return nil
  8753. case chatrecords.FieldBotID:
  8754. v, ok := value.(int64)
  8755. if !ok {
  8756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8757. }
  8758. m.AddBotID(v)
  8759. return nil
  8760. case chatrecords.FieldBotType:
  8761. v, ok := value.(int8)
  8762. if !ok {
  8763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8764. }
  8765. m.AddBotType(v)
  8766. return nil
  8767. }
  8768. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8769. }
  8770. // ClearedFields returns all nullable fields that were cleared during this
  8771. // mutation.
  8772. func (m *ChatRecordsMutation) ClearedFields() []string {
  8773. var fields []string
  8774. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8775. fields = append(fields, chatrecords.FieldDeletedAt)
  8776. }
  8777. return fields
  8778. }
  8779. // FieldCleared returns a boolean indicating if a field with the given name was
  8780. // cleared in this mutation.
  8781. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8782. _, ok := m.clearedFields[name]
  8783. return ok
  8784. }
  8785. // ClearField clears the value of the field with the given name. It returns an
  8786. // error if the field is not defined in the schema.
  8787. func (m *ChatRecordsMutation) ClearField(name string) error {
  8788. switch name {
  8789. case chatrecords.FieldDeletedAt:
  8790. m.ClearDeletedAt()
  8791. return nil
  8792. }
  8793. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8794. }
  8795. // ResetField resets all changes in the mutation for the field with the given name.
  8796. // It returns an error if the field is not defined in the schema.
  8797. func (m *ChatRecordsMutation) ResetField(name string) error {
  8798. switch name {
  8799. case chatrecords.FieldCreatedAt:
  8800. m.ResetCreatedAt()
  8801. return nil
  8802. case chatrecords.FieldUpdatedAt:
  8803. m.ResetUpdatedAt()
  8804. return nil
  8805. case chatrecords.FieldDeletedAt:
  8806. m.ResetDeletedAt()
  8807. return nil
  8808. case chatrecords.FieldContent:
  8809. m.ResetContent()
  8810. return nil
  8811. case chatrecords.FieldContentType:
  8812. m.ResetContentType()
  8813. return nil
  8814. case chatrecords.FieldSessionID:
  8815. m.ResetSessionID()
  8816. return nil
  8817. case chatrecords.FieldUserID:
  8818. m.ResetUserID()
  8819. return nil
  8820. case chatrecords.FieldBotID:
  8821. m.ResetBotID()
  8822. return nil
  8823. case chatrecords.FieldBotType:
  8824. m.ResetBotType()
  8825. return nil
  8826. }
  8827. return fmt.Errorf("unknown ChatRecords field %s", name)
  8828. }
  8829. // AddedEdges returns all edge names that were set/added in this mutation.
  8830. func (m *ChatRecordsMutation) AddedEdges() []string {
  8831. edges := make([]string, 0, 0)
  8832. return edges
  8833. }
  8834. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8835. // name in this mutation.
  8836. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8837. return nil
  8838. }
  8839. // RemovedEdges returns all edge names that were removed in this mutation.
  8840. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8841. edges := make([]string, 0, 0)
  8842. return edges
  8843. }
  8844. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8845. // the given name in this mutation.
  8846. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8847. return nil
  8848. }
  8849. // ClearedEdges returns all edge names that were cleared in this mutation.
  8850. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8851. edges := make([]string, 0, 0)
  8852. return edges
  8853. }
  8854. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8855. // was cleared in this mutation.
  8856. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8857. return false
  8858. }
  8859. // ClearEdge clears the value of the edge with the given name. It returns an error
  8860. // if that edge is not defined in the schema.
  8861. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8862. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8863. }
  8864. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8865. // It returns an error if the edge is not defined in the schema.
  8866. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8867. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8868. }
  8869. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8870. type ChatSessionMutation struct {
  8871. config
  8872. op Op
  8873. typ string
  8874. id *uint64
  8875. created_at *time.Time
  8876. updated_at *time.Time
  8877. deleted_at *time.Time
  8878. name *string
  8879. user_id *uint64
  8880. adduser_id *int64
  8881. bot_id *uint64
  8882. addbot_id *int64
  8883. bot_type *uint8
  8884. addbot_type *int8
  8885. clearedFields map[string]struct{}
  8886. done bool
  8887. oldValue func(context.Context) (*ChatSession, error)
  8888. predicates []predicate.ChatSession
  8889. }
  8890. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8891. // chatsessionOption allows management of the mutation configuration using functional options.
  8892. type chatsessionOption func(*ChatSessionMutation)
  8893. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8894. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8895. m := &ChatSessionMutation{
  8896. config: c,
  8897. op: op,
  8898. typ: TypeChatSession,
  8899. clearedFields: make(map[string]struct{}),
  8900. }
  8901. for _, opt := range opts {
  8902. opt(m)
  8903. }
  8904. return m
  8905. }
  8906. // withChatSessionID sets the ID field of the mutation.
  8907. func withChatSessionID(id uint64) chatsessionOption {
  8908. return func(m *ChatSessionMutation) {
  8909. var (
  8910. err error
  8911. once sync.Once
  8912. value *ChatSession
  8913. )
  8914. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8915. once.Do(func() {
  8916. if m.done {
  8917. err = errors.New("querying old values post mutation is not allowed")
  8918. } else {
  8919. value, err = m.Client().ChatSession.Get(ctx, id)
  8920. }
  8921. })
  8922. return value, err
  8923. }
  8924. m.id = &id
  8925. }
  8926. }
  8927. // withChatSession sets the old ChatSession of the mutation.
  8928. func withChatSession(node *ChatSession) chatsessionOption {
  8929. return func(m *ChatSessionMutation) {
  8930. m.oldValue = func(context.Context) (*ChatSession, error) {
  8931. return node, nil
  8932. }
  8933. m.id = &node.ID
  8934. }
  8935. }
  8936. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8937. // executed in a transaction (ent.Tx), a transactional client is returned.
  8938. func (m ChatSessionMutation) Client() *Client {
  8939. client := &Client{config: m.config}
  8940. client.init()
  8941. return client
  8942. }
  8943. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8944. // it returns an error otherwise.
  8945. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8946. if _, ok := m.driver.(*txDriver); !ok {
  8947. return nil, errors.New("ent: mutation is not running in a transaction")
  8948. }
  8949. tx := &Tx{config: m.config}
  8950. tx.init()
  8951. return tx, nil
  8952. }
  8953. // SetID sets the value of the id field. Note that this
  8954. // operation is only accepted on creation of ChatSession entities.
  8955. func (m *ChatSessionMutation) SetID(id uint64) {
  8956. m.id = &id
  8957. }
  8958. // ID returns the ID value in the mutation. Note that the ID is only available
  8959. // if it was provided to the builder or after it was returned from the database.
  8960. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8961. if m.id == nil {
  8962. return
  8963. }
  8964. return *m.id, true
  8965. }
  8966. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8967. // That means, if the mutation is applied within a transaction with an isolation level such
  8968. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8969. // or updated by the mutation.
  8970. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8971. switch {
  8972. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8973. id, exists := m.ID()
  8974. if exists {
  8975. return []uint64{id}, nil
  8976. }
  8977. fallthrough
  8978. case m.op.Is(OpUpdate | OpDelete):
  8979. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8980. default:
  8981. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8982. }
  8983. }
  8984. // SetCreatedAt sets the "created_at" field.
  8985. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8986. m.created_at = &t
  8987. }
  8988. // CreatedAt returns the value of the "created_at" field in the mutation.
  8989. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8990. v := m.created_at
  8991. if v == nil {
  8992. return
  8993. }
  8994. return *v, true
  8995. }
  8996. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8997. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8999. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9000. if !m.op.Is(OpUpdateOne) {
  9001. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9002. }
  9003. if m.id == nil || m.oldValue == nil {
  9004. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9005. }
  9006. oldValue, err := m.oldValue(ctx)
  9007. if err != nil {
  9008. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9009. }
  9010. return oldValue.CreatedAt, nil
  9011. }
  9012. // ResetCreatedAt resets all changes to the "created_at" field.
  9013. func (m *ChatSessionMutation) ResetCreatedAt() {
  9014. m.created_at = nil
  9015. }
  9016. // SetUpdatedAt sets the "updated_at" field.
  9017. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  9018. m.updated_at = &t
  9019. }
  9020. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9021. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  9022. v := m.updated_at
  9023. if v == nil {
  9024. return
  9025. }
  9026. return *v, true
  9027. }
  9028. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  9029. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9031. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9032. if !m.op.Is(OpUpdateOne) {
  9033. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9034. }
  9035. if m.id == nil || m.oldValue == nil {
  9036. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9037. }
  9038. oldValue, err := m.oldValue(ctx)
  9039. if err != nil {
  9040. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9041. }
  9042. return oldValue.UpdatedAt, nil
  9043. }
  9044. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9045. func (m *ChatSessionMutation) ResetUpdatedAt() {
  9046. m.updated_at = nil
  9047. }
  9048. // SetDeletedAt sets the "deleted_at" field.
  9049. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  9050. m.deleted_at = &t
  9051. }
  9052. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9053. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  9054. v := m.deleted_at
  9055. if v == nil {
  9056. return
  9057. }
  9058. return *v, true
  9059. }
  9060. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  9061. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9063. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9064. if !m.op.Is(OpUpdateOne) {
  9065. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9066. }
  9067. if m.id == nil || m.oldValue == nil {
  9068. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9069. }
  9070. oldValue, err := m.oldValue(ctx)
  9071. if err != nil {
  9072. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9073. }
  9074. return oldValue.DeletedAt, nil
  9075. }
  9076. // ClearDeletedAt clears the value of the "deleted_at" field.
  9077. func (m *ChatSessionMutation) ClearDeletedAt() {
  9078. m.deleted_at = nil
  9079. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  9080. }
  9081. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9082. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  9083. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  9084. return ok
  9085. }
  9086. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9087. func (m *ChatSessionMutation) ResetDeletedAt() {
  9088. m.deleted_at = nil
  9089. delete(m.clearedFields, chatsession.FieldDeletedAt)
  9090. }
  9091. // SetName sets the "name" field.
  9092. func (m *ChatSessionMutation) SetName(s string) {
  9093. m.name = &s
  9094. }
  9095. // Name returns the value of the "name" field in the mutation.
  9096. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  9097. v := m.name
  9098. if v == nil {
  9099. return
  9100. }
  9101. return *v, true
  9102. }
  9103. // OldName returns the old "name" field's value of the ChatSession entity.
  9104. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9106. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  9107. if !m.op.Is(OpUpdateOne) {
  9108. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9109. }
  9110. if m.id == nil || m.oldValue == nil {
  9111. return v, errors.New("OldName requires an ID field in the mutation")
  9112. }
  9113. oldValue, err := m.oldValue(ctx)
  9114. if err != nil {
  9115. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9116. }
  9117. return oldValue.Name, nil
  9118. }
  9119. // ResetName resets all changes to the "name" field.
  9120. func (m *ChatSessionMutation) ResetName() {
  9121. m.name = nil
  9122. }
  9123. // SetUserID sets the "user_id" field.
  9124. func (m *ChatSessionMutation) SetUserID(u uint64) {
  9125. m.user_id = &u
  9126. m.adduser_id = nil
  9127. }
  9128. // UserID returns the value of the "user_id" field in the mutation.
  9129. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  9130. v := m.user_id
  9131. if v == nil {
  9132. return
  9133. }
  9134. return *v, true
  9135. }
  9136. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  9137. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9139. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  9140. if !m.op.Is(OpUpdateOne) {
  9141. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9142. }
  9143. if m.id == nil || m.oldValue == nil {
  9144. return v, errors.New("OldUserID requires an ID field in the mutation")
  9145. }
  9146. oldValue, err := m.oldValue(ctx)
  9147. if err != nil {
  9148. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9149. }
  9150. return oldValue.UserID, nil
  9151. }
  9152. // AddUserID adds u to the "user_id" field.
  9153. func (m *ChatSessionMutation) AddUserID(u int64) {
  9154. if m.adduser_id != nil {
  9155. *m.adduser_id += u
  9156. } else {
  9157. m.adduser_id = &u
  9158. }
  9159. }
  9160. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  9161. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  9162. v := m.adduser_id
  9163. if v == nil {
  9164. return
  9165. }
  9166. return *v, true
  9167. }
  9168. // ResetUserID resets all changes to the "user_id" field.
  9169. func (m *ChatSessionMutation) ResetUserID() {
  9170. m.user_id = nil
  9171. m.adduser_id = nil
  9172. }
  9173. // SetBotID sets the "bot_id" field.
  9174. func (m *ChatSessionMutation) SetBotID(u uint64) {
  9175. m.bot_id = &u
  9176. m.addbot_id = nil
  9177. }
  9178. // BotID returns the value of the "bot_id" field in the mutation.
  9179. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  9180. v := m.bot_id
  9181. if v == nil {
  9182. return
  9183. }
  9184. return *v, true
  9185. }
  9186. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  9187. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9189. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  9190. if !m.op.Is(OpUpdateOne) {
  9191. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  9192. }
  9193. if m.id == nil || m.oldValue == nil {
  9194. return v, errors.New("OldBotID requires an ID field in the mutation")
  9195. }
  9196. oldValue, err := m.oldValue(ctx)
  9197. if err != nil {
  9198. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  9199. }
  9200. return oldValue.BotID, nil
  9201. }
  9202. // AddBotID adds u to the "bot_id" field.
  9203. func (m *ChatSessionMutation) AddBotID(u int64) {
  9204. if m.addbot_id != nil {
  9205. *m.addbot_id += u
  9206. } else {
  9207. m.addbot_id = &u
  9208. }
  9209. }
  9210. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  9211. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  9212. v := m.addbot_id
  9213. if v == nil {
  9214. return
  9215. }
  9216. return *v, true
  9217. }
  9218. // ResetBotID resets all changes to the "bot_id" field.
  9219. func (m *ChatSessionMutation) ResetBotID() {
  9220. m.bot_id = nil
  9221. m.addbot_id = nil
  9222. }
  9223. // SetBotType sets the "bot_type" field.
  9224. func (m *ChatSessionMutation) SetBotType(u uint8) {
  9225. m.bot_type = &u
  9226. m.addbot_type = nil
  9227. }
  9228. // BotType returns the value of the "bot_type" field in the mutation.
  9229. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  9230. v := m.bot_type
  9231. if v == nil {
  9232. return
  9233. }
  9234. return *v, true
  9235. }
  9236. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  9237. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9239. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  9240. if !m.op.Is(OpUpdateOne) {
  9241. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  9242. }
  9243. if m.id == nil || m.oldValue == nil {
  9244. return v, errors.New("OldBotType requires an ID field in the mutation")
  9245. }
  9246. oldValue, err := m.oldValue(ctx)
  9247. if err != nil {
  9248. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9249. }
  9250. return oldValue.BotType, nil
  9251. }
  9252. // AddBotType adds u to the "bot_type" field.
  9253. func (m *ChatSessionMutation) AddBotType(u int8) {
  9254. if m.addbot_type != nil {
  9255. *m.addbot_type += u
  9256. } else {
  9257. m.addbot_type = &u
  9258. }
  9259. }
  9260. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9261. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  9262. v := m.addbot_type
  9263. if v == nil {
  9264. return
  9265. }
  9266. return *v, true
  9267. }
  9268. // ResetBotType resets all changes to the "bot_type" field.
  9269. func (m *ChatSessionMutation) ResetBotType() {
  9270. m.bot_type = nil
  9271. m.addbot_type = nil
  9272. }
  9273. // Where appends a list predicates to the ChatSessionMutation builder.
  9274. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  9275. m.predicates = append(m.predicates, ps...)
  9276. }
  9277. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  9278. // users can use type-assertion to append predicates that do not depend on any generated package.
  9279. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  9280. p := make([]predicate.ChatSession, len(ps))
  9281. for i := range ps {
  9282. p[i] = ps[i]
  9283. }
  9284. m.Where(p...)
  9285. }
  9286. // Op returns the operation name.
  9287. func (m *ChatSessionMutation) Op() Op {
  9288. return m.op
  9289. }
  9290. // SetOp allows setting the mutation operation.
  9291. func (m *ChatSessionMutation) SetOp(op Op) {
  9292. m.op = op
  9293. }
  9294. // Type returns the node type of this mutation (ChatSession).
  9295. func (m *ChatSessionMutation) Type() string {
  9296. return m.typ
  9297. }
  9298. // Fields returns all fields that were changed during this mutation. Note that in
  9299. // order to get all numeric fields that were incremented/decremented, call
  9300. // AddedFields().
  9301. func (m *ChatSessionMutation) Fields() []string {
  9302. fields := make([]string, 0, 7)
  9303. if m.created_at != nil {
  9304. fields = append(fields, chatsession.FieldCreatedAt)
  9305. }
  9306. if m.updated_at != nil {
  9307. fields = append(fields, chatsession.FieldUpdatedAt)
  9308. }
  9309. if m.deleted_at != nil {
  9310. fields = append(fields, chatsession.FieldDeletedAt)
  9311. }
  9312. if m.name != nil {
  9313. fields = append(fields, chatsession.FieldName)
  9314. }
  9315. if m.user_id != nil {
  9316. fields = append(fields, chatsession.FieldUserID)
  9317. }
  9318. if m.bot_id != nil {
  9319. fields = append(fields, chatsession.FieldBotID)
  9320. }
  9321. if m.bot_type != nil {
  9322. fields = append(fields, chatsession.FieldBotType)
  9323. }
  9324. return fields
  9325. }
  9326. // Field returns the value of a field with the given name. The second boolean
  9327. // return value indicates that this field was not set, or was not defined in the
  9328. // schema.
  9329. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9330. switch name {
  9331. case chatsession.FieldCreatedAt:
  9332. return m.CreatedAt()
  9333. case chatsession.FieldUpdatedAt:
  9334. return m.UpdatedAt()
  9335. case chatsession.FieldDeletedAt:
  9336. return m.DeletedAt()
  9337. case chatsession.FieldName:
  9338. return m.Name()
  9339. case chatsession.FieldUserID:
  9340. return m.UserID()
  9341. case chatsession.FieldBotID:
  9342. return m.BotID()
  9343. case chatsession.FieldBotType:
  9344. return m.BotType()
  9345. }
  9346. return nil, false
  9347. }
  9348. // OldField returns the old value of the field from the database. An error is
  9349. // returned if the mutation operation is not UpdateOne, or the query to the
  9350. // database failed.
  9351. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9352. switch name {
  9353. case chatsession.FieldCreatedAt:
  9354. return m.OldCreatedAt(ctx)
  9355. case chatsession.FieldUpdatedAt:
  9356. return m.OldUpdatedAt(ctx)
  9357. case chatsession.FieldDeletedAt:
  9358. return m.OldDeletedAt(ctx)
  9359. case chatsession.FieldName:
  9360. return m.OldName(ctx)
  9361. case chatsession.FieldUserID:
  9362. return m.OldUserID(ctx)
  9363. case chatsession.FieldBotID:
  9364. return m.OldBotID(ctx)
  9365. case chatsession.FieldBotType:
  9366. return m.OldBotType(ctx)
  9367. }
  9368. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9369. }
  9370. // SetField sets the value of a field with the given name. It returns an error if
  9371. // the field is not defined in the schema, or if the type mismatched the field
  9372. // type.
  9373. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9374. switch name {
  9375. case chatsession.FieldCreatedAt:
  9376. v, ok := value.(time.Time)
  9377. if !ok {
  9378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9379. }
  9380. m.SetCreatedAt(v)
  9381. return nil
  9382. case chatsession.FieldUpdatedAt:
  9383. v, ok := value.(time.Time)
  9384. if !ok {
  9385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9386. }
  9387. m.SetUpdatedAt(v)
  9388. return nil
  9389. case chatsession.FieldDeletedAt:
  9390. v, ok := value.(time.Time)
  9391. if !ok {
  9392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9393. }
  9394. m.SetDeletedAt(v)
  9395. return nil
  9396. case chatsession.FieldName:
  9397. v, ok := value.(string)
  9398. if !ok {
  9399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9400. }
  9401. m.SetName(v)
  9402. return nil
  9403. case chatsession.FieldUserID:
  9404. v, ok := value.(uint64)
  9405. if !ok {
  9406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9407. }
  9408. m.SetUserID(v)
  9409. return nil
  9410. case chatsession.FieldBotID:
  9411. v, ok := value.(uint64)
  9412. if !ok {
  9413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9414. }
  9415. m.SetBotID(v)
  9416. return nil
  9417. case chatsession.FieldBotType:
  9418. v, ok := value.(uint8)
  9419. if !ok {
  9420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9421. }
  9422. m.SetBotType(v)
  9423. return nil
  9424. }
  9425. return fmt.Errorf("unknown ChatSession field %s", name)
  9426. }
  9427. // AddedFields returns all numeric fields that were incremented/decremented during
  9428. // this mutation.
  9429. func (m *ChatSessionMutation) AddedFields() []string {
  9430. var fields []string
  9431. if m.adduser_id != nil {
  9432. fields = append(fields, chatsession.FieldUserID)
  9433. }
  9434. if m.addbot_id != nil {
  9435. fields = append(fields, chatsession.FieldBotID)
  9436. }
  9437. if m.addbot_type != nil {
  9438. fields = append(fields, chatsession.FieldBotType)
  9439. }
  9440. return fields
  9441. }
  9442. // AddedField returns the numeric value that was incremented/decremented on a field
  9443. // with the given name. The second boolean return value indicates that this field
  9444. // was not set, or was not defined in the schema.
  9445. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9446. switch name {
  9447. case chatsession.FieldUserID:
  9448. return m.AddedUserID()
  9449. case chatsession.FieldBotID:
  9450. return m.AddedBotID()
  9451. case chatsession.FieldBotType:
  9452. return m.AddedBotType()
  9453. }
  9454. return nil, false
  9455. }
  9456. // AddField adds the value to the field with the given name. It returns an error if
  9457. // the field is not defined in the schema, or if the type mismatched the field
  9458. // type.
  9459. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9460. switch name {
  9461. case chatsession.FieldUserID:
  9462. v, ok := value.(int64)
  9463. if !ok {
  9464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9465. }
  9466. m.AddUserID(v)
  9467. return nil
  9468. case chatsession.FieldBotID:
  9469. v, ok := value.(int64)
  9470. if !ok {
  9471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9472. }
  9473. m.AddBotID(v)
  9474. return nil
  9475. case chatsession.FieldBotType:
  9476. v, ok := value.(int8)
  9477. if !ok {
  9478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9479. }
  9480. m.AddBotType(v)
  9481. return nil
  9482. }
  9483. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9484. }
  9485. // ClearedFields returns all nullable fields that were cleared during this
  9486. // mutation.
  9487. func (m *ChatSessionMutation) ClearedFields() []string {
  9488. var fields []string
  9489. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9490. fields = append(fields, chatsession.FieldDeletedAt)
  9491. }
  9492. return fields
  9493. }
  9494. // FieldCleared returns a boolean indicating if a field with the given name was
  9495. // cleared in this mutation.
  9496. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9497. _, ok := m.clearedFields[name]
  9498. return ok
  9499. }
  9500. // ClearField clears the value of the field with the given name. It returns an
  9501. // error if the field is not defined in the schema.
  9502. func (m *ChatSessionMutation) ClearField(name string) error {
  9503. switch name {
  9504. case chatsession.FieldDeletedAt:
  9505. m.ClearDeletedAt()
  9506. return nil
  9507. }
  9508. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9509. }
  9510. // ResetField resets all changes in the mutation for the field with the given name.
  9511. // It returns an error if the field is not defined in the schema.
  9512. func (m *ChatSessionMutation) ResetField(name string) error {
  9513. switch name {
  9514. case chatsession.FieldCreatedAt:
  9515. m.ResetCreatedAt()
  9516. return nil
  9517. case chatsession.FieldUpdatedAt:
  9518. m.ResetUpdatedAt()
  9519. return nil
  9520. case chatsession.FieldDeletedAt:
  9521. m.ResetDeletedAt()
  9522. return nil
  9523. case chatsession.FieldName:
  9524. m.ResetName()
  9525. return nil
  9526. case chatsession.FieldUserID:
  9527. m.ResetUserID()
  9528. return nil
  9529. case chatsession.FieldBotID:
  9530. m.ResetBotID()
  9531. return nil
  9532. case chatsession.FieldBotType:
  9533. m.ResetBotType()
  9534. return nil
  9535. }
  9536. return fmt.Errorf("unknown ChatSession field %s", name)
  9537. }
  9538. // AddedEdges returns all edge names that were set/added in this mutation.
  9539. func (m *ChatSessionMutation) AddedEdges() []string {
  9540. edges := make([]string, 0, 0)
  9541. return edges
  9542. }
  9543. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9544. // name in this mutation.
  9545. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9546. return nil
  9547. }
  9548. // RemovedEdges returns all edge names that were removed in this mutation.
  9549. func (m *ChatSessionMutation) RemovedEdges() []string {
  9550. edges := make([]string, 0, 0)
  9551. return edges
  9552. }
  9553. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9554. // the given name in this mutation.
  9555. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9556. return nil
  9557. }
  9558. // ClearedEdges returns all edge names that were cleared in this mutation.
  9559. func (m *ChatSessionMutation) ClearedEdges() []string {
  9560. edges := make([]string, 0, 0)
  9561. return edges
  9562. }
  9563. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9564. // was cleared in this mutation.
  9565. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9566. return false
  9567. }
  9568. // ClearEdge clears the value of the edge with the given name. It returns an error
  9569. // if that edge is not defined in the schema.
  9570. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9571. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9572. }
  9573. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9574. // It returns an error if the edge is not defined in the schema.
  9575. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9576. return fmt.Errorf("unknown ChatSession edge %s", name)
  9577. }
  9578. // CompapiAsynctaskMutation represents an operation that mutates the CompapiAsynctask nodes in the graph.
  9579. type CompapiAsynctaskMutation struct {
  9580. config
  9581. op Op
  9582. typ string
  9583. id *uint64
  9584. created_at *time.Time
  9585. updated_at *time.Time
  9586. auth_token *string
  9587. event_type *string
  9588. chat_id *string
  9589. response_chat_item_id *string
  9590. organization_id *uint64
  9591. addorganization_id *int64
  9592. openai_base *string
  9593. openai_key *string
  9594. request_raw *string
  9595. response_raw *string
  9596. callback_url *string
  9597. callback_response_raw *string
  9598. model *string
  9599. task_status *int8
  9600. addtask_status *int8
  9601. retry_count *int8
  9602. addretry_count *int8
  9603. last_error *string
  9604. clearedFields map[string]struct{}
  9605. done bool
  9606. oldValue func(context.Context) (*CompapiAsynctask, error)
  9607. predicates []predicate.CompapiAsynctask
  9608. }
  9609. var _ ent.Mutation = (*CompapiAsynctaskMutation)(nil)
  9610. // compapiasynctaskOption allows management of the mutation configuration using functional options.
  9611. type compapiasynctaskOption func(*CompapiAsynctaskMutation)
  9612. // newCompapiAsynctaskMutation creates new mutation for the CompapiAsynctask entity.
  9613. func newCompapiAsynctaskMutation(c config, op Op, opts ...compapiasynctaskOption) *CompapiAsynctaskMutation {
  9614. m := &CompapiAsynctaskMutation{
  9615. config: c,
  9616. op: op,
  9617. typ: TypeCompapiAsynctask,
  9618. clearedFields: make(map[string]struct{}),
  9619. }
  9620. for _, opt := range opts {
  9621. opt(m)
  9622. }
  9623. return m
  9624. }
  9625. // withCompapiAsynctaskID sets the ID field of the mutation.
  9626. func withCompapiAsynctaskID(id uint64) compapiasynctaskOption {
  9627. return func(m *CompapiAsynctaskMutation) {
  9628. var (
  9629. err error
  9630. once sync.Once
  9631. value *CompapiAsynctask
  9632. )
  9633. m.oldValue = func(ctx context.Context) (*CompapiAsynctask, error) {
  9634. once.Do(func() {
  9635. if m.done {
  9636. err = errors.New("querying old values post mutation is not allowed")
  9637. } else {
  9638. value, err = m.Client().CompapiAsynctask.Get(ctx, id)
  9639. }
  9640. })
  9641. return value, err
  9642. }
  9643. m.id = &id
  9644. }
  9645. }
  9646. // withCompapiAsynctask sets the old CompapiAsynctask of the mutation.
  9647. func withCompapiAsynctask(node *CompapiAsynctask) compapiasynctaskOption {
  9648. return func(m *CompapiAsynctaskMutation) {
  9649. m.oldValue = func(context.Context) (*CompapiAsynctask, error) {
  9650. return node, nil
  9651. }
  9652. m.id = &node.ID
  9653. }
  9654. }
  9655. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9656. // executed in a transaction (ent.Tx), a transactional client is returned.
  9657. func (m CompapiAsynctaskMutation) Client() *Client {
  9658. client := &Client{config: m.config}
  9659. client.init()
  9660. return client
  9661. }
  9662. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9663. // it returns an error otherwise.
  9664. func (m CompapiAsynctaskMutation) Tx() (*Tx, error) {
  9665. if _, ok := m.driver.(*txDriver); !ok {
  9666. return nil, errors.New("ent: mutation is not running in a transaction")
  9667. }
  9668. tx := &Tx{config: m.config}
  9669. tx.init()
  9670. return tx, nil
  9671. }
  9672. // SetID sets the value of the id field. Note that this
  9673. // operation is only accepted on creation of CompapiAsynctask entities.
  9674. func (m *CompapiAsynctaskMutation) SetID(id uint64) {
  9675. m.id = &id
  9676. }
  9677. // ID returns the ID value in the mutation. Note that the ID is only available
  9678. // if it was provided to the builder or after it was returned from the database.
  9679. func (m *CompapiAsynctaskMutation) ID() (id uint64, exists bool) {
  9680. if m.id == nil {
  9681. return
  9682. }
  9683. return *m.id, true
  9684. }
  9685. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9686. // That means, if the mutation is applied within a transaction with an isolation level such
  9687. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9688. // or updated by the mutation.
  9689. func (m *CompapiAsynctaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  9690. switch {
  9691. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9692. id, exists := m.ID()
  9693. if exists {
  9694. return []uint64{id}, nil
  9695. }
  9696. fallthrough
  9697. case m.op.Is(OpUpdate | OpDelete):
  9698. return m.Client().CompapiAsynctask.Query().Where(m.predicates...).IDs(ctx)
  9699. default:
  9700. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9701. }
  9702. }
  9703. // SetCreatedAt sets the "created_at" field.
  9704. func (m *CompapiAsynctaskMutation) SetCreatedAt(t time.Time) {
  9705. m.created_at = &t
  9706. }
  9707. // CreatedAt returns the value of the "created_at" field in the mutation.
  9708. func (m *CompapiAsynctaskMutation) CreatedAt() (r time.Time, exists bool) {
  9709. v := m.created_at
  9710. if v == nil {
  9711. return
  9712. }
  9713. return *v, true
  9714. }
  9715. // OldCreatedAt returns the old "created_at" field's value of the CompapiAsynctask entity.
  9716. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9718. func (m *CompapiAsynctaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9719. if !m.op.Is(OpUpdateOne) {
  9720. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9721. }
  9722. if m.id == nil || m.oldValue == nil {
  9723. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9724. }
  9725. oldValue, err := m.oldValue(ctx)
  9726. if err != nil {
  9727. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9728. }
  9729. return oldValue.CreatedAt, nil
  9730. }
  9731. // ResetCreatedAt resets all changes to the "created_at" field.
  9732. func (m *CompapiAsynctaskMutation) ResetCreatedAt() {
  9733. m.created_at = nil
  9734. }
  9735. // SetUpdatedAt sets the "updated_at" field.
  9736. func (m *CompapiAsynctaskMutation) SetUpdatedAt(t time.Time) {
  9737. m.updated_at = &t
  9738. }
  9739. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9740. func (m *CompapiAsynctaskMutation) UpdatedAt() (r time.Time, exists bool) {
  9741. v := m.updated_at
  9742. if v == nil {
  9743. return
  9744. }
  9745. return *v, true
  9746. }
  9747. // OldUpdatedAt returns the old "updated_at" field's value of the CompapiAsynctask entity.
  9748. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9750. func (m *CompapiAsynctaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9751. if !m.op.Is(OpUpdateOne) {
  9752. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9753. }
  9754. if m.id == nil || m.oldValue == nil {
  9755. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9756. }
  9757. oldValue, err := m.oldValue(ctx)
  9758. if err != nil {
  9759. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9760. }
  9761. return oldValue.UpdatedAt, nil
  9762. }
  9763. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9764. func (m *CompapiAsynctaskMutation) ResetUpdatedAt() {
  9765. m.updated_at = nil
  9766. }
  9767. // SetAuthToken sets the "auth_token" field.
  9768. func (m *CompapiAsynctaskMutation) SetAuthToken(s string) {
  9769. m.auth_token = &s
  9770. }
  9771. // AuthToken returns the value of the "auth_token" field in the mutation.
  9772. func (m *CompapiAsynctaskMutation) AuthToken() (r string, exists bool) {
  9773. v := m.auth_token
  9774. if v == nil {
  9775. return
  9776. }
  9777. return *v, true
  9778. }
  9779. // OldAuthToken returns the old "auth_token" field's value of the CompapiAsynctask entity.
  9780. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9782. func (m *CompapiAsynctaskMutation) OldAuthToken(ctx context.Context) (v string, err error) {
  9783. if !m.op.Is(OpUpdateOne) {
  9784. return v, errors.New("OldAuthToken is only allowed on UpdateOne operations")
  9785. }
  9786. if m.id == nil || m.oldValue == nil {
  9787. return v, errors.New("OldAuthToken requires an ID field in the mutation")
  9788. }
  9789. oldValue, err := m.oldValue(ctx)
  9790. if err != nil {
  9791. return v, fmt.Errorf("querying old value for OldAuthToken: %w", err)
  9792. }
  9793. return oldValue.AuthToken, nil
  9794. }
  9795. // ResetAuthToken resets all changes to the "auth_token" field.
  9796. func (m *CompapiAsynctaskMutation) ResetAuthToken() {
  9797. m.auth_token = nil
  9798. }
  9799. // SetEventType sets the "event_type" field.
  9800. func (m *CompapiAsynctaskMutation) SetEventType(s string) {
  9801. m.event_type = &s
  9802. }
  9803. // EventType returns the value of the "event_type" field in the mutation.
  9804. func (m *CompapiAsynctaskMutation) EventType() (r string, exists bool) {
  9805. v := m.event_type
  9806. if v == nil {
  9807. return
  9808. }
  9809. return *v, true
  9810. }
  9811. // OldEventType returns the old "event_type" field's value of the CompapiAsynctask entity.
  9812. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9814. func (m *CompapiAsynctaskMutation) OldEventType(ctx context.Context) (v string, err error) {
  9815. if !m.op.Is(OpUpdateOne) {
  9816. return v, errors.New("OldEventType is only allowed on UpdateOne operations")
  9817. }
  9818. if m.id == nil || m.oldValue == nil {
  9819. return v, errors.New("OldEventType requires an ID field in the mutation")
  9820. }
  9821. oldValue, err := m.oldValue(ctx)
  9822. if err != nil {
  9823. return v, fmt.Errorf("querying old value for OldEventType: %w", err)
  9824. }
  9825. return oldValue.EventType, nil
  9826. }
  9827. // ResetEventType resets all changes to the "event_type" field.
  9828. func (m *CompapiAsynctaskMutation) ResetEventType() {
  9829. m.event_type = nil
  9830. }
  9831. // SetChatID sets the "chat_id" field.
  9832. func (m *CompapiAsynctaskMutation) SetChatID(s string) {
  9833. m.chat_id = &s
  9834. }
  9835. // ChatID returns the value of the "chat_id" field in the mutation.
  9836. func (m *CompapiAsynctaskMutation) ChatID() (r string, exists bool) {
  9837. v := m.chat_id
  9838. if v == nil {
  9839. return
  9840. }
  9841. return *v, true
  9842. }
  9843. // OldChatID returns the old "chat_id" field's value of the CompapiAsynctask entity.
  9844. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9846. func (m *CompapiAsynctaskMutation) OldChatID(ctx context.Context) (v string, err error) {
  9847. if !m.op.Is(OpUpdateOne) {
  9848. return v, errors.New("OldChatID is only allowed on UpdateOne operations")
  9849. }
  9850. if m.id == nil || m.oldValue == nil {
  9851. return v, errors.New("OldChatID requires an ID field in the mutation")
  9852. }
  9853. oldValue, err := m.oldValue(ctx)
  9854. if err != nil {
  9855. return v, fmt.Errorf("querying old value for OldChatID: %w", err)
  9856. }
  9857. return oldValue.ChatID, nil
  9858. }
  9859. // ClearChatID clears the value of the "chat_id" field.
  9860. func (m *CompapiAsynctaskMutation) ClearChatID() {
  9861. m.chat_id = nil
  9862. m.clearedFields[compapiasynctask.FieldChatID] = struct{}{}
  9863. }
  9864. // ChatIDCleared returns if the "chat_id" field was cleared in this mutation.
  9865. func (m *CompapiAsynctaskMutation) ChatIDCleared() bool {
  9866. _, ok := m.clearedFields[compapiasynctask.FieldChatID]
  9867. return ok
  9868. }
  9869. // ResetChatID resets all changes to the "chat_id" field.
  9870. func (m *CompapiAsynctaskMutation) ResetChatID() {
  9871. m.chat_id = nil
  9872. delete(m.clearedFields, compapiasynctask.FieldChatID)
  9873. }
  9874. // SetResponseChatItemID sets the "response_chat_item_id" field.
  9875. func (m *CompapiAsynctaskMutation) SetResponseChatItemID(s string) {
  9876. m.response_chat_item_id = &s
  9877. }
  9878. // ResponseChatItemID returns the value of the "response_chat_item_id" field in the mutation.
  9879. func (m *CompapiAsynctaskMutation) ResponseChatItemID() (r string, exists bool) {
  9880. v := m.response_chat_item_id
  9881. if v == nil {
  9882. return
  9883. }
  9884. return *v, true
  9885. }
  9886. // OldResponseChatItemID returns the old "response_chat_item_id" field's value of the CompapiAsynctask entity.
  9887. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9889. func (m *CompapiAsynctaskMutation) OldResponseChatItemID(ctx context.Context) (v string, err error) {
  9890. if !m.op.Is(OpUpdateOne) {
  9891. return v, errors.New("OldResponseChatItemID is only allowed on UpdateOne operations")
  9892. }
  9893. if m.id == nil || m.oldValue == nil {
  9894. return v, errors.New("OldResponseChatItemID requires an ID field in the mutation")
  9895. }
  9896. oldValue, err := m.oldValue(ctx)
  9897. if err != nil {
  9898. return v, fmt.Errorf("querying old value for OldResponseChatItemID: %w", err)
  9899. }
  9900. return oldValue.ResponseChatItemID, nil
  9901. }
  9902. // ClearResponseChatItemID clears the value of the "response_chat_item_id" field.
  9903. func (m *CompapiAsynctaskMutation) ClearResponseChatItemID() {
  9904. m.response_chat_item_id = nil
  9905. m.clearedFields[compapiasynctask.FieldResponseChatItemID] = struct{}{}
  9906. }
  9907. // ResponseChatItemIDCleared returns if the "response_chat_item_id" field was cleared in this mutation.
  9908. func (m *CompapiAsynctaskMutation) ResponseChatItemIDCleared() bool {
  9909. _, ok := m.clearedFields[compapiasynctask.FieldResponseChatItemID]
  9910. return ok
  9911. }
  9912. // ResetResponseChatItemID resets all changes to the "response_chat_item_id" field.
  9913. func (m *CompapiAsynctaskMutation) ResetResponseChatItemID() {
  9914. m.response_chat_item_id = nil
  9915. delete(m.clearedFields, compapiasynctask.FieldResponseChatItemID)
  9916. }
  9917. // SetOrganizationID sets the "organization_id" field.
  9918. func (m *CompapiAsynctaskMutation) SetOrganizationID(u uint64) {
  9919. m.organization_id = &u
  9920. m.addorganization_id = nil
  9921. }
  9922. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9923. func (m *CompapiAsynctaskMutation) OrganizationID() (r uint64, exists bool) {
  9924. v := m.organization_id
  9925. if v == nil {
  9926. return
  9927. }
  9928. return *v, true
  9929. }
  9930. // OldOrganizationID returns the old "organization_id" field's value of the CompapiAsynctask entity.
  9931. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9933. func (m *CompapiAsynctaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9934. if !m.op.Is(OpUpdateOne) {
  9935. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9936. }
  9937. if m.id == nil || m.oldValue == nil {
  9938. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9939. }
  9940. oldValue, err := m.oldValue(ctx)
  9941. if err != nil {
  9942. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9943. }
  9944. return oldValue.OrganizationID, nil
  9945. }
  9946. // AddOrganizationID adds u to the "organization_id" field.
  9947. func (m *CompapiAsynctaskMutation) AddOrganizationID(u int64) {
  9948. if m.addorganization_id != nil {
  9949. *m.addorganization_id += u
  9950. } else {
  9951. m.addorganization_id = &u
  9952. }
  9953. }
  9954. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9955. func (m *CompapiAsynctaskMutation) AddedOrganizationID() (r int64, exists bool) {
  9956. v := m.addorganization_id
  9957. if v == nil {
  9958. return
  9959. }
  9960. return *v, true
  9961. }
  9962. // ResetOrganizationID resets all changes to the "organization_id" field.
  9963. func (m *CompapiAsynctaskMutation) ResetOrganizationID() {
  9964. m.organization_id = nil
  9965. m.addorganization_id = nil
  9966. }
  9967. // SetOpenaiBase sets the "openai_base" field.
  9968. func (m *CompapiAsynctaskMutation) SetOpenaiBase(s string) {
  9969. m.openai_base = &s
  9970. }
  9971. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  9972. func (m *CompapiAsynctaskMutation) OpenaiBase() (r string, exists bool) {
  9973. v := m.openai_base
  9974. if v == nil {
  9975. return
  9976. }
  9977. return *v, true
  9978. }
  9979. // OldOpenaiBase returns the old "openai_base" field's value of the CompapiAsynctask entity.
  9980. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9982. func (m *CompapiAsynctaskMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  9983. if !m.op.Is(OpUpdateOne) {
  9984. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  9985. }
  9986. if m.id == nil || m.oldValue == nil {
  9987. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  9988. }
  9989. oldValue, err := m.oldValue(ctx)
  9990. if err != nil {
  9991. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  9992. }
  9993. return oldValue.OpenaiBase, nil
  9994. }
  9995. // ResetOpenaiBase resets all changes to the "openai_base" field.
  9996. func (m *CompapiAsynctaskMutation) ResetOpenaiBase() {
  9997. m.openai_base = nil
  9998. }
  9999. // SetOpenaiKey sets the "openai_key" field.
  10000. func (m *CompapiAsynctaskMutation) SetOpenaiKey(s string) {
  10001. m.openai_key = &s
  10002. }
  10003. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  10004. func (m *CompapiAsynctaskMutation) OpenaiKey() (r string, exists bool) {
  10005. v := m.openai_key
  10006. if v == nil {
  10007. return
  10008. }
  10009. return *v, true
  10010. }
  10011. // OldOpenaiKey returns the old "openai_key" field's value of the CompapiAsynctask entity.
  10012. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10014. func (m *CompapiAsynctaskMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  10015. if !m.op.Is(OpUpdateOne) {
  10016. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  10017. }
  10018. if m.id == nil || m.oldValue == nil {
  10019. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  10020. }
  10021. oldValue, err := m.oldValue(ctx)
  10022. if err != nil {
  10023. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  10024. }
  10025. return oldValue.OpenaiKey, nil
  10026. }
  10027. // ResetOpenaiKey resets all changes to the "openai_key" field.
  10028. func (m *CompapiAsynctaskMutation) ResetOpenaiKey() {
  10029. m.openai_key = nil
  10030. }
  10031. // SetRequestRaw sets the "request_raw" field.
  10032. func (m *CompapiAsynctaskMutation) SetRequestRaw(s string) {
  10033. m.request_raw = &s
  10034. }
  10035. // RequestRaw returns the value of the "request_raw" field in the mutation.
  10036. func (m *CompapiAsynctaskMutation) RequestRaw() (r string, exists bool) {
  10037. v := m.request_raw
  10038. if v == nil {
  10039. return
  10040. }
  10041. return *v, true
  10042. }
  10043. // OldRequestRaw returns the old "request_raw" field's value of the CompapiAsynctask entity.
  10044. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10046. func (m *CompapiAsynctaskMutation) OldRequestRaw(ctx context.Context) (v string, err error) {
  10047. if !m.op.Is(OpUpdateOne) {
  10048. return v, errors.New("OldRequestRaw is only allowed on UpdateOne operations")
  10049. }
  10050. if m.id == nil || m.oldValue == nil {
  10051. return v, errors.New("OldRequestRaw requires an ID field in the mutation")
  10052. }
  10053. oldValue, err := m.oldValue(ctx)
  10054. if err != nil {
  10055. return v, fmt.Errorf("querying old value for OldRequestRaw: %w", err)
  10056. }
  10057. return oldValue.RequestRaw, nil
  10058. }
  10059. // ResetRequestRaw resets all changes to the "request_raw" field.
  10060. func (m *CompapiAsynctaskMutation) ResetRequestRaw() {
  10061. m.request_raw = nil
  10062. }
  10063. // SetResponseRaw sets the "response_raw" field.
  10064. func (m *CompapiAsynctaskMutation) SetResponseRaw(s string) {
  10065. m.response_raw = &s
  10066. }
  10067. // ResponseRaw returns the value of the "response_raw" field in the mutation.
  10068. func (m *CompapiAsynctaskMutation) ResponseRaw() (r string, exists bool) {
  10069. v := m.response_raw
  10070. if v == nil {
  10071. return
  10072. }
  10073. return *v, true
  10074. }
  10075. // OldResponseRaw returns the old "response_raw" field's value of the CompapiAsynctask entity.
  10076. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10078. func (m *CompapiAsynctaskMutation) OldResponseRaw(ctx context.Context) (v string, err error) {
  10079. if !m.op.Is(OpUpdateOne) {
  10080. return v, errors.New("OldResponseRaw is only allowed on UpdateOne operations")
  10081. }
  10082. if m.id == nil || m.oldValue == nil {
  10083. return v, errors.New("OldResponseRaw requires an ID field in the mutation")
  10084. }
  10085. oldValue, err := m.oldValue(ctx)
  10086. if err != nil {
  10087. return v, fmt.Errorf("querying old value for OldResponseRaw: %w", err)
  10088. }
  10089. return oldValue.ResponseRaw, nil
  10090. }
  10091. // ClearResponseRaw clears the value of the "response_raw" field.
  10092. func (m *CompapiAsynctaskMutation) ClearResponseRaw() {
  10093. m.response_raw = nil
  10094. m.clearedFields[compapiasynctask.FieldResponseRaw] = struct{}{}
  10095. }
  10096. // ResponseRawCleared returns if the "response_raw" field was cleared in this mutation.
  10097. func (m *CompapiAsynctaskMutation) ResponseRawCleared() bool {
  10098. _, ok := m.clearedFields[compapiasynctask.FieldResponseRaw]
  10099. return ok
  10100. }
  10101. // ResetResponseRaw resets all changes to the "response_raw" field.
  10102. func (m *CompapiAsynctaskMutation) ResetResponseRaw() {
  10103. m.response_raw = nil
  10104. delete(m.clearedFields, compapiasynctask.FieldResponseRaw)
  10105. }
  10106. // SetCallbackURL sets the "callback_url" field.
  10107. func (m *CompapiAsynctaskMutation) SetCallbackURL(s string) {
  10108. m.callback_url = &s
  10109. }
  10110. // CallbackURL returns the value of the "callback_url" field in the mutation.
  10111. func (m *CompapiAsynctaskMutation) CallbackURL() (r string, exists bool) {
  10112. v := m.callback_url
  10113. if v == nil {
  10114. return
  10115. }
  10116. return *v, true
  10117. }
  10118. // OldCallbackURL returns the old "callback_url" field's value of the CompapiAsynctask entity.
  10119. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10121. func (m *CompapiAsynctaskMutation) OldCallbackURL(ctx context.Context) (v string, err error) {
  10122. if !m.op.Is(OpUpdateOne) {
  10123. return v, errors.New("OldCallbackURL is only allowed on UpdateOne operations")
  10124. }
  10125. if m.id == nil || m.oldValue == nil {
  10126. return v, errors.New("OldCallbackURL requires an ID field in the mutation")
  10127. }
  10128. oldValue, err := m.oldValue(ctx)
  10129. if err != nil {
  10130. return v, fmt.Errorf("querying old value for OldCallbackURL: %w", err)
  10131. }
  10132. return oldValue.CallbackURL, nil
  10133. }
  10134. // ResetCallbackURL resets all changes to the "callback_url" field.
  10135. func (m *CompapiAsynctaskMutation) ResetCallbackURL() {
  10136. m.callback_url = nil
  10137. }
  10138. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  10139. func (m *CompapiAsynctaskMutation) SetCallbackResponseRaw(s string) {
  10140. m.callback_response_raw = &s
  10141. }
  10142. // CallbackResponseRaw returns the value of the "callback_response_raw" field in the mutation.
  10143. func (m *CompapiAsynctaskMutation) CallbackResponseRaw() (r string, exists bool) {
  10144. v := m.callback_response_raw
  10145. if v == nil {
  10146. return
  10147. }
  10148. return *v, true
  10149. }
  10150. // OldCallbackResponseRaw returns the old "callback_response_raw" field's value of the CompapiAsynctask entity.
  10151. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10153. func (m *CompapiAsynctaskMutation) OldCallbackResponseRaw(ctx context.Context) (v string, err error) {
  10154. if !m.op.Is(OpUpdateOne) {
  10155. return v, errors.New("OldCallbackResponseRaw is only allowed on UpdateOne operations")
  10156. }
  10157. if m.id == nil || m.oldValue == nil {
  10158. return v, errors.New("OldCallbackResponseRaw requires an ID field in the mutation")
  10159. }
  10160. oldValue, err := m.oldValue(ctx)
  10161. if err != nil {
  10162. return v, fmt.Errorf("querying old value for OldCallbackResponseRaw: %w", err)
  10163. }
  10164. return oldValue.CallbackResponseRaw, nil
  10165. }
  10166. // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field.
  10167. func (m *CompapiAsynctaskMutation) ClearCallbackResponseRaw() {
  10168. m.callback_response_raw = nil
  10169. m.clearedFields[compapiasynctask.FieldCallbackResponseRaw] = struct{}{}
  10170. }
  10171. // CallbackResponseRawCleared returns if the "callback_response_raw" field was cleared in this mutation.
  10172. func (m *CompapiAsynctaskMutation) CallbackResponseRawCleared() bool {
  10173. _, ok := m.clearedFields[compapiasynctask.FieldCallbackResponseRaw]
  10174. return ok
  10175. }
  10176. // ResetCallbackResponseRaw resets all changes to the "callback_response_raw" field.
  10177. func (m *CompapiAsynctaskMutation) ResetCallbackResponseRaw() {
  10178. m.callback_response_raw = nil
  10179. delete(m.clearedFields, compapiasynctask.FieldCallbackResponseRaw)
  10180. }
  10181. // SetModel sets the "model" field.
  10182. func (m *CompapiAsynctaskMutation) SetModel(s string) {
  10183. m.model = &s
  10184. }
  10185. // Model returns the value of the "model" field in the mutation.
  10186. func (m *CompapiAsynctaskMutation) Model() (r string, exists bool) {
  10187. v := m.model
  10188. if v == nil {
  10189. return
  10190. }
  10191. return *v, true
  10192. }
  10193. // OldModel returns the old "model" field's value of the CompapiAsynctask entity.
  10194. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10196. func (m *CompapiAsynctaskMutation) OldModel(ctx context.Context) (v string, err error) {
  10197. if !m.op.Is(OpUpdateOne) {
  10198. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  10199. }
  10200. if m.id == nil || m.oldValue == nil {
  10201. return v, errors.New("OldModel requires an ID field in the mutation")
  10202. }
  10203. oldValue, err := m.oldValue(ctx)
  10204. if err != nil {
  10205. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  10206. }
  10207. return oldValue.Model, nil
  10208. }
  10209. // ClearModel clears the value of the "model" field.
  10210. func (m *CompapiAsynctaskMutation) ClearModel() {
  10211. m.model = nil
  10212. m.clearedFields[compapiasynctask.FieldModel] = struct{}{}
  10213. }
  10214. // ModelCleared returns if the "model" field was cleared in this mutation.
  10215. func (m *CompapiAsynctaskMutation) ModelCleared() bool {
  10216. _, ok := m.clearedFields[compapiasynctask.FieldModel]
  10217. return ok
  10218. }
  10219. // ResetModel resets all changes to the "model" field.
  10220. func (m *CompapiAsynctaskMutation) ResetModel() {
  10221. m.model = nil
  10222. delete(m.clearedFields, compapiasynctask.FieldModel)
  10223. }
  10224. // SetTaskStatus sets the "task_status" field.
  10225. func (m *CompapiAsynctaskMutation) SetTaskStatus(i int8) {
  10226. m.task_status = &i
  10227. m.addtask_status = nil
  10228. }
  10229. // TaskStatus returns the value of the "task_status" field in the mutation.
  10230. func (m *CompapiAsynctaskMutation) TaskStatus() (r int8, exists bool) {
  10231. v := m.task_status
  10232. if v == nil {
  10233. return
  10234. }
  10235. return *v, true
  10236. }
  10237. // OldTaskStatus returns the old "task_status" field's value of the CompapiAsynctask entity.
  10238. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10240. func (m *CompapiAsynctaskMutation) OldTaskStatus(ctx context.Context) (v int8, err error) {
  10241. if !m.op.Is(OpUpdateOne) {
  10242. return v, errors.New("OldTaskStatus is only allowed on UpdateOne operations")
  10243. }
  10244. if m.id == nil || m.oldValue == nil {
  10245. return v, errors.New("OldTaskStatus requires an ID field in the mutation")
  10246. }
  10247. oldValue, err := m.oldValue(ctx)
  10248. if err != nil {
  10249. return v, fmt.Errorf("querying old value for OldTaskStatus: %w", err)
  10250. }
  10251. return oldValue.TaskStatus, nil
  10252. }
  10253. // AddTaskStatus adds i to the "task_status" field.
  10254. func (m *CompapiAsynctaskMutation) AddTaskStatus(i int8) {
  10255. if m.addtask_status != nil {
  10256. *m.addtask_status += i
  10257. } else {
  10258. m.addtask_status = &i
  10259. }
  10260. }
  10261. // AddedTaskStatus returns the value that was added to the "task_status" field in this mutation.
  10262. func (m *CompapiAsynctaskMutation) AddedTaskStatus() (r int8, exists bool) {
  10263. v := m.addtask_status
  10264. if v == nil {
  10265. return
  10266. }
  10267. return *v, true
  10268. }
  10269. // ClearTaskStatus clears the value of the "task_status" field.
  10270. func (m *CompapiAsynctaskMutation) ClearTaskStatus() {
  10271. m.task_status = nil
  10272. m.addtask_status = nil
  10273. m.clearedFields[compapiasynctask.FieldTaskStatus] = struct{}{}
  10274. }
  10275. // TaskStatusCleared returns if the "task_status" field was cleared in this mutation.
  10276. func (m *CompapiAsynctaskMutation) TaskStatusCleared() bool {
  10277. _, ok := m.clearedFields[compapiasynctask.FieldTaskStatus]
  10278. return ok
  10279. }
  10280. // ResetTaskStatus resets all changes to the "task_status" field.
  10281. func (m *CompapiAsynctaskMutation) ResetTaskStatus() {
  10282. m.task_status = nil
  10283. m.addtask_status = nil
  10284. delete(m.clearedFields, compapiasynctask.FieldTaskStatus)
  10285. }
  10286. // SetRetryCount sets the "retry_count" field.
  10287. func (m *CompapiAsynctaskMutation) SetRetryCount(i int8) {
  10288. m.retry_count = &i
  10289. m.addretry_count = nil
  10290. }
  10291. // RetryCount returns the value of the "retry_count" field in the mutation.
  10292. func (m *CompapiAsynctaskMutation) RetryCount() (r int8, exists bool) {
  10293. v := m.retry_count
  10294. if v == nil {
  10295. return
  10296. }
  10297. return *v, true
  10298. }
  10299. // OldRetryCount returns the old "retry_count" field's value of the CompapiAsynctask entity.
  10300. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10302. func (m *CompapiAsynctaskMutation) OldRetryCount(ctx context.Context) (v int8, err error) {
  10303. if !m.op.Is(OpUpdateOne) {
  10304. return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
  10305. }
  10306. if m.id == nil || m.oldValue == nil {
  10307. return v, errors.New("OldRetryCount requires an ID field in the mutation")
  10308. }
  10309. oldValue, err := m.oldValue(ctx)
  10310. if err != nil {
  10311. return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
  10312. }
  10313. return oldValue.RetryCount, nil
  10314. }
  10315. // AddRetryCount adds i to the "retry_count" field.
  10316. func (m *CompapiAsynctaskMutation) AddRetryCount(i int8) {
  10317. if m.addretry_count != nil {
  10318. *m.addretry_count += i
  10319. } else {
  10320. m.addretry_count = &i
  10321. }
  10322. }
  10323. // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
  10324. func (m *CompapiAsynctaskMutation) AddedRetryCount() (r int8, exists bool) {
  10325. v := m.addretry_count
  10326. if v == nil {
  10327. return
  10328. }
  10329. return *v, true
  10330. }
  10331. // ClearRetryCount clears the value of the "retry_count" field.
  10332. func (m *CompapiAsynctaskMutation) ClearRetryCount() {
  10333. m.retry_count = nil
  10334. m.addretry_count = nil
  10335. m.clearedFields[compapiasynctask.FieldRetryCount] = struct{}{}
  10336. }
  10337. // RetryCountCleared returns if the "retry_count" field was cleared in this mutation.
  10338. func (m *CompapiAsynctaskMutation) RetryCountCleared() bool {
  10339. _, ok := m.clearedFields[compapiasynctask.FieldRetryCount]
  10340. return ok
  10341. }
  10342. // ResetRetryCount resets all changes to the "retry_count" field.
  10343. func (m *CompapiAsynctaskMutation) ResetRetryCount() {
  10344. m.retry_count = nil
  10345. m.addretry_count = nil
  10346. delete(m.clearedFields, compapiasynctask.FieldRetryCount)
  10347. }
  10348. // SetLastError sets the "last_error" field.
  10349. func (m *CompapiAsynctaskMutation) SetLastError(s string) {
  10350. m.last_error = &s
  10351. }
  10352. // LastError returns the value of the "last_error" field in the mutation.
  10353. func (m *CompapiAsynctaskMutation) LastError() (r string, exists bool) {
  10354. v := m.last_error
  10355. if v == nil {
  10356. return
  10357. }
  10358. return *v, true
  10359. }
  10360. // OldLastError returns the old "last_error" field's value of the CompapiAsynctask entity.
  10361. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10363. func (m *CompapiAsynctaskMutation) OldLastError(ctx context.Context) (v string, err error) {
  10364. if !m.op.Is(OpUpdateOne) {
  10365. return v, errors.New("OldLastError is only allowed on UpdateOne operations")
  10366. }
  10367. if m.id == nil || m.oldValue == nil {
  10368. return v, errors.New("OldLastError requires an ID field in the mutation")
  10369. }
  10370. oldValue, err := m.oldValue(ctx)
  10371. if err != nil {
  10372. return v, fmt.Errorf("querying old value for OldLastError: %w", err)
  10373. }
  10374. return oldValue.LastError, nil
  10375. }
  10376. // ClearLastError clears the value of the "last_error" field.
  10377. func (m *CompapiAsynctaskMutation) ClearLastError() {
  10378. m.last_error = nil
  10379. m.clearedFields[compapiasynctask.FieldLastError] = struct{}{}
  10380. }
  10381. // LastErrorCleared returns if the "last_error" field was cleared in this mutation.
  10382. func (m *CompapiAsynctaskMutation) LastErrorCleared() bool {
  10383. _, ok := m.clearedFields[compapiasynctask.FieldLastError]
  10384. return ok
  10385. }
  10386. // ResetLastError resets all changes to the "last_error" field.
  10387. func (m *CompapiAsynctaskMutation) ResetLastError() {
  10388. m.last_error = nil
  10389. delete(m.clearedFields, compapiasynctask.FieldLastError)
  10390. }
  10391. // Where appends a list predicates to the CompapiAsynctaskMutation builder.
  10392. func (m *CompapiAsynctaskMutation) Where(ps ...predicate.CompapiAsynctask) {
  10393. m.predicates = append(m.predicates, ps...)
  10394. }
  10395. // WhereP appends storage-level predicates to the CompapiAsynctaskMutation builder. Using this method,
  10396. // users can use type-assertion to append predicates that do not depend on any generated package.
  10397. func (m *CompapiAsynctaskMutation) WhereP(ps ...func(*sql.Selector)) {
  10398. p := make([]predicate.CompapiAsynctask, len(ps))
  10399. for i := range ps {
  10400. p[i] = ps[i]
  10401. }
  10402. m.Where(p...)
  10403. }
  10404. // Op returns the operation name.
  10405. func (m *CompapiAsynctaskMutation) Op() Op {
  10406. return m.op
  10407. }
  10408. // SetOp allows setting the mutation operation.
  10409. func (m *CompapiAsynctaskMutation) SetOp(op Op) {
  10410. m.op = op
  10411. }
  10412. // Type returns the node type of this mutation (CompapiAsynctask).
  10413. func (m *CompapiAsynctaskMutation) Type() string {
  10414. return m.typ
  10415. }
  10416. // Fields returns all fields that were changed during this mutation. Note that in
  10417. // order to get all numeric fields that were incremented/decremented, call
  10418. // AddedFields().
  10419. func (m *CompapiAsynctaskMutation) Fields() []string {
  10420. fields := make([]string, 0, 17)
  10421. if m.created_at != nil {
  10422. fields = append(fields, compapiasynctask.FieldCreatedAt)
  10423. }
  10424. if m.updated_at != nil {
  10425. fields = append(fields, compapiasynctask.FieldUpdatedAt)
  10426. }
  10427. if m.auth_token != nil {
  10428. fields = append(fields, compapiasynctask.FieldAuthToken)
  10429. }
  10430. if m.event_type != nil {
  10431. fields = append(fields, compapiasynctask.FieldEventType)
  10432. }
  10433. if m.chat_id != nil {
  10434. fields = append(fields, compapiasynctask.FieldChatID)
  10435. }
  10436. if m.response_chat_item_id != nil {
  10437. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  10438. }
  10439. if m.organization_id != nil {
  10440. fields = append(fields, compapiasynctask.FieldOrganizationID)
  10441. }
  10442. if m.openai_base != nil {
  10443. fields = append(fields, compapiasynctask.FieldOpenaiBase)
  10444. }
  10445. if m.openai_key != nil {
  10446. fields = append(fields, compapiasynctask.FieldOpenaiKey)
  10447. }
  10448. if m.request_raw != nil {
  10449. fields = append(fields, compapiasynctask.FieldRequestRaw)
  10450. }
  10451. if m.response_raw != nil {
  10452. fields = append(fields, compapiasynctask.FieldResponseRaw)
  10453. }
  10454. if m.callback_url != nil {
  10455. fields = append(fields, compapiasynctask.FieldCallbackURL)
  10456. }
  10457. if m.callback_response_raw != nil {
  10458. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  10459. }
  10460. if m.model != nil {
  10461. fields = append(fields, compapiasynctask.FieldModel)
  10462. }
  10463. if m.task_status != nil {
  10464. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10465. }
  10466. if m.retry_count != nil {
  10467. fields = append(fields, compapiasynctask.FieldRetryCount)
  10468. }
  10469. if m.last_error != nil {
  10470. fields = append(fields, compapiasynctask.FieldLastError)
  10471. }
  10472. return fields
  10473. }
  10474. // Field returns the value of a field with the given name. The second boolean
  10475. // return value indicates that this field was not set, or was not defined in the
  10476. // schema.
  10477. func (m *CompapiAsynctaskMutation) Field(name string) (ent.Value, bool) {
  10478. switch name {
  10479. case compapiasynctask.FieldCreatedAt:
  10480. return m.CreatedAt()
  10481. case compapiasynctask.FieldUpdatedAt:
  10482. return m.UpdatedAt()
  10483. case compapiasynctask.FieldAuthToken:
  10484. return m.AuthToken()
  10485. case compapiasynctask.FieldEventType:
  10486. return m.EventType()
  10487. case compapiasynctask.FieldChatID:
  10488. return m.ChatID()
  10489. case compapiasynctask.FieldResponseChatItemID:
  10490. return m.ResponseChatItemID()
  10491. case compapiasynctask.FieldOrganizationID:
  10492. return m.OrganizationID()
  10493. case compapiasynctask.FieldOpenaiBase:
  10494. return m.OpenaiBase()
  10495. case compapiasynctask.FieldOpenaiKey:
  10496. return m.OpenaiKey()
  10497. case compapiasynctask.FieldRequestRaw:
  10498. return m.RequestRaw()
  10499. case compapiasynctask.FieldResponseRaw:
  10500. return m.ResponseRaw()
  10501. case compapiasynctask.FieldCallbackURL:
  10502. return m.CallbackURL()
  10503. case compapiasynctask.FieldCallbackResponseRaw:
  10504. return m.CallbackResponseRaw()
  10505. case compapiasynctask.FieldModel:
  10506. return m.Model()
  10507. case compapiasynctask.FieldTaskStatus:
  10508. return m.TaskStatus()
  10509. case compapiasynctask.FieldRetryCount:
  10510. return m.RetryCount()
  10511. case compapiasynctask.FieldLastError:
  10512. return m.LastError()
  10513. }
  10514. return nil, false
  10515. }
  10516. // OldField returns the old value of the field from the database. An error is
  10517. // returned if the mutation operation is not UpdateOne, or the query to the
  10518. // database failed.
  10519. func (m *CompapiAsynctaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10520. switch name {
  10521. case compapiasynctask.FieldCreatedAt:
  10522. return m.OldCreatedAt(ctx)
  10523. case compapiasynctask.FieldUpdatedAt:
  10524. return m.OldUpdatedAt(ctx)
  10525. case compapiasynctask.FieldAuthToken:
  10526. return m.OldAuthToken(ctx)
  10527. case compapiasynctask.FieldEventType:
  10528. return m.OldEventType(ctx)
  10529. case compapiasynctask.FieldChatID:
  10530. return m.OldChatID(ctx)
  10531. case compapiasynctask.FieldResponseChatItemID:
  10532. return m.OldResponseChatItemID(ctx)
  10533. case compapiasynctask.FieldOrganizationID:
  10534. return m.OldOrganizationID(ctx)
  10535. case compapiasynctask.FieldOpenaiBase:
  10536. return m.OldOpenaiBase(ctx)
  10537. case compapiasynctask.FieldOpenaiKey:
  10538. return m.OldOpenaiKey(ctx)
  10539. case compapiasynctask.FieldRequestRaw:
  10540. return m.OldRequestRaw(ctx)
  10541. case compapiasynctask.FieldResponseRaw:
  10542. return m.OldResponseRaw(ctx)
  10543. case compapiasynctask.FieldCallbackURL:
  10544. return m.OldCallbackURL(ctx)
  10545. case compapiasynctask.FieldCallbackResponseRaw:
  10546. return m.OldCallbackResponseRaw(ctx)
  10547. case compapiasynctask.FieldModel:
  10548. return m.OldModel(ctx)
  10549. case compapiasynctask.FieldTaskStatus:
  10550. return m.OldTaskStatus(ctx)
  10551. case compapiasynctask.FieldRetryCount:
  10552. return m.OldRetryCount(ctx)
  10553. case compapiasynctask.FieldLastError:
  10554. return m.OldLastError(ctx)
  10555. }
  10556. return nil, fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10557. }
  10558. // SetField sets the value of a field with the given name. It returns an error if
  10559. // the field is not defined in the schema, or if the type mismatched the field
  10560. // type.
  10561. func (m *CompapiAsynctaskMutation) SetField(name string, value ent.Value) error {
  10562. switch name {
  10563. case compapiasynctask.FieldCreatedAt:
  10564. v, ok := value.(time.Time)
  10565. if !ok {
  10566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10567. }
  10568. m.SetCreatedAt(v)
  10569. return nil
  10570. case compapiasynctask.FieldUpdatedAt:
  10571. v, ok := value.(time.Time)
  10572. if !ok {
  10573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10574. }
  10575. m.SetUpdatedAt(v)
  10576. return nil
  10577. case compapiasynctask.FieldAuthToken:
  10578. v, ok := value.(string)
  10579. if !ok {
  10580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10581. }
  10582. m.SetAuthToken(v)
  10583. return nil
  10584. case compapiasynctask.FieldEventType:
  10585. v, ok := value.(string)
  10586. if !ok {
  10587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10588. }
  10589. m.SetEventType(v)
  10590. return nil
  10591. case compapiasynctask.FieldChatID:
  10592. v, ok := value.(string)
  10593. if !ok {
  10594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10595. }
  10596. m.SetChatID(v)
  10597. return nil
  10598. case compapiasynctask.FieldResponseChatItemID:
  10599. v, ok := value.(string)
  10600. if !ok {
  10601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10602. }
  10603. m.SetResponseChatItemID(v)
  10604. return nil
  10605. case compapiasynctask.FieldOrganizationID:
  10606. v, ok := value.(uint64)
  10607. if !ok {
  10608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10609. }
  10610. m.SetOrganizationID(v)
  10611. return nil
  10612. case compapiasynctask.FieldOpenaiBase:
  10613. v, ok := value.(string)
  10614. if !ok {
  10615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10616. }
  10617. m.SetOpenaiBase(v)
  10618. return nil
  10619. case compapiasynctask.FieldOpenaiKey:
  10620. v, ok := value.(string)
  10621. if !ok {
  10622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10623. }
  10624. m.SetOpenaiKey(v)
  10625. return nil
  10626. case compapiasynctask.FieldRequestRaw:
  10627. v, ok := value.(string)
  10628. if !ok {
  10629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10630. }
  10631. m.SetRequestRaw(v)
  10632. return nil
  10633. case compapiasynctask.FieldResponseRaw:
  10634. v, ok := value.(string)
  10635. if !ok {
  10636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10637. }
  10638. m.SetResponseRaw(v)
  10639. return nil
  10640. case compapiasynctask.FieldCallbackURL:
  10641. v, ok := value.(string)
  10642. if !ok {
  10643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10644. }
  10645. m.SetCallbackURL(v)
  10646. return nil
  10647. case compapiasynctask.FieldCallbackResponseRaw:
  10648. v, ok := value.(string)
  10649. if !ok {
  10650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10651. }
  10652. m.SetCallbackResponseRaw(v)
  10653. return nil
  10654. case compapiasynctask.FieldModel:
  10655. v, ok := value.(string)
  10656. if !ok {
  10657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10658. }
  10659. m.SetModel(v)
  10660. return nil
  10661. case compapiasynctask.FieldTaskStatus:
  10662. v, ok := value.(int8)
  10663. if !ok {
  10664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10665. }
  10666. m.SetTaskStatus(v)
  10667. return nil
  10668. case compapiasynctask.FieldRetryCount:
  10669. v, ok := value.(int8)
  10670. if !ok {
  10671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10672. }
  10673. m.SetRetryCount(v)
  10674. return nil
  10675. case compapiasynctask.FieldLastError:
  10676. v, ok := value.(string)
  10677. if !ok {
  10678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10679. }
  10680. m.SetLastError(v)
  10681. return nil
  10682. }
  10683. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10684. }
  10685. // AddedFields returns all numeric fields that were incremented/decremented during
  10686. // this mutation.
  10687. func (m *CompapiAsynctaskMutation) AddedFields() []string {
  10688. var fields []string
  10689. if m.addorganization_id != nil {
  10690. fields = append(fields, compapiasynctask.FieldOrganizationID)
  10691. }
  10692. if m.addtask_status != nil {
  10693. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10694. }
  10695. if m.addretry_count != nil {
  10696. fields = append(fields, compapiasynctask.FieldRetryCount)
  10697. }
  10698. return fields
  10699. }
  10700. // AddedField returns the numeric value that was incremented/decremented on a field
  10701. // with the given name. The second boolean return value indicates that this field
  10702. // was not set, or was not defined in the schema.
  10703. func (m *CompapiAsynctaskMutation) AddedField(name string) (ent.Value, bool) {
  10704. switch name {
  10705. case compapiasynctask.FieldOrganizationID:
  10706. return m.AddedOrganizationID()
  10707. case compapiasynctask.FieldTaskStatus:
  10708. return m.AddedTaskStatus()
  10709. case compapiasynctask.FieldRetryCount:
  10710. return m.AddedRetryCount()
  10711. }
  10712. return nil, false
  10713. }
  10714. // AddField adds the value to the field with the given name. It returns an error if
  10715. // the field is not defined in the schema, or if the type mismatched the field
  10716. // type.
  10717. func (m *CompapiAsynctaskMutation) AddField(name string, value ent.Value) error {
  10718. switch name {
  10719. case compapiasynctask.FieldOrganizationID:
  10720. v, ok := value.(int64)
  10721. if !ok {
  10722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10723. }
  10724. m.AddOrganizationID(v)
  10725. return nil
  10726. case compapiasynctask.FieldTaskStatus:
  10727. v, ok := value.(int8)
  10728. if !ok {
  10729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10730. }
  10731. m.AddTaskStatus(v)
  10732. return nil
  10733. case compapiasynctask.FieldRetryCount:
  10734. v, ok := value.(int8)
  10735. if !ok {
  10736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10737. }
  10738. m.AddRetryCount(v)
  10739. return nil
  10740. }
  10741. return fmt.Errorf("unknown CompapiAsynctask numeric field %s", name)
  10742. }
  10743. // ClearedFields returns all nullable fields that were cleared during this
  10744. // mutation.
  10745. func (m *CompapiAsynctaskMutation) ClearedFields() []string {
  10746. var fields []string
  10747. if m.FieldCleared(compapiasynctask.FieldChatID) {
  10748. fields = append(fields, compapiasynctask.FieldChatID)
  10749. }
  10750. if m.FieldCleared(compapiasynctask.FieldResponseChatItemID) {
  10751. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  10752. }
  10753. if m.FieldCleared(compapiasynctask.FieldResponseRaw) {
  10754. fields = append(fields, compapiasynctask.FieldResponseRaw)
  10755. }
  10756. if m.FieldCleared(compapiasynctask.FieldCallbackResponseRaw) {
  10757. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  10758. }
  10759. if m.FieldCleared(compapiasynctask.FieldModel) {
  10760. fields = append(fields, compapiasynctask.FieldModel)
  10761. }
  10762. if m.FieldCleared(compapiasynctask.FieldTaskStatus) {
  10763. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10764. }
  10765. if m.FieldCleared(compapiasynctask.FieldRetryCount) {
  10766. fields = append(fields, compapiasynctask.FieldRetryCount)
  10767. }
  10768. if m.FieldCleared(compapiasynctask.FieldLastError) {
  10769. fields = append(fields, compapiasynctask.FieldLastError)
  10770. }
  10771. return fields
  10772. }
  10773. // FieldCleared returns a boolean indicating if a field with the given name was
  10774. // cleared in this mutation.
  10775. func (m *CompapiAsynctaskMutation) FieldCleared(name string) bool {
  10776. _, ok := m.clearedFields[name]
  10777. return ok
  10778. }
  10779. // ClearField clears the value of the field with the given name. It returns an
  10780. // error if the field is not defined in the schema.
  10781. func (m *CompapiAsynctaskMutation) ClearField(name string) error {
  10782. switch name {
  10783. case compapiasynctask.FieldChatID:
  10784. m.ClearChatID()
  10785. return nil
  10786. case compapiasynctask.FieldResponseChatItemID:
  10787. m.ClearResponseChatItemID()
  10788. return nil
  10789. case compapiasynctask.FieldResponseRaw:
  10790. m.ClearResponseRaw()
  10791. return nil
  10792. case compapiasynctask.FieldCallbackResponseRaw:
  10793. m.ClearCallbackResponseRaw()
  10794. return nil
  10795. case compapiasynctask.FieldModel:
  10796. m.ClearModel()
  10797. return nil
  10798. case compapiasynctask.FieldTaskStatus:
  10799. m.ClearTaskStatus()
  10800. return nil
  10801. case compapiasynctask.FieldRetryCount:
  10802. m.ClearRetryCount()
  10803. return nil
  10804. case compapiasynctask.FieldLastError:
  10805. m.ClearLastError()
  10806. return nil
  10807. }
  10808. return fmt.Errorf("unknown CompapiAsynctask nullable field %s", name)
  10809. }
  10810. // ResetField resets all changes in the mutation for the field with the given name.
  10811. // It returns an error if the field is not defined in the schema.
  10812. func (m *CompapiAsynctaskMutation) ResetField(name string) error {
  10813. switch name {
  10814. case compapiasynctask.FieldCreatedAt:
  10815. m.ResetCreatedAt()
  10816. return nil
  10817. case compapiasynctask.FieldUpdatedAt:
  10818. m.ResetUpdatedAt()
  10819. return nil
  10820. case compapiasynctask.FieldAuthToken:
  10821. m.ResetAuthToken()
  10822. return nil
  10823. case compapiasynctask.FieldEventType:
  10824. m.ResetEventType()
  10825. return nil
  10826. case compapiasynctask.FieldChatID:
  10827. m.ResetChatID()
  10828. return nil
  10829. case compapiasynctask.FieldResponseChatItemID:
  10830. m.ResetResponseChatItemID()
  10831. return nil
  10832. case compapiasynctask.FieldOrganizationID:
  10833. m.ResetOrganizationID()
  10834. return nil
  10835. case compapiasynctask.FieldOpenaiBase:
  10836. m.ResetOpenaiBase()
  10837. return nil
  10838. case compapiasynctask.FieldOpenaiKey:
  10839. m.ResetOpenaiKey()
  10840. return nil
  10841. case compapiasynctask.FieldRequestRaw:
  10842. m.ResetRequestRaw()
  10843. return nil
  10844. case compapiasynctask.FieldResponseRaw:
  10845. m.ResetResponseRaw()
  10846. return nil
  10847. case compapiasynctask.FieldCallbackURL:
  10848. m.ResetCallbackURL()
  10849. return nil
  10850. case compapiasynctask.FieldCallbackResponseRaw:
  10851. m.ResetCallbackResponseRaw()
  10852. return nil
  10853. case compapiasynctask.FieldModel:
  10854. m.ResetModel()
  10855. return nil
  10856. case compapiasynctask.FieldTaskStatus:
  10857. m.ResetTaskStatus()
  10858. return nil
  10859. case compapiasynctask.FieldRetryCount:
  10860. m.ResetRetryCount()
  10861. return nil
  10862. case compapiasynctask.FieldLastError:
  10863. m.ResetLastError()
  10864. return nil
  10865. }
  10866. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10867. }
  10868. // AddedEdges returns all edge names that were set/added in this mutation.
  10869. func (m *CompapiAsynctaskMutation) AddedEdges() []string {
  10870. edges := make([]string, 0, 0)
  10871. return edges
  10872. }
  10873. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10874. // name in this mutation.
  10875. func (m *CompapiAsynctaskMutation) AddedIDs(name string) []ent.Value {
  10876. return nil
  10877. }
  10878. // RemovedEdges returns all edge names that were removed in this mutation.
  10879. func (m *CompapiAsynctaskMutation) RemovedEdges() []string {
  10880. edges := make([]string, 0, 0)
  10881. return edges
  10882. }
  10883. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10884. // the given name in this mutation.
  10885. func (m *CompapiAsynctaskMutation) RemovedIDs(name string) []ent.Value {
  10886. return nil
  10887. }
  10888. // ClearedEdges returns all edge names that were cleared in this mutation.
  10889. func (m *CompapiAsynctaskMutation) ClearedEdges() []string {
  10890. edges := make([]string, 0, 0)
  10891. return edges
  10892. }
  10893. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10894. // was cleared in this mutation.
  10895. func (m *CompapiAsynctaskMutation) EdgeCleared(name string) bool {
  10896. return false
  10897. }
  10898. // ClearEdge clears the value of the edge with the given name. It returns an error
  10899. // if that edge is not defined in the schema.
  10900. func (m *CompapiAsynctaskMutation) ClearEdge(name string) error {
  10901. return fmt.Errorf("unknown CompapiAsynctask unique edge %s", name)
  10902. }
  10903. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10904. // It returns an error if the edge is not defined in the schema.
  10905. func (m *CompapiAsynctaskMutation) ResetEdge(name string) error {
  10906. return fmt.Errorf("unknown CompapiAsynctask edge %s", name)
  10907. }
  10908. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  10909. type ContactMutation struct {
  10910. config
  10911. op Op
  10912. typ string
  10913. id *uint64
  10914. created_at *time.Time
  10915. updated_at *time.Time
  10916. status *uint8
  10917. addstatus *int8
  10918. deleted_at *time.Time
  10919. wx_wxid *string
  10920. _type *int
  10921. add_type *int
  10922. wxid *string
  10923. account *string
  10924. nickname *string
  10925. markname *string
  10926. headimg *string
  10927. sex *int
  10928. addsex *int
  10929. starrole *string
  10930. dontseeit *int
  10931. adddontseeit *int
  10932. dontseeme *int
  10933. adddontseeme *int
  10934. lag *string
  10935. gid *string
  10936. gname *string
  10937. v3 *string
  10938. organization_id *uint64
  10939. addorganization_id *int64
  10940. ctype *uint64
  10941. addctype *int64
  10942. cage *int
  10943. addcage *int
  10944. cname *string
  10945. carea *string
  10946. cbirthday *string
  10947. cbirtharea *string
  10948. cidcard_no *string
  10949. ctitle *string
  10950. cc *string
  10951. phone *string
  10952. clearedFields map[string]struct{}
  10953. contact_relationships map[uint64]struct{}
  10954. removedcontact_relationships map[uint64]struct{}
  10955. clearedcontact_relationships bool
  10956. contact_fields map[uint64]struct{}
  10957. removedcontact_fields map[uint64]struct{}
  10958. clearedcontact_fields bool
  10959. contact_messages map[uint64]struct{}
  10960. removedcontact_messages map[uint64]struct{}
  10961. clearedcontact_messages bool
  10962. done bool
  10963. oldValue func(context.Context) (*Contact, error)
  10964. predicates []predicate.Contact
  10965. }
  10966. var _ ent.Mutation = (*ContactMutation)(nil)
  10967. // contactOption allows management of the mutation configuration using functional options.
  10968. type contactOption func(*ContactMutation)
  10969. // newContactMutation creates new mutation for the Contact entity.
  10970. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  10971. m := &ContactMutation{
  10972. config: c,
  10973. op: op,
  10974. typ: TypeContact,
  10975. clearedFields: make(map[string]struct{}),
  10976. }
  10977. for _, opt := range opts {
  10978. opt(m)
  10979. }
  10980. return m
  10981. }
  10982. // withContactID sets the ID field of the mutation.
  10983. func withContactID(id uint64) contactOption {
  10984. return func(m *ContactMutation) {
  10985. var (
  10986. err error
  10987. once sync.Once
  10988. value *Contact
  10989. )
  10990. m.oldValue = func(ctx context.Context) (*Contact, error) {
  10991. once.Do(func() {
  10992. if m.done {
  10993. err = errors.New("querying old values post mutation is not allowed")
  10994. } else {
  10995. value, err = m.Client().Contact.Get(ctx, id)
  10996. }
  10997. })
  10998. return value, err
  10999. }
  11000. m.id = &id
  11001. }
  11002. }
  11003. // withContact sets the old Contact of the mutation.
  11004. func withContact(node *Contact) contactOption {
  11005. return func(m *ContactMutation) {
  11006. m.oldValue = func(context.Context) (*Contact, error) {
  11007. return node, nil
  11008. }
  11009. m.id = &node.ID
  11010. }
  11011. }
  11012. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11013. // executed in a transaction (ent.Tx), a transactional client is returned.
  11014. func (m ContactMutation) Client() *Client {
  11015. client := &Client{config: m.config}
  11016. client.init()
  11017. return client
  11018. }
  11019. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11020. // it returns an error otherwise.
  11021. func (m ContactMutation) Tx() (*Tx, error) {
  11022. if _, ok := m.driver.(*txDriver); !ok {
  11023. return nil, errors.New("ent: mutation is not running in a transaction")
  11024. }
  11025. tx := &Tx{config: m.config}
  11026. tx.init()
  11027. return tx, nil
  11028. }
  11029. // SetID sets the value of the id field. Note that this
  11030. // operation is only accepted on creation of Contact entities.
  11031. func (m *ContactMutation) SetID(id uint64) {
  11032. m.id = &id
  11033. }
  11034. // ID returns the ID value in the mutation. Note that the ID is only available
  11035. // if it was provided to the builder or after it was returned from the database.
  11036. func (m *ContactMutation) ID() (id uint64, exists bool) {
  11037. if m.id == nil {
  11038. return
  11039. }
  11040. return *m.id, true
  11041. }
  11042. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11043. // That means, if the mutation is applied within a transaction with an isolation level such
  11044. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11045. // or updated by the mutation.
  11046. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  11047. switch {
  11048. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11049. id, exists := m.ID()
  11050. if exists {
  11051. return []uint64{id}, nil
  11052. }
  11053. fallthrough
  11054. case m.op.Is(OpUpdate | OpDelete):
  11055. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  11056. default:
  11057. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11058. }
  11059. }
  11060. // SetCreatedAt sets the "created_at" field.
  11061. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  11062. m.created_at = &t
  11063. }
  11064. // CreatedAt returns the value of the "created_at" field in the mutation.
  11065. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  11066. v := m.created_at
  11067. if v == nil {
  11068. return
  11069. }
  11070. return *v, true
  11071. }
  11072. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  11073. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11075. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11076. if !m.op.Is(OpUpdateOne) {
  11077. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11078. }
  11079. if m.id == nil || m.oldValue == nil {
  11080. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11081. }
  11082. oldValue, err := m.oldValue(ctx)
  11083. if err != nil {
  11084. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11085. }
  11086. return oldValue.CreatedAt, nil
  11087. }
  11088. // ResetCreatedAt resets all changes to the "created_at" field.
  11089. func (m *ContactMutation) ResetCreatedAt() {
  11090. m.created_at = nil
  11091. }
  11092. // SetUpdatedAt sets the "updated_at" field.
  11093. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  11094. m.updated_at = &t
  11095. }
  11096. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11097. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  11098. v := m.updated_at
  11099. if v == nil {
  11100. return
  11101. }
  11102. return *v, true
  11103. }
  11104. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  11105. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11107. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11108. if !m.op.Is(OpUpdateOne) {
  11109. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11110. }
  11111. if m.id == nil || m.oldValue == nil {
  11112. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11113. }
  11114. oldValue, err := m.oldValue(ctx)
  11115. if err != nil {
  11116. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11117. }
  11118. return oldValue.UpdatedAt, nil
  11119. }
  11120. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11121. func (m *ContactMutation) ResetUpdatedAt() {
  11122. m.updated_at = nil
  11123. }
  11124. // SetStatus sets the "status" field.
  11125. func (m *ContactMutation) SetStatus(u uint8) {
  11126. m.status = &u
  11127. m.addstatus = nil
  11128. }
  11129. // Status returns the value of the "status" field in the mutation.
  11130. func (m *ContactMutation) Status() (r uint8, exists bool) {
  11131. v := m.status
  11132. if v == nil {
  11133. return
  11134. }
  11135. return *v, true
  11136. }
  11137. // OldStatus returns the old "status" field's value of the Contact entity.
  11138. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11140. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11141. if !m.op.Is(OpUpdateOne) {
  11142. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11143. }
  11144. if m.id == nil || m.oldValue == nil {
  11145. return v, errors.New("OldStatus requires an ID field in the mutation")
  11146. }
  11147. oldValue, err := m.oldValue(ctx)
  11148. if err != nil {
  11149. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11150. }
  11151. return oldValue.Status, nil
  11152. }
  11153. // AddStatus adds u to the "status" field.
  11154. func (m *ContactMutation) AddStatus(u int8) {
  11155. if m.addstatus != nil {
  11156. *m.addstatus += u
  11157. } else {
  11158. m.addstatus = &u
  11159. }
  11160. }
  11161. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11162. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  11163. v := m.addstatus
  11164. if v == nil {
  11165. return
  11166. }
  11167. return *v, true
  11168. }
  11169. // ClearStatus clears the value of the "status" field.
  11170. func (m *ContactMutation) ClearStatus() {
  11171. m.status = nil
  11172. m.addstatus = nil
  11173. m.clearedFields[contact.FieldStatus] = struct{}{}
  11174. }
  11175. // StatusCleared returns if the "status" field was cleared in this mutation.
  11176. func (m *ContactMutation) StatusCleared() bool {
  11177. _, ok := m.clearedFields[contact.FieldStatus]
  11178. return ok
  11179. }
  11180. // ResetStatus resets all changes to the "status" field.
  11181. func (m *ContactMutation) ResetStatus() {
  11182. m.status = nil
  11183. m.addstatus = nil
  11184. delete(m.clearedFields, contact.FieldStatus)
  11185. }
  11186. // SetDeletedAt sets the "deleted_at" field.
  11187. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  11188. m.deleted_at = &t
  11189. }
  11190. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11191. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  11192. v := m.deleted_at
  11193. if v == nil {
  11194. return
  11195. }
  11196. return *v, true
  11197. }
  11198. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  11199. // If the Contact 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 *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11202. if !m.op.Is(OpUpdateOne) {
  11203. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11204. }
  11205. if m.id == nil || m.oldValue == nil {
  11206. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  11211. }
  11212. return oldValue.DeletedAt, nil
  11213. }
  11214. // ClearDeletedAt clears the value of the "deleted_at" field.
  11215. func (m *ContactMutation) ClearDeletedAt() {
  11216. m.deleted_at = nil
  11217. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  11218. }
  11219. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11220. func (m *ContactMutation) DeletedAtCleared() bool {
  11221. _, ok := m.clearedFields[contact.FieldDeletedAt]
  11222. return ok
  11223. }
  11224. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11225. func (m *ContactMutation) ResetDeletedAt() {
  11226. m.deleted_at = nil
  11227. delete(m.clearedFields, contact.FieldDeletedAt)
  11228. }
  11229. // SetWxWxid sets the "wx_wxid" field.
  11230. func (m *ContactMutation) SetWxWxid(s string) {
  11231. m.wx_wxid = &s
  11232. }
  11233. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  11234. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  11235. v := m.wx_wxid
  11236. if v == nil {
  11237. return
  11238. }
  11239. return *v, true
  11240. }
  11241. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  11242. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11244. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  11245. if !m.op.Is(OpUpdateOne) {
  11246. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  11247. }
  11248. if m.id == nil || m.oldValue == nil {
  11249. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  11250. }
  11251. oldValue, err := m.oldValue(ctx)
  11252. if err != nil {
  11253. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  11254. }
  11255. return oldValue.WxWxid, nil
  11256. }
  11257. // ResetWxWxid resets all changes to the "wx_wxid" field.
  11258. func (m *ContactMutation) ResetWxWxid() {
  11259. m.wx_wxid = nil
  11260. }
  11261. // SetType sets the "type" field.
  11262. func (m *ContactMutation) SetType(i int) {
  11263. m._type = &i
  11264. m.add_type = nil
  11265. }
  11266. // GetType returns the value of the "type" field in the mutation.
  11267. func (m *ContactMutation) GetType() (r int, exists bool) {
  11268. v := m._type
  11269. if v == nil {
  11270. return
  11271. }
  11272. return *v, true
  11273. }
  11274. // OldType returns the old "type" field's value of the Contact entity.
  11275. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11277. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  11278. if !m.op.Is(OpUpdateOne) {
  11279. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11280. }
  11281. if m.id == nil || m.oldValue == nil {
  11282. return v, errors.New("OldType requires an ID field in the mutation")
  11283. }
  11284. oldValue, err := m.oldValue(ctx)
  11285. if err != nil {
  11286. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11287. }
  11288. return oldValue.Type, nil
  11289. }
  11290. // AddType adds i to the "type" field.
  11291. func (m *ContactMutation) AddType(i int) {
  11292. if m.add_type != nil {
  11293. *m.add_type += i
  11294. } else {
  11295. m.add_type = &i
  11296. }
  11297. }
  11298. // AddedType returns the value that was added to the "type" field in this mutation.
  11299. func (m *ContactMutation) AddedType() (r int, exists bool) {
  11300. v := m.add_type
  11301. if v == nil {
  11302. return
  11303. }
  11304. return *v, true
  11305. }
  11306. // ClearType clears the value of the "type" field.
  11307. func (m *ContactMutation) ClearType() {
  11308. m._type = nil
  11309. m.add_type = nil
  11310. m.clearedFields[contact.FieldType] = struct{}{}
  11311. }
  11312. // TypeCleared returns if the "type" field was cleared in this mutation.
  11313. func (m *ContactMutation) TypeCleared() bool {
  11314. _, ok := m.clearedFields[contact.FieldType]
  11315. return ok
  11316. }
  11317. // ResetType resets all changes to the "type" field.
  11318. func (m *ContactMutation) ResetType() {
  11319. m._type = nil
  11320. m.add_type = nil
  11321. delete(m.clearedFields, contact.FieldType)
  11322. }
  11323. // SetWxid sets the "wxid" field.
  11324. func (m *ContactMutation) SetWxid(s string) {
  11325. m.wxid = &s
  11326. }
  11327. // Wxid returns the value of the "wxid" field in the mutation.
  11328. func (m *ContactMutation) Wxid() (r string, exists bool) {
  11329. v := m.wxid
  11330. if v == nil {
  11331. return
  11332. }
  11333. return *v, true
  11334. }
  11335. // OldWxid returns the old "wxid" field's value of the Contact entity.
  11336. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11338. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  11339. if !m.op.Is(OpUpdateOne) {
  11340. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  11341. }
  11342. if m.id == nil || m.oldValue == nil {
  11343. return v, errors.New("OldWxid requires an ID field in the mutation")
  11344. }
  11345. oldValue, err := m.oldValue(ctx)
  11346. if err != nil {
  11347. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  11348. }
  11349. return oldValue.Wxid, nil
  11350. }
  11351. // ResetWxid resets all changes to the "wxid" field.
  11352. func (m *ContactMutation) ResetWxid() {
  11353. m.wxid = nil
  11354. }
  11355. // SetAccount sets the "account" field.
  11356. func (m *ContactMutation) SetAccount(s string) {
  11357. m.account = &s
  11358. }
  11359. // Account returns the value of the "account" field in the mutation.
  11360. func (m *ContactMutation) Account() (r string, exists bool) {
  11361. v := m.account
  11362. if v == nil {
  11363. return
  11364. }
  11365. return *v, true
  11366. }
  11367. // OldAccount returns the old "account" field's value of the Contact entity.
  11368. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11370. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  11371. if !m.op.Is(OpUpdateOne) {
  11372. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  11373. }
  11374. if m.id == nil || m.oldValue == nil {
  11375. return v, errors.New("OldAccount requires an ID field in the mutation")
  11376. }
  11377. oldValue, err := m.oldValue(ctx)
  11378. if err != nil {
  11379. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  11380. }
  11381. return oldValue.Account, nil
  11382. }
  11383. // ResetAccount resets all changes to the "account" field.
  11384. func (m *ContactMutation) ResetAccount() {
  11385. m.account = nil
  11386. }
  11387. // SetNickname sets the "nickname" field.
  11388. func (m *ContactMutation) SetNickname(s string) {
  11389. m.nickname = &s
  11390. }
  11391. // Nickname returns the value of the "nickname" field in the mutation.
  11392. func (m *ContactMutation) Nickname() (r string, exists bool) {
  11393. v := m.nickname
  11394. if v == nil {
  11395. return
  11396. }
  11397. return *v, true
  11398. }
  11399. // OldNickname returns the old "nickname" field's value of the Contact entity.
  11400. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11402. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  11403. if !m.op.Is(OpUpdateOne) {
  11404. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  11405. }
  11406. if m.id == nil || m.oldValue == nil {
  11407. return v, errors.New("OldNickname requires an ID field in the mutation")
  11408. }
  11409. oldValue, err := m.oldValue(ctx)
  11410. if err != nil {
  11411. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  11412. }
  11413. return oldValue.Nickname, nil
  11414. }
  11415. // ResetNickname resets all changes to the "nickname" field.
  11416. func (m *ContactMutation) ResetNickname() {
  11417. m.nickname = nil
  11418. }
  11419. // SetMarkname sets the "markname" field.
  11420. func (m *ContactMutation) SetMarkname(s string) {
  11421. m.markname = &s
  11422. }
  11423. // Markname returns the value of the "markname" field in the mutation.
  11424. func (m *ContactMutation) Markname() (r string, exists bool) {
  11425. v := m.markname
  11426. if v == nil {
  11427. return
  11428. }
  11429. return *v, true
  11430. }
  11431. // OldMarkname returns the old "markname" field's value of the Contact entity.
  11432. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11434. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  11435. if !m.op.Is(OpUpdateOne) {
  11436. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  11437. }
  11438. if m.id == nil || m.oldValue == nil {
  11439. return v, errors.New("OldMarkname requires an ID field in the mutation")
  11440. }
  11441. oldValue, err := m.oldValue(ctx)
  11442. if err != nil {
  11443. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  11444. }
  11445. return oldValue.Markname, nil
  11446. }
  11447. // ResetMarkname resets all changes to the "markname" field.
  11448. func (m *ContactMutation) ResetMarkname() {
  11449. m.markname = nil
  11450. }
  11451. // SetHeadimg sets the "headimg" field.
  11452. func (m *ContactMutation) SetHeadimg(s string) {
  11453. m.headimg = &s
  11454. }
  11455. // Headimg returns the value of the "headimg" field in the mutation.
  11456. func (m *ContactMutation) Headimg() (r string, exists bool) {
  11457. v := m.headimg
  11458. if v == nil {
  11459. return
  11460. }
  11461. return *v, true
  11462. }
  11463. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  11464. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11466. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  11467. if !m.op.Is(OpUpdateOne) {
  11468. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  11469. }
  11470. if m.id == nil || m.oldValue == nil {
  11471. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  11472. }
  11473. oldValue, err := m.oldValue(ctx)
  11474. if err != nil {
  11475. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  11476. }
  11477. return oldValue.Headimg, nil
  11478. }
  11479. // ResetHeadimg resets all changes to the "headimg" field.
  11480. func (m *ContactMutation) ResetHeadimg() {
  11481. m.headimg = nil
  11482. }
  11483. // SetSex sets the "sex" field.
  11484. func (m *ContactMutation) SetSex(i int) {
  11485. m.sex = &i
  11486. m.addsex = nil
  11487. }
  11488. // Sex returns the value of the "sex" field in the mutation.
  11489. func (m *ContactMutation) Sex() (r int, exists bool) {
  11490. v := m.sex
  11491. if v == nil {
  11492. return
  11493. }
  11494. return *v, true
  11495. }
  11496. // OldSex returns the old "sex" field's value of the Contact entity.
  11497. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11499. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  11500. if !m.op.Is(OpUpdateOne) {
  11501. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  11502. }
  11503. if m.id == nil || m.oldValue == nil {
  11504. return v, errors.New("OldSex requires an ID field in the mutation")
  11505. }
  11506. oldValue, err := m.oldValue(ctx)
  11507. if err != nil {
  11508. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  11509. }
  11510. return oldValue.Sex, nil
  11511. }
  11512. // AddSex adds i to the "sex" field.
  11513. func (m *ContactMutation) AddSex(i int) {
  11514. if m.addsex != nil {
  11515. *m.addsex += i
  11516. } else {
  11517. m.addsex = &i
  11518. }
  11519. }
  11520. // AddedSex returns the value that was added to the "sex" field in this mutation.
  11521. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  11522. v := m.addsex
  11523. if v == nil {
  11524. return
  11525. }
  11526. return *v, true
  11527. }
  11528. // ResetSex resets all changes to the "sex" field.
  11529. func (m *ContactMutation) ResetSex() {
  11530. m.sex = nil
  11531. m.addsex = nil
  11532. }
  11533. // SetStarrole sets the "starrole" field.
  11534. func (m *ContactMutation) SetStarrole(s string) {
  11535. m.starrole = &s
  11536. }
  11537. // Starrole returns the value of the "starrole" field in the mutation.
  11538. func (m *ContactMutation) Starrole() (r string, exists bool) {
  11539. v := m.starrole
  11540. if v == nil {
  11541. return
  11542. }
  11543. return *v, true
  11544. }
  11545. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  11546. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11548. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  11549. if !m.op.Is(OpUpdateOne) {
  11550. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  11551. }
  11552. if m.id == nil || m.oldValue == nil {
  11553. return v, errors.New("OldStarrole requires an ID field in the mutation")
  11554. }
  11555. oldValue, err := m.oldValue(ctx)
  11556. if err != nil {
  11557. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  11558. }
  11559. return oldValue.Starrole, nil
  11560. }
  11561. // ResetStarrole resets all changes to the "starrole" field.
  11562. func (m *ContactMutation) ResetStarrole() {
  11563. m.starrole = nil
  11564. }
  11565. // SetDontseeit sets the "dontseeit" field.
  11566. func (m *ContactMutation) SetDontseeit(i int) {
  11567. m.dontseeit = &i
  11568. m.adddontseeit = nil
  11569. }
  11570. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  11571. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  11572. v := m.dontseeit
  11573. if v == nil {
  11574. return
  11575. }
  11576. return *v, true
  11577. }
  11578. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  11579. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11581. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  11582. if !m.op.Is(OpUpdateOne) {
  11583. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  11584. }
  11585. if m.id == nil || m.oldValue == nil {
  11586. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  11587. }
  11588. oldValue, err := m.oldValue(ctx)
  11589. if err != nil {
  11590. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  11591. }
  11592. return oldValue.Dontseeit, nil
  11593. }
  11594. // AddDontseeit adds i to the "dontseeit" field.
  11595. func (m *ContactMutation) AddDontseeit(i int) {
  11596. if m.adddontseeit != nil {
  11597. *m.adddontseeit += i
  11598. } else {
  11599. m.adddontseeit = &i
  11600. }
  11601. }
  11602. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  11603. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  11604. v := m.adddontseeit
  11605. if v == nil {
  11606. return
  11607. }
  11608. return *v, true
  11609. }
  11610. // ResetDontseeit resets all changes to the "dontseeit" field.
  11611. func (m *ContactMutation) ResetDontseeit() {
  11612. m.dontseeit = nil
  11613. m.adddontseeit = nil
  11614. }
  11615. // SetDontseeme sets the "dontseeme" field.
  11616. func (m *ContactMutation) SetDontseeme(i int) {
  11617. m.dontseeme = &i
  11618. m.adddontseeme = nil
  11619. }
  11620. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  11621. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  11622. v := m.dontseeme
  11623. if v == nil {
  11624. return
  11625. }
  11626. return *v, true
  11627. }
  11628. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  11629. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11631. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  11632. if !m.op.Is(OpUpdateOne) {
  11633. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  11634. }
  11635. if m.id == nil || m.oldValue == nil {
  11636. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  11637. }
  11638. oldValue, err := m.oldValue(ctx)
  11639. if err != nil {
  11640. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  11641. }
  11642. return oldValue.Dontseeme, nil
  11643. }
  11644. // AddDontseeme adds i to the "dontseeme" field.
  11645. func (m *ContactMutation) AddDontseeme(i int) {
  11646. if m.adddontseeme != nil {
  11647. *m.adddontseeme += i
  11648. } else {
  11649. m.adddontseeme = &i
  11650. }
  11651. }
  11652. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  11653. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  11654. v := m.adddontseeme
  11655. if v == nil {
  11656. return
  11657. }
  11658. return *v, true
  11659. }
  11660. // ResetDontseeme resets all changes to the "dontseeme" field.
  11661. func (m *ContactMutation) ResetDontseeme() {
  11662. m.dontseeme = nil
  11663. m.adddontseeme = nil
  11664. }
  11665. // SetLag sets the "lag" field.
  11666. func (m *ContactMutation) SetLag(s string) {
  11667. m.lag = &s
  11668. }
  11669. // Lag returns the value of the "lag" field in the mutation.
  11670. func (m *ContactMutation) Lag() (r string, exists bool) {
  11671. v := m.lag
  11672. if v == nil {
  11673. return
  11674. }
  11675. return *v, true
  11676. }
  11677. // OldLag returns the old "lag" field's value of the Contact entity.
  11678. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11680. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  11681. if !m.op.Is(OpUpdateOne) {
  11682. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  11683. }
  11684. if m.id == nil || m.oldValue == nil {
  11685. return v, errors.New("OldLag requires an ID field in the mutation")
  11686. }
  11687. oldValue, err := m.oldValue(ctx)
  11688. if err != nil {
  11689. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  11690. }
  11691. return oldValue.Lag, nil
  11692. }
  11693. // ResetLag resets all changes to the "lag" field.
  11694. func (m *ContactMutation) ResetLag() {
  11695. m.lag = nil
  11696. }
  11697. // SetGid sets the "gid" field.
  11698. func (m *ContactMutation) SetGid(s string) {
  11699. m.gid = &s
  11700. }
  11701. // Gid returns the value of the "gid" field in the mutation.
  11702. func (m *ContactMutation) Gid() (r string, exists bool) {
  11703. v := m.gid
  11704. if v == nil {
  11705. return
  11706. }
  11707. return *v, true
  11708. }
  11709. // OldGid returns the old "gid" field's value of the Contact entity.
  11710. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11712. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  11713. if !m.op.Is(OpUpdateOne) {
  11714. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  11715. }
  11716. if m.id == nil || m.oldValue == nil {
  11717. return v, errors.New("OldGid requires an ID field in the mutation")
  11718. }
  11719. oldValue, err := m.oldValue(ctx)
  11720. if err != nil {
  11721. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  11722. }
  11723. return oldValue.Gid, nil
  11724. }
  11725. // ResetGid resets all changes to the "gid" field.
  11726. func (m *ContactMutation) ResetGid() {
  11727. m.gid = nil
  11728. }
  11729. // SetGname sets the "gname" field.
  11730. func (m *ContactMutation) SetGname(s string) {
  11731. m.gname = &s
  11732. }
  11733. // Gname returns the value of the "gname" field in the mutation.
  11734. func (m *ContactMutation) Gname() (r string, exists bool) {
  11735. v := m.gname
  11736. if v == nil {
  11737. return
  11738. }
  11739. return *v, true
  11740. }
  11741. // OldGname returns the old "gname" field's value of the Contact entity.
  11742. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11744. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  11745. if !m.op.Is(OpUpdateOne) {
  11746. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  11747. }
  11748. if m.id == nil || m.oldValue == nil {
  11749. return v, errors.New("OldGname requires an ID field in the mutation")
  11750. }
  11751. oldValue, err := m.oldValue(ctx)
  11752. if err != nil {
  11753. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  11754. }
  11755. return oldValue.Gname, nil
  11756. }
  11757. // ResetGname resets all changes to the "gname" field.
  11758. func (m *ContactMutation) ResetGname() {
  11759. m.gname = nil
  11760. }
  11761. // SetV3 sets the "v3" field.
  11762. func (m *ContactMutation) SetV3(s string) {
  11763. m.v3 = &s
  11764. }
  11765. // V3 returns the value of the "v3" field in the mutation.
  11766. func (m *ContactMutation) V3() (r string, exists bool) {
  11767. v := m.v3
  11768. if v == nil {
  11769. return
  11770. }
  11771. return *v, true
  11772. }
  11773. // OldV3 returns the old "v3" field's value of the Contact entity.
  11774. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11776. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  11777. if !m.op.Is(OpUpdateOne) {
  11778. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  11779. }
  11780. if m.id == nil || m.oldValue == nil {
  11781. return v, errors.New("OldV3 requires an ID field in the mutation")
  11782. }
  11783. oldValue, err := m.oldValue(ctx)
  11784. if err != nil {
  11785. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  11786. }
  11787. return oldValue.V3, nil
  11788. }
  11789. // ResetV3 resets all changes to the "v3" field.
  11790. func (m *ContactMutation) ResetV3() {
  11791. m.v3 = nil
  11792. }
  11793. // SetOrganizationID sets the "organization_id" field.
  11794. func (m *ContactMutation) SetOrganizationID(u uint64) {
  11795. m.organization_id = &u
  11796. m.addorganization_id = nil
  11797. }
  11798. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11799. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  11800. v := m.organization_id
  11801. if v == nil {
  11802. return
  11803. }
  11804. return *v, true
  11805. }
  11806. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  11807. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11809. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11810. if !m.op.Is(OpUpdateOne) {
  11811. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11812. }
  11813. if m.id == nil || m.oldValue == nil {
  11814. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11815. }
  11816. oldValue, err := m.oldValue(ctx)
  11817. if err != nil {
  11818. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11819. }
  11820. return oldValue.OrganizationID, nil
  11821. }
  11822. // AddOrganizationID adds u to the "organization_id" field.
  11823. func (m *ContactMutation) AddOrganizationID(u int64) {
  11824. if m.addorganization_id != nil {
  11825. *m.addorganization_id += u
  11826. } else {
  11827. m.addorganization_id = &u
  11828. }
  11829. }
  11830. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11831. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  11832. v := m.addorganization_id
  11833. if v == nil {
  11834. return
  11835. }
  11836. return *v, true
  11837. }
  11838. // ClearOrganizationID clears the value of the "organization_id" field.
  11839. func (m *ContactMutation) ClearOrganizationID() {
  11840. m.organization_id = nil
  11841. m.addorganization_id = nil
  11842. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  11843. }
  11844. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11845. func (m *ContactMutation) OrganizationIDCleared() bool {
  11846. _, ok := m.clearedFields[contact.FieldOrganizationID]
  11847. return ok
  11848. }
  11849. // ResetOrganizationID resets all changes to the "organization_id" field.
  11850. func (m *ContactMutation) ResetOrganizationID() {
  11851. m.organization_id = nil
  11852. m.addorganization_id = nil
  11853. delete(m.clearedFields, contact.FieldOrganizationID)
  11854. }
  11855. // SetCtype sets the "ctype" field.
  11856. func (m *ContactMutation) SetCtype(u uint64) {
  11857. m.ctype = &u
  11858. m.addctype = nil
  11859. }
  11860. // Ctype returns the value of the "ctype" field in the mutation.
  11861. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  11862. v := m.ctype
  11863. if v == nil {
  11864. return
  11865. }
  11866. return *v, true
  11867. }
  11868. // OldCtype returns the old "ctype" field's value of the Contact entity.
  11869. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11871. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  11872. if !m.op.Is(OpUpdateOne) {
  11873. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  11874. }
  11875. if m.id == nil || m.oldValue == nil {
  11876. return v, errors.New("OldCtype requires an ID field in the mutation")
  11877. }
  11878. oldValue, err := m.oldValue(ctx)
  11879. if err != nil {
  11880. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  11881. }
  11882. return oldValue.Ctype, nil
  11883. }
  11884. // AddCtype adds u to the "ctype" field.
  11885. func (m *ContactMutation) AddCtype(u int64) {
  11886. if m.addctype != nil {
  11887. *m.addctype += u
  11888. } else {
  11889. m.addctype = &u
  11890. }
  11891. }
  11892. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  11893. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  11894. v := m.addctype
  11895. if v == nil {
  11896. return
  11897. }
  11898. return *v, true
  11899. }
  11900. // ResetCtype resets all changes to the "ctype" field.
  11901. func (m *ContactMutation) ResetCtype() {
  11902. m.ctype = nil
  11903. m.addctype = nil
  11904. }
  11905. // SetCage sets the "cage" field.
  11906. func (m *ContactMutation) SetCage(i int) {
  11907. m.cage = &i
  11908. m.addcage = nil
  11909. }
  11910. // Cage returns the value of the "cage" field in the mutation.
  11911. func (m *ContactMutation) Cage() (r int, exists bool) {
  11912. v := m.cage
  11913. if v == nil {
  11914. return
  11915. }
  11916. return *v, true
  11917. }
  11918. // OldCage returns the old "cage" field's value of the Contact entity.
  11919. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11921. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  11922. if !m.op.Is(OpUpdateOne) {
  11923. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  11924. }
  11925. if m.id == nil || m.oldValue == nil {
  11926. return v, errors.New("OldCage requires an ID field in the mutation")
  11927. }
  11928. oldValue, err := m.oldValue(ctx)
  11929. if err != nil {
  11930. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  11931. }
  11932. return oldValue.Cage, nil
  11933. }
  11934. // AddCage adds i to the "cage" field.
  11935. func (m *ContactMutation) AddCage(i int) {
  11936. if m.addcage != nil {
  11937. *m.addcage += i
  11938. } else {
  11939. m.addcage = &i
  11940. }
  11941. }
  11942. // AddedCage returns the value that was added to the "cage" field in this mutation.
  11943. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  11944. v := m.addcage
  11945. if v == nil {
  11946. return
  11947. }
  11948. return *v, true
  11949. }
  11950. // ResetCage resets all changes to the "cage" field.
  11951. func (m *ContactMutation) ResetCage() {
  11952. m.cage = nil
  11953. m.addcage = nil
  11954. }
  11955. // SetCname sets the "cname" field.
  11956. func (m *ContactMutation) SetCname(s string) {
  11957. m.cname = &s
  11958. }
  11959. // Cname returns the value of the "cname" field in the mutation.
  11960. func (m *ContactMutation) Cname() (r string, exists bool) {
  11961. v := m.cname
  11962. if v == nil {
  11963. return
  11964. }
  11965. return *v, true
  11966. }
  11967. // OldCname returns the old "cname" field's value of the Contact entity.
  11968. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11970. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  11971. if !m.op.Is(OpUpdateOne) {
  11972. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  11973. }
  11974. if m.id == nil || m.oldValue == nil {
  11975. return v, errors.New("OldCname requires an ID field in the mutation")
  11976. }
  11977. oldValue, err := m.oldValue(ctx)
  11978. if err != nil {
  11979. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  11980. }
  11981. return oldValue.Cname, nil
  11982. }
  11983. // ResetCname resets all changes to the "cname" field.
  11984. func (m *ContactMutation) ResetCname() {
  11985. m.cname = nil
  11986. }
  11987. // SetCarea sets the "carea" field.
  11988. func (m *ContactMutation) SetCarea(s string) {
  11989. m.carea = &s
  11990. }
  11991. // Carea returns the value of the "carea" field in the mutation.
  11992. func (m *ContactMutation) Carea() (r string, exists bool) {
  11993. v := m.carea
  11994. if v == nil {
  11995. return
  11996. }
  11997. return *v, true
  11998. }
  11999. // OldCarea returns the old "carea" field's value of the Contact entity.
  12000. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12002. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  12003. if !m.op.Is(OpUpdateOne) {
  12004. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  12005. }
  12006. if m.id == nil || m.oldValue == nil {
  12007. return v, errors.New("OldCarea requires an ID field in the mutation")
  12008. }
  12009. oldValue, err := m.oldValue(ctx)
  12010. if err != nil {
  12011. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  12012. }
  12013. return oldValue.Carea, nil
  12014. }
  12015. // ResetCarea resets all changes to the "carea" field.
  12016. func (m *ContactMutation) ResetCarea() {
  12017. m.carea = nil
  12018. }
  12019. // SetCbirthday sets the "cbirthday" field.
  12020. func (m *ContactMutation) SetCbirthday(s string) {
  12021. m.cbirthday = &s
  12022. }
  12023. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  12024. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  12025. v := m.cbirthday
  12026. if v == nil {
  12027. return
  12028. }
  12029. return *v, true
  12030. }
  12031. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  12032. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12034. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  12035. if !m.op.Is(OpUpdateOne) {
  12036. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  12037. }
  12038. if m.id == nil || m.oldValue == nil {
  12039. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  12040. }
  12041. oldValue, err := m.oldValue(ctx)
  12042. if err != nil {
  12043. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  12044. }
  12045. return oldValue.Cbirthday, nil
  12046. }
  12047. // ResetCbirthday resets all changes to the "cbirthday" field.
  12048. func (m *ContactMutation) ResetCbirthday() {
  12049. m.cbirthday = nil
  12050. }
  12051. // SetCbirtharea sets the "cbirtharea" field.
  12052. func (m *ContactMutation) SetCbirtharea(s string) {
  12053. m.cbirtharea = &s
  12054. }
  12055. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  12056. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  12057. v := m.cbirtharea
  12058. if v == nil {
  12059. return
  12060. }
  12061. return *v, true
  12062. }
  12063. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  12064. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12066. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  12067. if !m.op.Is(OpUpdateOne) {
  12068. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  12069. }
  12070. if m.id == nil || m.oldValue == nil {
  12071. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  12072. }
  12073. oldValue, err := m.oldValue(ctx)
  12074. if err != nil {
  12075. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  12076. }
  12077. return oldValue.Cbirtharea, nil
  12078. }
  12079. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  12080. func (m *ContactMutation) ResetCbirtharea() {
  12081. m.cbirtharea = nil
  12082. }
  12083. // SetCidcardNo sets the "cidcard_no" field.
  12084. func (m *ContactMutation) SetCidcardNo(s string) {
  12085. m.cidcard_no = &s
  12086. }
  12087. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  12088. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  12089. v := m.cidcard_no
  12090. if v == nil {
  12091. return
  12092. }
  12093. return *v, true
  12094. }
  12095. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  12096. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12098. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  12099. if !m.op.Is(OpUpdateOne) {
  12100. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  12101. }
  12102. if m.id == nil || m.oldValue == nil {
  12103. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  12104. }
  12105. oldValue, err := m.oldValue(ctx)
  12106. if err != nil {
  12107. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  12108. }
  12109. return oldValue.CidcardNo, nil
  12110. }
  12111. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  12112. func (m *ContactMutation) ResetCidcardNo() {
  12113. m.cidcard_no = nil
  12114. }
  12115. // SetCtitle sets the "ctitle" field.
  12116. func (m *ContactMutation) SetCtitle(s string) {
  12117. m.ctitle = &s
  12118. }
  12119. // Ctitle returns the value of the "ctitle" field in the mutation.
  12120. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  12121. v := m.ctitle
  12122. if v == nil {
  12123. return
  12124. }
  12125. return *v, true
  12126. }
  12127. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  12128. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12130. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  12131. if !m.op.Is(OpUpdateOne) {
  12132. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  12133. }
  12134. if m.id == nil || m.oldValue == nil {
  12135. return v, errors.New("OldCtitle requires an ID field in the mutation")
  12136. }
  12137. oldValue, err := m.oldValue(ctx)
  12138. if err != nil {
  12139. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  12140. }
  12141. return oldValue.Ctitle, nil
  12142. }
  12143. // ResetCtitle resets all changes to the "ctitle" field.
  12144. func (m *ContactMutation) ResetCtitle() {
  12145. m.ctitle = nil
  12146. }
  12147. // SetCc sets the "cc" field.
  12148. func (m *ContactMutation) SetCc(s string) {
  12149. m.cc = &s
  12150. }
  12151. // Cc returns the value of the "cc" field in the mutation.
  12152. func (m *ContactMutation) Cc() (r string, exists bool) {
  12153. v := m.cc
  12154. if v == nil {
  12155. return
  12156. }
  12157. return *v, true
  12158. }
  12159. // OldCc returns the old "cc" field's value of the Contact entity.
  12160. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12162. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  12163. if !m.op.Is(OpUpdateOne) {
  12164. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  12165. }
  12166. if m.id == nil || m.oldValue == nil {
  12167. return v, errors.New("OldCc requires an ID field in the mutation")
  12168. }
  12169. oldValue, err := m.oldValue(ctx)
  12170. if err != nil {
  12171. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  12172. }
  12173. return oldValue.Cc, nil
  12174. }
  12175. // ResetCc resets all changes to the "cc" field.
  12176. func (m *ContactMutation) ResetCc() {
  12177. m.cc = nil
  12178. }
  12179. // SetPhone sets the "phone" field.
  12180. func (m *ContactMutation) SetPhone(s string) {
  12181. m.phone = &s
  12182. }
  12183. // Phone returns the value of the "phone" field in the mutation.
  12184. func (m *ContactMutation) Phone() (r string, exists bool) {
  12185. v := m.phone
  12186. if v == nil {
  12187. return
  12188. }
  12189. return *v, true
  12190. }
  12191. // OldPhone returns the old "phone" field's value of the Contact entity.
  12192. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12194. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  12195. if !m.op.Is(OpUpdateOne) {
  12196. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  12197. }
  12198. if m.id == nil || m.oldValue == nil {
  12199. return v, errors.New("OldPhone requires an ID field in the mutation")
  12200. }
  12201. oldValue, err := m.oldValue(ctx)
  12202. if err != nil {
  12203. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  12204. }
  12205. return oldValue.Phone, nil
  12206. }
  12207. // ResetPhone resets all changes to the "phone" field.
  12208. func (m *ContactMutation) ResetPhone() {
  12209. m.phone = nil
  12210. }
  12211. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  12212. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  12213. if m.contact_relationships == nil {
  12214. m.contact_relationships = make(map[uint64]struct{})
  12215. }
  12216. for i := range ids {
  12217. m.contact_relationships[ids[i]] = struct{}{}
  12218. }
  12219. }
  12220. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  12221. func (m *ContactMutation) ClearContactRelationships() {
  12222. m.clearedcontact_relationships = true
  12223. }
  12224. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  12225. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  12226. return m.clearedcontact_relationships
  12227. }
  12228. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  12229. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  12230. if m.removedcontact_relationships == nil {
  12231. m.removedcontact_relationships = make(map[uint64]struct{})
  12232. }
  12233. for i := range ids {
  12234. delete(m.contact_relationships, ids[i])
  12235. m.removedcontact_relationships[ids[i]] = struct{}{}
  12236. }
  12237. }
  12238. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  12239. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  12240. for id := range m.removedcontact_relationships {
  12241. ids = append(ids, id)
  12242. }
  12243. return
  12244. }
  12245. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  12246. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  12247. for id := range m.contact_relationships {
  12248. ids = append(ids, id)
  12249. }
  12250. return
  12251. }
  12252. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  12253. func (m *ContactMutation) ResetContactRelationships() {
  12254. m.contact_relationships = nil
  12255. m.clearedcontact_relationships = false
  12256. m.removedcontact_relationships = nil
  12257. }
  12258. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
  12259. func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
  12260. if m.contact_fields == nil {
  12261. m.contact_fields = make(map[uint64]struct{})
  12262. }
  12263. for i := range ids {
  12264. m.contact_fields[ids[i]] = struct{}{}
  12265. }
  12266. }
  12267. // ClearContactFields clears the "contact_fields" edge to the ContactField entity.
  12268. func (m *ContactMutation) ClearContactFields() {
  12269. m.clearedcontact_fields = true
  12270. }
  12271. // ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
  12272. func (m *ContactMutation) ContactFieldsCleared() bool {
  12273. return m.clearedcontact_fields
  12274. }
  12275. // RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
  12276. func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
  12277. if m.removedcontact_fields == nil {
  12278. m.removedcontact_fields = make(map[uint64]struct{})
  12279. }
  12280. for i := range ids {
  12281. delete(m.contact_fields, ids[i])
  12282. m.removedcontact_fields[ids[i]] = struct{}{}
  12283. }
  12284. }
  12285. // RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
  12286. func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
  12287. for id := range m.removedcontact_fields {
  12288. ids = append(ids, id)
  12289. }
  12290. return
  12291. }
  12292. // ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
  12293. func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
  12294. for id := range m.contact_fields {
  12295. ids = append(ids, id)
  12296. }
  12297. return
  12298. }
  12299. // ResetContactFields resets all changes to the "contact_fields" edge.
  12300. func (m *ContactMutation) ResetContactFields() {
  12301. m.contact_fields = nil
  12302. m.clearedcontact_fields = false
  12303. m.removedcontact_fields = nil
  12304. }
  12305. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  12306. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  12307. if m.contact_messages == nil {
  12308. m.contact_messages = make(map[uint64]struct{})
  12309. }
  12310. for i := range ids {
  12311. m.contact_messages[ids[i]] = struct{}{}
  12312. }
  12313. }
  12314. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  12315. func (m *ContactMutation) ClearContactMessages() {
  12316. m.clearedcontact_messages = true
  12317. }
  12318. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  12319. func (m *ContactMutation) ContactMessagesCleared() bool {
  12320. return m.clearedcontact_messages
  12321. }
  12322. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  12323. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  12324. if m.removedcontact_messages == nil {
  12325. m.removedcontact_messages = make(map[uint64]struct{})
  12326. }
  12327. for i := range ids {
  12328. delete(m.contact_messages, ids[i])
  12329. m.removedcontact_messages[ids[i]] = struct{}{}
  12330. }
  12331. }
  12332. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  12333. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  12334. for id := range m.removedcontact_messages {
  12335. ids = append(ids, id)
  12336. }
  12337. return
  12338. }
  12339. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  12340. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  12341. for id := range m.contact_messages {
  12342. ids = append(ids, id)
  12343. }
  12344. return
  12345. }
  12346. // ResetContactMessages resets all changes to the "contact_messages" edge.
  12347. func (m *ContactMutation) ResetContactMessages() {
  12348. m.contact_messages = nil
  12349. m.clearedcontact_messages = false
  12350. m.removedcontact_messages = nil
  12351. }
  12352. // Where appends a list predicates to the ContactMutation builder.
  12353. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  12354. m.predicates = append(m.predicates, ps...)
  12355. }
  12356. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  12357. // users can use type-assertion to append predicates that do not depend on any generated package.
  12358. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  12359. p := make([]predicate.Contact, len(ps))
  12360. for i := range ps {
  12361. p[i] = ps[i]
  12362. }
  12363. m.Where(p...)
  12364. }
  12365. // Op returns the operation name.
  12366. func (m *ContactMutation) Op() Op {
  12367. return m.op
  12368. }
  12369. // SetOp allows setting the mutation operation.
  12370. func (m *ContactMutation) SetOp(op Op) {
  12371. m.op = op
  12372. }
  12373. // Type returns the node type of this mutation (Contact).
  12374. func (m *ContactMutation) Type() string {
  12375. return m.typ
  12376. }
  12377. // Fields returns all fields that were changed during this mutation. Note that in
  12378. // order to get all numeric fields that were incremented/decremented, call
  12379. // AddedFields().
  12380. func (m *ContactMutation) Fields() []string {
  12381. fields := make([]string, 0, 30)
  12382. if m.created_at != nil {
  12383. fields = append(fields, contact.FieldCreatedAt)
  12384. }
  12385. if m.updated_at != nil {
  12386. fields = append(fields, contact.FieldUpdatedAt)
  12387. }
  12388. if m.status != nil {
  12389. fields = append(fields, contact.FieldStatus)
  12390. }
  12391. if m.deleted_at != nil {
  12392. fields = append(fields, contact.FieldDeletedAt)
  12393. }
  12394. if m.wx_wxid != nil {
  12395. fields = append(fields, contact.FieldWxWxid)
  12396. }
  12397. if m._type != nil {
  12398. fields = append(fields, contact.FieldType)
  12399. }
  12400. if m.wxid != nil {
  12401. fields = append(fields, contact.FieldWxid)
  12402. }
  12403. if m.account != nil {
  12404. fields = append(fields, contact.FieldAccount)
  12405. }
  12406. if m.nickname != nil {
  12407. fields = append(fields, contact.FieldNickname)
  12408. }
  12409. if m.markname != nil {
  12410. fields = append(fields, contact.FieldMarkname)
  12411. }
  12412. if m.headimg != nil {
  12413. fields = append(fields, contact.FieldHeadimg)
  12414. }
  12415. if m.sex != nil {
  12416. fields = append(fields, contact.FieldSex)
  12417. }
  12418. if m.starrole != nil {
  12419. fields = append(fields, contact.FieldStarrole)
  12420. }
  12421. if m.dontseeit != nil {
  12422. fields = append(fields, contact.FieldDontseeit)
  12423. }
  12424. if m.dontseeme != nil {
  12425. fields = append(fields, contact.FieldDontseeme)
  12426. }
  12427. if m.lag != nil {
  12428. fields = append(fields, contact.FieldLag)
  12429. }
  12430. if m.gid != nil {
  12431. fields = append(fields, contact.FieldGid)
  12432. }
  12433. if m.gname != nil {
  12434. fields = append(fields, contact.FieldGname)
  12435. }
  12436. if m.v3 != nil {
  12437. fields = append(fields, contact.FieldV3)
  12438. }
  12439. if m.organization_id != nil {
  12440. fields = append(fields, contact.FieldOrganizationID)
  12441. }
  12442. if m.ctype != nil {
  12443. fields = append(fields, contact.FieldCtype)
  12444. }
  12445. if m.cage != nil {
  12446. fields = append(fields, contact.FieldCage)
  12447. }
  12448. if m.cname != nil {
  12449. fields = append(fields, contact.FieldCname)
  12450. }
  12451. if m.carea != nil {
  12452. fields = append(fields, contact.FieldCarea)
  12453. }
  12454. if m.cbirthday != nil {
  12455. fields = append(fields, contact.FieldCbirthday)
  12456. }
  12457. if m.cbirtharea != nil {
  12458. fields = append(fields, contact.FieldCbirtharea)
  12459. }
  12460. if m.cidcard_no != nil {
  12461. fields = append(fields, contact.FieldCidcardNo)
  12462. }
  12463. if m.ctitle != nil {
  12464. fields = append(fields, contact.FieldCtitle)
  12465. }
  12466. if m.cc != nil {
  12467. fields = append(fields, contact.FieldCc)
  12468. }
  12469. if m.phone != nil {
  12470. fields = append(fields, contact.FieldPhone)
  12471. }
  12472. return fields
  12473. }
  12474. // Field returns the value of a field with the given name. The second boolean
  12475. // return value indicates that this field was not set, or was not defined in the
  12476. // schema.
  12477. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  12478. switch name {
  12479. case contact.FieldCreatedAt:
  12480. return m.CreatedAt()
  12481. case contact.FieldUpdatedAt:
  12482. return m.UpdatedAt()
  12483. case contact.FieldStatus:
  12484. return m.Status()
  12485. case contact.FieldDeletedAt:
  12486. return m.DeletedAt()
  12487. case contact.FieldWxWxid:
  12488. return m.WxWxid()
  12489. case contact.FieldType:
  12490. return m.GetType()
  12491. case contact.FieldWxid:
  12492. return m.Wxid()
  12493. case contact.FieldAccount:
  12494. return m.Account()
  12495. case contact.FieldNickname:
  12496. return m.Nickname()
  12497. case contact.FieldMarkname:
  12498. return m.Markname()
  12499. case contact.FieldHeadimg:
  12500. return m.Headimg()
  12501. case contact.FieldSex:
  12502. return m.Sex()
  12503. case contact.FieldStarrole:
  12504. return m.Starrole()
  12505. case contact.FieldDontseeit:
  12506. return m.Dontseeit()
  12507. case contact.FieldDontseeme:
  12508. return m.Dontseeme()
  12509. case contact.FieldLag:
  12510. return m.Lag()
  12511. case contact.FieldGid:
  12512. return m.Gid()
  12513. case contact.FieldGname:
  12514. return m.Gname()
  12515. case contact.FieldV3:
  12516. return m.V3()
  12517. case contact.FieldOrganizationID:
  12518. return m.OrganizationID()
  12519. case contact.FieldCtype:
  12520. return m.Ctype()
  12521. case contact.FieldCage:
  12522. return m.Cage()
  12523. case contact.FieldCname:
  12524. return m.Cname()
  12525. case contact.FieldCarea:
  12526. return m.Carea()
  12527. case contact.FieldCbirthday:
  12528. return m.Cbirthday()
  12529. case contact.FieldCbirtharea:
  12530. return m.Cbirtharea()
  12531. case contact.FieldCidcardNo:
  12532. return m.CidcardNo()
  12533. case contact.FieldCtitle:
  12534. return m.Ctitle()
  12535. case contact.FieldCc:
  12536. return m.Cc()
  12537. case contact.FieldPhone:
  12538. return m.Phone()
  12539. }
  12540. return nil, false
  12541. }
  12542. // OldField returns the old value of the field from the database. An error is
  12543. // returned if the mutation operation is not UpdateOne, or the query to the
  12544. // database failed.
  12545. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12546. switch name {
  12547. case contact.FieldCreatedAt:
  12548. return m.OldCreatedAt(ctx)
  12549. case contact.FieldUpdatedAt:
  12550. return m.OldUpdatedAt(ctx)
  12551. case contact.FieldStatus:
  12552. return m.OldStatus(ctx)
  12553. case contact.FieldDeletedAt:
  12554. return m.OldDeletedAt(ctx)
  12555. case contact.FieldWxWxid:
  12556. return m.OldWxWxid(ctx)
  12557. case contact.FieldType:
  12558. return m.OldType(ctx)
  12559. case contact.FieldWxid:
  12560. return m.OldWxid(ctx)
  12561. case contact.FieldAccount:
  12562. return m.OldAccount(ctx)
  12563. case contact.FieldNickname:
  12564. return m.OldNickname(ctx)
  12565. case contact.FieldMarkname:
  12566. return m.OldMarkname(ctx)
  12567. case contact.FieldHeadimg:
  12568. return m.OldHeadimg(ctx)
  12569. case contact.FieldSex:
  12570. return m.OldSex(ctx)
  12571. case contact.FieldStarrole:
  12572. return m.OldStarrole(ctx)
  12573. case contact.FieldDontseeit:
  12574. return m.OldDontseeit(ctx)
  12575. case contact.FieldDontseeme:
  12576. return m.OldDontseeme(ctx)
  12577. case contact.FieldLag:
  12578. return m.OldLag(ctx)
  12579. case contact.FieldGid:
  12580. return m.OldGid(ctx)
  12581. case contact.FieldGname:
  12582. return m.OldGname(ctx)
  12583. case contact.FieldV3:
  12584. return m.OldV3(ctx)
  12585. case contact.FieldOrganizationID:
  12586. return m.OldOrganizationID(ctx)
  12587. case contact.FieldCtype:
  12588. return m.OldCtype(ctx)
  12589. case contact.FieldCage:
  12590. return m.OldCage(ctx)
  12591. case contact.FieldCname:
  12592. return m.OldCname(ctx)
  12593. case contact.FieldCarea:
  12594. return m.OldCarea(ctx)
  12595. case contact.FieldCbirthday:
  12596. return m.OldCbirthday(ctx)
  12597. case contact.FieldCbirtharea:
  12598. return m.OldCbirtharea(ctx)
  12599. case contact.FieldCidcardNo:
  12600. return m.OldCidcardNo(ctx)
  12601. case contact.FieldCtitle:
  12602. return m.OldCtitle(ctx)
  12603. case contact.FieldCc:
  12604. return m.OldCc(ctx)
  12605. case contact.FieldPhone:
  12606. return m.OldPhone(ctx)
  12607. }
  12608. return nil, fmt.Errorf("unknown Contact field %s", name)
  12609. }
  12610. // SetField sets the value of a field with the given name. It returns an error if
  12611. // the field is not defined in the schema, or if the type mismatched the field
  12612. // type.
  12613. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  12614. switch name {
  12615. case contact.FieldCreatedAt:
  12616. v, ok := value.(time.Time)
  12617. if !ok {
  12618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12619. }
  12620. m.SetCreatedAt(v)
  12621. return nil
  12622. case contact.FieldUpdatedAt:
  12623. v, ok := value.(time.Time)
  12624. if !ok {
  12625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12626. }
  12627. m.SetUpdatedAt(v)
  12628. return nil
  12629. case contact.FieldStatus:
  12630. v, ok := value.(uint8)
  12631. if !ok {
  12632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12633. }
  12634. m.SetStatus(v)
  12635. return nil
  12636. case contact.FieldDeletedAt:
  12637. v, ok := value.(time.Time)
  12638. if !ok {
  12639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12640. }
  12641. m.SetDeletedAt(v)
  12642. return nil
  12643. case contact.FieldWxWxid:
  12644. v, ok := value.(string)
  12645. if !ok {
  12646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12647. }
  12648. m.SetWxWxid(v)
  12649. return nil
  12650. case contact.FieldType:
  12651. v, ok := value.(int)
  12652. if !ok {
  12653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12654. }
  12655. m.SetType(v)
  12656. return nil
  12657. case contact.FieldWxid:
  12658. v, ok := value.(string)
  12659. if !ok {
  12660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12661. }
  12662. m.SetWxid(v)
  12663. return nil
  12664. case contact.FieldAccount:
  12665. v, ok := value.(string)
  12666. if !ok {
  12667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12668. }
  12669. m.SetAccount(v)
  12670. return nil
  12671. case contact.FieldNickname:
  12672. v, ok := value.(string)
  12673. if !ok {
  12674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12675. }
  12676. m.SetNickname(v)
  12677. return nil
  12678. case contact.FieldMarkname:
  12679. v, ok := value.(string)
  12680. if !ok {
  12681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12682. }
  12683. m.SetMarkname(v)
  12684. return nil
  12685. case contact.FieldHeadimg:
  12686. v, ok := value.(string)
  12687. if !ok {
  12688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12689. }
  12690. m.SetHeadimg(v)
  12691. return nil
  12692. case contact.FieldSex:
  12693. v, ok := value.(int)
  12694. if !ok {
  12695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12696. }
  12697. m.SetSex(v)
  12698. return nil
  12699. case contact.FieldStarrole:
  12700. v, ok := value.(string)
  12701. if !ok {
  12702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12703. }
  12704. m.SetStarrole(v)
  12705. return nil
  12706. case contact.FieldDontseeit:
  12707. v, ok := value.(int)
  12708. if !ok {
  12709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12710. }
  12711. m.SetDontseeit(v)
  12712. return nil
  12713. case contact.FieldDontseeme:
  12714. v, ok := value.(int)
  12715. if !ok {
  12716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12717. }
  12718. m.SetDontseeme(v)
  12719. return nil
  12720. case contact.FieldLag:
  12721. v, ok := value.(string)
  12722. if !ok {
  12723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12724. }
  12725. m.SetLag(v)
  12726. return nil
  12727. case contact.FieldGid:
  12728. v, ok := value.(string)
  12729. if !ok {
  12730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12731. }
  12732. m.SetGid(v)
  12733. return nil
  12734. case contact.FieldGname:
  12735. v, ok := value.(string)
  12736. if !ok {
  12737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12738. }
  12739. m.SetGname(v)
  12740. return nil
  12741. case contact.FieldV3:
  12742. v, ok := value.(string)
  12743. if !ok {
  12744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12745. }
  12746. m.SetV3(v)
  12747. return nil
  12748. case contact.FieldOrganizationID:
  12749. v, ok := value.(uint64)
  12750. if !ok {
  12751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12752. }
  12753. m.SetOrganizationID(v)
  12754. return nil
  12755. case contact.FieldCtype:
  12756. v, ok := value.(uint64)
  12757. if !ok {
  12758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12759. }
  12760. m.SetCtype(v)
  12761. return nil
  12762. case contact.FieldCage:
  12763. v, ok := value.(int)
  12764. if !ok {
  12765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12766. }
  12767. m.SetCage(v)
  12768. return nil
  12769. case contact.FieldCname:
  12770. v, ok := value.(string)
  12771. if !ok {
  12772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12773. }
  12774. m.SetCname(v)
  12775. return nil
  12776. case contact.FieldCarea:
  12777. v, ok := value.(string)
  12778. if !ok {
  12779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12780. }
  12781. m.SetCarea(v)
  12782. return nil
  12783. case contact.FieldCbirthday:
  12784. v, ok := value.(string)
  12785. if !ok {
  12786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12787. }
  12788. m.SetCbirthday(v)
  12789. return nil
  12790. case contact.FieldCbirtharea:
  12791. v, ok := value.(string)
  12792. if !ok {
  12793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12794. }
  12795. m.SetCbirtharea(v)
  12796. return nil
  12797. case contact.FieldCidcardNo:
  12798. v, ok := value.(string)
  12799. if !ok {
  12800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12801. }
  12802. m.SetCidcardNo(v)
  12803. return nil
  12804. case contact.FieldCtitle:
  12805. v, ok := value.(string)
  12806. if !ok {
  12807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12808. }
  12809. m.SetCtitle(v)
  12810. return nil
  12811. case contact.FieldCc:
  12812. v, ok := value.(string)
  12813. if !ok {
  12814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12815. }
  12816. m.SetCc(v)
  12817. return nil
  12818. case contact.FieldPhone:
  12819. v, ok := value.(string)
  12820. if !ok {
  12821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12822. }
  12823. m.SetPhone(v)
  12824. return nil
  12825. }
  12826. return fmt.Errorf("unknown Contact field %s", name)
  12827. }
  12828. // AddedFields returns all numeric fields that were incremented/decremented during
  12829. // this mutation.
  12830. func (m *ContactMutation) AddedFields() []string {
  12831. var fields []string
  12832. if m.addstatus != nil {
  12833. fields = append(fields, contact.FieldStatus)
  12834. }
  12835. if m.add_type != nil {
  12836. fields = append(fields, contact.FieldType)
  12837. }
  12838. if m.addsex != nil {
  12839. fields = append(fields, contact.FieldSex)
  12840. }
  12841. if m.adddontseeit != nil {
  12842. fields = append(fields, contact.FieldDontseeit)
  12843. }
  12844. if m.adddontseeme != nil {
  12845. fields = append(fields, contact.FieldDontseeme)
  12846. }
  12847. if m.addorganization_id != nil {
  12848. fields = append(fields, contact.FieldOrganizationID)
  12849. }
  12850. if m.addctype != nil {
  12851. fields = append(fields, contact.FieldCtype)
  12852. }
  12853. if m.addcage != nil {
  12854. fields = append(fields, contact.FieldCage)
  12855. }
  12856. return fields
  12857. }
  12858. // AddedField returns the numeric value that was incremented/decremented on a field
  12859. // with the given name. The second boolean return value indicates that this field
  12860. // was not set, or was not defined in the schema.
  12861. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  12862. switch name {
  12863. case contact.FieldStatus:
  12864. return m.AddedStatus()
  12865. case contact.FieldType:
  12866. return m.AddedType()
  12867. case contact.FieldSex:
  12868. return m.AddedSex()
  12869. case contact.FieldDontseeit:
  12870. return m.AddedDontseeit()
  12871. case contact.FieldDontseeme:
  12872. return m.AddedDontseeme()
  12873. case contact.FieldOrganizationID:
  12874. return m.AddedOrganizationID()
  12875. case contact.FieldCtype:
  12876. return m.AddedCtype()
  12877. case contact.FieldCage:
  12878. return m.AddedCage()
  12879. }
  12880. return nil, false
  12881. }
  12882. // AddField adds the value to the field with the given name. It returns an error if
  12883. // the field is not defined in the schema, or if the type mismatched the field
  12884. // type.
  12885. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  12886. switch name {
  12887. case contact.FieldStatus:
  12888. v, ok := value.(int8)
  12889. if !ok {
  12890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12891. }
  12892. m.AddStatus(v)
  12893. return nil
  12894. case contact.FieldType:
  12895. v, ok := value.(int)
  12896. if !ok {
  12897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12898. }
  12899. m.AddType(v)
  12900. return nil
  12901. case contact.FieldSex:
  12902. v, ok := value.(int)
  12903. if !ok {
  12904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12905. }
  12906. m.AddSex(v)
  12907. return nil
  12908. case contact.FieldDontseeit:
  12909. v, ok := value.(int)
  12910. if !ok {
  12911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12912. }
  12913. m.AddDontseeit(v)
  12914. return nil
  12915. case contact.FieldDontseeme:
  12916. v, ok := value.(int)
  12917. if !ok {
  12918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12919. }
  12920. m.AddDontseeme(v)
  12921. return nil
  12922. case contact.FieldOrganizationID:
  12923. v, ok := value.(int64)
  12924. if !ok {
  12925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12926. }
  12927. m.AddOrganizationID(v)
  12928. return nil
  12929. case contact.FieldCtype:
  12930. v, ok := value.(int64)
  12931. if !ok {
  12932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12933. }
  12934. m.AddCtype(v)
  12935. return nil
  12936. case contact.FieldCage:
  12937. v, ok := value.(int)
  12938. if !ok {
  12939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12940. }
  12941. m.AddCage(v)
  12942. return nil
  12943. }
  12944. return fmt.Errorf("unknown Contact numeric field %s", name)
  12945. }
  12946. // ClearedFields returns all nullable fields that were cleared during this
  12947. // mutation.
  12948. func (m *ContactMutation) ClearedFields() []string {
  12949. var fields []string
  12950. if m.FieldCleared(contact.FieldStatus) {
  12951. fields = append(fields, contact.FieldStatus)
  12952. }
  12953. if m.FieldCleared(contact.FieldDeletedAt) {
  12954. fields = append(fields, contact.FieldDeletedAt)
  12955. }
  12956. if m.FieldCleared(contact.FieldType) {
  12957. fields = append(fields, contact.FieldType)
  12958. }
  12959. if m.FieldCleared(contact.FieldOrganizationID) {
  12960. fields = append(fields, contact.FieldOrganizationID)
  12961. }
  12962. return fields
  12963. }
  12964. // FieldCleared returns a boolean indicating if a field with the given name was
  12965. // cleared in this mutation.
  12966. func (m *ContactMutation) FieldCleared(name string) bool {
  12967. _, ok := m.clearedFields[name]
  12968. return ok
  12969. }
  12970. // ClearField clears the value of the field with the given name. It returns an
  12971. // error if the field is not defined in the schema.
  12972. func (m *ContactMutation) ClearField(name string) error {
  12973. switch name {
  12974. case contact.FieldStatus:
  12975. m.ClearStatus()
  12976. return nil
  12977. case contact.FieldDeletedAt:
  12978. m.ClearDeletedAt()
  12979. return nil
  12980. case contact.FieldType:
  12981. m.ClearType()
  12982. return nil
  12983. case contact.FieldOrganizationID:
  12984. m.ClearOrganizationID()
  12985. return nil
  12986. }
  12987. return fmt.Errorf("unknown Contact nullable field %s", name)
  12988. }
  12989. // ResetField resets all changes in the mutation for the field with the given name.
  12990. // It returns an error if the field is not defined in the schema.
  12991. func (m *ContactMutation) ResetField(name string) error {
  12992. switch name {
  12993. case contact.FieldCreatedAt:
  12994. m.ResetCreatedAt()
  12995. return nil
  12996. case contact.FieldUpdatedAt:
  12997. m.ResetUpdatedAt()
  12998. return nil
  12999. case contact.FieldStatus:
  13000. m.ResetStatus()
  13001. return nil
  13002. case contact.FieldDeletedAt:
  13003. m.ResetDeletedAt()
  13004. return nil
  13005. case contact.FieldWxWxid:
  13006. m.ResetWxWxid()
  13007. return nil
  13008. case contact.FieldType:
  13009. m.ResetType()
  13010. return nil
  13011. case contact.FieldWxid:
  13012. m.ResetWxid()
  13013. return nil
  13014. case contact.FieldAccount:
  13015. m.ResetAccount()
  13016. return nil
  13017. case contact.FieldNickname:
  13018. m.ResetNickname()
  13019. return nil
  13020. case contact.FieldMarkname:
  13021. m.ResetMarkname()
  13022. return nil
  13023. case contact.FieldHeadimg:
  13024. m.ResetHeadimg()
  13025. return nil
  13026. case contact.FieldSex:
  13027. m.ResetSex()
  13028. return nil
  13029. case contact.FieldStarrole:
  13030. m.ResetStarrole()
  13031. return nil
  13032. case contact.FieldDontseeit:
  13033. m.ResetDontseeit()
  13034. return nil
  13035. case contact.FieldDontseeme:
  13036. m.ResetDontseeme()
  13037. return nil
  13038. case contact.FieldLag:
  13039. m.ResetLag()
  13040. return nil
  13041. case contact.FieldGid:
  13042. m.ResetGid()
  13043. return nil
  13044. case contact.FieldGname:
  13045. m.ResetGname()
  13046. return nil
  13047. case contact.FieldV3:
  13048. m.ResetV3()
  13049. return nil
  13050. case contact.FieldOrganizationID:
  13051. m.ResetOrganizationID()
  13052. return nil
  13053. case contact.FieldCtype:
  13054. m.ResetCtype()
  13055. return nil
  13056. case contact.FieldCage:
  13057. m.ResetCage()
  13058. return nil
  13059. case contact.FieldCname:
  13060. m.ResetCname()
  13061. return nil
  13062. case contact.FieldCarea:
  13063. m.ResetCarea()
  13064. return nil
  13065. case contact.FieldCbirthday:
  13066. m.ResetCbirthday()
  13067. return nil
  13068. case contact.FieldCbirtharea:
  13069. m.ResetCbirtharea()
  13070. return nil
  13071. case contact.FieldCidcardNo:
  13072. m.ResetCidcardNo()
  13073. return nil
  13074. case contact.FieldCtitle:
  13075. m.ResetCtitle()
  13076. return nil
  13077. case contact.FieldCc:
  13078. m.ResetCc()
  13079. return nil
  13080. case contact.FieldPhone:
  13081. m.ResetPhone()
  13082. return nil
  13083. }
  13084. return fmt.Errorf("unknown Contact field %s", name)
  13085. }
  13086. // AddedEdges returns all edge names that were set/added in this mutation.
  13087. func (m *ContactMutation) AddedEdges() []string {
  13088. edges := make([]string, 0, 3)
  13089. if m.contact_relationships != nil {
  13090. edges = append(edges, contact.EdgeContactRelationships)
  13091. }
  13092. if m.contact_fields != nil {
  13093. edges = append(edges, contact.EdgeContactFields)
  13094. }
  13095. if m.contact_messages != nil {
  13096. edges = append(edges, contact.EdgeContactMessages)
  13097. }
  13098. return edges
  13099. }
  13100. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13101. // name in this mutation.
  13102. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  13103. switch name {
  13104. case contact.EdgeContactRelationships:
  13105. ids := make([]ent.Value, 0, len(m.contact_relationships))
  13106. for id := range m.contact_relationships {
  13107. ids = append(ids, id)
  13108. }
  13109. return ids
  13110. case contact.EdgeContactFields:
  13111. ids := make([]ent.Value, 0, len(m.contact_fields))
  13112. for id := range m.contact_fields {
  13113. ids = append(ids, id)
  13114. }
  13115. return ids
  13116. case contact.EdgeContactMessages:
  13117. ids := make([]ent.Value, 0, len(m.contact_messages))
  13118. for id := range m.contact_messages {
  13119. ids = append(ids, id)
  13120. }
  13121. return ids
  13122. }
  13123. return nil
  13124. }
  13125. // RemovedEdges returns all edge names that were removed in this mutation.
  13126. func (m *ContactMutation) RemovedEdges() []string {
  13127. edges := make([]string, 0, 3)
  13128. if m.removedcontact_relationships != nil {
  13129. edges = append(edges, contact.EdgeContactRelationships)
  13130. }
  13131. if m.removedcontact_fields != nil {
  13132. edges = append(edges, contact.EdgeContactFields)
  13133. }
  13134. if m.removedcontact_messages != nil {
  13135. edges = append(edges, contact.EdgeContactMessages)
  13136. }
  13137. return edges
  13138. }
  13139. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13140. // the given name in this mutation.
  13141. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  13142. switch name {
  13143. case contact.EdgeContactRelationships:
  13144. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  13145. for id := range m.removedcontact_relationships {
  13146. ids = append(ids, id)
  13147. }
  13148. return ids
  13149. case contact.EdgeContactFields:
  13150. ids := make([]ent.Value, 0, len(m.removedcontact_fields))
  13151. for id := range m.removedcontact_fields {
  13152. ids = append(ids, id)
  13153. }
  13154. return ids
  13155. case contact.EdgeContactMessages:
  13156. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  13157. for id := range m.removedcontact_messages {
  13158. ids = append(ids, id)
  13159. }
  13160. return ids
  13161. }
  13162. return nil
  13163. }
  13164. // ClearedEdges returns all edge names that were cleared in this mutation.
  13165. func (m *ContactMutation) ClearedEdges() []string {
  13166. edges := make([]string, 0, 3)
  13167. if m.clearedcontact_relationships {
  13168. edges = append(edges, contact.EdgeContactRelationships)
  13169. }
  13170. if m.clearedcontact_fields {
  13171. edges = append(edges, contact.EdgeContactFields)
  13172. }
  13173. if m.clearedcontact_messages {
  13174. edges = append(edges, contact.EdgeContactMessages)
  13175. }
  13176. return edges
  13177. }
  13178. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13179. // was cleared in this mutation.
  13180. func (m *ContactMutation) EdgeCleared(name string) bool {
  13181. switch name {
  13182. case contact.EdgeContactRelationships:
  13183. return m.clearedcontact_relationships
  13184. case contact.EdgeContactFields:
  13185. return m.clearedcontact_fields
  13186. case contact.EdgeContactMessages:
  13187. return m.clearedcontact_messages
  13188. }
  13189. return false
  13190. }
  13191. // ClearEdge clears the value of the edge with the given name. It returns an error
  13192. // if that edge is not defined in the schema.
  13193. func (m *ContactMutation) ClearEdge(name string) error {
  13194. switch name {
  13195. }
  13196. return fmt.Errorf("unknown Contact unique edge %s", name)
  13197. }
  13198. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13199. // It returns an error if the edge is not defined in the schema.
  13200. func (m *ContactMutation) ResetEdge(name string) error {
  13201. switch name {
  13202. case contact.EdgeContactRelationships:
  13203. m.ResetContactRelationships()
  13204. return nil
  13205. case contact.EdgeContactFields:
  13206. m.ResetContactFields()
  13207. return nil
  13208. case contact.EdgeContactMessages:
  13209. m.ResetContactMessages()
  13210. return nil
  13211. }
  13212. return fmt.Errorf("unknown Contact edge %s", name)
  13213. }
  13214. // ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
  13215. type ContactFieldMutation struct {
  13216. config
  13217. op Op
  13218. typ string
  13219. id *uint64
  13220. created_at *time.Time
  13221. updated_at *time.Time
  13222. status *uint8
  13223. addstatus *int8
  13224. deleted_at *time.Time
  13225. form_id *string
  13226. value *[]string
  13227. appendvalue []string
  13228. clearedFields map[string]struct{}
  13229. field_contact *uint64
  13230. clearedfield_contact bool
  13231. done bool
  13232. oldValue func(context.Context) (*ContactField, error)
  13233. predicates []predicate.ContactField
  13234. }
  13235. var _ ent.Mutation = (*ContactFieldMutation)(nil)
  13236. // contactfieldOption allows management of the mutation configuration using functional options.
  13237. type contactfieldOption func(*ContactFieldMutation)
  13238. // newContactFieldMutation creates new mutation for the ContactField entity.
  13239. func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
  13240. m := &ContactFieldMutation{
  13241. config: c,
  13242. op: op,
  13243. typ: TypeContactField,
  13244. clearedFields: make(map[string]struct{}),
  13245. }
  13246. for _, opt := range opts {
  13247. opt(m)
  13248. }
  13249. return m
  13250. }
  13251. // withContactFieldID sets the ID field of the mutation.
  13252. func withContactFieldID(id uint64) contactfieldOption {
  13253. return func(m *ContactFieldMutation) {
  13254. var (
  13255. err error
  13256. once sync.Once
  13257. value *ContactField
  13258. )
  13259. m.oldValue = func(ctx context.Context) (*ContactField, error) {
  13260. once.Do(func() {
  13261. if m.done {
  13262. err = errors.New("querying old values post mutation is not allowed")
  13263. } else {
  13264. value, err = m.Client().ContactField.Get(ctx, id)
  13265. }
  13266. })
  13267. return value, err
  13268. }
  13269. m.id = &id
  13270. }
  13271. }
  13272. // withContactField sets the old ContactField of the mutation.
  13273. func withContactField(node *ContactField) contactfieldOption {
  13274. return func(m *ContactFieldMutation) {
  13275. m.oldValue = func(context.Context) (*ContactField, error) {
  13276. return node, nil
  13277. }
  13278. m.id = &node.ID
  13279. }
  13280. }
  13281. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13282. // executed in a transaction (ent.Tx), a transactional client is returned.
  13283. func (m ContactFieldMutation) Client() *Client {
  13284. client := &Client{config: m.config}
  13285. client.init()
  13286. return client
  13287. }
  13288. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13289. // it returns an error otherwise.
  13290. func (m ContactFieldMutation) Tx() (*Tx, error) {
  13291. if _, ok := m.driver.(*txDriver); !ok {
  13292. return nil, errors.New("ent: mutation is not running in a transaction")
  13293. }
  13294. tx := &Tx{config: m.config}
  13295. tx.init()
  13296. return tx, nil
  13297. }
  13298. // SetID sets the value of the id field. Note that this
  13299. // operation is only accepted on creation of ContactField entities.
  13300. func (m *ContactFieldMutation) SetID(id uint64) {
  13301. m.id = &id
  13302. }
  13303. // ID returns the ID value in the mutation. Note that the ID is only available
  13304. // if it was provided to the builder or after it was returned from the database.
  13305. func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
  13306. if m.id == nil {
  13307. return
  13308. }
  13309. return *m.id, true
  13310. }
  13311. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13312. // That means, if the mutation is applied within a transaction with an isolation level such
  13313. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13314. // or updated by the mutation.
  13315. func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
  13316. switch {
  13317. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13318. id, exists := m.ID()
  13319. if exists {
  13320. return []uint64{id}, nil
  13321. }
  13322. fallthrough
  13323. case m.op.Is(OpUpdate | OpDelete):
  13324. return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
  13325. default:
  13326. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13327. }
  13328. }
  13329. // SetCreatedAt sets the "created_at" field.
  13330. func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
  13331. m.created_at = &t
  13332. }
  13333. // CreatedAt returns the value of the "created_at" field in the mutation.
  13334. func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
  13335. v := m.created_at
  13336. if v == nil {
  13337. return
  13338. }
  13339. return *v, true
  13340. }
  13341. // OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
  13342. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13344. func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13345. if !m.op.Is(OpUpdateOne) {
  13346. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13347. }
  13348. if m.id == nil || m.oldValue == nil {
  13349. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13350. }
  13351. oldValue, err := m.oldValue(ctx)
  13352. if err != nil {
  13353. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13354. }
  13355. return oldValue.CreatedAt, nil
  13356. }
  13357. // ResetCreatedAt resets all changes to the "created_at" field.
  13358. func (m *ContactFieldMutation) ResetCreatedAt() {
  13359. m.created_at = nil
  13360. }
  13361. // SetUpdatedAt sets the "updated_at" field.
  13362. func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
  13363. m.updated_at = &t
  13364. }
  13365. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13366. func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
  13367. v := m.updated_at
  13368. if v == nil {
  13369. return
  13370. }
  13371. return *v, true
  13372. }
  13373. // OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
  13374. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13376. func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13377. if !m.op.Is(OpUpdateOne) {
  13378. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13379. }
  13380. if m.id == nil || m.oldValue == nil {
  13381. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13382. }
  13383. oldValue, err := m.oldValue(ctx)
  13384. if err != nil {
  13385. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13386. }
  13387. return oldValue.UpdatedAt, nil
  13388. }
  13389. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13390. func (m *ContactFieldMutation) ResetUpdatedAt() {
  13391. m.updated_at = nil
  13392. }
  13393. // SetStatus sets the "status" field.
  13394. func (m *ContactFieldMutation) SetStatus(u uint8) {
  13395. m.status = &u
  13396. m.addstatus = nil
  13397. }
  13398. // Status returns the value of the "status" field in the mutation.
  13399. func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
  13400. v := m.status
  13401. if v == nil {
  13402. return
  13403. }
  13404. return *v, true
  13405. }
  13406. // OldStatus returns the old "status" field's value of the ContactField entity.
  13407. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13409. func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13410. if !m.op.Is(OpUpdateOne) {
  13411. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13412. }
  13413. if m.id == nil || m.oldValue == nil {
  13414. return v, errors.New("OldStatus requires an ID field in the mutation")
  13415. }
  13416. oldValue, err := m.oldValue(ctx)
  13417. if err != nil {
  13418. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13419. }
  13420. return oldValue.Status, nil
  13421. }
  13422. // AddStatus adds u to the "status" field.
  13423. func (m *ContactFieldMutation) AddStatus(u int8) {
  13424. if m.addstatus != nil {
  13425. *m.addstatus += u
  13426. } else {
  13427. m.addstatus = &u
  13428. }
  13429. }
  13430. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13431. func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
  13432. v := m.addstatus
  13433. if v == nil {
  13434. return
  13435. }
  13436. return *v, true
  13437. }
  13438. // ClearStatus clears the value of the "status" field.
  13439. func (m *ContactFieldMutation) ClearStatus() {
  13440. m.status = nil
  13441. m.addstatus = nil
  13442. m.clearedFields[contactfield.FieldStatus] = struct{}{}
  13443. }
  13444. // StatusCleared returns if the "status" field was cleared in this mutation.
  13445. func (m *ContactFieldMutation) StatusCleared() bool {
  13446. _, ok := m.clearedFields[contactfield.FieldStatus]
  13447. return ok
  13448. }
  13449. // ResetStatus resets all changes to the "status" field.
  13450. func (m *ContactFieldMutation) ResetStatus() {
  13451. m.status = nil
  13452. m.addstatus = nil
  13453. delete(m.clearedFields, contactfield.FieldStatus)
  13454. }
  13455. // SetDeletedAt sets the "deleted_at" field.
  13456. func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
  13457. m.deleted_at = &t
  13458. }
  13459. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13460. func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
  13461. v := m.deleted_at
  13462. if v == nil {
  13463. return
  13464. }
  13465. return *v, true
  13466. }
  13467. // OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
  13468. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13470. func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13471. if !m.op.Is(OpUpdateOne) {
  13472. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13473. }
  13474. if m.id == nil || m.oldValue == nil {
  13475. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13476. }
  13477. oldValue, err := m.oldValue(ctx)
  13478. if err != nil {
  13479. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13480. }
  13481. return oldValue.DeletedAt, nil
  13482. }
  13483. // ClearDeletedAt clears the value of the "deleted_at" field.
  13484. func (m *ContactFieldMutation) ClearDeletedAt() {
  13485. m.deleted_at = nil
  13486. m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
  13487. }
  13488. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13489. func (m *ContactFieldMutation) DeletedAtCleared() bool {
  13490. _, ok := m.clearedFields[contactfield.FieldDeletedAt]
  13491. return ok
  13492. }
  13493. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13494. func (m *ContactFieldMutation) ResetDeletedAt() {
  13495. m.deleted_at = nil
  13496. delete(m.clearedFields, contactfield.FieldDeletedAt)
  13497. }
  13498. // SetContactID sets the "contact_id" field.
  13499. func (m *ContactFieldMutation) SetContactID(u uint64) {
  13500. m.field_contact = &u
  13501. }
  13502. // ContactID returns the value of the "contact_id" field in the mutation.
  13503. func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
  13504. v := m.field_contact
  13505. if v == nil {
  13506. return
  13507. }
  13508. return *v, true
  13509. }
  13510. // OldContactID returns the old "contact_id" field's value of the ContactField entity.
  13511. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13513. func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13514. if !m.op.Is(OpUpdateOne) {
  13515. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13516. }
  13517. if m.id == nil || m.oldValue == nil {
  13518. return v, errors.New("OldContactID requires an ID field in the mutation")
  13519. }
  13520. oldValue, err := m.oldValue(ctx)
  13521. if err != nil {
  13522. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13523. }
  13524. return oldValue.ContactID, nil
  13525. }
  13526. // ResetContactID resets all changes to the "contact_id" field.
  13527. func (m *ContactFieldMutation) ResetContactID() {
  13528. m.field_contact = nil
  13529. }
  13530. // SetFormID sets the "form_id" field.
  13531. func (m *ContactFieldMutation) SetFormID(s string) {
  13532. m.form_id = &s
  13533. }
  13534. // FormID returns the value of the "form_id" field in the mutation.
  13535. func (m *ContactFieldMutation) FormID() (r string, exists bool) {
  13536. v := m.form_id
  13537. if v == nil {
  13538. return
  13539. }
  13540. return *v, true
  13541. }
  13542. // OldFormID returns the old "form_id" field's value of the ContactField entity.
  13543. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13545. func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
  13546. if !m.op.Is(OpUpdateOne) {
  13547. return v, errors.New("OldFormID is only allowed on UpdateOne operations")
  13548. }
  13549. if m.id == nil || m.oldValue == nil {
  13550. return v, errors.New("OldFormID requires an ID field in the mutation")
  13551. }
  13552. oldValue, err := m.oldValue(ctx)
  13553. if err != nil {
  13554. return v, fmt.Errorf("querying old value for OldFormID: %w", err)
  13555. }
  13556. return oldValue.FormID, nil
  13557. }
  13558. // ResetFormID resets all changes to the "form_id" field.
  13559. func (m *ContactFieldMutation) ResetFormID() {
  13560. m.form_id = nil
  13561. }
  13562. // SetValue sets the "value" field.
  13563. func (m *ContactFieldMutation) SetValue(s []string) {
  13564. m.value = &s
  13565. m.appendvalue = nil
  13566. }
  13567. // Value returns the value of the "value" field in the mutation.
  13568. func (m *ContactFieldMutation) Value() (r []string, exists bool) {
  13569. v := m.value
  13570. if v == nil {
  13571. return
  13572. }
  13573. return *v, true
  13574. }
  13575. // OldValue returns the old "value" field's value of the ContactField entity.
  13576. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13578. func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
  13579. if !m.op.Is(OpUpdateOne) {
  13580. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  13581. }
  13582. if m.id == nil || m.oldValue == nil {
  13583. return v, errors.New("OldValue requires an ID field in the mutation")
  13584. }
  13585. oldValue, err := m.oldValue(ctx)
  13586. if err != nil {
  13587. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  13588. }
  13589. return oldValue.Value, nil
  13590. }
  13591. // AppendValue adds s to the "value" field.
  13592. func (m *ContactFieldMutation) AppendValue(s []string) {
  13593. m.appendvalue = append(m.appendvalue, s...)
  13594. }
  13595. // AppendedValue returns the list of values that were appended to the "value" field in this mutation.
  13596. func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
  13597. if len(m.appendvalue) == 0 {
  13598. return nil, false
  13599. }
  13600. return m.appendvalue, true
  13601. }
  13602. // ResetValue resets all changes to the "value" field.
  13603. func (m *ContactFieldMutation) ResetValue() {
  13604. m.value = nil
  13605. m.appendvalue = nil
  13606. }
  13607. // SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
  13608. func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
  13609. m.field_contact = &id
  13610. }
  13611. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  13612. func (m *ContactFieldMutation) ClearFieldContact() {
  13613. m.clearedfield_contact = true
  13614. m.clearedFields[contactfield.FieldContactID] = struct{}{}
  13615. }
  13616. // FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
  13617. func (m *ContactFieldMutation) FieldContactCleared() bool {
  13618. return m.clearedfield_contact
  13619. }
  13620. // FieldContactID returns the "field_contact" edge ID in the mutation.
  13621. func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
  13622. if m.field_contact != nil {
  13623. return *m.field_contact, true
  13624. }
  13625. return
  13626. }
  13627. // FieldContactIDs returns the "field_contact" edge IDs in the mutation.
  13628. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13629. // FieldContactID instead. It exists only for internal usage by the builders.
  13630. func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
  13631. if id := m.field_contact; id != nil {
  13632. ids = append(ids, *id)
  13633. }
  13634. return
  13635. }
  13636. // ResetFieldContact resets all changes to the "field_contact" edge.
  13637. func (m *ContactFieldMutation) ResetFieldContact() {
  13638. m.field_contact = nil
  13639. m.clearedfield_contact = false
  13640. }
  13641. // Where appends a list predicates to the ContactFieldMutation builder.
  13642. func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
  13643. m.predicates = append(m.predicates, ps...)
  13644. }
  13645. // WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
  13646. // users can use type-assertion to append predicates that do not depend on any generated package.
  13647. func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
  13648. p := make([]predicate.ContactField, len(ps))
  13649. for i := range ps {
  13650. p[i] = ps[i]
  13651. }
  13652. m.Where(p...)
  13653. }
  13654. // Op returns the operation name.
  13655. func (m *ContactFieldMutation) Op() Op {
  13656. return m.op
  13657. }
  13658. // SetOp allows setting the mutation operation.
  13659. func (m *ContactFieldMutation) SetOp(op Op) {
  13660. m.op = op
  13661. }
  13662. // Type returns the node type of this mutation (ContactField).
  13663. func (m *ContactFieldMutation) Type() string {
  13664. return m.typ
  13665. }
  13666. // Fields returns all fields that were changed during this mutation. Note that in
  13667. // order to get all numeric fields that were incremented/decremented, call
  13668. // AddedFields().
  13669. func (m *ContactFieldMutation) Fields() []string {
  13670. fields := make([]string, 0, 7)
  13671. if m.created_at != nil {
  13672. fields = append(fields, contactfield.FieldCreatedAt)
  13673. }
  13674. if m.updated_at != nil {
  13675. fields = append(fields, contactfield.FieldUpdatedAt)
  13676. }
  13677. if m.status != nil {
  13678. fields = append(fields, contactfield.FieldStatus)
  13679. }
  13680. if m.deleted_at != nil {
  13681. fields = append(fields, contactfield.FieldDeletedAt)
  13682. }
  13683. if m.field_contact != nil {
  13684. fields = append(fields, contactfield.FieldContactID)
  13685. }
  13686. if m.form_id != nil {
  13687. fields = append(fields, contactfield.FieldFormID)
  13688. }
  13689. if m.value != nil {
  13690. fields = append(fields, contactfield.FieldValue)
  13691. }
  13692. return fields
  13693. }
  13694. // Field returns the value of a field with the given name. The second boolean
  13695. // return value indicates that this field was not set, or was not defined in the
  13696. // schema.
  13697. func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
  13698. switch name {
  13699. case contactfield.FieldCreatedAt:
  13700. return m.CreatedAt()
  13701. case contactfield.FieldUpdatedAt:
  13702. return m.UpdatedAt()
  13703. case contactfield.FieldStatus:
  13704. return m.Status()
  13705. case contactfield.FieldDeletedAt:
  13706. return m.DeletedAt()
  13707. case contactfield.FieldContactID:
  13708. return m.ContactID()
  13709. case contactfield.FieldFormID:
  13710. return m.FormID()
  13711. case contactfield.FieldValue:
  13712. return m.Value()
  13713. }
  13714. return nil, false
  13715. }
  13716. // OldField returns the old value of the field from the database. An error is
  13717. // returned if the mutation operation is not UpdateOne, or the query to the
  13718. // database failed.
  13719. func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13720. switch name {
  13721. case contactfield.FieldCreatedAt:
  13722. return m.OldCreatedAt(ctx)
  13723. case contactfield.FieldUpdatedAt:
  13724. return m.OldUpdatedAt(ctx)
  13725. case contactfield.FieldStatus:
  13726. return m.OldStatus(ctx)
  13727. case contactfield.FieldDeletedAt:
  13728. return m.OldDeletedAt(ctx)
  13729. case contactfield.FieldContactID:
  13730. return m.OldContactID(ctx)
  13731. case contactfield.FieldFormID:
  13732. return m.OldFormID(ctx)
  13733. case contactfield.FieldValue:
  13734. return m.OldValue(ctx)
  13735. }
  13736. return nil, fmt.Errorf("unknown ContactField field %s", name)
  13737. }
  13738. // SetField sets the value of a field with the given name. It returns an error if
  13739. // the field is not defined in the schema, or if the type mismatched the field
  13740. // type.
  13741. func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
  13742. switch name {
  13743. case contactfield.FieldCreatedAt:
  13744. v, ok := value.(time.Time)
  13745. if !ok {
  13746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13747. }
  13748. m.SetCreatedAt(v)
  13749. return nil
  13750. case contactfield.FieldUpdatedAt:
  13751. v, ok := value.(time.Time)
  13752. if !ok {
  13753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13754. }
  13755. m.SetUpdatedAt(v)
  13756. return nil
  13757. case contactfield.FieldStatus:
  13758. v, ok := value.(uint8)
  13759. if !ok {
  13760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13761. }
  13762. m.SetStatus(v)
  13763. return nil
  13764. case contactfield.FieldDeletedAt:
  13765. v, ok := value.(time.Time)
  13766. if !ok {
  13767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13768. }
  13769. m.SetDeletedAt(v)
  13770. return nil
  13771. case contactfield.FieldContactID:
  13772. v, ok := value.(uint64)
  13773. if !ok {
  13774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13775. }
  13776. m.SetContactID(v)
  13777. return nil
  13778. case contactfield.FieldFormID:
  13779. v, ok := value.(string)
  13780. if !ok {
  13781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13782. }
  13783. m.SetFormID(v)
  13784. return nil
  13785. case contactfield.FieldValue:
  13786. v, ok := value.([]string)
  13787. if !ok {
  13788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13789. }
  13790. m.SetValue(v)
  13791. return nil
  13792. }
  13793. return fmt.Errorf("unknown ContactField field %s", name)
  13794. }
  13795. // AddedFields returns all numeric fields that were incremented/decremented during
  13796. // this mutation.
  13797. func (m *ContactFieldMutation) AddedFields() []string {
  13798. var fields []string
  13799. if m.addstatus != nil {
  13800. fields = append(fields, contactfield.FieldStatus)
  13801. }
  13802. return fields
  13803. }
  13804. // AddedField returns the numeric value that was incremented/decremented on a field
  13805. // with the given name. The second boolean return value indicates that this field
  13806. // was not set, or was not defined in the schema.
  13807. func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
  13808. switch name {
  13809. case contactfield.FieldStatus:
  13810. return m.AddedStatus()
  13811. }
  13812. return nil, false
  13813. }
  13814. // AddField adds the value to the field with the given name. It returns an error if
  13815. // the field is not defined in the schema, or if the type mismatched the field
  13816. // type.
  13817. func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
  13818. switch name {
  13819. case contactfield.FieldStatus:
  13820. v, ok := value.(int8)
  13821. if !ok {
  13822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13823. }
  13824. m.AddStatus(v)
  13825. return nil
  13826. }
  13827. return fmt.Errorf("unknown ContactField numeric field %s", name)
  13828. }
  13829. // ClearedFields returns all nullable fields that were cleared during this
  13830. // mutation.
  13831. func (m *ContactFieldMutation) ClearedFields() []string {
  13832. var fields []string
  13833. if m.FieldCleared(contactfield.FieldStatus) {
  13834. fields = append(fields, contactfield.FieldStatus)
  13835. }
  13836. if m.FieldCleared(contactfield.FieldDeletedAt) {
  13837. fields = append(fields, contactfield.FieldDeletedAt)
  13838. }
  13839. return fields
  13840. }
  13841. // FieldCleared returns a boolean indicating if a field with the given name was
  13842. // cleared in this mutation.
  13843. func (m *ContactFieldMutation) FieldCleared(name string) bool {
  13844. _, ok := m.clearedFields[name]
  13845. return ok
  13846. }
  13847. // ClearField clears the value of the field with the given name. It returns an
  13848. // error if the field is not defined in the schema.
  13849. func (m *ContactFieldMutation) ClearField(name string) error {
  13850. switch name {
  13851. case contactfield.FieldStatus:
  13852. m.ClearStatus()
  13853. return nil
  13854. case contactfield.FieldDeletedAt:
  13855. m.ClearDeletedAt()
  13856. return nil
  13857. }
  13858. return fmt.Errorf("unknown ContactField nullable field %s", name)
  13859. }
  13860. // ResetField resets all changes in the mutation for the field with the given name.
  13861. // It returns an error if the field is not defined in the schema.
  13862. func (m *ContactFieldMutation) ResetField(name string) error {
  13863. switch name {
  13864. case contactfield.FieldCreatedAt:
  13865. m.ResetCreatedAt()
  13866. return nil
  13867. case contactfield.FieldUpdatedAt:
  13868. m.ResetUpdatedAt()
  13869. return nil
  13870. case contactfield.FieldStatus:
  13871. m.ResetStatus()
  13872. return nil
  13873. case contactfield.FieldDeletedAt:
  13874. m.ResetDeletedAt()
  13875. return nil
  13876. case contactfield.FieldContactID:
  13877. m.ResetContactID()
  13878. return nil
  13879. case contactfield.FieldFormID:
  13880. m.ResetFormID()
  13881. return nil
  13882. case contactfield.FieldValue:
  13883. m.ResetValue()
  13884. return nil
  13885. }
  13886. return fmt.Errorf("unknown ContactField field %s", name)
  13887. }
  13888. // AddedEdges returns all edge names that were set/added in this mutation.
  13889. func (m *ContactFieldMutation) AddedEdges() []string {
  13890. edges := make([]string, 0, 1)
  13891. if m.field_contact != nil {
  13892. edges = append(edges, contactfield.EdgeFieldContact)
  13893. }
  13894. return edges
  13895. }
  13896. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13897. // name in this mutation.
  13898. func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
  13899. switch name {
  13900. case contactfield.EdgeFieldContact:
  13901. if id := m.field_contact; id != nil {
  13902. return []ent.Value{*id}
  13903. }
  13904. }
  13905. return nil
  13906. }
  13907. // RemovedEdges returns all edge names that were removed in this mutation.
  13908. func (m *ContactFieldMutation) RemovedEdges() []string {
  13909. edges := make([]string, 0, 1)
  13910. return edges
  13911. }
  13912. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13913. // the given name in this mutation.
  13914. func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
  13915. return nil
  13916. }
  13917. // ClearedEdges returns all edge names that were cleared in this mutation.
  13918. func (m *ContactFieldMutation) ClearedEdges() []string {
  13919. edges := make([]string, 0, 1)
  13920. if m.clearedfield_contact {
  13921. edges = append(edges, contactfield.EdgeFieldContact)
  13922. }
  13923. return edges
  13924. }
  13925. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13926. // was cleared in this mutation.
  13927. func (m *ContactFieldMutation) EdgeCleared(name string) bool {
  13928. switch name {
  13929. case contactfield.EdgeFieldContact:
  13930. return m.clearedfield_contact
  13931. }
  13932. return false
  13933. }
  13934. // ClearEdge clears the value of the edge with the given name. It returns an error
  13935. // if that edge is not defined in the schema.
  13936. func (m *ContactFieldMutation) ClearEdge(name string) error {
  13937. switch name {
  13938. case contactfield.EdgeFieldContact:
  13939. m.ClearFieldContact()
  13940. return nil
  13941. }
  13942. return fmt.Errorf("unknown ContactField unique edge %s", name)
  13943. }
  13944. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13945. // It returns an error if the edge is not defined in the schema.
  13946. func (m *ContactFieldMutation) ResetEdge(name string) error {
  13947. switch name {
  13948. case contactfield.EdgeFieldContact:
  13949. m.ResetFieldContact()
  13950. return nil
  13951. }
  13952. return fmt.Errorf("unknown ContactField edge %s", name)
  13953. }
  13954. // ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
  13955. type ContactFieldTemplateMutation struct {
  13956. config
  13957. op Op
  13958. typ string
  13959. id *uint64
  13960. created_at *time.Time
  13961. updated_at *time.Time
  13962. status *uint8
  13963. addstatus *int8
  13964. deleted_at *time.Time
  13965. organization_id *uint64
  13966. addorganization_id *int64
  13967. template *[]custom_types.ContactFieldTemplate
  13968. appendtemplate []custom_types.ContactFieldTemplate
  13969. clearedFields map[string]struct{}
  13970. done bool
  13971. oldValue func(context.Context) (*ContactFieldTemplate, error)
  13972. predicates []predicate.ContactFieldTemplate
  13973. }
  13974. var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
  13975. // contactfieldtemplateOption allows management of the mutation configuration using functional options.
  13976. type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
  13977. // newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
  13978. func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
  13979. m := &ContactFieldTemplateMutation{
  13980. config: c,
  13981. op: op,
  13982. typ: TypeContactFieldTemplate,
  13983. clearedFields: make(map[string]struct{}),
  13984. }
  13985. for _, opt := range opts {
  13986. opt(m)
  13987. }
  13988. return m
  13989. }
  13990. // withContactFieldTemplateID sets the ID field of the mutation.
  13991. func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
  13992. return func(m *ContactFieldTemplateMutation) {
  13993. var (
  13994. err error
  13995. once sync.Once
  13996. value *ContactFieldTemplate
  13997. )
  13998. m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
  13999. once.Do(func() {
  14000. if m.done {
  14001. err = errors.New("querying old values post mutation is not allowed")
  14002. } else {
  14003. value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
  14004. }
  14005. })
  14006. return value, err
  14007. }
  14008. m.id = &id
  14009. }
  14010. }
  14011. // withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
  14012. func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
  14013. return func(m *ContactFieldTemplateMutation) {
  14014. m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
  14015. return node, nil
  14016. }
  14017. m.id = &node.ID
  14018. }
  14019. }
  14020. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14021. // executed in a transaction (ent.Tx), a transactional client is returned.
  14022. func (m ContactFieldTemplateMutation) Client() *Client {
  14023. client := &Client{config: m.config}
  14024. client.init()
  14025. return client
  14026. }
  14027. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14028. // it returns an error otherwise.
  14029. func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
  14030. if _, ok := m.driver.(*txDriver); !ok {
  14031. return nil, errors.New("ent: mutation is not running in a transaction")
  14032. }
  14033. tx := &Tx{config: m.config}
  14034. tx.init()
  14035. return tx, nil
  14036. }
  14037. // SetID sets the value of the id field. Note that this
  14038. // operation is only accepted on creation of ContactFieldTemplate entities.
  14039. func (m *ContactFieldTemplateMutation) SetID(id uint64) {
  14040. m.id = &id
  14041. }
  14042. // ID returns the ID value in the mutation. Note that the ID is only available
  14043. // if it was provided to the builder or after it was returned from the database.
  14044. func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
  14045. if m.id == nil {
  14046. return
  14047. }
  14048. return *m.id, true
  14049. }
  14050. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14051. // That means, if the mutation is applied within a transaction with an isolation level such
  14052. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14053. // or updated by the mutation.
  14054. func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
  14055. switch {
  14056. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14057. id, exists := m.ID()
  14058. if exists {
  14059. return []uint64{id}, nil
  14060. }
  14061. fallthrough
  14062. case m.op.Is(OpUpdate | OpDelete):
  14063. return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
  14064. default:
  14065. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14066. }
  14067. }
  14068. // SetCreatedAt sets the "created_at" field.
  14069. func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
  14070. m.created_at = &t
  14071. }
  14072. // CreatedAt returns the value of the "created_at" field in the mutation.
  14073. func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  14074. v := m.created_at
  14075. if v == nil {
  14076. return
  14077. }
  14078. return *v, true
  14079. }
  14080. // OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
  14081. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14083. func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14084. if !m.op.Is(OpUpdateOne) {
  14085. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14086. }
  14087. if m.id == nil || m.oldValue == nil {
  14088. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14089. }
  14090. oldValue, err := m.oldValue(ctx)
  14091. if err != nil {
  14092. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14093. }
  14094. return oldValue.CreatedAt, nil
  14095. }
  14096. // ResetCreatedAt resets all changes to the "created_at" field.
  14097. func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
  14098. m.created_at = nil
  14099. }
  14100. // SetUpdatedAt sets the "updated_at" field.
  14101. func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
  14102. m.updated_at = &t
  14103. }
  14104. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14105. func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  14106. v := m.updated_at
  14107. if v == nil {
  14108. return
  14109. }
  14110. return *v, true
  14111. }
  14112. // OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
  14113. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14115. func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14116. if !m.op.Is(OpUpdateOne) {
  14117. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14118. }
  14119. if m.id == nil || m.oldValue == nil {
  14120. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14121. }
  14122. oldValue, err := m.oldValue(ctx)
  14123. if err != nil {
  14124. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14125. }
  14126. return oldValue.UpdatedAt, nil
  14127. }
  14128. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14129. func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
  14130. m.updated_at = nil
  14131. }
  14132. // SetStatus sets the "status" field.
  14133. func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
  14134. m.status = &u
  14135. m.addstatus = nil
  14136. }
  14137. // Status returns the value of the "status" field in the mutation.
  14138. func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
  14139. v := m.status
  14140. if v == nil {
  14141. return
  14142. }
  14143. return *v, true
  14144. }
  14145. // OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
  14146. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14148. func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14149. if !m.op.Is(OpUpdateOne) {
  14150. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14151. }
  14152. if m.id == nil || m.oldValue == nil {
  14153. return v, errors.New("OldStatus requires an ID field in the mutation")
  14154. }
  14155. oldValue, err := m.oldValue(ctx)
  14156. if err != nil {
  14157. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14158. }
  14159. return oldValue.Status, nil
  14160. }
  14161. // AddStatus adds u to the "status" field.
  14162. func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
  14163. if m.addstatus != nil {
  14164. *m.addstatus += u
  14165. } else {
  14166. m.addstatus = &u
  14167. }
  14168. }
  14169. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14170. func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
  14171. v := m.addstatus
  14172. if v == nil {
  14173. return
  14174. }
  14175. return *v, true
  14176. }
  14177. // ClearStatus clears the value of the "status" field.
  14178. func (m *ContactFieldTemplateMutation) ClearStatus() {
  14179. m.status = nil
  14180. m.addstatus = nil
  14181. m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
  14182. }
  14183. // StatusCleared returns if the "status" field was cleared in this mutation.
  14184. func (m *ContactFieldTemplateMutation) StatusCleared() bool {
  14185. _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
  14186. return ok
  14187. }
  14188. // ResetStatus resets all changes to the "status" field.
  14189. func (m *ContactFieldTemplateMutation) ResetStatus() {
  14190. m.status = nil
  14191. m.addstatus = nil
  14192. delete(m.clearedFields, contactfieldtemplate.FieldStatus)
  14193. }
  14194. // SetDeletedAt sets the "deleted_at" field.
  14195. func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
  14196. m.deleted_at = &t
  14197. }
  14198. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14199. func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
  14200. v := m.deleted_at
  14201. if v == nil {
  14202. return
  14203. }
  14204. return *v, true
  14205. }
  14206. // OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
  14207. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14209. func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14210. if !m.op.Is(OpUpdateOne) {
  14211. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14212. }
  14213. if m.id == nil || m.oldValue == nil {
  14214. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14215. }
  14216. oldValue, err := m.oldValue(ctx)
  14217. if err != nil {
  14218. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14219. }
  14220. return oldValue.DeletedAt, nil
  14221. }
  14222. // ClearDeletedAt clears the value of the "deleted_at" field.
  14223. func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
  14224. m.deleted_at = nil
  14225. m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
  14226. }
  14227. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14228. func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
  14229. _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
  14230. return ok
  14231. }
  14232. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14233. func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
  14234. m.deleted_at = nil
  14235. delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
  14236. }
  14237. // SetOrganizationID sets the "organization_id" field.
  14238. func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
  14239. m.organization_id = &u
  14240. m.addorganization_id = nil
  14241. }
  14242. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14243. func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
  14244. v := m.organization_id
  14245. if v == nil {
  14246. return
  14247. }
  14248. return *v, true
  14249. }
  14250. // OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
  14251. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14253. func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14254. if !m.op.Is(OpUpdateOne) {
  14255. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14256. }
  14257. if m.id == nil || m.oldValue == nil {
  14258. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14259. }
  14260. oldValue, err := m.oldValue(ctx)
  14261. if err != nil {
  14262. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14263. }
  14264. return oldValue.OrganizationID, nil
  14265. }
  14266. // AddOrganizationID adds u to the "organization_id" field.
  14267. func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
  14268. if m.addorganization_id != nil {
  14269. *m.addorganization_id += u
  14270. } else {
  14271. m.addorganization_id = &u
  14272. }
  14273. }
  14274. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14275. func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
  14276. v := m.addorganization_id
  14277. if v == nil {
  14278. return
  14279. }
  14280. return *v, true
  14281. }
  14282. // ResetOrganizationID resets all changes to the "organization_id" field.
  14283. func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
  14284. m.organization_id = nil
  14285. m.addorganization_id = nil
  14286. }
  14287. // SetTemplate sets the "template" field.
  14288. func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
  14289. m.template = &ctft
  14290. m.appendtemplate = nil
  14291. }
  14292. // Template returns the value of the "template" field in the mutation.
  14293. func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
  14294. v := m.template
  14295. if v == nil {
  14296. return
  14297. }
  14298. return *v, true
  14299. }
  14300. // OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
  14301. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14303. func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
  14304. if !m.op.Is(OpUpdateOne) {
  14305. return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
  14306. }
  14307. if m.id == nil || m.oldValue == nil {
  14308. return v, errors.New("OldTemplate requires an ID field in the mutation")
  14309. }
  14310. oldValue, err := m.oldValue(ctx)
  14311. if err != nil {
  14312. return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
  14313. }
  14314. return oldValue.Template, nil
  14315. }
  14316. // AppendTemplate adds ctft to the "template" field.
  14317. func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
  14318. m.appendtemplate = append(m.appendtemplate, ctft...)
  14319. }
  14320. // AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
  14321. func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
  14322. if len(m.appendtemplate) == 0 {
  14323. return nil, false
  14324. }
  14325. return m.appendtemplate, true
  14326. }
  14327. // ResetTemplate resets all changes to the "template" field.
  14328. func (m *ContactFieldTemplateMutation) ResetTemplate() {
  14329. m.template = nil
  14330. m.appendtemplate = nil
  14331. }
  14332. // Where appends a list predicates to the ContactFieldTemplateMutation builder.
  14333. func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
  14334. m.predicates = append(m.predicates, ps...)
  14335. }
  14336. // WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
  14337. // users can use type-assertion to append predicates that do not depend on any generated package.
  14338. func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  14339. p := make([]predicate.ContactFieldTemplate, len(ps))
  14340. for i := range ps {
  14341. p[i] = ps[i]
  14342. }
  14343. m.Where(p...)
  14344. }
  14345. // Op returns the operation name.
  14346. func (m *ContactFieldTemplateMutation) Op() Op {
  14347. return m.op
  14348. }
  14349. // SetOp allows setting the mutation operation.
  14350. func (m *ContactFieldTemplateMutation) SetOp(op Op) {
  14351. m.op = op
  14352. }
  14353. // Type returns the node type of this mutation (ContactFieldTemplate).
  14354. func (m *ContactFieldTemplateMutation) Type() string {
  14355. return m.typ
  14356. }
  14357. // Fields returns all fields that were changed during this mutation. Note that in
  14358. // order to get all numeric fields that were incremented/decremented, call
  14359. // AddedFields().
  14360. func (m *ContactFieldTemplateMutation) Fields() []string {
  14361. fields := make([]string, 0, 6)
  14362. if m.created_at != nil {
  14363. fields = append(fields, contactfieldtemplate.FieldCreatedAt)
  14364. }
  14365. if m.updated_at != nil {
  14366. fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
  14367. }
  14368. if m.status != nil {
  14369. fields = append(fields, contactfieldtemplate.FieldStatus)
  14370. }
  14371. if m.deleted_at != nil {
  14372. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  14373. }
  14374. if m.organization_id != nil {
  14375. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  14376. }
  14377. if m.template != nil {
  14378. fields = append(fields, contactfieldtemplate.FieldTemplate)
  14379. }
  14380. return fields
  14381. }
  14382. // Field returns the value of a field with the given name. The second boolean
  14383. // return value indicates that this field was not set, or was not defined in the
  14384. // schema.
  14385. func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
  14386. switch name {
  14387. case contactfieldtemplate.FieldCreatedAt:
  14388. return m.CreatedAt()
  14389. case contactfieldtemplate.FieldUpdatedAt:
  14390. return m.UpdatedAt()
  14391. case contactfieldtemplate.FieldStatus:
  14392. return m.Status()
  14393. case contactfieldtemplate.FieldDeletedAt:
  14394. return m.DeletedAt()
  14395. case contactfieldtemplate.FieldOrganizationID:
  14396. return m.OrganizationID()
  14397. case contactfieldtemplate.FieldTemplate:
  14398. return m.Template()
  14399. }
  14400. return nil, false
  14401. }
  14402. // OldField returns the old value of the field from the database. An error is
  14403. // returned if the mutation operation is not UpdateOne, or the query to the
  14404. // database failed.
  14405. func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14406. switch name {
  14407. case contactfieldtemplate.FieldCreatedAt:
  14408. return m.OldCreatedAt(ctx)
  14409. case contactfieldtemplate.FieldUpdatedAt:
  14410. return m.OldUpdatedAt(ctx)
  14411. case contactfieldtemplate.FieldStatus:
  14412. return m.OldStatus(ctx)
  14413. case contactfieldtemplate.FieldDeletedAt:
  14414. return m.OldDeletedAt(ctx)
  14415. case contactfieldtemplate.FieldOrganizationID:
  14416. return m.OldOrganizationID(ctx)
  14417. case contactfieldtemplate.FieldTemplate:
  14418. return m.OldTemplate(ctx)
  14419. }
  14420. return nil, fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14421. }
  14422. // SetField sets the value of a field with the given name. It returns an error if
  14423. // the field is not defined in the schema, or if the type mismatched the field
  14424. // type.
  14425. func (m *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
  14426. switch name {
  14427. case contactfieldtemplate.FieldCreatedAt:
  14428. v, ok := value.(time.Time)
  14429. if !ok {
  14430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14431. }
  14432. m.SetCreatedAt(v)
  14433. return nil
  14434. case contactfieldtemplate.FieldUpdatedAt:
  14435. v, ok := value.(time.Time)
  14436. if !ok {
  14437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14438. }
  14439. m.SetUpdatedAt(v)
  14440. return nil
  14441. case contactfieldtemplate.FieldStatus:
  14442. v, ok := value.(uint8)
  14443. if !ok {
  14444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14445. }
  14446. m.SetStatus(v)
  14447. return nil
  14448. case contactfieldtemplate.FieldDeletedAt:
  14449. v, ok := value.(time.Time)
  14450. if !ok {
  14451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14452. }
  14453. m.SetDeletedAt(v)
  14454. return nil
  14455. case contactfieldtemplate.FieldOrganizationID:
  14456. v, ok := value.(uint64)
  14457. if !ok {
  14458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14459. }
  14460. m.SetOrganizationID(v)
  14461. return nil
  14462. case contactfieldtemplate.FieldTemplate:
  14463. v, ok := value.([]custom_types.ContactFieldTemplate)
  14464. if !ok {
  14465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14466. }
  14467. m.SetTemplate(v)
  14468. return nil
  14469. }
  14470. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14471. }
  14472. // AddedFields returns all numeric fields that were incremented/decremented during
  14473. // this mutation.
  14474. func (m *ContactFieldTemplateMutation) AddedFields() []string {
  14475. var fields []string
  14476. if m.addstatus != nil {
  14477. fields = append(fields, contactfieldtemplate.FieldStatus)
  14478. }
  14479. if m.addorganization_id != nil {
  14480. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  14481. }
  14482. return fields
  14483. }
  14484. // AddedField returns the numeric value that was incremented/decremented on a field
  14485. // with the given name. The second boolean return value indicates that this field
  14486. // was not set, or was not defined in the schema.
  14487. func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
  14488. switch name {
  14489. case contactfieldtemplate.FieldStatus:
  14490. return m.AddedStatus()
  14491. case contactfieldtemplate.FieldOrganizationID:
  14492. return m.AddedOrganizationID()
  14493. }
  14494. return nil, false
  14495. }
  14496. // AddField adds the value to the field with the given name. It returns an error if
  14497. // the field is not defined in the schema, or if the type mismatched the field
  14498. // type.
  14499. func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
  14500. switch name {
  14501. case contactfieldtemplate.FieldStatus:
  14502. v, ok := value.(int8)
  14503. if !ok {
  14504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14505. }
  14506. m.AddStatus(v)
  14507. return nil
  14508. case contactfieldtemplate.FieldOrganizationID:
  14509. v, ok := value.(int64)
  14510. if !ok {
  14511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14512. }
  14513. m.AddOrganizationID(v)
  14514. return nil
  14515. }
  14516. return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
  14517. }
  14518. // ClearedFields returns all nullable fields that were cleared during this
  14519. // mutation.
  14520. func (m *ContactFieldTemplateMutation) ClearedFields() []string {
  14521. var fields []string
  14522. if m.FieldCleared(contactfieldtemplate.FieldStatus) {
  14523. fields = append(fields, contactfieldtemplate.FieldStatus)
  14524. }
  14525. if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
  14526. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  14527. }
  14528. return fields
  14529. }
  14530. // FieldCleared returns a boolean indicating if a field with the given name was
  14531. // cleared in this mutation.
  14532. func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
  14533. _, ok := m.clearedFields[name]
  14534. return ok
  14535. }
  14536. // ClearField clears the value of the field with the given name. It returns an
  14537. // error if the field is not defined in the schema.
  14538. func (m *ContactFieldTemplateMutation) ClearField(name string) error {
  14539. switch name {
  14540. case contactfieldtemplate.FieldStatus:
  14541. m.ClearStatus()
  14542. return nil
  14543. case contactfieldtemplate.FieldDeletedAt:
  14544. m.ClearDeletedAt()
  14545. return nil
  14546. }
  14547. return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
  14548. }
  14549. // ResetField resets all changes in the mutation for the field with the given name.
  14550. // It returns an error if the field is not defined in the schema.
  14551. func (m *ContactFieldTemplateMutation) ResetField(name string) error {
  14552. switch name {
  14553. case contactfieldtemplate.FieldCreatedAt:
  14554. m.ResetCreatedAt()
  14555. return nil
  14556. case contactfieldtemplate.FieldUpdatedAt:
  14557. m.ResetUpdatedAt()
  14558. return nil
  14559. case contactfieldtemplate.FieldStatus:
  14560. m.ResetStatus()
  14561. return nil
  14562. case contactfieldtemplate.FieldDeletedAt:
  14563. m.ResetDeletedAt()
  14564. return nil
  14565. case contactfieldtemplate.FieldOrganizationID:
  14566. m.ResetOrganizationID()
  14567. return nil
  14568. case contactfieldtemplate.FieldTemplate:
  14569. m.ResetTemplate()
  14570. return nil
  14571. }
  14572. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14573. }
  14574. // AddedEdges returns all edge names that were set/added in this mutation.
  14575. func (m *ContactFieldTemplateMutation) AddedEdges() []string {
  14576. edges := make([]string, 0, 0)
  14577. return edges
  14578. }
  14579. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14580. // name in this mutation.
  14581. func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
  14582. return nil
  14583. }
  14584. // RemovedEdges returns all edge names that were removed in this mutation.
  14585. func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
  14586. edges := make([]string, 0, 0)
  14587. return edges
  14588. }
  14589. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14590. // the given name in this mutation.
  14591. func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
  14592. return nil
  14593. }
  14594. // ClearedEdges returns all edge names that were cleared in this mutation.
  14595. func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
  14596. edges := make([]string, 0, 0)
  14597. return edges
  14598. }
  14599. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14600. // was cleared in this mutation.
  14601. func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
  14602. return false
  14603. }
  14604. // ClearEdge clears the value of the edge with the given name. It returns an error
  14605. // if that edge is not defined in the schema.
  14606. func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
  14607. return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
  14608. }
  14609. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14610. // It returns an error if the edge is not defined in the schema.
  14611. func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
  14612. return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
  14613. }
  14614. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  14615. type CreditBalanceMutation struct {
  14616. config
  14617. op Op
  14618. typ string
  14619. id *uint64
  14620. created_at *time.Time
  14621. updated_at *time.Time
  14622. deleted_at *time.Time
  14623. user_id *string
  14624. balance *float64
  14625. addbalance *float64
  14626. status *int
  14627. addstatus *int
  14628. organization_id *uint64
  14629. addorganization_id *int64
  14630. clearedFields map[string]struct{}
  14631. done bool
  14632. oldValue func(context.Context) (*CreditBalance, error)
  14633. predicates []predicate.CreditBalance
  14634. }
  14635. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  14636. // creditbalanceOption allows management of the mutation configuration using functional options.
  14637. type creditbalanceOption func(*CreditBalanceMutation)
  14638. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  14639. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  14640. m := &CreditBalanceMutation{
  14641. config: c,
  14642. op: op,
  14643. typ: TypeCreditBalance,
  14644. clearedFields: make(map[string]struct{}),
  14645. }
  14646. for _, opt := range opts {
  14647. opt(m)
  14648. }
  14649. return m
  14650. }
  14651. // withCreditBalanceID sets the ID field of the mutation.
  14652. func withCreditBalanceID(id uint64) creditbalanceOption {
  14653. return func(m *CreditBalanceMutation) {
  14654. var (
  14655. err error
  14656. once sync.Once
  14657. value *CreditBalance
  14658. )
  14659. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  14660. once.Do(func() {
  14661. if m.done {
  14662. err = errors.New("querying old values post mutation is not allowed")
  14663. } else {
  14664. value, err = m.Client().CreditBalance.Get(ctx, id)
  14665. }
  14666. })
  14667. return value, err
  14668. }
  14669. m.id = &id
  14670. }
  14671. }
  14672. // withCreditBalance sets the old CreditBalance of the mutation.
  14673. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  14674. return func(m *CreditBalanceMutation) {
  14675. m.oldValue = func(context.Context) (*CreditBalance, error) {
  14676. return node, nil
  14677. }
  14678. m.id = &node.ID
  14679. }
  14680. }
  14681. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14682. // executed in a transaction (ent.Tx), a transactional client is returned.
  14683. func (m CreditBalanceMutation) Client() *Client {
  14684. client := &Client{config: m.config}
  14685. client.init()
  14686. return client
  14687. }
  14688. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14689. // it returns an error otherwise.
  14690. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  14691. if _, ok := m.driver.(*txDriver); !ok {
  14692. return nil, errors.New("ent: mutation is not running in a transaction")
  14693. }
  14694. tx := &Tx{config: m.config}
  14695. tx.init()
  14696. return tx, nil
  14697. }
  14698. // SetID sets the value of the id field. Note that this
  14699. // operation is only accepted on creation of CreditBalance entities.
  14700. func (m *CreditBalanceMutation) SetID(id uint64) {
  14701. m.id = &id
  14702. }
  14703. // ID returns the ID value in the mutation. Note that the ID is only available
  14704. // if it was provided to the builder or after it was returned from the database.
  14705. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  14706. if m.id == nil {
  14707. return
  14708. }
  14709. return *m.id, true
  14710. }
  14711. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14712. // That means, if the mutation is applied within a transaction with an isolation level such
  14713. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14714. // or updated by the mutation.
  14715. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  14716. switch {
  14717. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14718. id, exists := m.ID()
  14719. if exists {
  14720. return []uint64{id}, nil
  14721. }
  14722. fallthrough
  14723. case m.op.Is(OpUpdate | OpDelete):
  14724. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  14725. default:
  14726. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14727. }
  14728. }
  14729. // SetCreatedAt sets the "created_at" field.
  14730. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  14731. m.created_at = &t
  14732. }
  14733. // CreatedAt returns the value of the "created_at" field in the mutation.
  14734. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  14735. v := m.created_at
  14736. if v == nil {
  14737. return
  14738. }
  14739. return *v, true
  14740. }
  14741. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  14742. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14744. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14745. if !m.op.Is(OpUpdateOne) {
  14746. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14747. }
  14748. if m.id == nil || m.oldValue == nil {
  14749. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14750. }
  14751. oldValue, err := m.oldValue(ctx)
  14752. if err != nil {
  14753. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14754. }
  14755. return oldValue.CreatedAt, nil
  14756. }
  14757. // ResetCreatedAt resets all changes to the "created_at" field.
  14758. func (m *CreditBalanceMutation) ResetCreatedAt() {
  14759. m.created_at = nil
  14760. }
  14761. // SetUpdatedAt sets the "updated_at" field.
  14762. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  14763. m.updated_at = &t
  14764. }
  14765. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14766. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  14767. v := m.updated_at
  14768. if v == nil {
  14769. return
  14770. }
  14771. return *v, true
  14772. }
  14773. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  14774. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14776. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14777. if !m.op.Is(OpUpdateOne) {
  14778. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14779. }
  14780. if m.id == nil || m.oldValue == nil {
  14781. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14782. }
  14783. oldValue, err := m.oldValue(ctx)
  14784. if err != nil {
  14785. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14786. }
  14787. return oldValue.UpdatedAt, nil
  14788. }
  14789. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14790. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  14791. m.updated_at = nil
  14792. }
  14793. // SetDeletedAt sets the "deleted_at" field.
  14794. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  14795. m.deleted_at = &t
  14796. }
  14797. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14798. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  14799. v := m.deleted_at
  14800. if v == nil {
  14801. return
  14802. }
  14803. return *v, true
  14804. }
  14805. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  14806. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14808. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14809. if !m.op.Is(OpUpdateOne) {
  14810. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14811. }
  14812. if m.id == nil || m.oldValue == nil {
  14813. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14814. }
  14815. oldValue, err := m.oldValue(ctx)
  14816. if err != nil {
  14817. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14818. }
  14819. return oldValue.DeletedAt, nil
  14820. }
  14821. // ClearDeletedAt clears the value of the "deleted_at" field.
  14822. func (m *CreditBalanceMutation) ClearDeletedAt() {
  14823. m.deleted_at = nil
  14824. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  14825. }
  14826. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14827. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  14828. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  14829. return ok
  14830. }
  14831. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14832. func (m *CreditBalanceMutation) ResetDeletedAt() {
  14833. m.deleted_at = nil
  14834. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  14835. }
  14836. // SetUserID sets the "user_id" field.
  14837. func (m *CreditBalanceMutation) SetUserID(s string) {
  14838. m.user_id = &s
  14839. }
  14840. // UserID returns the value of the "user_id" field in the mutation.
  14841. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  14842. v := m.user_id
  14843. if v == nil {
  14844. return
  14845. }
  14846. return *v, true
  14847. }
  14848. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  14849. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14851. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  14852. if !m.op.Is(OpUpdateOne) {
  14853. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  14854. }
  14855. if m.id == nil || m.oldValue == nil {
  14856. return v, errors.New("OldUserID requires an ID field in the mutation")
  14857. }
  14858. oldValue, err := m.oldValue(ctx)
  14859. if err != nil {
  14860. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  14861. }
  14862. return oldValue.UserID, nil
  14863. }
  14864. // ClearUserID clears the value of the "user_id" field.
  14865. func (m *CreditBalanceMutation) ClearUserID() {
  14866. m.user_id = nil
  14867. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  14868. }
  14869. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  14870. func (m *CreditBalanceMutation) UserIDCleared() bool {
  14871. _, ok := m.clearedFields[creditbalance.FieldUserID]
  14872. return ok
  14873. }
  14874. // ResetUserID resets all changes to the "user_id" field.
  14875. func (m *CreditBalanceMutation) ResetUserID() {
  14876. m.user_id = nil
  14877. delete(m.clearedFields, creditbalance.FieldUserID)
  14878. }
  14879. // SetBalance sets the "balance" field.
  14880. func (m *CreditBalanceMutation) SetBalance(f float64) {
  14881. m.balance = &f
  14882. m.addbalance = nil
  14883. }
  14884. // Balance returns the value of the "balance" field in the mutation.
  14885. func (m *CreditBalanceMutation) Balance() (r float64, exists bool) {
  14886. v := m.balance
  14887. if v == nil {
  14888. return
  14889. }
  14890. return *v, true
  14891. }
  14892. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  14893. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14895. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float64, err error) {
  14896. if !m.op.Is(OpUpdateOne) {
  14897. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  14898. }
  14899. if m.id == nil || m.oldValue == nil {
  14900. return v, errors.New("OldBalance requires an ID field in the mutation")
  14901. }
  14902. oldValue, err := m.oldValue(ctx)
  14903. if err != nil {
  14904. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  14905. }
  14906. return oldValue.Balance, nil
  14907. }
  14908. // AddBalance adds f to the "balance" field.
  14909. func (m *CreditBalanceMutation) AddBalance(f float64) {
  14910. if m.addbalance != nil {
  14911. *m.addbalance += f
  14912. } else {
  14913. m.addbalance = &f
  14914. }
  14915. }
  14916. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  14917. func (m *CreditBalanceMutation) AddedBalance() (r float64, exists bool) {
  14918. v := m.addbalance
  14919. if v == nil {
  14920. return
  14921. }
  14922. return *v, true
  14923. }
  14924. // ResetBalance resets all changes to the "balance" field.
  14925. func (m *CreditBalanceMutation) ResetBalance() {
  14926. m.balance = nil
  14927. m.addbalance = nil
  14928. }
  14929. // SetStatus sets the "status" field.
  14930. func (m *CreditBalanceMutation) SetStatus(i int) {
  14931. m.status = &i
  14932. m.addstatus = nil
  14933. }
  14934. // Status returns the value of the "status" field in the mutation.
  14935. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  14936. v := m.status
  14937. if v == nil {
  14938. return
  14939. }
  14940. return *v, true
  14941. }
  14942. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  14943. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14945. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  14946. if !m.op.Is(OpUpdateOne) {
  14947. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14948. }
  14949. if m.id == nil || m.oldValue == nil {
  14950. return v, errors.New("OldStatus requires an ID field in the mutation")
  14951. }
  14952. oldValue, err := m.oldValue(ctx)
  14953. if err != nil {
  14954. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14955. }
  14956. return oldValue.Status, nil
  14957. }
  14958. // AddStatus adds i to the "status" field.
  14959. func (m *CreditBalanceMutation) AddStatus(i int) {
  14960. if m.addstatus != nil {
  14961. *m.addstatus += i
  14962. } else {
  14963. m.addstatus = &i
  14964. }
  14965. }
  14966. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14967. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  14968. v := m.addstatus
  14969. if v == nil {
  14970. return
  14971. }
  14972. return *v, true
  14973. }
  14974. // ClearStatus clears the value of the "status" field.
  14975. func (m *CreditBalanceMutation) ClearStatus() {
  14976. m.status = nil
  14977. m.addstatus = nil
  14978. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  14979. }
  14980. // StatusCleared returns if the "status" field was cleared in this mutation.
  14981. func (m *CreditBalanceMutation) StatusCleared() bool {
  14982. _, ok := m.clearedFields[creditbalance.FieldStatus]
  14983. return ok
  14984. }
  14985. // ResetStatus resets all changes to the "status" field.
  14986. func (m *CreditBalanceMutation) ResetStatus() {
  14987. m.status = nil
  14988. m.addstatus = nil
  14989. delete(m.clearedFields, creditbalance.FieldStatus)
  14990. }
  14991. // SetOrganizationID sets the "organization_id" field.
  14992. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  14993. m.organization_id = &u
  14994. m.addorganization_id = nil
  14995. }
  14996. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14997. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  14998. v := m.organization_id
  14999. if v == nil {
  15000. return
  15001. }
  15002. return *v, true
  15003. }
  15004. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  15005. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15007. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15008. if !m.op.Is(OpUpdateOne) {
  15009. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15010. }
  15011. if m.id == nil || m.oldValue == nil {
  15012. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15013. }
  15014. oldValue, err := m.oldValue(ctx)
  15015. if err != nil {
  15016. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15017. }
  15018. return oldValue.OrganizationID, nil
  15019. }
  15020. // AddOrganizationID adds u to the "organization_id" field.
  15021. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  15022. if m.addorganization_id != nil {
  15023. *m.addorganization_id += u
  15024. } else {
  15025. m.addorganization_id = &u
  15026. }
  15027. }
  15028. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15029. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  15030. v := m.addorganization_id
  15031. if v == nil {
  15032. return
  15033. }
  15034. return *v, true
  15035. }
  15036. // ClearOrganizationID clears the value of the "organization_id" field.
  15037. func (m *CreditBalanceMutation) ClearOrganizationID() {
  15038. m.organization_id = nil
  15039. m.addorganization_id = nil
  15040. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  15041. }
  15042. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15043. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  15044. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  15045. return ok
  15046. }
  15047. // ResetOrganizationID resets all changes to the "organization_id" field.
  15048. func (m *CreditBalanceMutation) ResetOrganizationID() {
  15049. m.organization_id = nil
  15050. m.addorganization_id = nil
  15051. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  15052. }
  15053. // Where appends a list predicates to the CreditBalanceMutation builder.
  15054. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  15055. m.predicates = append(m.predicates, ps...)
  15056. }
  15057. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  15058. // users can use type-assertion to append predicates that do not depend on any generated package.
  15059. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  15060. p := make([]predicate.CreditBalance, len(ps))
  15061. for i := range ps {
  15062. p[i] = ps[i]
  15063. }
  15064. m.Where(p...)
  15065. }
  15066. // Op returns the operation name.
  15067. func (m *CreditBalanceMutation) Op() Op {
  15068. return m.op
  15069. }
  15070. // SetOp allows setting the mutation operation.
  15071. func (m *CreditBalanceMutation) SetOp(op Op) {
  15072. m.op = op
  15073. }
  15074. // Type returns the node type of this mutation (CreditBalance).
  15075. func (m *CreditBalanceMutation) Type() string {
  15076. return m.typ
  15077. }
  15078. // Fields returns all fields that were changed during this mutation. Note that in
  15079. // order to get all numeric fields that were incremented/decremented, call
  15080. // AddedFields().
  15081. func (m *CreditBalanceMutation) Fields() []string {
  15082. fields := make([]string, 0, 7)
  15083. if m.created_at != nil {
  15084. fields = append(fields, creditbalance.FieldCreatedAt)
  15085. }
  15086. if m.updated_at != nil {
  15087. fields = append(fields, creditbalance.FieldUpdatedAt)
  15088. }
  15089. if m.deleted_at != nil {
  15090. fields = append(fields, creditbalance.FieldDeletedAt)
  15091. }
  15092. if m.user_id != nil {
  15093. fields = append(fields, creditbalance.FieldUserID)
  15094. }
  15095. if m.balance != nil {
  15096. fields = append(fields, creditbalance.FieldBalance)
  15097. }
  15098. if m.status != nil {
  15099. fields = append(fields, creditbalance.FieldStatus)
  15100. }
  15101. if m.organization_id != nil {
  15102. fields = append(fields, creditbalance.FieldOrganizationID)
  15103. }
  15104. return fields
  15105. }
  15106. // Field returns the value of a field with the given name. The second boolean
  15107. // return value indicates that this field was not set, or was not defined in the
  15108. // schema.
  15109. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  15110. switch name {
  15111. case creditbalance.FieldCreatedAt:
  15112. return m.CreatedAt()
  15113. case creditbalance.FieldUpdatedAt:
  15114. return m.UpdatedAt()
  15115. case creditbalance.FieldDeletedAt:
  15116. return m.DeletedAt()
  15117. case creditbalance.FieldUserID:
  15118. return m.UserID()
  15119. case creditbalance.FieldBalance:
  15120. return m.Balance()
  15121. case creditbalance.FieldStatus:
  15122. return m.Status()
  15123. case creditbalance.FieldOrganizationID:
  15124. return m.OrganizationID()
  15125. }
  15126. return nil, false
  15127. }
  15128. // OldField returns the old value of the field from the database. An error is
  15129. // returned if the mutation operation is not UpdateOne, or the query to the
  15130. // database failed.
  15131. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15132. switch name {
  15133. case creditbalance.FieldCreatedAt:
  15134. return m.OldCreatedAt(ctx)
  15135. case creditbalance.FieldUpdatedAt:
  15136. return m.OldUpdatedAt(ctx)
  15137. case creditbalance.FieldDeletedAt:
  15138. return m.OldDeletedAt(ctx)
  15139. case creditbalance.FieldUserID:
  15140. return m.OldUserID(ctx)
  15141. case creditbalance.FieldBalance:
  15142. return m.OldBalance(ctx)
  15143. case creditbalance.FieldStatus:
  15144. return m.OldStatus(ctx)
  15145. case creditbalance.FieldOrganizationID:
  15146. return m.OldOrganizationID(ctx)
  15147. }
  15148. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  15149. }
  15150. // SetField sets the value of a field with the given name. It returns an error if
  15151. // the field is not defined in the schema, or if the type mismatched the field
  15152. // type.
  15153. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  15154. switch name {
  15155. case creditbalance.FieldCreatedAt:
  15156. v, ok := value.(time.Time)
  15157. if !ok {
  15158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15159. }
  15160. m.SetCreatedAt(v)
  15161. return nil
  15162. case creditbalance.FieldUpdatedAt:
  15163. v, ok := value.(time.Time)
  15164. if !ok {
  15165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15166. }
  15167. m.SetUpdatedAt(v)
  15168. return nil
  15169. case creditbalance.FieldDeletedAt:
  15170. v, ok := value.(time.Time)
  15171. if !ok {
  15172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15173. }
  15174. m.SetDeletedAt(v)
  15175. return nil
  15176. case creditbalance.FieldUserID:
  15177. v, ok := value.(string)
  15178. if !ok {
  15179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15180. }
  15181. m.SetUserID(v)
  15182. return nil
  15183. case creditbalance.FieldBalance:
  15184. v, ok := value.(float64)
  15185. if !ok {
  15186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15187. }
  15188. m.SetBalance(v)
  15189. return nil
  15190. case creditbalance.FieldStatus:
  15191. v, ok := value.(int)
  15192. if !ok {
  15193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15194. }
  15195. m.SetStatus(v)
  15196. return nil
  15197. case creditbalance.FieldOrganizationID:
  15198. v, ok := value.(uint64)
  15199. if !ok {
  15200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15201. }
  15202. m.SetOrganizationID(v)
  15203. return nil
  15204. }
  15205. return fmt.Errorf("unknown CreditBalance field %s", name)
  15206. }
  15207. // AddedFields returns all numeric fields that were incremented/decremented during
  15208. // this mutation.
  15209. func (m *CreditBalanceMutation) AddedFields() []string {
  15210. var fields []string
  15211. if m.addbalance != nil {
  15212. fields = append(fields, creditbalance.FieldBalance)
  15213. }
  15214. if m.addstatus != nil {
  15215. fields = append(fields, creditbalance.FieldStatus)
  15216. }
  15217. if m.addorganization_id != nil {
  15218. fields = append(fields, creditbalance.FieldOrganizationID)
  15219. }
  15220. return fields
  15221. }
  15222. // AddedField returns the numeric value that was incremented/decremented on a field
  15223. // with the given name. The second boolean return value indicates that this field
  15224. // was not set, or was not defined in the schema.
  15225. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  15226. switch name {
  15227. case creditbalance.FieldBalance:
  15228. return m.AddedBalance()
  15229. case creditbalance.FieldStatus:
  15230. return m.AddedStatus()
  15231. case creditbalance.FieldOrganizationID:
  15232. return m.AddedOrganizationID()
  15233. }
  15234. return nil, false
  15235. }
  15236. // AddField adds the value to the field with the given name. It returns an error if
  15237. // the field is not defined in the schema, or if the type mismatched the field
  15238. // type.
  15239. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  15240. switch name {
  15241. case creditbalance.FieldBalance:
  15242. v, ok := value.(float64)
  15243. if !ok {
  15244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15245. }
  15246. m.AddBalance(v)
  15247. return nil
  15248. case creditbalance.FieldStatus:
  15249. v, ok := value.(int)
  15250. if !ok {
  15251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15252. }
  15253. m.AddStatus(v)
  15254. return nil
  15255. case creditbalance.FieldOrganizationID:
  15256. v, ok := value.(int64)
  15257. if !ok {
  15258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15259. }
  15260. m.AddOrganizationID(v)
  15261. return nil
  15262. }
  15263. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  15264. }
  15265. // ClearedFields returns all nullable fields that were cleared during this
  15266. // mutation.
  15267. func (m *CreditBalanceMutation) ClearedFields() []string {
  15268. var fields []string
  15269. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  15270. fields = append(fields, creditbalance.FieldDeletedAt)
  15271. }
  15272. if m.FieldCleared(creditbalance.FieldUserID) {
  15273. fields = append(fields, creditbalance.FieldUserID)
  15274. }
  15275. if m.FieldCleared(creditbalance.FieldStatus) {
  15276. fields = append(fields, creditbalance.FieldStatus)
  15277. }
  15278. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  15279. fields = append(fields, creditbalance.FieldOrganizationID)
  15280. }
  15281. return fields
  15282. }
  15283. // FieldCleared returns a boolean indicating if a field with the given name was
  15284. // cleared in this mutation.
  15285. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  15286. _, ok := m.clearedFields[name]
  15287. return ok
  15288. }
  15289. // ClearField clears the value of the field with the given name. It returns an
  15290. // error if the field is not defined in the schema.
  15291. func (m *CreditBalanceMutation) ClearField(name string) error {
  15292. switch name {
  15293. case creditbalance.FieldDeletedAt:
  15294. m.ClearDeletedAt()
  15295. return nil
  15296. case creditbalance.FieldUserID:
  15297. m.ClearUserID()
  15298. return nil
  15299. case creditbalance.FieldStatus:
  15300. m.ClearStatus()
  15301. return nil
  15302. case creditbalance.FieldOrganizationID:
  15303. m.ClearOrganizationID()
  15304. return nil
  15305. }
  15306. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  15307. }
  15308. // ResetField resets all changes in the mutation for the field with the given name.
  15309. // It returns an error if the field is not defined in the schema.
  15310. func (m *CreditBalanceMutation) ResetField(name string) error {
  15311. switch name {
  15312. case creditbalance.FieldCreatedAt:
  15313. m.ResetCreatedAt()
  15314. return nil
  15315. case creditbalance.FieldUpdatedAt:
  15316. m.ResetUpdatedAt()
  15317. return nil
  15318. case creditbalance.FieldDeletedAt:
  15319. m.ResetDeletedAt()
  15320. return nil
  15321. case creditbalance.FieldUserID:
  15322. m.ResetUserID()
  15323. return nil
  15324. case creditbalance.FieldBalance:
  15325. m.ResetBalance()
  15326. return nil
  15327. case creditbalance.FieldStatus:
  15328. m.ResetStatus()
  15329. return nil
  15330. case creditbalance.FieldOrganizationID:
  15331. m.ResetOrganizationID()
  15332. return nil
  15333. }
  15334. return fmt.Errorf("unknown CreditBalance field %s", name)
  15335. }
  15336. // AddedEdges returns all edge names that were set/added in this mutation.
  15337. func (m *CreditBalanceMutation) AddedEdges() []string {
  15338. edges := make([]string, 0, 0)
  15339. return edges
  15340. }
  15341. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15342. // name in this mutation.
  15343. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  15344. return nil
  15345. }
  15346. // RemovedEdges returns all edge names that were removed in this mutation.
  15347. func (m *CreditBalanceMutation) RemovedEdges() []string {
  15348. edges := make([]string, 0, 0)
  15349. return edges
  15350. }
  15351. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15352. // the given name in this mutation.
  15353. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  15354. return nil
  15355. }
  15356. // ClearedEdges returns all edge names that were cleared in this mutation.
  15357. func (m *CreditBalanceMutation) ClearedEdges() []string {
  15358. edges := make([]string, 0, 0)
  15359. return edges
  15360. }
  15361. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15362. // was cleared in this mutation.
  15363. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  15364. return false
  15365. }
  15366. // ClearEdge clears the value of the edge with the given name. It returns an error
  15367. // if that edge is not defined in the schema.
  15368. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  15369. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  15370. }
  15371. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15372. // It returns an error if the edge is not defined in the schema.
  15373. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  15374. return fmt.Errorf("unknown CreditBalance edge %s", name)
  15375. }
  15376. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  15377. type CreditUsageMutation struct {
  15378. config
  15379. op Op
  15380. typ string
  15381. id *uint64
  15382. created_at *time.Time
  15383. updated_at *time.Time
  15384. deleted_at *time.Time
  15385. user_id *string
  15386. number *float64
  15387. addnumber *float64
  15388. pay_number *float64
  15389. addpay_number *float64
  15390. before_number *float64
  15391. addbefore_number *float64
  15392. after_number *float64
  15393. addafter_number *float64
  15394. pay_method *int
  15395. addpay_method *int
  15396. status *int
  15397. addstatus *int
  15398. ntype *int
  15399. addntype *int
  15400. table *string
  15401. organization_id *uint64
  15402. addorganization_id *int64
  15403. nid *uint64
  15404. addnid *int64
  15405. reason *string
  15406. operator *string
  15407. clearedFields map[string]struct{}
  15408. done bool
  15409. oldValue func(context.Context) (*CreditUsage, error)
  15410. predicates []predicate.CreditUsage
  15411. }
  15412. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  15413. // creditusageOption allows management of the mutation configuration using functional options.
  15414. type creditusageOption func(*CreditUsageMutation)
  15415. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  15416. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  15417. m := &CreditUsageMutation{
  15418. config: c,
  15419. op: op,
  15420. typ: TypeCreditUsage,
  15421. clearedFields: make(map[string]struct{}),
  15422. }
  15423. for _, opt := range opts {
  15424. opt(m)
  15425. }
  15426. return m
  15427. }
  15428. // withCreditUsageID sets the ID field of the mutation.
  15429. func withCreditUsageID(id uint64) creditusageOption {
  15430. return func(m *CreditUsageMutation) {
  15431. var (
  15432. err error
  15433. once sync.Once
  15434. value *CreditUsage
  15435. )
  15436. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  15437. once.Do(func() {
  15438. if m.done {
  15439. err = errors.New("querying old values post mutation is not allowed")
  15440. } else {
  15441. value, err = m.Client().CreditUsage.Get(ctx, id)
  15442. }
  15443. })
  15444. return value, err
  15445. }
  15446. m.id = &id
  15447. }
  15448. }
  15449. // withCreditUsage sets the old CreditUsage of the mutation.
  15450. func withCreditUsage(node *CreditUsage) creditusageOption {
  15451. return func(m *CreditUsageMutation) {
  15452. m.oldValue = func(context.Context) (*CreditUsage, error) {
  15453. return node, nil
  15454. }
  15455. m.id = &node.ID
  15456. }
  15457. }
  15458. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15459. // executed in a transaction (ent.Tx), a transactional client is returned.
  15460. func (m CreditUsageMutation) Client() *Client {
  15461. client := &Client{config: m.config}
  15462. client.init()
  15463. return client
  15464. }
  15465. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15466. // it returns an error otherwise.
  15467. func (m CreditUsageMutation) Tx() (*Tx, error) {
  15468. if _, ok := m.driver.(*txDriver); !ok {
  15469. return nil, errors.New("ent: mutation is not running in a transaction")
  15470. }
  15471. tx := &Tx{config: m.config}
  15472. tx.init()
  15473. return tx, nil
  15474. }
  15475. // SetID sets the value of the id field. Note that this
  15476. // operation is only accepted on creation of CreditUsage entities.
  15477. func (m *CreditUsageMutation) SetID(id uint64) {
  15478. m.id = &id
  15479. }
  15480. // ID returns the ID value in the mutation. Note that the ID is only available
  15481. // if it was provided to the builder or after it was returned from the database.
  15482. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  15483. if m.id == nil {
  15484. return
  15485. }
  15486. return *m.id, true
  15487. }
  15488. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15489. // That means, if the mutation is applied within a transaction with an isolation level such
  15490. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15491. // or updated by the mutation.
  15492. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  15493. switch {
  15494. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15495. id, exists := m.ID()
  15496. if exists {
  15497. return []uint64{id}, nil
  15498. }
  15499. fallthrough
  15500. case m.op.Is(OpUpdate | OpDelete):
  15501. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  15502. default:
  15503. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15504. }
  15505. }
  15506. // SetCreatedAt sets the "created_at" field.
  15507. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  15508. m.created_at = &t
  15509. }
  15510. // CreatedAt returns the value of the "created_at" field in the mutation.
  15511. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  15512. v := m.created_at
  15513. if v == nil {
  15514. return
  15515. }
  15516. return *v, true
  15517. }
  15518. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  15519. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15521. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15522. if !m.op.Is(OpUpdateOne) {
  15523. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15524. }
  15525. if m.id == nil || m.oldValue == nil {
  15526. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15527. }
  15528. oldValue, err := m.oldValue(ctx)
  15529. if err != nil {
  15530. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15531. }
  15532. return oldValue.CreatedAt, nil
  15533. }
  15534. // ResetCreatedAt resets all changes to the "created_at" field.
  15535. func (m *CreditUsageMutation) ResetCreatedAt() {
  15536. m.created_at = nil
  15537. }
  15538. // SetUpdatedAt sets the "updated_at" field.
  15539. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  15540. m.updated_at = &t
  15541. }
  15542. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15543. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  15544. v := m.updated_at
  15545. if v == nil {
  15546. return
  15547. }
  15548. return *v, true
  15549. }
  15550. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  15551. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15553. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15554. if !m.op.Is(OpUpdateOne) {
  15555. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15556. }
  15557. if m.id == nil || m.oldValue == nil {
  15558. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15559. }
  15560. oldValue, err := m.oldValue(ctx)
  15561. if err != nil {
  15562. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15563. }
  15564. return oldValue.UpdatedAt, nil
  15565. }
  15566. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15567. func (m *CreditUsageMutation) ResetUpdatedAt() {
  15568. m.updated_at = nil
  15569. }
  15570. // SetDeletedAt sets the "deleted_at" field.
  15571. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  15572. m.deleted_at = &t
  15573. }
  15574. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15575. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  15576. v := m.deleted_at
  15577. if v == nil {
  15578. return
  15579. }
  15580. return *v, true
  15581. }
  15582. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  15583. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15585. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15586. if !m.op.Is(OpUpdateOne) {
  15587. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15588. }
  15589. if m.id == nil || m.oldValue == nil {
  15590. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15591. }
  15592. oldValue, err := m.oldValue(ctx)
  15593. if err != nil {
  15594. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15595. }
  15596. return oldValue.DeletedAt, nil
  15597. }
  15598. // ClearDeletedAt clears the value of the "deleted_at" field.
  15599. func (m *CreditUsageMutation) ClearDeletedAt() {
  15600. m.deleted_at = nil
  15601. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  15602. }
  15603. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15604. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  15605. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  15606. return ok
  15607. }
  15608. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15609. func (m *CreditUsageMutation) ResetDeletedAt() {
  15610. m.deleted_at = nil
  15611. delete(m.clearedFields, creditusage.FieldDeletedAt)
  15612. }
  15613. // SetUserID sets the "user_id" field.
  15614. func (m *CreditUsageMutation) SetUserID(s string) {
  15615. m.user_id = &s
  15616. }
  15617. // UserID returns the value of the "user_id" field in the mutation.
  15618. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  15619. v := m.user_id
  15620. if v == nil {
  15621. return
  15622. }
  15623. return *v, true
  15624. }
  15625. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  15626. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15628. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  15629. if !m.op.Is(OpUpdateOne) {
  15630. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  15631. }
  15632. if m.id == nil || m.oldValue == nil {
  15633. return v, errors.New("OldUserID requires an ID field in the mutation")
  15634. }
  15635. oldValue, err := m.oldValue(ctx)
  15636. if err != nil {
  15637. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  15638. }
  15639. return oldValue.UserID, nil
  15640. }
  15641. // ClearUserID clears the value of the "user_id" field.
  15642. func (m *CreditUsageMutation) ClearUserID() {
  15643. m.user_id = nil
  15644. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  15645. }
  15646. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  15647. func (m *CreditUsageMutation) UserIDCleared() bool {
  15648. _, ok := m.clearedFields[creditusage.FieldUserID]
  15649. return ok
  15650. }
  15651. // ResetUserID resets all changes to the "user_id" field.
  15652. func (m *CreditUsageMutation) ResetUserID() {
  15653. m.user_id = nil
  15654. delete(m.clearedFields, creditusage.FieldUserID)
  15655. }
  15656. // SetNumber sets the "number" field.
  15657. func (m *CreditUsageMutation) SetNumber(f float64) {
  15658. m.number = &f
  15659. m.addnumber = nil
  15660. }
  15661. // Number returns the value of the "number" field in the mutation.
  15662. func (m *CreditUsageMutation) Number() (r float64, exists bool) {
  15663. v := m.number
  15664. if v == nil {
  15665. return
  15666. }
  15667. return *v, true
  15668. }
  15669. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  15670. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15672. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float64, err error) {
  15673. if !m.op.Is(OpUpdateOne) {
  15674. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  15675. }
  15676. if m.id == nil || m.oldValue == nil {
  15677. return v, errors.New("OldNumber requires an ID field in the mutation")
  15678. }
  15679. oldValue, err := m.oldValue(ctx)
  15680. if err != nil {
  15681. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  15682. }
  15683. return oldValue.Number, nil
  15684. }
  15685. // AddNumber adds f to the "number" field.
  15686. func (m *CreditUsageMutation) AddNumber(f float64) {
  15687. if m.addnumber != nil {
  15688. *m.addnumber += f
  15689. } else {
  15690. m.addnumber = &f
  15691. }
  15692. }
  15693. // AddedNumber returns the value that was added to the "number" field in this mutation.
  15694. func (m *CreditUsageMutation) AddedNumber() (r float64, exists bool) {
  15695. v := m.addnumber
  15696. if v == nil {
  15697. return
  15698. }
  15699. return *v, true
  15700. }
  15701. // ResetNumber resets all changes to the "number" field.
  15702. func (m *CreditUsageMutation) ResetNumber() {
  15703. m.number = nil
  15704. m.addnumber = nil
  15705. }
  15706. // SetPayNumber sets the "pay_number" field.
  15707. func (m *CreditUsageMutation) SetPayNumber(f float64) {
  15708. m.pay_number = &f
  15709. m.addpay_number = nil
  15710. }
  15711. // PayNumber returns the value of the "pay_number" field in the mutation.
  15712. func (m *CreditUsageMutation) PayNumber() (r float64, exists bool) {
  15713. v := m.pay_number
  15714. if v == nil {
  15715. return
  15716. }
  15717. return *v, true
  15718. }
  15719. // OldPayNumber returns the old "pay_number" field's value of the CreditUsage entity.
  15720. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15722. func (m *CreditUsageMutation) OldPayNumber(ctx context.Context) (v float64, err error) {
  15723. if !m.op.Is(OpUpdateOne) {
  15724. return v, errors.New("OldPayNumber is only allowed on UpdateOne operations")
  15725. }
  15726. if m.id == nil || m.oldValue == nil {
  15727. return v, errors.New("OldPayNumber requires an ID field in the mutation")
  15728. }
  15729. oldValue, err := m.oldValue(ctx)
  15730. if err != nil {
  15731. return v, fmt.Errorf("querying old value for OldPayNumber: %w", err)
  15732. }
  15733. return oldValue.PayNumber, nil
  15734. }
  15735. // AddPayNumber adds f to the "pay_number" field.
  15736. func (m *CreditUsageMutation) AddPayNumber(f float64) {
  15737. if m.addpay_number != nil {
  15738. *m.addpay_number += f
  15739. } else {
  15740. m.addpay_number = &f
  15741. }
  15742. }
  15743. // AddedPayNumber returns the value that was added to the "pay_number" field in this mutation.
  15744. func (m *CreditUsageMutation) AddedPayNumber() (r float64, exists bool) {
  15745. v := m.addpay_number
  15746. if v == nil {
  15747. return
  15748. }
  15749. return *v, true
  15750. }
  15751. // ClearPayNumber clears the value of the "pay_number" field.
  15752. func (m *CreditUsageMutation) ClearPayNumber() {
  15753. m.pay_number = nil
  15754. m.addpay_number = nil
  15755. m.clearedFields[creditusage.FieldPayNumber] = struct{}{}
  15756. }
  15757. // PayNumberCleared returns if the "pay_number" field was cleared in this mutation.
  15758. func (m *CreditUsageMutation) PayNumberCleared() bool {
  15759. _, ok := m.clearedFields[creditusage.FieldPayNumber]
  15760. return ok
  15761. }
  15762. // ResetPayNumber resets all changes to the "pay_number" field.
  15763. func (m *CreditUsageMutation) ResetPayNumber() {
  15764. m.pay_number = nil
  15765. m.addpay_number = nil
  15766. delete(m.clearedFields, creditusage.FieldPayNumber)
  15767. }
  15768. // SetBeforeNumber sets the "before_number" field.
  15769. func (m *CreditUsageMutation) SetBeforeNumber(f float64) {
  15770. m.before_number = &f
  15771. m.addbefore_number = nil
  15772. }
  15773. // BeforeNumber returns the value of the "before_number" field in the mutation.
  15774. func (m *CreditUsageMutation) BeforeNumber() (r float64, exists bool) {
  15775. v := m.before_number
  15776. if v == nil {
  15777. return
  15778. }
  15779. return *v, true
  15780. }
  15781. // OldBeforeNumber returns the old "before_number" field's value of the CreditUsage entity.
  15782. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15784. func (m *CreditUsageMutation) OldBeforeNumber(ctx context.Context) (v float64, err error) {
  15785. if !m.op.Is(OpUpdateOne) {
  15786. return v, errors.New("OldBeforeNumber is only allowed on UpdateOne operations")
  15787. }
  15788. if m.id == nil || m.oldValue == nil {
  15789. return v, errors.New("OldBeforeNumber requires an ID field in the mutation")
  15790. }
  15791. oldValue, err := m.oldValue(ctx)
  15792. if err != nil {
  15793. return v, fmt.Errorf("querying old value for OldBeforeNumber: %w", err)
  15794. }
  15795. return oldValue.BeforeNumber, nil
  15796. }
  15797. // AddBeforeNumber adds f to the "before_number" field.
  15798. func (m *CreditUsageMutation) AddBeforeNumber(f float64) {
  15799. if m.addbefore_number != nil {
  15800. *m.addbefore_number += f
  15801. } else {
  15802. m.addbefore_number = &f
  15803. }
  15804. }
  15805. // AddedBeforeNumber returns the value that was added to the "before_number" field in this mutation.
  15806. func (m *CreditUsageMutation) AddedBeforeNumber() (r float64, exists bool) {
  15807. v := m.addbefore_number
  15808. if v == nil {
  15809. return
  15810. }
  15811. return *v, true
  15812. }
  15813. // ClearBeforeNumber clears the value of the "before_number" field.
  15814. func (m *CreditUsageMutation) ClearBeforeNumber() {
  15815. m.before_number = nil
  15816. m.addbefore_number = nil
  15817. m.clearedFields[creditusage.FieldBeforeNumber] = struct{}{}
  15818. }
  15819. // BeforeNumberCleared returns if the "before_number" field was cleared in this mutation.
  15820. func (m *CreditUsageMutation) BeforeNumberCleared() bool {
  15821. _, ok := m.clearedFields[creditusage.FieldBeforeNumber]
  15822. return ok
  15823. }
  15824. // ResetBeforeNumber resets all changes to the "before_number" field.
  15825. func (m *CreditUsageMutation) ResetBeforeNumber() {
  15826. m.before_number = nil
  15827. m.addbefore_number = nil
  15828. delete(m.clearedFields, creditusage.FieldBeforeNumber)
  15829. }
  15830. // SetAfterNumber sets the "after_number" field.
  15831. func (m *CreditUsageMutation) SetAfterNumber(f float64) {
  15832. m.after_number = &f
  15833. m.addafter_number = nil
  15834. }
  15835. // AfterNumber returns the value of the "after_number" field in the mutation.
  15836. func (m *CreditUsageMutation) AfterNumber() (r float64, exists bool) {
  15837. v := m.after_number
  15838. if v == nil {
  15839. return
  15840. }
  15841. return *v, true
  15842. }
  15843. // OldAfterNumber returns the old "after_number" field's value of the CreditUsage entity.
  15844. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15846. func (m *CreditUsageMutation) OldAfterNumber(ctx context.Context) (v float64, err error) {
  15847. if !m.op.Is(OpUpdateOne) {
  15848. return v, errors.New("OldAfterNumber is only allowed on UpdateOne operations")
  15849. }
  15850. if m.id == nil || m.oldValue == nil {
  15851. return v, errors.New("OldAfterNumber requires an ID field in the mutation")
  15852. }
  15853. oldValue, err := m.oldValue(ctx)
  15854. if err != nil {
  15855. return v, fmt.Errorf("querying old value for OldAfterNumber: %w", err)
  15856. }
  15857. return oldValue.AfterNumber, nil
  15858. }
  15859. // AddAfterNumber adds f to the "after_number" field.
  15860. func (m *CreditUsageMutation) AddAfterNumber(f float64) {
  15861. if m.addafter_number != nil {
  15862. *m.addafter_number += f
  15863. } else {
  15864. m.addafter_number = &f
  15865. }
  15866. }
  15867. // AddedAfterNumber returns the value that was added to the "after_number" field in this mutation.
  15868. func (m *CreditUsageMutation) AddedAfterNumber() (r float64, exists bool) {
  15869. v := m.addafter_number
  15870. if v == nil {
  15871. return
  15872. }
  15873. return *v, true
  15874. }
  15875. // ClearAfterNumber clears the value of the "after_number" field.
  15876. func (m *CreditUsageMutation) ClearAfterNumber() {
  15877. m.after_number = nil
  15878. m.addafter_number = nil
  15879. m.clearedFields[creditusage.FieldAfterNumber] = struct{}{}
  15880. }
  15881. // AfterNumberCleared returns if the "after_number" field was cleared in this mutation.
  15882. func (m *CreditUsageMutation) AfterNumberCleared() bool {
  15883. _, ok := m.clearedFields[creditusage.FieldAfterNumber]
  15884. return ok
  15885. }
  15886. // ResetAfterNumber resets all changes to the "after_number" field.
  15887. func (m *CreditUsageMutation) ResetAfterNumber() {
  15888. m.after_number = nil
  15889. m.addafter_number = nil
  15890. delete(m.clearedFields, creditusage.FieldAfterNumber)
  15891. }
  15892. // SetPayMethod sets the "pay_method" field.
  15893. func (m *CreditUsageMutation) SetPayMethod(i int) {
  15894. m.pay_method = &i
  15895. m.addpay_method = nil
  15896. }
  15897. // PayMethod returns the value of the "pay_method" field in the mutation.
  15898. func (m *CreditUsageMutation) PayMethod() (r int, exists bool) {
  15899. v := m.pay_method
  15900. if v == nil {
  15901. return
  15902. }
  15903. return *v, true
  15904. }
  15905. // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
  15906. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15908. func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v int, err error) {
  15909. if !m.op.Is(OpUpdateOne) {
  15910. return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
  15911. }
  15912. if m.id == nil || m.oldValue == nil {
  15913. return v, errors.New("OldPayMethod requires an ID field in the mutation")
  15914. }
  15915. oldValue, err := m.oldValue(ctx)
  15916. if err != nil {
  15917. return v, fmt.Errorf("querying old value for OldPayMethod: %w", err)
  15918. }
  15919. return oldValue.PayMethod, nil
  15920. }
  15921. // AddPayMethod adds i to the "pay_method" field.
  15922. func (m *CreditUsageMutation) AddPayMethod(i int) {
  15923. if m.addpay_method != nil {
  15924. *m.addpay_method += i
  15925. } else {
  15926. m.addpay_method = &i
  15927. }
  15928. }
  15929. // AddedPayMethod returns the value that was added to the "pay_method" field in this mutation.
  15930. func (m *CreditUsageMutation) AddedPayMethod() (r int, exists bool) {
  15931. v := m.addpay_method
  15932. if v == nil {
  15933. return
  15934. }
  15935. return *v, true
  15936. }
  15937. // ClearPayMethod clears the value of the "pay_method" field.
  15938. func (m *CreditUsageMutation) ClearPayMethod() {
  15939. m.pay_method = nil
  15940. m.addpay_method = nil
  15941. m.clearedFields[creditusage.FieldPayMethod] = struct{}{}
  15942. }
  15943. // PayMethodCleared returns if the "pay_method" field was cleared in this mutation.
  15944. func (m *CreditUsageMutation) PayMethodCleared() bool {
  15945. _, ok := m.clearedFields[creditusage.FieldPayMethod]
  15946. return ok
  15947. }
  15948. // ResetPayMethod resets all changes to the "pay_method" field.
  15949. func (m *CreditUsageMutation) ResetPayMethod() {
  15950. m.pay_method = nil
  15951. m.addpay_method = nil
  15952. delete(m.clearedFields, creditusage.FieldPayMethod)
  15953. }
  15954. // SetStatus sets the "status" field.
  15955. func (m *CreditUsageMutation) SetStatus(i int) {
  15956. m.status = &i
  15957. m.addstatus = nil
  15958. }
  15959. // Status returns the value of the "status" field in the mutation.
  15960. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  15961. v := m.status
  15962. if v == nil {
  15963. return
  15964. }
  15965. return *v, true
  15966. }
  15967. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  15968. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15970. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  15971. if !m.op.Is(OpUpdateOne) {
  15972. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15973. }
  15974. if m.id == nil || m.oldValue == nil {
  15975. return v, errors.New("OldStatus requires an ID field in the mutation")
  15976. }
  15977. oldValue, err := m.oldValue(ctx)
  15978. if err != nil {
  15979. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15980. }
  15981. return oldValue.Status, nil
  15982. }
  15983. // AddStatus adds i to the "status" field.
  15984. func (m *CreditUsageMutation) AddStatus(i int) {
  15985. if m.addstatus != nil {
  15986. *m.addstatus += i
  15987. } else {
  15988. m.addstatus = &i
  15989. }
  15990. }
  15991. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15992. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  15993. v := m.addstatus
  15994. if v == nil {
  15995. return
  15996. }
  15997. return *v, true
  15998. }
  15999. // ClearStatus clears the value of the "status" field.
  16000. func (m *CreditUsageMutation) ClearStatus() {
  16001. m.status = nil
  16002. m.addstatus = nil
  16003. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  16004. }
  16005. // StatusCleared returns if the "status" field was cleared in this mutation.
  16006. func (m *CreditUsageMutation) StatusCleared() bool {
  16007. _, ok := m.clearedFields[creditusage.FieldStatus]
  16008. return ok
  16009. }
  16010. // ResetStatus resets all changes to the "status" field.
  16011. func (m *CreditUsageMutation) ResetStatus() {
  16012. m.status = nil
  16013. m.addstatus = nil
  16014. delete(m.clearedFields, creditusage.FieldStatus)
  16015. }
  16016. // SetNtype sets the "ntype" field.
  16017. func (m *CreditUsageMutation) SetNtype(i int) {
  16018. m.ntype = &i
  16019. m.addntype = nil
  16020. }
  16021. // Ntype returns the value of the "ntype" field in the mutation.
  16022. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  16023. v := m.ntype
  16024. if v == nil {
  16025. return
  16026. }
  16027. return *v, true
  16028. }
  16029. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  16030. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16032. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  16033. if !m.op.Is(OpUpdateOne) {
  16034. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  16035. }
  16036. if m.id == nil || m.oldValue == nil {
  16037. return v, errors.New("OldNtype requires an ID field in the mutation")
  16038. }
  16039. oldValue, err := m.oldValue(ctx)
  16040. if err != nil {
  16041. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  16042. }
  16043. return oldValue.Ntype, nil
  16044. }
  16045. // AddNtype adds i to the "ntype" field.
  16046. func (m *CreditUsageMutation) AddNtype(i int) {
  16047. if m.addntype != nil {
  16048. *m.addntype += i
  16049. } else {
  16050. m.addntype = &i
  16051. }
  16052. }
  16053. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  16054. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  16055. v := m.addntype
  16056. if v == nil {
  16057. return
  16058. }
  16059. return *v, true
  16060. }
  16061. // ResetNtype resets all changes to the "ntype" field.
  16062. func (m *CreditUsageMutation) ResetNtype() {
  16063. m.ntype = nil
  16064. m.addntype = nil
  16065. }
  16066. // SetTable sets the "table" field.
  16067. func (m *CreditUsageMutation) SetTable(s string) {
  16068. m.table = &s
  16069. }
  16070. // Table returns the value of the "table" field in the mutation.
  16071. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  16072. v := m.table
  16073. if v == nil {
  16074. return
  16075. }
  16076. return *v, true
  16077. }
  16078. // OldTable returns the old "table" field's value of the CreditUsage entity.
  16079. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16081. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  16082. if !m.op.Is(OpUpdateOne) {
  16083. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  16084. }
  16085. if m.id == nil || m.oldValue == nil {
  16086. return v, errors.New("OldTable requires an ID field in the mutation")
  16087. }
  16088. oldValue, err := m.oldValue(ctx)
  16089. if err != nil {
  16090. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  16091. }
  16092. return oldValue.Table, nil
  16093. }
  16094. // ResetTable resets all changes to the "table" field.
  16095. func (m *CreditUsageMutation) ResetTable() {
  16096. m.table = nil
  16097. }
  16098. // SetOrganizationID sets the "organization_id" field.
  16099. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  16100. m.organization_id = &u
  16101. m.addorganization_id = nil
  16102. }
  16103. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16104. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  16105. v := m.organization_id
  16106. if v == nil {
  16107. return
  16108. }
  16109. return *v, true
  16110. }
  16111. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  16112. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16114. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16115. if !m.op.Is(OpUpdateOne) {
  16116. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16117. }
  16118. if m.id == nil || m.oldValue == nil {
  16119. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16120. }
  16121. oldValue, err := m.oldValue(ctx)
  16122. if err != nil {
  16123. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16124. }
  16125. return oldValue.OrganizationID, nil
  16126. }
  16127. // AddOrganizationID adds u to the "organization_id" field.
  16128. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  16129. if m.addorganization_id != nil {
  16130. *m.addorganization_id += u
  16131. } else {
  16132. m.addorganization_id = &u
  16133. }
  16134. }
  16135. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16136. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  16137. v := m.addorganization_id
  16138. if v == nil {
  16139. return
  16140. }
  16141. return *v, true
  16142. }
  16143. // ClearOrganizationID clears the value of the "organization_id" field.
  16144. func (m *CreditUsageMutation) ClearOrganizationID() {
  16145. m.organization_id = nil
  16146. m.addorganization_id = nil
  16147. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  16148. }
  16149. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16150. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  16151. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  16152. return ok
  16153. }
  16154. // ResetOrganizationID resets all changes to the "organization_id" field.
  16155. func (m *CreditUsageMutation) ResetOrganizationID() {
  16156. m.organization_id = nil
  16157. m.addorganization_id = nil
  16158. delete(m.clearedFields, creditusage.FieldOrganizationID)
  16159. }
  16160. // SetNid sets the "nid" field.
  16161. func (m *CreditUsageMutation) SetNid(u uint64) {
  16162. m.nid = &u
  16163. m.addnid = nil
  16164. }
  16165. // Nid returns the value of the "nid" field in the mutation.
  16166. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  16167. v := m.nid
  16168. if v == nil {
  16169. return
  16170. }
  16171. return *v, true
  16172. }
  16173. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  16174. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16176. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  16177. if !m.op.Is(OpUpdateOne) {
  16178. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  16179. }
  16180. if m.id == nil || m.oldValue == nil {
  16181. return v, errors.New("OldNid requires an ID field in the mutation")
  16182. }
  16183. oldValue, err := m.oldValue(ctx)
  16184. if err != nil {
  16185. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  16186. }
  16187. return oldValue.Nid, nil
  16188. }
  16189. // AddNid adds u to the "nid" field.
  16190. func (m *CreditUsageMutation) AddNid(u int64) {
  16191. if m.addnid != nil {
  16192. *m.addnid += u
  16193. } else {
  16194. m.addnid = &u
  16195. }
  16196. }
  16197. // AddedNid returns the value that was added to the "nid" field in this mutation.
  16198. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  16199. v := m.addnid
  16200. if v == nil {
  16201. return
  16202. }
  16203. return *v, true
  16204. }
  16205. // ResetNid resets all changes to the "nid" field.
  16206. func (m *CreditUsageMutation) ResetNid() {
  16207. m.nid = nil
  16208. m.addnid = nil
  16209. }
  16210. // SetReason sets the "reason" field.
  16211. func (m *CreditUsageMutation) SetReason(s string) {
  16212. m.reason = &s
  16213. }
  16214. // Reason returns the value of the "reason" field in the mutation.
  16215. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  16216. v := m.reason
  16217. if v == nil {
  16218. return
  16219. }
  16220. return *v, true
  16221. }
  16222. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  16223. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16225. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  16226. if !m.op.Is(OpUpdateOne) {
  16227. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  16228. }
  16229. if m.id == nil || m.oldValue == nil {
  16230. return v, errors.New("OldReason requires an ID field in the mutation")
  16231. }
  16232. oldValue, err := m.oldValue(ctx)
  16233. if err != nil {
  16234. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  16235. }
  16236. return oldValue.Reason, nil
  16237. }
  16238. // ResetReason resets all changes to the "reason" field.
  16239. func (m *CreditUsageMutation) ResetReason() {
  16240. m.reason = nil
  16241. }
  16242. // SetOperator sets the "operator" field.
  16243. func (m *CreditUsageMutation) SetOperator(s string) {
  16244. m.operator = &s
  16245. }
  16246. // Operator returns the value of the "operator" field in the mutation.
  16247. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  16248. v := m.operator
  16249. if v == nil {
  16250. return
  16251. }
  16252. return *v, true
  16253. }
  16254. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  16255. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16257. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  16258. if !m.op.Is(OpUpdateOne) {
  16259. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  16260. }
  16261. if m.id == nil || m.oldValue == nil {
  16262. return v, errors.New("OldOperator requires an ID field in the mutation")
  16263. }
  16264. oldValue, err := m.oldValue(ctx)
  16265. if err != nil {
  16266. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  16267. }
  16268. return oldValue.Operator, nil
  16269. }
  16270. // ResetOperator resets all changes to the "operator" field.
  16271. func (m *CreditUsageMutation) ResetOperator() {
  16272. m.operator = nil
  16273. }
  16274. // Where appends a list predicates to the CreditUsageMutation builder.
  16275. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  16276. m.predicates = append(m.predicates, ps...)
  16277. }
  16278. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  16279. // users can use type-assertion to append predicates that do not depend on any generated package.
  16280. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  16281. p := make([]predicate.CreditUsage, len(ps))
  16282. for i := range ps {
  16283. p[i] = ps[i]
  16284. }
  16285. m.Where(p...)
  16286. }
  16287. // Op returns the operation name.
  16288. func (m *CreditUsageMutation) Op() Op {
  16289. return m.op
  16290. }
  16291. // SetOp allows setting the mutation operation.
  16292. func (m *CreditUsageMutation) SetOp(op Op) {
  16293. m.op = op
  16294. }
  16295. // Type returns the node type of this mutation (CreditUsage).
  16296. func (m *CreditUsageMutation) Type() string {
  16297. return m.typ
  16298. }
  16299. // Fields returns all fields that were changed during this mutation. Note that in
  16300. // order to get all numeric fields that were incremented/decremented, call
  16301. // AddedFields().
  16302. func (m *CreditUsageMutation) Fields() []string {
  16303. fields := make([]string, 0, 16)
  16304. if m.created_at != nil {
  16305. fields = append(fields, creditusage.FieldCreatedAt)
  16306. }
  16307. if m.updated_at != nil {
  16308. fields = append(fields, creditusage.FieldUpdatedAt)
  16309. }
  16310. if m.deleted_at != nil {
  16311. fields = append(fields, creditusage.FieldDeletedAt)
  16312. }
  16313. if m.user_id != nil {
  16314. fields = append(fields, creditusage.FieldUserID)
  16315. }
  16316. if m.number != nil {
  16317. fields = append(fields, creditusage.FieldNumber)
  16318. }
  16319. if m.pay_number != nil {
  16320. fields = append(fields, creditusage.FieldPayNumber)
  16321. }
  16322. if m.before_number != nil {
  16323. fields = append(fields, creditusage.FieldBeforeNumber)
  16324. }
  16325. if m.after_number != nil {
  16326. fields = append(fields, creditusage.FieldAfterNumber)
  16327. }
  16328. if m.pay_method != nil {
  16329. fields = append(fields, creditusage.FieldPayMethod)
  16330. }
  16331. if m.status != nil {
  16332. fields = append(fields, creditusage.FieldStatus)
  16333. }
  16334. if m.ntype != nil {
  16335. fields = append(fields, creditusage.FieldNtype)
  16336. }
  16337. if m.table != nil {
  16338. fields = append(fields, creditusage.FieldTable)
  16339. }
  16340. if m.organization_id != nil {
  16341. fields = append(fields, creditusage.FieldOrganizationID)
  16342. }
  16343. if m.nid != nil {
  16344. fields = append(fields, creditusage.FieldNid)
  16345. }
  16346. if m.reason != nil {
  16347. fields = append(fields, creditusage.FieldReason)
  16348. }
  16349. if m.operator != nil {
  16350. fields = append(fields, creditusage.FieldOperator)
  16351. }
  16352. return fields
  16353. }
  16354. // Field returns the value of a field with the given name. The second boolean
  16355. // return value indicates that this field was not set, or was not defined in the
  16356. // schema.
  16357. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  16358. switch name {
  16359. case creditusage.FieldCreatedAt:
  16360. return m.CreatedAt()
  16361. case creditusage.FieldUpdatedAt:
  16362. return m.UpdatedAt()
  16363. case creditusage.FieldDeletedAt:
  16364. return m.DeletedAt()
  16365. case creditusage.FieldUserID:
  16366. return m.UserID()
  16367. case creditusage.FieldNumber:
  16368. return m.Number()
  16369. case creditusage.FieldPayNumber:
  16370. return m.PayNumber()
  16371. case creditusage.FieldBeforeNumber:
  16372. return m.BeforeNumber()
  16373. case creditusage.FieldAfterNumber:
  16374. return m.AfterNumber()
  16375. case creditusage.FieldPayMethod:
  16376. return m.PayMethod()
  16377. case creditusage.FieldStatus:
  16378. return m.Status()
  16379. case creditusage.FieldNtype:
  16380. return m.Ntype()
  16381. case creditusage.FieldTable:
  16382. return m.Table()
  16383. case creditusage.FieldOrganizationID:
  16384. return m.OrganizationID()
  16385. case creditusage.FieldNid:
  16386. return m.Nid()
  16387. case creditusage.FieldReason:
  16388. return m.Reason()
  16389. case creditusage.FieldOperator:
  16390. return m.Operator()
  16391. }
  16392. return nil, false
  16393. }
  16394. // OldField returns the old value of the field from the database. An error is
  16395. // returned if the mutation operation is not UpdateOne, or the query to the
  16396. // database failed.
  16397. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16398. switch name {
  16399. case creditusage.FieldCreatedAt:
  16400. return m.OldCreatedAt(ctx)
  16401. case creditusage.FieldUpdatedAt:
  16402. return m.OldUpdatedAt(ctx)
  16403. case creditusage.FieldDeletedAt:
  16404. return m.OldDeletedAt(ctx)
  16405. case creditusage.FieldUserID:
  16406. return m.OldUserID(ctx)
  16407. case creditusage.FieldNumber:
  16408. return m.OldNumber(ctx)
  16409. case creditusage.FieldPayNumber:
  16410. return m.OldPayNumber(ctx)
  16411. case creditusage.FieldBeforeNumber:
  16412. return m.OldBeforeNumber(ctx)
  16413. case creditusage.FieldAfterNumber:
  16414. return m.OldAfterNumber(ctx)
  16415. case creditusage.FieldPayMethod:
  16416. return m.OldPayMethod(ctx)
  16417. case creditusage.FieldStatus:
  16418. return m.OldStatus(ctx)
  16419. case creditusage.FieldNtype:
  16420. return m.OldNtype(ctx)
  16421. case creditusage.FieldTable:
  16422. return m.OldTable(ctx)
  16423. case creditusage.FieldOrganizationID:
  16424. return m.OldOrganizationID(ctx)
  16425. case creditusage.FieldNid:
  16426. return m.OldNid(ctx)
  16427. case creditusage.FieldReason:
  16428. return m.OldReason(ctx)
  16429. case creditusage.FieldOperator:
  16430. return m.OldOperator(ctx)
  16431. }
  16432. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  16433. }
  16434. // SetField sets the value of a field with the given name. It returns an error if
  16435. // the field is not defined in the schema, or if the type mismatched the field
  16436. // type.
  16437. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  16438. switch name {
  16439. case creditusage.FieldCreatedAt:
  16440. v, ok := value.(time.Time)
  16441. if !ok {
  16442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16443. }
  16444. m.SetCreatedAt(v)
  16445. return nil
  16446. case creditusage.FieldUpdatedAt:
  16447. v, ok := value.(time.Time)
  16448. if !ok {
  16449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16450. }
  16451. m.SetUpdatedAt(v)
  16452. return nil
  16453. case creditusage.FieldDeletedAt:
  16454. v, ok := value.(time.Time)
  16455. if !ok {
  16456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16457. }
  16458. m.SetDeletedAt(v)
  16459. return nil
  16460. case creditusage.FieldUserID:
  16461. v, ok := value.(string)
  16462. if !ok {
  16463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16464. }
  16465. m.SetUserID(v)
  16466. return nil
  16467. case creditusage.FieldNumber:
  16468. v, ok := value.(float64)
  16469. if !ok {
  16470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16471. }
  16472. m.SetNumber(v)
  16473. return nil
  16474. case creditusage.FieldPayNumber:
  16475. v, ok := value.(float64)
  16476. if !ok {
  16477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16478. }
  16479. m.SetPayNumber(v)
  16480. return nil
  16481. case creditusage.FieldBeforeNumber:
  16482. v, ok := value.(float64)
  16483. if !ok {
  16484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16485. }
  16486. m.SetBeforeNumber(v)
  16487. return nil
  16488. case creditusage.FieldAfterNumber:
  16489. v, ok := value.(float64)
  16490. if !ok {
  16491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16492. }
  16493. m.SetAfterNumber(v)
  16494. return nil
  16495. case creditusage.FieldPayMethod:
  16496. v, ok := value.(int)
  16497. if !ok {
  16498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16499. }
  16500. m.SetPayMethod(v)
  16501. return nil
  16502. case creditusage.FieldStatus:
  16503. v, ok := value.(int)
  16504. if !ok {
  16505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16506. }
  16507. m.SetStatus(v)
  16508. return nil
  16509. case creditusage.FieldNtype:
  16510. v, ok := value.(int)
  16511. if !ok {
  16512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16513. }
  16514. m.SetNtype(v)
  16515. return nil
  16516. case creditusage.FieldTable:
  16517. v, ok := value.(string)
  16518. if !ok {
  16519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16520. }
  16521. m.SetTable(v)
  16522. return nil
  16523. case creditusage.FieldOrganizationID:
  16524. v, ok := value.(uint64)
  16525. if !ok {
  16526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16527. }
  16528. m.SetOrganizationID(v)
  16529. return nil
  16530. case creditusage.FieldNid:
  16531. v, ok := value.(uint64)
  16532. if !ok {
  16533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16534. }
  16535. m.SetNid(v)
  16536. return nil
  16537. case creditusage.FieldReason:
  16538. v, ok := value.(string)
  16539. if !ok {
  16540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16541. }
  16542. m.SetReason(v)
  16543. return nil
  16544. case creditusage.FieldOperator:
  16545. v, ok := value.(string)
  16546. if !ok {
  16547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16548. }
  16549. m.SetOperator(v)
  16550. return nil
  16551. }
  16552. return fmt.Errorf("unknown CreditUsage field %s", name)
  16553. }
  16554. // AddedFields returns all numeric fields that were incremented/decremented during
  16555. // this mutation.
  16556. func (m *CreditUsageMutation) AddedFields() []string {
  16557. var fields []string
  16558. if m.addnumber != nil {
  16559. fields = append(fields, creditusage.FieldNumber)
  16560. }
  16561. if m.addpay_number != nil {
  16562. fields = append(fields, creditusage.FieldPayNumber)
  16563. }
  16564. if m.addbefore_number != nil {
  16565. fields = append(fields, creditusage.FieldBeforeNumber)
  16566. }
  16567. if m.addafter_number != nil {
  16568. fields = append(fields, creditusage.FieldAfterNumber)
  16569. }
  16570. if m.addpay_method != nil {
  16571. fields = append(fields, creditusage.FieldPayMethod)
  16572. }
  16573. if m.addstatus != nil {
  16574. fields = append(fields, creditusage.FieldStatus)
  16575. }
  16576. if m.addntype != nil {
  16577. fields = append(fields, creditusage.FieldNtype)
  16578. }
  16579. if m.addorganization_id != nil {
  16580. fields = append(fields, creditusage.FieldOrganizationID)
  16581. }
  16582. if m.addnid != nil {
  16583. fields = append(fields, creditusage.FieldNid)
  16584. }
  16585. return fields
  16586. }
  16587. // AddedField returns the numeric value that was incremented/decremented on a field
  16588. // with the given name. The second boolean return value indicates that this field
  16589. // was not set, or was not defined in the schema.
  16590. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  16591. switch name {
  16592. case creditusage.FieldNumber:
  16593. return m.AddedNumber()
  16594. case creditusage.FieldPayNumber:
  16595. return m.AddedPayNumber()
  16596. case creditusage.FieldBeforeNumber:
  16597. return m.AddedBeforeNumber()
  16598. case creditusage.FieldAfterNumber:
  16599. return m.AddedAfterNumber()
  16600. case creditusage.FieldPayMethod:
  16601. return m.AddedPayMethod()
  16602. case creditusage.FieldStatus:
  16603. return m.AddedStatus()
  16604. case creditusage.FieldNtype:
  16605. return m.AddedNtype()
  16606. case creditusage.FieldOrganizationID:
  16607. return m.AddedOrganizationID()
  16608. case creditusage.FieldNid:
  16609. return m.AddedNid()
  16610. }
  16611. return nil, false
  16612. }
  16613. // AddField adds the value to the field with the given name. It returns an error if
  16614. // the field is not defined in the schema, or if the type mismatched the field
  16615. // type.
  16616. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  16617. switch name {
  16618. case creditusage.FieldNumber:
  16619. v, ok := value.(float64)
  16620. if !ok {
  16621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16622. }
  16623. m.AddNumber(v)
  16624. return nil
  16625. case creditusage.FieldPayNumber:
  16626. v, ok := value.(float64)
  16627. if !ok {
  16628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16629. }
  16630. m.AddPayNumber(v)
  16631. return nil
  16632. case creditusage.FieldBeforeNumber:
  16633. v, ok := value.(float64)
  16634. if !ok {
  16635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16636. }
  16637. m.AddBeforeNumber(v)
  16638. return nil
  16639. case creditusage.FieldAfterNumber:
  16640. v, ok := value.(float64)
  16641. if !ok {
  16642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16643. }
  16644. m.AddAfterNumber(v)
  16645. return nil
  16646. case creditusage.FieldPayMethod:
  16647. v, ok := value.(int)
  16648. if !ok {
  16649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16650. }
  16651. m.AddPayMethod(v)
  16652. return nil
  16653. case creditusage.FieldStatus:
  16654. v, ok := value.(int)
  16655. if !ok {
  16656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16657. }
  16658. m.AddStatus(v)
  16659. return nil
  16660. case creditusage.FieldNtype:
  16661. v, ok := value.(int)
  16662. if !ok {
  16663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16664. }
  16665. m.AddNtype(v)
  16666. return nil
  16667. case creditusage.FieldOrganizationID:
  16668. v, ok := value.(int64)
  16669. if !ok {
  16670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16671. }
  16672. m.AddOrganizationID(v)
  16673. return nil
  16674. case creditusage.FieldNid:
  16675. v, ok := value.(int64)
  16676. if !ok {
  16677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16678. }
  16679. m.AddNid(v)
  16680. return nil
  16681. }
  16682. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  16683. }
  16684. // ClearedFields returns all nullable fields that were cleared during this
  16685. // mutation.
  16686. func (m *CreditUsageMutation) ClearedFields() []string {
  16687. var fields []string
  16688. if m.FieldCleared(creditusage.FieldDeletedAt) {
  16689. fields = append(fields, creditusage.FieldDeletedAt)
  16690. }
  16691. if m.FieldCleared(creditusage.FieldUserID) {
  16692. fields = append(fields, creditusage.FieldUserID)
  16693. }
  16694. if m.FieldCleared(creditusage.FieldPayNumber) {
  16695. fields = append(fields, creditusage.FieldPayNumber)
  16696. }
  16697. if m.FieldCleared(creditusage.FieldBeforeNumber) {
  16698. fields = append(fields, creditusage.FieldBeforeNumber)
  16699. }
  16700. if m.FieldCleared(creditusage.FieldAfterNumber) {
  16701. fields = append(fields, creditusage.FieldAfterNumber)
  16702. }
  16703. if m.FieldCleared(creditusage.FieldPayMethod) {
  16704. fields = append(fields, creditusage.FieldPayMethod)
  16705. }
  16706. if m.FieldCleared(creditusage.FieldStatus) {
  16707. fields = append(fields, creditusage.FieldStatus)
  16708. }
  16709. if m.FieldCleared(creditusage.FieldOrganizationID) {
  16710. fields = append(fields, creditusage.FieldOrganizationID)
  16711. }
  16712. return fields
  16713. }
  16714. // FieldCleared returns a boolean indicating if a field with the given name was
  16715. // cleared in this mutation.
  16716. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  16717. _, ok := m.clearedFields[name]
  16718. return ok
  16719. }
  16720. // ClearField clears the value of the field with the given name. It returns an
  16721. // error if the field is not defined in the schema.
  16722. func (m *CreditUsageMutation) ClearField(name string) error {
  16723. switch name {
  16724. case creditusage.FieldDeletedAt:
  16725. m.ClearDeletedAt()
  16726. return nil
  16727. case creditusage.FieldUserID:
  16728. m.ClearUserID()
  16729. return nil
  16730. case creditusage.FieldPayNumber:
  16731. m.ClearPayNumber()
  16732. return nil
  16733. case creditusage.FieldBeforeNumber:
  16734. m.ClearBeforeNumber()
  16735. return nil
  16736. case creditusage.FieldAfterNumber:
  16737. m.ClearAfterNumber()
  16738. return nil
  16739. case creditusage.FieldPayMethod:
  16740. m.ClearPayMethod()
  16741. return nil
  16742. case creditusage.FieldStatus:
  16743. m.ClearStatus()
  16744. return nil
  16745. case creditusage.FieldOrganizationID:
  16746. m.ClearOrganizationID()
  16747. return nil
  16748. }
  16749. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  16750. }
  16751. // ResetField resets all changes in the mutation for the field with the given name.
  16752. // It returns an error if the field is not defined in the schema.
  16753. func (m *CreditUsageMutation) ResetField(name string) error {
  16754. switch name {
  16755. case creditusage.FieldCreatedAt:
  16756. m.ResetCreatedAt()
  16757. return nil
  16758. case creditusage.FieldUpdatedAt:
  16759. m.ResetUpdatedAt()
  16760. return nil
  16761. case creditusage.FieldDeletedAt:
  16762. m.ResetDeletedAt()
  16763. return nil
  16764. case creditusage.FieldUserID:
  16765. m.ResetUserID()
  16766. return nil
  16767. case creditusage.FieldNumber:
  16768. m.ResetNumber()
  16769. return nil
  16770. case creditusage.FieldPayNumber:
  16771. m.ResetPayNumber()
  16772. return nil
  16773. case creditusage.FieldBeforeNumber:
  16774. m.ResetBeforeNumber()
  16775. return nil
  16776. case creditusage.FieldAfterNumber:
  16777. m.ResetAfterNumber()
  16778. return nil
  16779. case creditusage.FieldPayMethod:
  16780. m.ResetPayMethod()
  16781. return nil
  16782. case creditusage.FieldStatus:
  16783. m.ResetStatus()
  16784. return nil
  16785. case creditusage.FieldNtype:
  16786. m.ResetNtype()
  16787. return nil
  16788. case creditusage.FieldTable:
  16789. m.ResetTable()
  16790. return nil
  16791. case creditusage.FieldOrganizationID:
  16792. m.ResetOrganizationID()
  16793. return nil
  16794. case creditusage.FieldNid:
  16795. m.ResetNid()
  16796. return nil
  16797. case creditusage.FieldReason:
  16798. m.ResetReason()
  16799. return nil
  16800. case creditusage.FieldOperator:
  16801. m.ResetOperator()
  16802. return nil
  16803. }
  16804. return fmt.Errorf("unknown CreditUsage field %s", name)
  16805. }
  16806. // AddedEdges returns all edge names that were set/added in this mutation.
  16807. func (m *CreditUsageMutation) AddedEdges() []string {
  16808. edges := make([]string, 0, 0)
  16809. return edges
  16810. }
  16811. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16812. // name in this mutation.
  16813. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  16814. return nil
  16815. }
  16816. // RemovedEdges returns all edge names that were removed in this mutation.
  16817. func (m *CreditUsageMutation) RemovedEdges() []string {
  16818. edges := make([]string, 0, 0)
  16819. return edges
  16820. }
  16821. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16822. // the given name in this mutation.
  16823. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  16824. return nil
  16825. }
  16826. // ClearedEdges returns all edge names that were cleared in this mutation.
  16827. func (m *CreditUsageMutation) ClearedEdges() []string {
  16828. edges := make([]string, 0, 0)
  16829. return edges
  16830. }
  16831. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16832. // was cleared in this mutation.
  16833. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  16834. return false
  16835. }
  16836. // ClearEdge clears the value of the edge with the given name. It returns an error
  16837. // if that edge is not defined in the schema.
  16838. func (m *CreditUsageMutation) ClearEdge(name string) error {
  16839. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  16840. }
  16841. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16842. // It returns an error if the edge is not defined in the schema.
  16843. func (m *CreditUsageMutation) ResetEdge(name string) error {
  16844. return fmt.Errorf("unknown CreditUsage edge %s", name)
  16845. }
  16846. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  16847. type EmployeeMutation struct {
  16848. config
  16849. op Op
  16850. typ string
  16851. id *uint64
  16852. created_at *time.Time
  16853. updated_at *time.Time
  16854. deleted_at *time.Time
  16855. title *string
  16856. avatar *string
  16857. tags *string
  16858. hire_count *int
  16859. addhire_count *int
  16860. service_count *int
  16861. addservice_count *int
  16862. achievement_count *int
  16863. addachievement_count *int
  16864. intro *string
  16865. estimate *string
  16866. skill *string
  16867. ability_type *string
  16868. scene *string
  16869. switch_in *string
  16870. video_url *string
  16871. organization_id *uint64
  16872. addorganization_id *int64
  16873. category_id *uint64
  16874. addcategory_id *int64
  16875. api_base *string
  16876. api_key *string
  16877. ai_info *string
  16878. is_vip *int
  16879. addis_vip *int
  16880. chat_url *string
  16881. clearedFields map[string]struct{}
  16882. em_work_experiences map[uint64]struct{}
  16883. removedem_work_experiences map[uint64]struct{}
  16884. clearedem_work_experiences bool
  16885. em_tutorial map[uint64]struct{}
  16886. removedem_tutorial map[uint64]struct{}
  16887. clearedem_tutorial bool
  16888. done bool
  16889. oldValue func(context.Context) (*Employee, error)
  16890. predicates []predicate.Employee
  16891. }
  16892. var _ ent.Mutation = (*EmployeeMutation)(nil)
  16893. // employeeOption allows management of the mutation configuration using functional options.
  16894. type employeeOption func(*EmployeeMutation)
  16895. // newEmployeeMutation creates new mutation for the Employee entity.
  16896. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  16897. m := &EmployeeMutation{
  16898. config: c,
  16899. op: op,
  16900. typ: TypeEmployee,
  16901. clearedFields: make(map[string]struct{}),
  16902. }
  16903. for _, opt := range opts {
  16904. opt(m)
  16905. }
  16906. return m
  16907. }
  16908. // withEmployeeID sets the ID field of the mutation.
  16909. func withEmployeeID(id uint64) employeeOption {
  16910. return func(m *EmployeeMutation) {
  16911. var (
  16912. err error
  16913. once sync.Once
  16914. value *Employee
  16915. )
  16916. m.oldValue = func(ctx context.Context) (*Employee, error) {
  16917. once.Do(func() {
  16918. if m.done {
  16919. err = errors.New("querying old values post mutation is not allowed")
  16920. } else {
  16921. value, err = m.Client().Employee.Get(ctx, id)
  16922. }
  16923. })
  16924. return value, err
  16925. }
  16926. m.id = &id
  16927. }
  16928. }
  16929. // withEmployee sets the old Employee of the mutation.
  16930. func withEmployee(node *Employee) employeeOption {
  16931. return func(m *EmployeeMutation) {
  16932. m.oldValue = func(context.Context) (*Employee, error) {
  16933. return node, nil
  16934. }
  16935. m.id = &node.ID
  16936. }
  16937. }
  16938. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16939. // executed in a transaction (ent.Tx), a transactional client is returned.
  16940. func (m EmployeeMutation) Client() *Client {
  16941. client := &Client{config: m.config}
  16942. client.init()
  16943. return client
  16944. }
  16945. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16946. // it returns an error otherwise.
  16947. func (m EmployeeMutation) Tx() (*Tx, error) {
  16948. if _, ok := m.driver.(*txDriver); !ok {
  16949. return nil, errors.New("ent: mutation is not running in a transaction")
  16950. }
  16951. tx := &Tx{config: m.config}
  16952. tx.init()
  16953. return tx, nil
  16954. }
  16955. // SetID sets the value of the id field. Note that this
  16956. // operation is only accepted on creation of Employee entities.
  16957. func (m *EmployeeMutation) SetID(id uint64) {
  16958. m.id = &id
  16959. }
  16960. // ID returns the ID value in the mutation. Note that the ID is only available
  16961. // if it was provided to the builder or after it was returned from the database.
  16962. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  16963. if m.id == nil {
  16964. return
  16965. }
  16966. return *m.id, true
  16967. }
  16968. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16969. // That means, if the mutation is applied within a transaction with an isolation level such
  16970. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16971. // or updated by the mutation.
  16972. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  16973. switch {
  16974. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16975. id, exists := m.ID()
  16976. if exists {
  16977. return []uint64{id}, nil
  16978. }
  16979. fallthrough
  16980. case m.op.Is(OpUpdate | OpDelete):
  16981. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  16982. default:
  16983. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16984. }
  16985. }
  16986. // SetCreatedAt sets the "created_at" field.
  16987. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  16988. m.created_at = &t
  16989. }
  16990. // CreatedAt returns the value of the "created_at" field in the mutation.
  16991. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  16992. v := m.created_at
  16993. if v == nil {
  16994. return
  16995. }
  16996. return *v, true
  16997. }
  16998. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  16999. // If the Employee 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 *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17002. if !m.op.Is(OpUpdateOne) {
  17003. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17004. }
  17005. if m.id == nil || m.oldValue == nil {
  17006. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  17011. }
  17012. return oldValue.CreatedAt, nil
  17013. }
  17014. // ResetCreatedAt resets all changes to the "created_at" field.
  17015. func (m *EmployeeMutation) ResetCreatedAt() {
  17016. m.created_at = nil
  17017. }
  17018. // SetUpdatedAt sets the "updated_at" field.
  17019. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  17020. m.updated_at = &t
  17021. }
  17022. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17023. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  17024. v := m.updated_at
  17025. if v == nil {
  17026. return
  17027. }
  17028. return *v, true
  17029. }
  17030. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  17031. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17033. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17034. if !m.op.Is(OpUpdateOne) {
  17035. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17036. }
  17037. if m.id == nil || m.oldValue == nil {
  17038. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17039. }
  17040. oldValue, err := m.oldValue(ctx)
  17041. if err != nil {
  17042. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17043. }
  17044. return oldValue.UpdatedAt, nil
  17045. }
  17046. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17047. func (m *EmployeeMutation) ResetUpdatedAt() {
  17048. m.updated_at = nil
  17049. }
  17050. // SetDeletedAt sets the "deleted_at" field.
  17051. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  17052. m.deleted_at = &t
  17053. }
  17054. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17055. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  17056. v := m.deleted_at
  17057. if v == nil {
  17058. return
  17059. }
  17060. return *v, true
  17061. }
  17062. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  17063. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17065. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17066. if !m.op.Is(OpUpdateOne) {
  17067. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17068. }
  17069. if m.id == nil || m.oldValue == nil {
  17070. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17071. }
  17072. oldValue, err := m.oldValue(ctx)
  17073. if err != nil {
  17074. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17075. }
  17076. return oldValue.DeletedAt, nil
  17077. }
  17078. // ClearDeletedAt clears the value of the "deleted_at" field.
  17079. func (m *EmployeeMutation) ClearDeletedAt() {
  17080. m.deleted_at = nil
  17081. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  17082. }
  17083. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17084. func (m *EmployeeMutation) DeletedAtCleared() bool {
  17085. _, ok := m.clearedFields[employee.FieldDeletedAt]
  17086. return ok
  17087. }
  17088. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17089. func (m *EmployeeMutation) ResetDeletedAt() {
  17090. m.deleted_at = nil
  17091. delete(m.clearedFields, employee.FieldDeletedAt)
  17092. }
  17093. // SetTitle sets the "title" field.
  17094. func (m *EmployeeMutation) SetTitle(s string) {
  17095. m.title = &s
  17096. }
  17097. // Title returns the value of the "title" field in the mutation.
  17098. func (m *EmployeeMutation) Title() (r string, exists bool) {
  17099. v := m.title
  17100. if v == nil {
  17101. return
  17102. }
  17103. return *v, true
  17104. }
  17105. // OldTitle returns the old "title" field's value of the Employee entity.
  17106. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17108. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  17109. if !m.op.Is(OpUpdateOne) {
  17110. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  17111. }
  17112. if m.id == nil || m.oldValue == nil {
  17113. return v, errors.New("OldTitle requires an ID field in the mutation")
  17114. }
  17115. oldValue, err := m.oldValue(ctx)
  17116. if err != nil {
  17117. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  17118. }
  17119. return oldValue.Title, nil
  17120. }
  17121. // ResetTitle resets all changes to the "title" field.
  17122. func (m *EmployeeMutation) ResetTitle() {
  17123. m.title = nil
  17124. }
  17125. // SetAvatar sets the "avatar" field.
  17126. func (m *EmployeeMutation) SetAvatar(s string) {
  17127. m.avatar = &s
  17128. }
  17129. // Avatar returns the value of the "avatar" field in the mutation.
  17130. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  17131. v := m.avatar
  17132. if v == nil {
  17133. return
  17134. }
  17135. return *v, true
  17136. }
  17137. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  17138. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17140. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  17141. if !m.op.Is(OpUpdateOne) {
  17142. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  17143. }
  17144. if m.id == nil || m.oldValue == nil {
  17145. return v, errors.New("OldAvatar requires an ID field in the mutation")
  17146. }
  17147. oldValue, err := m.oldValue(ctx)
  17148. if err != nil {
  17149. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  17150. }
  17151. return oldValue.Avatar, nil
  17152. }
  17153. // ResetAvatar resets all changes to the "avatar" field.
  17154. func (m *EmployeeMutation) ResetAvatar() {
  17155. m.avatar = nil
  17156. }
  17157. // SetTags sets the "tags" field.
  17158. func (m *EmployeeMutation) SetTags(s string) {
  17159. m.tags = &s
  17160. }
  17161. // Tags returns the value of the "tags" field in the mutation.
  17162. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  17163. v := m.tags
  17164. if v == nil {
  17165. return
  17166. }
  17167. return *v, true
  17168. }
  17169. // OldTags returns the old "tags" field's value of the Employee entity.
  17170. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17172. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  17173. if !m.op.Is(OpUpdateOne) {
  17174. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  17175. }
  17176. if m.id == nil || m.oldValue == nil {
  17177. return v, errors.New("OldTags requires an ID field in the mutation")
  17178. }
  17179. oldValue, err := m.oldValue(ctx)
  17180. if err != nil {
  17181. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  17182. }
  17183. return oldValue.Tags, nil
  17184. }
  17185. // ResetTags resets all changes to the "tags" field.
  17186. func (m *EmployeeMutation) ResetTags() {
  17187. m.tags = nil
  17188. }
  17189. // SetHireCount sets the "hire_count" field.
  17190. func (m *EmployeeMutation) SetHireCount(i int) {
  17191. m.hire_count = &i
  17192. m.addhire_count = nil
  17193. }
  17194. // HireCount returns the value of the "hire_count" field in the mutation.
  17195. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  17196. v := m.hire_count
  17197. if v == nil {
  17198. return
  17199. }
  17200. return *v, true
  17201. }
  17202. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  17203. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17205. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  17206. if !m.op.Is(OpUpdateOne) {
  17207. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  17208. }
  17209. if m.id == nil || m.oldValue == nil {
  17210. return v, errors.New("OldHireCount requires an ID field in the mutation")
  17211. }
  17212. oldValue, err := m.oldValue(ctx)
  17213. if err != nil {
  17214. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  17215. }
  17216. return oldValue.HireCount, nil
  17217. }
  17218. // AddHireCount adds i to the "hire_count" field.
  17219. func (m *EmployeeMutation) AddHireCount(i int) {
  17220. if m.addhire_count != nil {
  17221. *m.addhire_count += i
  17222. } else {
  17223. m.addhire_count = &i
  17224. }
  17225. }
  17226. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  17227. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  17228. v := m.addhire_count
  17229. if v == nil {
  17230. return
  17231. }
  17232. return *v, true
  17233. }
  17234. // ResetHireCount resets all changes to the "hire_count" field.
  17235. func (m *EmployeeMutation) ResetHireCount() {
  17236. m.hire_count = nil
  17237. m.addhire_count = nil
  17238. }
  17239. // SetServiceCount sets the "service_count" field.
  17240. func (m *EmployeeMutation) SetServiceCount(i int) {
  17241. m.service_count = &i
  17242. m.addservice_count = nil
  17243. }
  17244. // ServiceCount returns the value of the "service_count" field in the mutation.
  17245. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  17246. v := m.service_count
  17247. if v == nil {
  17248. return
  17249. }
  17250. return *v, true
  17251. }
  17252. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  17253. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17255. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  17256. if !m.op.Is(OpUpdateOne) {
  17257. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  17258. }
  17259. if m.id == nil || m.oldValue == nil {
  17260. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  17261. }
  17262. oldValue, err := m.oldValue(ctx)
  17263. if err != nil {
  17264. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  17265. }
  17266. return oldValue.ServiceCount, nil
  17267. }
  17268. // AddServiceCount adds i to the "service_count" field.
  17269. func (m *EmployeeMutation) AddServiceCount(i int) {
  17270. if m.addservice_count != nil {
  17271. *m.addservice_count += i
  17272. } else {
  17273. m.addservice_count = &i
  17274. }
  17275. }
  17276. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  17277. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  17278. v := m.addservice_count
  17279. if v == nil {
  17280. return
  17281. }
  17282. return *v, true
  17283. }
  17284. // ResetServiceCount resets all changes to the "service_count" field.
  17285. func (m *EmployeeMutation) ResetServiceCount() {
  17286. m.service_count = nil
  17287. m.addservice_count = nil
  17288. }
  17289. // SetAchievementCount sets the "achievement_count" field.
  17290. func (m *EmployeeMutation) SetAchievementCount(i int) {
  17291. m.achievement_count = &i
  17292. m.addachievement_count = nil
  17293. }
  17294. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  17295. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  17296. v := m.achievement_count
  17297. if v == nil {
  17298. return
  17299. }
  17300. return *v, true
  17301. }
  17302. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  17303. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17305. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  17306. if !m.op.Is(OpUpdateOne) {
  17307. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  17308. }
  17309. if m.id == nil || m.oldValue == nil {
  17310. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  17311. }
  17312. oldValue, err := m.oldValue(ctx)
  17313. if err != nil {
  17314. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  17315. }
  17316. return oldValue.AchievementCount, nil
  17317. }
  17318. // AddAchievementCount adds i to the "achievement_count" field.
  17319. func (m *EmployeeMutation) AddAchievementCount(i int) {
  17320. if m.addachievement_count != nil {
  17321. *m.addachievement_count += i
  17322. } else {
  17323. m.addachievement_count = &i
  17324. }
  17325. }
  17326. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  17327. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  17328. v := m.addachievement_count
  17329. if v == nil {
  17330. return
  17331. }
  17332. return *v, true
  17333. }
  17334. // ResetAchievementCount resets all changes to the "achievement_count" field.
  17335. func (m *EmployeeMutation) ResetAchievementCount() {
  17336. m.achievement_count = nil
  17337. m.addachievement_count = nil
  17338. }
  17339. // SetIntro sets the "intro" field.
  17340. func (m *EmployeeMutation) SetIntro(s string) {
  17341. m.intro = &s
  17342. }
  17343. // Intro returns the value of the "intro" field in the mutation.
  17344. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  17345. v := m.intro
  17346. if v == nil {
  17347. return
  17348. }
  17349. return *v, true
  17350. }
  17351. // OldIntro returns the old "intro" field's value of the Employee entity.
  17352. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17354. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  17355. if !m.op.Is(OpUpdateOne) {
  17356. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  17357. }
  17358. if m.id == nil || m.oldValue == nil {
  17359. return v, errors.New("OldIntro requires an ID field in the mutation")
  17360. }
  17361. oldValue, err := m.oldValue(ctx)
  17362. if err != nil {
  17363. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  17364. }
  17365. return oldValue.Intro, nil
  17366. }
  17367. // ResetIntro resets all changes to the "intro" field.
  17368. func (m *EmployeeMutation) ResetIntro() {
  17369. m.intro = nil
  17370. }
  17371. // SetEstimate sets the "estimate" field.
  17372. func (m *EmployeeMutation) SetEstimate(s string) {
  17373. m.estimate = &s
  17374. }
  17375. // Estimate returns the value of the "estimate" field in the mutation.
  17376. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  17377. v := m.estimate
  17378. if v == nil {
  17379. return
  17380. }
  17381. return *v, true
  17382. }
  17383. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  17384. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17386. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  17387. if !m.op.Is(OpUpdateOne) {
  17388. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  17389. }
  17390. if m.id == nil || m.oldValue == nil {
  17391. return v, errors.New("OldEstimate requires an ID field in the mutation")
  17392. }
  17393. oldValue, err := m.oldValue(ctx)
  17394. if err != nil {
  17395. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  17396. }
  17397. return oldValue.Estimate, nil
  17398. }
  17399. // ResetEstimate resets all changes to the "estimate" field.
  17400. func (m *EmployeeMutation) ResetEstimate() {
  17401. m.estimate = nil
  17402. }
  17403. // SetSkill sets the "skill" field.
  17404. func (m *EmployeeMutation) SetSkill(s string) {
  17405. m.skill = &s
  17406. }
  17407. // Skill returns the value of the "skill" field in the mutation.
  17408. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  17409. v := m.skill
  17410. if v == nil {
  17411. return
  17412. }
  17413. return *v, true
  17414. }
  17415. // OldSkill returns the old "skill" field's value of the Employee entity.
  17416. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17418. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  17419. if !m.op.Is(OpUpdateOne) {
  17420. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  17421. }
  17422. if m.id == nil || m.oldValue == nil {
  17423. return v, errors.New("OldSkill requires an ID field in the mutation")
  17424. }
  17425. oldValue, err := m.oldValue(ctx)
  17426. if err != nil {
  17427. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  17428. }
  17429. return oldValue.Skill, nil
  17430. }
  17431. // ResetSkill resets all changes to the "skill" field.
  17432. func (m *EmployeeMutation) ResetSkill() {
  17433. m.skill = nil
  17434. }
  17435. // SetAbilityType sets the "ability_type" field.
  17436. func (m *EmployeeMutation) SetAbilityType(s string) {
  17437. m.ability_type = &s
  17438. }
  17439. // AbilityType returns the value of the "ability_type" field in the mutation.
  17440. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  17441. v := m.ability_type
  17442. if v == nil {
  17443. return
  17444. }
  17445. return *v, true
  17446. }
  17447. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  17448. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17450. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  17451. if !m.op.Is(OpUpdateOne) {
  17452. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  17453. }
  17454. if m.id == nil || m.oldValue == nil {
  17455. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  17456. }
  17457. oldValue, err := m.oldValue(ctx)
  17458. if err != nil {
  17459. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  17460. }
  17461. return oldValue.AbilityType, nil
  17462. }
  17463. // ResetAbilityType resets all changes to the "ability_type" field.
  17464. func (m *EmployeeMutation) ResetAbilityType() {
  17465. m.ability_type = nil
  17466. }
  17467. // SetScene sets the "scene" field.
  17468. func (m *EmployeeMutation) SetScene(s string) {
  17469. m.scene = &s
  17470. }
  17471. // Scene returns the value of the "scene" field in the mutation.
  17472. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  17473. v := m.scene
  17474. if v == nil {
  17475. return
  17476. }
  17477. return *v, true
  17478. }
  17479. // OldScene returns the old "scene" field's value of the Employee entity.
  17480. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17482. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  17483. if !m.op.Is(OpUpdateOne) {
  17484. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  17485. }
  17486. if m.id == nil || m.oldValue == nil {
  17487. return v, errors.New("OldScene requires an ID field in the mutation")
  17488. }
  17489. oldValue, err := m.oldValue(ctx)
  17490. if err != nil {
  17491. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  17492. }
  17493. return oldValue.Scene, nil
  17494. }
  17495. // ResetScene resets all changes to the "scene" field.
  17496. func (m *EmployeeMutation) ResetScene() {
  17497. m.scene = nil
  17498. }
  17499. // SetSwitchIn sets the "switch_in" field.
  17500. func (m *EmployeeMutation) SetSwitchIn(s string) {
  17501. m.switch_in = &s
  17502. }
  17503. // SwitchIn returns the value of the "switch_in" field in the mutation.
  17504. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  17505. v := m.switch_in
  17506. if v == nil {
  17507. return
  17508. }
  17509. return *v, true
  17510. }
  17511. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  17512. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17514. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  17515. if !m.op.Is(OpUpdateOne) {
  17516. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  17517. }
  17518. if m.id == nil || m.oldValue == nil {
  17519. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  17520. }
  17521. oldValue, err := m.oldValue(ctx)
  17522. if err != nil {
  17523. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  17524. }
  17525. return oldValue.SwitchIn, nil
  17526. }
  17527. // ResetSwitchIn resets all changes to the "switch_in" field.
  17528. func (m *EmployeeMutation) ResetSwitchIn() {
  17529. m.switch_in = nil
  17530. }
  17531. // SetVideoURL sets the "video_url" field.
  17532. func (m *EmployeeMutation) SetVideoURL(s string) {
  17533. m.video_url = &s
  17534. }
  17535. // VideoURL returns the value of the "video_url" field in the mutation.
  17536. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  17537. v := m.video_url
  17538. if v == nil {
  17539. return
  17540. }
  17541. return *v, true
  17542. }
  17543. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  17544. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17546. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  17547. if !m.op.Is(OpUpdateOne) {
  17548. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  17549. }
  17550. if m.id == nil || m.oldValue == nil {
  17551. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  17552. }
  17553. oldValue, err := m.oldValue(ctx)
  17554. if err != nil {
  17555. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  17556. }
  17557. return oldValue.VideoURL, nil
  17558. }
  17559. // ResetVideoURL resets all changes to the "video_url" field.
  17560. func (m *EmployeeMutation) ResetVideoURL() {
  17561. m.video_url = nil
  17562. }
  17563. // SetOrganizationID sets the "organization_id" field.
  17564. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  17565. m.organization_id = &u
  17566. m.addorganization_id = nil
  17567. }
  17568. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17569. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  17570. v := m.organization_id
  17571. if v == nil {
  17572. return
  17573. }
  17574. return *v, true
  17575. }
  17576. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  17577. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17579. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17580. if !m.op.Is(OpUpdateOne) {
  17581. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17582. }
  17583. if m.id == nil || m.oldValue == nil {
  17584. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17585. }
  17586. oldValue, err := m.oldValue(ctx)
  17587. if err != nil {
  17588. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17589. }
  17590. return oldValue.OrganizationID, nil
  17591. }
  17592. // AddOrganizationID adds u to the "organization_id" field.
  17593. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  17594. if m.addorganization_id != nil {
  17595. *m.addorganization_id += u
  17596. } else {
  17597. m.addorganization_id = &u
  17598. }
  17599. }
  17600. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17601. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  17602. v := m.addorganization_id
  17603. if v == nil {
  17604. return
  17605. }
  17606. return *v, true
  17607. }
  17608. // ResetOrganizationID resets all changes to the "organization_id" field.
  17609. func (m *EmployeeMutation) ResetOrganizationID() {
  17610. m.organization_id = nil
  17611. m.addorganization_id = nil
  17612. }
  17613. // SetCategoryID sets the "category_id" field.
  17614. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  17615. m.category_id = &u
  17616. m.addcategory_id = nil
  17617. }
  17618. // CategoryID returns the value of the "category_id" field in the mutation.
  17619. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  17620. v := m.category_id
  17621. if v == nil {
  17622. return
  17623. }
  17624. return *v, true
  17625. }
  17626. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  17627. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17629. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  17630. if !m.op.Is(OpUpdateOne) {
  17631. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  17632. }
  17633. if m.id == nil || m.oldValue == nil {
  17634. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  17635. }
  17636. oldValue, err := m.oldValue(ctx)
  17637. if err != nil {
  17638. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  17639. }
  17640. return oldValue.CategoryID, nil
  17641. }
  17642. // AddCategoryID adds u to the "category_id" field.
  17643. func (m *EmployeeMutation) AddCategoryID(u int64) {
  17644. if m.addcategory_id != nil {
  17645. *m.addcategory_id += u
  17646. } else {
  17647. m.addcategory_id = &u
  17648. }
  17649. }
  17650. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  17651. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  17652. v := m.addcategory_id
  17653. if v == nil {
  17654. return
  17655. }
  17656. return *v, true
  17657. }
  17658. // ResetCategoryID resets all changes to the "category_id" field.
  17659. func (m *EmployeeMutation) ResetCategoryID() {
  17660. m.category_id = nil
  17661. m.addcategory_id = nil
  17662. }
  17663. // SetAPIBase sets the "api_base" field.
  17664. func (m *EmployeeMutation) SetAPIBase(s string) {
  17665. m.api_base = &s
  17666. }
  17667. // APIBase returns the value of the "api_base" field in the mutation.
  17668. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  17669. v := m.api_base
  17670. if v == nil {
  17671. return
  17672. }
  17673. return *v, true
  17674. }
  17675. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  17676. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17678. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  17679. if !m.op.Is(OpUpdateOne) {
  17680. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  17681. }
  17682. if m.id == nil || m.oldValue == nil {
  17683. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  17684. }
  17685. oldValue, err := m.oldValue(ctx)
  17686. if err != nil {
  17687. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  17688. }
  17689. return oldValue.APIBase, nil
  17690. }
  17691. // ResetAPIBase resets all changes to the "api_base" field.
  17692. func (m *EmployeeMutation) ResetAPIBase() {
  17693. m.api_base = nil
  17694. }
  17695. // SetAPIKey sets the "api_key" field.
  17696. func (m *EmployeeMutation) SetAPIKey(s string) {
  17697. m.api_key = &s
  17698. }
  17699. // APIKey returns the value of the "api_key" field in the mutation.
  17700. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  17701. v := m.api_key
  17702. if v == nil {
  17703. return
  17704. }
  17705. return *v, true
  17706. }
  17707. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  17708. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17710. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  17711. if !m.op.Is(OpUpdateOne) {
  17712. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  17713. }
  17714. if m.id == nil || m.oldValue == nil {
  17715. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  17716. }
  17717. oldValue, err := m.oldValue(ctx)
  17718. if err != nil {
  17719. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  17720. }
  17721. return oldValue.APIKey, nil
  17722. }
  17723. // ResetAPIKey resets all changes to the "api_key" field.
  17724. func (m *EmployeeMutation) ResetAPIKey() {
  17725. m.api_key = nil
  17726. }
  17727. // SetAiInfo sets the "ai_info" field.
  17728. func (m *EmployeeMutation) SetAiInfo(s string) {
  17729. m.ai_info = &s
  17730. }
  17731. // AiInfo returns the value of the "ai_info" field in the mutation.
  17732. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  17733. v := m.ai_info
  17734. if v == nil {
  17735. return
  17736. }
  17737. return *v, true
  17738. }
  17739. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  17740. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17742. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  17743. if !m.op.Is(OpUpdateOne) {
  17744. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  17745. }
  17746. if m.id == nil || m.oldValue == nil {
  17747. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  17748. }
  17749. oldValue, err := m.oldValue(ctx)
  17750. if err != nil {
  17751. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  17752. }
  17753. return oldValue.AiInfo, nil
  17754. }
  17755. // ClearAiInfo clears the value of the "ai_info" field.
  17756. func (m *EmployeeMutation) ClearAiInfo() {
  17757. m.ai_info = nil
  17758. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  17759. }
  17760. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  17761. func (m *EmployeeMutation) AiInfoCleared() bool {
  17762. _, ok := m.clearedFields[employee.FieldAiInfo]
  17763. return ok
  17764. }
  17765. // ResetAiInfo resets all changes to the "ai_info" field.
  17766. func (m *EmployeeMutation) ResetAiInfo() {
  17767. m.ai_info = nil
  17768. delete(m.clearedFields, employee.FieldAiInfo)
  17769. }
  17770. // SetIsVip sets the "is_vip" field.
  17771. func (m *EmployeeMutation) SetIsVip(i int) {
  17772. m.is_vip = &i
  17773. m.addis_vip = nil
  17774. }
  17775. // IsVip returns the value of the "is_vip" field in the mutation.
  17776. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  17777. v := m.is_vip
  17778. if v == nil {
  17779. return
  17780. }
  17781. return *v, true
  17782. }
  17783. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  17784. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17786. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  17787. if !m.op.Is(OpUpdateOne) {
  17788. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  17789. }
  17790. if m.id == nil || m.oldValue == nil {
  17791. return v, errors.New("OldIsVip requires an ID field in the mutation")
  17792. }
  17793. oldValue, err := m.oldValue(ctx)
  17794. if err != nil {
  17795. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  17796. }
  17797. return oldValue.IsVip, nil
  17798. }
  17799. // AddIsVip adds i to the "is_vip" field.
  17800. func (m *EmployeeMutation) AddIsVip(i int) {
  17801. if m.addis_vip != nil {
  17802. *m.addis_vip += i
  17803. } else {
  17804. m.addis_vip = &i
  17805. }
  17806. }
  17807. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  17808. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  17809. v := m.addis_vip
  17810. if v == nil {
  17811. return
  17812. }
  17813. return *v, true
  17814. }
  17815. // ResetIsVip resets all changes to the "is_vip" field.
  17816. func (m *EmployeeMutation) ResetIsVip() {
  17817. m.is_vip = nil
  17818. m.addis_vip = nil
  17819. }
  17820. // SetChatURL sets the "chat_url" field.
  17821. func (m *EmployeeMutation) SetChatURL(s string) {
  17822. m.chat_url = &s
  17823. }
  17824. // ChatURL returns the value of the "chat_url" field in the mutation.
  17825. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  17826. v := m.chat_url
  17827. if v == nil {
  17828. return
  17829. }
  17830. return *v, true
  17831. }
  17832. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  17833. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17835. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  17836. if !m.op.Is(OpUpdateOne) {
  17837. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  17838. }
  17839. if m.id == nil || m.oldValue == nil {
  17840. return v, errors.New("OldChatURL requires an ID field in the mutation")
  17841. }
  17842. oldValue, err := m.oldValue(ctx)
  17843. if err != nil {
  17844. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  17845. }
  17846. return oldValue.ChatURL, nil
  17847. }
  17848. // ResetChatURL resets all changes to the "chat_url" field.
  17849. func (m *EmployeeMutation) ResetChatURL() {
  17850. m.chat_url = nil
  17851. }
  17852. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  17853. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  17854. if m.em_work_experiences == nil {
  17855. m.em_work_experiences = make(map[uint64]struct{})
  17856. }
  17857. for i := range ids {
  17858. m.em_work_experiences[ids[i]] = struct{}{}
  17859. }
  17860. }
  17861. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  17862. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  17863. m.clearedem_work_experiences = true
  17864. }
  17865. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  17866. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  17867. return m.clearedem_work_experiences
  17868. }
  17869. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  17870. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  17871. if m.removedem_work_experiences == nil {
  17872. m.removedem_work_experiences = make(map[uint64]struct{})
  17873. }
  17874. for i := range ids {
  17875. delete(m.em_work_experiences, ids[i])
  17876. m.removedem_work_experiences[ids[i]] = struct{}{}
  17877. }
  17878. }
  17879. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  17880. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  17881. for id := range m.removedem_work_experiences {
  17882. ids = append(ids, id)
  17883. }
  17884. return
  17885. }
  17886. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  17887. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  17888. for id := range m.em_work_experiences {
  17889. ids = append(ids, id)
  17890. }
  17891. return
  17892. }
  17893. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  17894. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  17895. m.em_work_experiences = nil
  17896. m.clearedem_work_experiences = false
  17897. m.removedem_work_experiences = nil
  17898. }
  17899. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  17900. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  17901. if m.em_tutorial == nil {
  17902. m.em_tutorial = make(map[uint64]struct{})
  17903. }
  17904. for i := range ids {
  17905. m.em_tutorial[ids[i]] = struct{}{}
  17906. }
  17907. }
  17908. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  17909. func (m *EmployeeMutation) ClearEmTutorial() {
  17910. m.clearedem_tutorial = true
  17911. }
  17912. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  17913. func (m *EmployeeMutation) EmTutorialCleared() bool {
  17914. return m.clearedem_tutorial
  17915. }
  17916. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  17917. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  17918. if m.removedem_tutorial == nil {
  17919. m.removedem_tutorial = make(map[uint64]struct{})
  17920. }
  17921. for i := range ids {
  17922. delete(m.em_tutorial, ids[i])
  17923. m.removedem_tutorial[ids[i]] = struct{}{}
  17924. }
  17925. }
  17926. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  17927. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  17928. for id := range m.removedem_tutorial {
  17929. ids = append(ids, id)
  17930. }
  17931. return
  17932. }
  17933. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  17934. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  17935. for id := range m.em_tutorial {
  17936. ids = append(ids, id)
  17937. }
  17938. return
  17939. }
  17940. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  17941. func (m *EmployeeMutation) ResetEmTutorial() {
  17942. m.em_tutorial = nil
  17943. m.clearedem_tutorial = false
  17944. m.removedem_tutorial = nil
  17945. }
  17946. // Where appends a list predicates to the EmployeeMutation builder.
  17947. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  17948. m.predicates = append(m.predicates, ps...)
  17949. }
  17950. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  17951. // users can use type-assertion to append predicates that do not depend on any generated package.
  17952. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  17953. p := make([]predicate.Employee, len(ps))
  17954. for i := range ps {
  17955. p[i] = ps[i]
  17956. }
  17957. m.Where(p...)
  17958. }
  17959. // Op returns the operation name.
  17960. func (m *EmployeeMutation) Op() Op {
  17961. return m.op
  17962. }
  17963. // SetOp allows setting the mutation operation.
  17964. func (m *EmployeeMutation) SetOp(op Op) {
  17965. m.op = op
  17966. }
  17967. // Type returns the node type of this mutation (Employee).
  17968. func (m *EmployeeMutation) Type() string {
  17969. return m.typ
  17970. }
  17971. // Fields returns all fields that were changed during this mutation. Note that in
  17972. // order to get all numeric fields that were incremented/decremented, call
  17973. // AddedFields().
  17974. func (m *EmployeeMutation) Fields() []string {
  17975. fields := make([]string, 0, 23)
  17976. if m.created_at != nil {
  17977. fields = append(fields, employee.FieldCreatedAt)
  17978. }
  17979. if m.updated_at != nil {
  17980. fields = append(fields, employee.FieldUpdatedAt)
  17981. }
  17982. if m.deleted_at != nil {
  17983. fields = append(fields, employee.FieldDeletedAt)
  17984. }
  17985. if m.title != nil {
  17986. fields = append(fields, employee.FieldTitle)
  17987. }
  17988. if m.avatar != nil {
  17989. fields = append(fields, employee.FieldAvatar)
  17990. }
  17991. if m.tags != nil {
  17992. fields = append(fields, employee.FieldTags)
  17993. }
  17994. if m.hire_count != nil {
  17995. fields = append(fields, employee.FieldHireCount)
  17996. }
  17997. if m.service_count != nil {
  17998. fields = append(fields, employee.FieldServiceCount)
  17999. }
  18000. if m.achievement_count != nil {
  18001. fields = append(fields, employee.FieldAchievementCount)
  18002. }
  18003. if m.intro != nil {
  18004. fields = append(fields, employee.FieldIntro)
  18005. }
  18006. if m.estimate != nil {
  18007. fields = append(fields, employee.FieldEstimate)
  18008. }
  18009. if m.skill != nil {
  18010. fields = append(fields, employee.FieldSkill)
  18011. }
  18012. if m.ability_type != nil {
  18013. fields = append(fields, employee.FieldAbilityType)
  18014. }
  18015. if m.scene != nil {
  18016. fields = append(fields, employee.FieldScene)
  18017. }
  18018. if m.switch_in != nil {
  18019. fields = append(fields, employee.FieldSwitchIn)
  18020. }
  18021. if m.video_url != nil {
  18022. fields = append(fields, employee.FieldVideoURL)
  18023. }
  18024. if m.organization_id != nil {
  18025. fields = append(fields, employee.FieldOrganizationID)
  18026. }
  18027. if m.category_id != nil {
  18028. fields = append(fields, employee.FieldCategoryID)
  18029. }
  18030. if m.api_base != nil {
  18031. fields = append(fields, employee.FieldAPIBase)
  18032. }
  18033. if m.api_key != nil {
  18034. fields = append(fields, employee.FieldAPIKey)
  18035. }
  18036. if m.ai_info != nil {
  18037. fields = append(fields, employee.FieldAiInfo)
  18038. }
  18039. if m.is_vip != nil {
  18040. fields = append(fields, employee.FieldIsVip)
  18041. }
  18042. if m.chat_url != nil {
  18043. fields = append(fields, employee.FieldChatURL)
  18044. }
  18045. return fields
  18046. }
  18047. // Field returns the value of a field with the given name. The second boolean
  18048. // return value indicates that this field was not set, or was not defined in the
  18049. // schema.
  18050. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  18051. switch name {
  18052. case employee.FieldCreatedAt:
  18053. return m.CreatedAt()
  18054. case employee.FieldUpdatedAt:
  18055. return m.UpdatedAt()
  18056. case employee.FieldDeletedAt:
  18057. return m.DeletedAt()
  18058. case employee.FieldTitle:
  18059. return m.Title()
  18060. case employee.FieldAvatar:
  18061. return m.Avatar()
  18062. case employee.FieldTags:
  18063. return m.Tags()
  18064. case employee.FieldHireCount:
  18065. return m.HireCount()
  18066. case employee.FieldServiceCount:
  18067. return m.ServiceCount()
  18068. case employee.FieldAchievementCount:
  18069. return m.AchievementCount()
  18070. case employee.FieldIntro:
  18071. return m.Intro()
  18072. case employee.FieldEstimate:
  18073. return m.Estimate()
  18074. case employee.FieldSkill:
  18075. return m.Skill()
  18076. case employee.FieldAbilityType:
  18077. return m.AbilityType()
  18078. case employee.FieldScene:
  18079. return m.Scene()
  18080. case employee.FieldSwitchIn:
  18081. return m.SwitchIn()
  18082. case employee.FieldVideoURL:
  18083. return m.VideoURL()
  18084. case employee.FieldOrganizationID:
  18085. return m.OrganizationID()
  18086. case employee.FieldCategoryID:
  18087. return m.CategoryID()
  18088. case employee.FieldAPIBase:
  18089. return m.APIBase()
  18090. case employee.FieldAPIKey:
  18091. return m.APIKey()
  18092. case employee.FieldAiInfo:
  18093. return m.AiInfo()
  18094. case employee.FieldIsVip:
  18095. return m.IsVip()
  18096. case employee.FieldChatURL:
  18097. return m.ChatURL()
  18098. }
  18099. return nil, false
  18100. }
  18101. // OldField returns the old value of the field from the database. An error is
  18102. // returned if the mutation operation is not UpdateOne, or the query to the
  18103. // database failed.
  18104. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18105. switch name {
  18106. case employee.FieldCreatedAt:
  18107. return m.OldCreatedAt(ctx)
  18108. case employee.FieldUpdatedAt:
  18109. return m.OldUpdatedAt(ctx)
  18110. case employee.FieldDeletedAt:
  18111. return m.OldDeletedAt(ctx)
  18112. case employee.FieldTitle:
  18113. return m.OldTitle(ctx)
  18114. case employee.FieldAvatar:
  18115. return m.OldAvatar(ctx)
  18116. case employee.FieldTags:
  18117. return m.OldTags(ctx)
  18118. case employee.FieldHireCount:
  18119. return m.OldHireCount(ctx)
  18120. case employee.FieldServiceCount:
  18121. return m.OldServiceCount(ctx)
  18122. case employee.FieldAchievementCount:
  18123. return m.OldAchievementCount(ctx)
  18124. case employee.FieldIntro:
  18125. return m.OldIntro(ctx)
  18126. case employee.FieldEstimate:
  18127. return m.OldEstimate(ctx)
  18128. case employee.FieldSkill:
  18129. return m.OldSkill(ctx)
  18130. case employee.FieldAbilityType:
  18131. return m.OldAbilityType(ctx)
  18132. case employee.FieldScene:
  18133. return m.OldScene(ctx)
  18134. case employee.FieldSwitchIn:
  18135. return m.OldSwitchIn(ctx)
  18136. case employee.FieldVideoURL:
  18137. return m.OldVideoURL(ctx)
  18138. case employee.FieldOrganizationID:
  18139. return m.OldOrganizationID(ctx)
  18140. case employee.FieldCategoryID:
  18141. return m.OldCategoryID(ctx)
  18142. case employee.FieldAPIBase:
  18143. return m.OldAPIBase(ctx)
  18144. case employee.FieldAPIKey:
  18145. return m.OldAPIKey(ctx)
  18146. case employee.FieldAiInfo:
  18147. return m.OldAiInfo(ctx)
  18148. case employee.FieldIsVip:
  18149. return m.OldIsVip(ctx)
  18150. case employee.FieldChatURL:
  18151. return m.OldChatURL(ctx)
  18152. }
  18153. return nil, fmt.Errorf("unknown Employee field %s", name)
  18154. }
  18155. // SetField sets the value of a field with the given name. It returns an error if
  18156. // the field is not defined in the schema, or if the type mismatched the field
  18157. // type.
  18158. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  18159. switch name {
  18160. case employee.FieldCreatedAt:
  18161. v, ok := value.(time.Time)
  18162. if !ok {
  18163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18164. }
  18165. m.SetCreatedAt(v)
  18166. return nil
  18167. case employee.FieldUpdatedAt:
  18168. v, ok := value.(time.Time)
  18169. if !ok {
  18170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18171. }
  18172. m.SetUpdatedAt(v)
  18173. return nil
  18174. case employee.FieldDeletedAt:
  18175. v, ok := value.(time.Time)
  18176. if !ok {
  18177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18178. }
  18179. m.SetDeletedAt(v)
  18180. return nil
  18181. case employee.FieldTitle:
  18182. v, ok := value.(string)
  18183. if !ok {
  18184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18185. }
  18186. m.SetTitle(v)
  18187. return nil
  18188. case employee.FieldAvatar:
  18189. v, ok := value.(string)
  18190. if !ok {
  18191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18192. }
  18193. m.SetAvatar(v)
  18194. return nil
  18195. case employee.FieldTags:
  18196. v, ok := value.(string)
  18197. if !ok {
  18198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18199. }
  18200. m.SetTags(v)
  18201. return nil
  18202. case employee.FieldHireCount:
  18203. v, ok := value.(int)
  18204. if !ok {
  18205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18206. }
  18207. m.SetHireCount(v)
  18208. return nil
  18209. case employee.FieldServiceCount:
  18210. v, ok := value.(int)
  18211. if !ok {
  18212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18213. }
  18214. m.SetServiceCount(v)
  18215. return nil
  18216. case employee.FieldAchievementCount:
  18217. v, ok := value.(int)
  18218. if !ok {
  18219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18220. }
  18221. m.SetAchievementCount(v)
  18222. return nil
  18223. case employee.FieldIntro:
  18224. v, ok := value.(string)
  18225. if !ok {
  18226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18227. }
  18228. m.SetIntro(v)
  18229. return nil
  18230. case employee.FieldEstimate:
  18231. v, ok := value.(string)
  18232. if !ok {
  18233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18234. }
  18235. m.SetEstimate(v)
  18236. return nil
  18237. case employee.FieldSkill:
  18238. v, ok := value.(string)
  18239. if !ok {
  18240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18241. }
  18242. m.SetSkill(v)
  18243. return nil
  18244. case employee.FieldAbilityType:
  18245. v, ok := value.(string)
  18246. if !ok {
  18247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18248. }
  18249. m.SetAbilityType(v)
  18250. return nil
  18251. case employee.FieldScene:
  18252. v, ok := value.(string)
  18253. if !ok {
  18254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18255. }
  18256. m.SetScene(v)
  18257. return nil
  18258. case employee.FieldSwitchIn:
  18259. v, ok := value.(string)
  18260. if !ok {
  18261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18262. }
  18263. m.SetSwitchIn(v)
  18264. return nil
  18265. case employee.FieldVideoURL:
  18266. v, ok := value.(string)
  18267. if !ok {
  18268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18269. }
  18270. m.SetVideoURL(v)
  18271. return nil
  18272. case employee.FieldOrganizationID:
  18273. v, ok := value.(uint64)
  18274. if !ok {
  18275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18276. }
  18277. m.SetOrganizationID(v)
  18278. return nil
  18279. case employee.FieldCategoryID:
  18280. v, ok := value.(uint64)
  18281. if !ok {
  18282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18283. }
  18284. m.SetCategoryID(v)
  18285. return nil
  18286. case employee.FieldAPIBase:
  18287. v, ok := value.(string)
  18288. if !ok {
  18289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18290. }
  18291. m.SetAPIBase(v)
  18292. return nil
  18293. case employee.FieldAPIKey:
  18294. v, ok := value.(string)
  18295. if !ok {
  18296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18297. }
  18298. m.SetAPIKey(v)
  18299. return nil
  18300. case employee.FieldAiInfo:
  18301. v, ok := value.(string)
  18302. if !ok {
  18303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18304. }
  18305. m.SetAiInfo(v)
  18306. return nil
  18307. case employee.FieldIsVip:
  18308. v, ok := value.(int)
  18309. if !ok {
  18310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18311. }
  18312. m.SetIsVip(v)
  18313. return nil
  18314. case employee.FieldChatURL:
  18315. v, ok := value.(string)
  18316. if !ok {
  18317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18318. }
  18319. m.SetChatURL(v)
  18320. return nil
  18321. }
  18322. return fmt.Errorf("unknown Employee field %s", name)
  18323. }
  18324. // AddedFields returns all numeric fields that were incremented/decremented during
  18325. // this mutation.
  18326. func (m *EmployeeMutation) AddedFields() []string {
  18327. var fields []string
  18328. if m.addhire_count != nil {
  18329. fields = append(fields, employee.FieldHireCount)
  18330. }
  18331. if m.addservice_count != nil {
  18332. fields = append(fields, employee.FieldServiceCount)
  18333. }
  18334. if m.addachievement_count != nil {
  18335. fields = append(fields, employee.FieldAchievementCount)
  18336. }
  18337. if m.addorganization_id != nil {
  18338. fields = append(fields, employee.FieldOrganizationID)
  18339. }
  18340. if m.addcategory_id != nil {
  18341. fields = append(fields, employee.FieldCategoryID)
  18342. }
  18343. if m.addis_vip != nil {
  18344. fields = append(fields, employee.FieldIsVip)
  18345. }
  18346. return fields
  18347. }
  18348. // AddedField returns the numeric value that was incremented/decremented on a field
  18349. // with the given name. The second boolean return value indicates that this field
  18350. // was not set, or was not defined in the schema.
  18351. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  18352. switch name {
  18353. case employee.FieldHireCount:
  18354. return m.AddedHireCount()
  18355. case employee.FieldServiceCount:
  18356. return m.AddedServiceCount()
  18357. case employee.FieldAchievementCount:
  18358. return m.AddedAchievementCount()
  18359. case employee.FieldOrganizationID:
  18360. return m.AddedOrganizationID()
  18361. case employee.FieldCategoryID:
  18362. return m.AddedCategoryID()
  18363. case employee.FieldIsVip:
  18364. return m.AddedIsVip()
  18365. }
  18366. return nil, false
  18367. }
  18368. // AddField adds the value to the field with the given name. It returns an error if
  18369. // the field is not defined in the schema, or if the type mismatched the field
  18370. // type.
  18371. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  18372. switch name {
  18373. case employee.FieldHireCount:
  18374. v, ok := value.(int)
  18375. if !ok {
  18376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18377. }
  18378. m.AddHireCount(v)
  18379. return nil
  18380. case employee.FieldServiceCount:
  18381. v, ok := value.(int)
  18382. if !ok {
  18383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18384. }
  18385. m.AddServiceCount(v)
  18386. return nil
  18387. case employee.FieldAchievementCount:
  18388. v, ok := value.(int)
  18389. if !ok {
  18390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18391. }
  18392. m.AddAchievementCount(v)
  18393. return nil
  18394. case employee.FieldOrganizationID:
  18395. v, ok := value.(int64)
  18396. if !ok {
  18397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18398. }
  18399. m.AddOrganizationID(v)
  18400. return nil
  18401. case employee.FieldCategoryID:
  18402. v, ok := value.(int64)
  18403. if !ok {
  18404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18405. }
  18406. m.AddCategoryID(v)
  18407. return nil
  18408. case employee.FieldIsVip:
  18409. v, ok := value.(int)
  18410. if !ok {
  18411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18412. }
  18413. m.AddIsVip(v)
  18414. return nil
  18415. }
  18416. return fmt.Errorf("unknown Employee numeric field %s", name)
  18417. }
  18418. // ClearedFields returns all nullable fields that were cleared during this
  18419. // mutation.
  18420. func (m *EmployeeMutation) ClearedFields() []string {
  18421. var fields []string
  18422. if m.FieldCleared(employee.FieldDeletedAt) {
  18423. fields = append(fields, employee.FieldDeletedAt)
  18424. }
  18425. if m.FieldCleared(employee.FieldAiInfo) {
  18426. fields = append(fields, employee.FieldAiInfo)
  18427. }
  18428. return fields
  18429. }
  18430. // FieldCleared returns a boolean indicating if a field with the given name was
  18431. // cleared in this mutation.
  18432. func (m *EmployeeMutation) FieldCleared(name string) bool {
  18433. _, ok := m.clearedFields[name]
  18434. return ok
  18435. }
  18436. // ClearField clears the value of the field with the given name. It returns an
  18437. // error if the field is not defined in the schema.
  18438. func (m *EmployeeMutation) ClearField(name string) error {
  18439. switch name {
  18440. case employee.FieldDeletedAt:
  18441. m.ClearDeletedAt()
  18442. return nil
  18443. case employee.FieldAiInfo:
  18444. m.ClearAiInfo()
  18445. return nil
  18446. }
  18447. return fmt.Errorf("unknown Employee nullable field %s", name)
  18448. }
  18449. // ResetField resets all changes in the mutation for the field with the given name.
  18450. // It returns an error if the field is not defined in the schema.
  18451. func (m *EmployeeMutation) ResetField(name string) error {
  18452. switch name {
  18453. case employee.FieldCreatedAt:
  18454. m.ResetCreatedAt()
  18455. return nil
  18456. case employee.FieldUpdatedAt:
  18457. m.ResetUpdatedAt()
  18458. return nil
  18459. case employee.FieldDeletedAt:
  18460. m.ResetDeletedAt()
  18461. return nil
  18462. case employee.FieldTitle:
  18463. m.ResetTitle()
  18464. return nil
  18465. case employee.FieldAvatar:
  18466. m.ResetAvatar()
  18467. return nil
  18468. case employee.FieldTags:
  18469. m.ResetTags()
  18470. return nil
  18471. case employee.FieldHireCount:
  18472. m.ResetHireCount()
  18473. return nil
  18474. case employee.FieldServiceCount:
  18475. m.ResetServiceCount()
  18476. return nil
  18477. case employee.FieldAchievementCount:
  18478. m.ResetAchievementCount()
  18479. return nil
  18480. case employee.FieldIntro:
  18481. m.ResetIntro()
  18482. return nil
  18483. case employee.FieldEstimate:
  18484. m.ResetEstimate()
  18485. return nil
  18486. case employee.FieldSkill:
  18487. m.ResetSkill()
  18488. return nil
  18489. case employee.FieldAbilityType:
  18490. m.ResetAbilityType()
  18491. return nil
  18492. case employee.FieldScene:
  18493. m.ResetScene()
  18494. return nil
  18495. case employee.FieldSwitchIn:
  18496. m.ResetSwitchIn()
  18497. return nil
  18498. case employee.FieldVideoURL:
  18499. m.ResetVideoURL()
  18500. return nil
  18501. case employee.FieldOrganizationID:
  18502. m.ResetOrganizationID()
  18503. return nil
  18504. case employee.FieldCategoryID:
  18505. m.ResetCategoryID()
  18506. return nil
  18507. case employee.FieldAPIBase:
  18508. m.ResetAPIBase()
  18509. return nil
  18510. case employee.FieldAPIKey:
  18511. m.ResetAPIKey()
  18512. return nil
  18513. case employee.FieldAiInfo:
  18514. m.ResetAiInfo()
  18515. return nil
  18516. case employee.FieldIsVip:
  18517. m.ResetIsVip()
  18518. return nil
  18519. case employee.FieldChatURL:
  18520. m.ResetChatURL()
  18521. return nil
  18522. }
  18523. return fmt.Errorf("unknown Employee field %s", name)
  18524. }
  18525. // AddedEdges returns all edge names that were set/added in this mutation.
  18526. func (m *EmployeeMutation) AddedEdges() []string {
  18527. edges := make([]string, 0, 2)
  18528. if m.em_work_experiences != nil {
  18529. edges = append(edges, employee.EdgeEmWorkExperiences)
  18530. }
  18531. if m.em_tutorial != nil {
  18532. edges = append(edges, employee.EdgeEmTutorial)
  18533. }
  18534. return edges
  18535. }
  18536. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18537. // name in this mutation.
  18538. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  18539. switch name {
  18540. case employee.EdgeEmWorkExperiences:
  18541. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  18542. for id := range m.em_work_experiences {
  18543. ids = append(ids, id)
  18544. }
  18545. return ids
  18546. case employee.EdgeEmTutorial:
  18547. ids := make([]ent.Value, 0, len(m.em_tutorial))
  18548. for id := range m.em_tutorial {
  18549. ids = append(ids, id)
  18550. }
  18551. return ids
  18552. }
  18553. return nil
  18554. }
  18555. // RemovedEdges returns all edge names that were removed in this mutation.
  18556. func (m *EmployeeMutation) RemovedEdges() []string {
  18557. edges := make([]string, 0, 2)
  18558. if m.removedem_work_experiences != nil {
  18559. edges = append(edges, employee.EdgeEmWorkExperiences)
  18560. }
  18561. if m.removedem_tutorial != nil {
  18562. edges = append(edges, employee.EdgeEmTutorial)
  18563. }
  18564. return edges
  18565. }
  18566. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18567. // the given name in this mutation.
  18568. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  18569. switch name {
  18570. case employee.EdgeEmWorkExperiences:
  18571. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  18572. for id := range m.removedem_work_experiences {
  18573. ids = append(ids, id)
  18574. }
  18575. return ids
  18576. case employee.EdgeEmTutorial:
  18577. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  18578. for id := range m.removedem_tutorial {
  18579. ids = append(ids, id)
  18580. }
  18581. return ids
  18582. }
  18583. return nil
  18584. }
  18585. // ClearedEdges returns all edge names that were cleared in this mutation.
  18586. func (m *EmployeeMutation) ClearedEdges() []string {
  18587. edges := make([]string, 0, 2)
  18588. if m.clearedem_work_experiences {
  18589. edges = append(edges, employee.EdgeEmWorkExperiences)
  18590. }
  18591. if m.clearedem_tutorial {
  18592. edges = append(edges, employee.EdgeEmTutorial)
  18593. }
  18594. return edges
  18595. }
  18596. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18597. // was cleared in this mutation.
  18598. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  18599. switch name {
  18600. case employee.EdgeEmWorkExperiences:
  18601. return m.clearedem_work_experiences
  18602. case employee.EdgeEmTutorial:
  18603. return m.clearedem_tutorial
  18604. }
  18605. return false
  18606. }
  18607. // ClearEdge clears the value of the edge with the given name. It returns an error
  18608. // if that edge is not defined in the schema.
  18609. func (m *EmployeeMutation) ClearEdge(name string) error {
  18610. switch name {
  18611. }
  18612. return fmt.Errorf("unknown Employee unique edge %s", name)
  18613. }
  18614. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18615. // It returns an error if the edge is not defined in the schema.
  18616. func (m *EmployeeMutation) ResetEdge(name string) error {
  18617. switch name {
  18618. case employee.EdgeEmWorkExperiences:
  18619. m.ResetEmWorkExperiences()
  18620. return nil
  18621. case employee.EdgeEmTutorial:
  18622. m.ResetEmTutorial()
  18623. return nil
  18624. }
  18625. return fmt.Errorf("unknown Employee edge %s", name)
  18626. }
  18627. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  18628. type EmployeeConfigMutation struct {
  18629. config
  18630. op Op
  18631. typ string
  18632. id *uint64
  18633. created_at *time.Time
  18634. updated_at *time.Time
  18635. deleted_at *time.Time
  18636. stype *string
  18637. title *string
  18638. photo *string
  18639. organization_id *uint64
  18640. addorganization_id *int64
  18641. clearedFields map[string]struct{}
  18642. done bool
  18643. oldValue func(context.Context) (*EmployeeConfig, error)
  18644. predicates []predicate.EmployeeConfig
  18645. }
  18646. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  18647. // employeeconfigOption allows management of the mutation configuration using functional options.
  18648. type employeeconfigOption func(*EmployeeConfigMutation)
  18649. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  18650. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  18651. m := &EmployeeConfigMutation{
  18652. config: c,
  18653. op: op,
  18654. typ: TypeEmployeeConfig,
  18655. clearedFields: make(map[string]struct{}),
  18656. }
  18657. for _, opt := range opts {
  18658. opt(m)
  18659. }
  18660. return m
  18661. }
  18662. // withEmployeeConfigID sets the ID field of the mutation.
  18663. func withEmployeeConfigID(id uint64) employeeconfigOption {
  18664. return func(m *EmployeeConfigMutation) {
  18665. var (
  18666. err error
  18667. once sync.Once
  18668. value *EmployeeConfig
  18669. )
  18670. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  18671. once.Do(func() {
  18672. if m.done {
  18673. err = errors.New("querying old values post mutation is not allowed")
  18674. } else {
  18675. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  18676. }
  18677. })
  18678. return value, err
  18679. }
  18680. m.id = &id
  18681. }
  18682. }
  18683. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  18684. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  18685. return func(m *EmployeeConfigMutation) {
  18686. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  18687. return node, nil
  18688. }
  18689. m.id = &node.ID
  18690. }
  18691. }
  18692. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18693. // executed in a transaction (ent.Tx), a transactional client is returned.
  18694. func (m EmployeeConfigMutation) Client() *Client {
  18695. client := &Client{config: m.config}
  18696. client.init()
  18697. return client
  18698. }
  18699. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18700. // it returns an error otherwise.
  18701. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  18702. if _, ok := m.driver.(*txDriver); !ok {
  18703. return nil, errors.New("ent: mutation is not running in a transaction")
  18704. }
  18705. tx := &Tx{config: m.config}
  18706. tx.init()
  18707. return tx, nil
  18708. }
  18709. // SetID sets the value of the id field. Note that this
  18710. // operation is only accepted on creation of EmployeeConfig entities.
  18711. func (m *EmployeeConfigMutation) SetID(id uint64) {
  18712. m.id = &id
  18713. }
  18714. // ID returns the ID value in the mutation. Note that the ID is only available
  18715. // if it was provided to the builder or after it was returned from the database.
  18716. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  18717. if m.id == nil {
  18718. return
  18719. }
  18720. return *m.id, true
  18721. }
  18722. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18723. // That means, if the mutation is applied within a transaction with an isolation level such
  18724. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18725. // or updated by the mutation.
  18726. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  18727. switch {
  18728. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18729. id, exists := m.ID()
  18730. if exists {
  18731. return []uint64{id}, nil
  18732. }
  18733. fallthrough
  18734. case m.op.Is(OpUpdate | OpDelete):
  18735. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  18736. default:
  18737. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18738. }
  18739. }
  18740. // SetCreatedAt sets the "created_at" field.
  18741. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  18742. m.created_at = &t
  18743. }
  18744. // CreatedAt returns the value of the "created_at" field in the mutation.
  18745. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  18746. v := m.created_at
  18747. if v == nil {
  18748. return
  18749. }
  18750. return *v, true
  18751. }
  18752. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  18753. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18755. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18756. if !m.op.Is(OpUpdateOne) {
  18757. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18758. }
  18759. if m.id == nil || m.oldValue == nil {
  18760. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18761. }
  18762. oldValue, err := m.oldValue(ctx)
  18763. if err != nil {
  18764. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18765. }
  18766. return oldValue.CreatedAt, nil
  18767. }
  18768. // ResetCreatedAt resets all changes to the "created_at" field.
  18769. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  18770. m.created_at = nil
  18771. }
  18772. // SetUpdatedAt sets the "updated_at" field.
  18773. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  18774. m.updated_at = &t
  18775. }
  18776. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18777. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  18778. v := m.updated_at
  18779. if v == nil {
  18780. return
  18781. }
  18782. return *v, true
  18783. }
  18784. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  18785. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18787. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18788. if !m.op.Is(OpUpdateOne) {
  18789. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18790. }
  18791. if m.id == nil || m.oldValue == nil {
  18792. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18793. }
  18794. oldValue, err := m.oldValue(ctx)
  18795. if err != nil {
  18796. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18797. }
  18798. return oldValue.UpdatedAt, nil
  18799. }
  18800. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18801. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  18802. m.updated_at = nil
  18803. }
  18804. // SetDeletedAt sets the "deleted_at" field.
  18805. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  18806. m.deleted_at = &t
  18807. }
  18808. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18809. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  18810. v := m.deleted_at
  18811. if v == nil {
  18812. return
  18813. }
  18814. return *v, true
  18815. }
  18816. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  18817. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18819. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18820. if !m.op.Is(OpUpdateOne) {
  18821. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18822. }
  18823. if m.id == nil || m.oldValue == nil {
  18824. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18825. }
  18826. oldValue, err := m.oldValue(ctx)
  18827. if err != nil {
  18828. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18829. }
  18830. return oldValue.DeletedAt, nil
  18831. }
  18832. // ClearDeletedAt clears the value of the "deleted_at" field.
  18833. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  18834. m.deleted_at = nil
  18835. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  18836. }
  18837. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18838. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  18839. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  18840. return ok
  18841. }
  18842. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18843. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  18844. m.deleted_at = nil
  18845. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  18846. }
  18847. // SetStype sets the "stype" field.
  18848. func (m *EmployeeConfigMutation) SetStype(s string) {
  18849. m.stype = &s
  18850. }
  18851. // Stype returns the value of the "stype" field in the mutation.
  18852. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  18853. v := m.stype
  18854. if v == nil {
  18855. return
  18856. }
  18857. return *v, true
  18858. }
  18859. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  18860. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18862. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  18863. if !m.op.Is(OpUpdateOne) {
  18864. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  18865. }
  18866. if m.id == nil || m.oldValue == nil {
  18867. return v, errors.New("OldStype requires an ID field in the mutation")
  18868. }
  18869. oldValue, err := m.oldValue(ctx)
  18870. if err != nil {
  18871. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  18872. }
  18873. return oldValue.Stype, nil
  18874. }
  18875. // ResetStype resets all changes to the "stype" field.
  18876. func (m *EmployeeConfigMutation) ResetStype() {
  18877. m.stype = nil
  18878. }
  18879. // SetTitle sets the "title" field.
  18880. func (m *EmployeeConfigMutation) SetTitle(s string) {
  18881. m.title = &s
  18882. }
  18883. // Title returns the value of the "title" field in the mutation.
  18884. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  18885. v := m.title
  18886. if v == nil {
  18887. return
  18888. }
  18889. return *v, true
  18890. }
  18891. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  18892. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18894. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  18895. if !m.op.Is(OpUpdateOne) {
  18896. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  18897. }
  18898. if m.id == nil || m.oldValue == nil {
  18899. return v, errors.New("OldTitle requires an ID field in the mutation")
  18900. }
  18901. oldValue, err := m.oldValue(ctx)
  18902. if err != nil {
  18903. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  18904. }
  18905. return oldValue.Title, nil
  18906. }
  18907. // ResetTitle resets all changes to the "title" field.
  18908. func (m *EmployeeConfigMutation) ResetTitle() {
  18909. m.title = nil
  18910. }
  18911. // SetPhoto sets the "photo" field.
  18912. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  18913. m.photo = &s
  18914. }
  18915. // Photo returns the value of the "photo" field in the mutation.
  18916. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  18917. v := m.photo
  18918. if v == nil {
  18919. return
  18920. }
  18921. return *v, true
  18922. }
  18923. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  18924. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18926. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  18927. if !m.op.Is(OpUpdateOne) {
  18928. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  18929. }
  18930. if m.id == nil || m.oldValue == nil {
  18931. return v, errors.New("OldPhoto requires an ID field in the mutation")
  18932. }
  18933. oldValue, err := m.oldValue(ctx)
  18934. if err != nil {
  18935. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  18936. }
  18937. return oldValue.Photo, nil
  18938. }
  18939. // ResetPhoto resets all changes to the "photo" field.
  18940. func (m *EmployeeConfigMutation) ResetPhoto() {
  18941. m.photo = nil
  18942. }
  18943. // SetOrganizationID sets the "organization_id" field.
  18944. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  18945. m.organization_id = &u
  18946. m.addorganization_id = nil
  18947. }
  18948. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18949. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  18950. v := m.organization_id
  18951. if v == nil {
  18952. return
  18953. }
  18954. return *v, true
  18955. }
  18956. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  18957. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18959. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18960. if !m.op.Is(OpUpdateOne) {
  18961. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18962. }
  18963. if m.id == nil || m.oldValue == nil {
  18964. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18965. }
  18966. oldValue, err := m.oldValue(ctx)
  18967. if err != nil {
  18968. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18969. }
  18970. return oldValue.OrganizationID, nil
  18971. }
  18972. // AddOrganizationID adds u to the "organization_id" field.
  18973. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  18974. if m.addorganization_id != nil {
  18975. *m.addorganization_id += u
  18976. } else {
  18977. m.addorganization_id = &u
  18978. }
  18979. }
  18980. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18981. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  18982. v := m.addorganization_id
  18983. if v == nil {
  18984. return
  18985. }
  18986. return *v, true
  18987. }
  18988. // ClearOrganizationID clears the value of the "organization_id" field.
  18989. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  18990. m.organization_id = nil
  18991. m.addorganization_id = nil
  18992. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  18993. }
  18994. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18995. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  18996. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  18997. return ok
  18998. }
  18999. // ResetOrganizationID resets all changes to the "organization_id" field.
  19000. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  19001. m.organization_id = nil
  19002. m.addorganization_id = nil
  19003. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  19004. }
  19005. // Where appends a list predicates to the EmployeeConfigMutation builder.
  19006. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  19007. m.predicates = append(m.predicates, ps...)
  19008. }
  19009. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  19010. // users can use type-assertion to append predicates that do not depend on any generated package.
  19011. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  19012. p := make([]predicate.EmployeeConfig, len(ps))
  19013. for i := range ps {
  19014. p[i] = ps[i]
  19015. }
  19016. m.Where(p...)
  19017. }
  19018. // Op returns the operation name.
  19019. func (m *EmployeeConfigMutation) Op() Op {
  19020. return m.op
  19021. }
  19022. // SetOp allows setting the mutation operation.
  19023. func (m *EmployeeConfigMutation) SetOp(op Op) {
  19024. m.op = op
  19025. }
  19026. // Type returns the node type of this mutation (EmployeeConfig).
  19027. func (m *EmployeeConfigMutation) Type() string {
  19028. return m.typ
  19029. }
  19030. // Fields returns all fields that were changed during this mutation. Note that in
  19031. // order to get all numeric fields that were incremented/decremented, call
  19032. // AddedFields().
  19033. func (m *EmployeeConfigMutation) Fields() []string {
  19034. fields := make([]string, 0, 7)
  19035. if m.created_at != nil {
  19036. fields = append(fields, employeeconfig.FieldCreatedAt)
  19037. }
  19038. if m.updated_at != nil {
  19039. fields = append(fields, employeeconfig.FieldUpdatedAt)
  19040. }
  19041. if m.deleted_at != nil {
  19042. fields = append(fields, employeeconfig.FieldDeletedAt)
  19043. }
  19044. if m.stype != nil {
  19045. fields = append(fields, employeeconfig.FieldStype)
  19046. }
  19047. if m.title != nil {
  19048. fields = append(fields, employeeconfig.FieldTitle)
  19049. }
  19050. if m.photo != nil {
  19051. fields = append(fields, employeeconfig.FieldPhoto)
  19052. }
  19053. if m.organization_id != nil {
  19054. fields = append(fields, employeeconfig.FieldOrganizationID)
  19055. }
  19056. return fields
  19057. }
  19058. // Field returns the value of a field with the given name. The second boolean
  19059. // return value indicates that this field was not set, or was not defined in the
  19060. // schema.
  19061. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  19062. switch name {
  19063. case employeeconfig.FieldCreatedAt:
  19064. return m.CreatedAt()
  19065. case employeeconfig.FieldUpdatedAt:
  19066. return m.UpdatedAt()
  19067. case employeeconfig.FieldDeletedAt:
  19068. return m.DeletedAt()
  19069. case employeeconfig.FieldStype:
  19070. return m.Stype()
  19071. case employeeconfig.FieldTitle:
  19072. return m.Title()
  19073. case employeeconfig.FieldPhoto:
  19074. return m.Photo()
  19075. case employeeconfig.FieldOrganizationID:
  19076. return m.OrganizationID()
  19077. }
  19078. return nil, false
  19079. }
  19080. // OldField returns the old value of the field from the database. An error is
  19081. // returned if the mutation operation is not UpdateOne, or the query to the
  19082. // database failed.
  19083. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19084. switch name {
  19085. case employeeconfig.FieldCreatedAt:
  19086. return m.OldCreatedAt(ctx)
  19087. case employeeconfig.FieldUpdatedAt:
  19088. return m.OldUpdatedAt(ctx)
  19089. case employeeconfig.FieldDeletedAt:
  19090. return m.OldDeletedAt(ctx)
  19091. case employeeconfig.FieldStype:
  19092. return m.OldStype(ctx)
  19093. case employeeconfig.FieldTitle:
  19094. return m.OldTitle(ctx)
  19095. case employeeconfig.FieldPhoto:
  19096. return m.OldPhoto(ctx)
  19097. case employeeconfig.FieldOrganizationID:
  19098. return m.OldOrganizationID(ctx)
  19099. }
  19100. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  19101. }
  19102. // SetField sets the value of a field with the given name. It returns an error if
  19103. // the field is not defined in the schema, or if the type mismatched the field
  19104. // type.
  19105. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  19106. switch name {
  19107. case employeeconfig.FieldCreatedAt:
  19108. v, ok := value.(time.Time)
  19109. if !ok {
  19110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19111. }
  19112. m.SetCreatedAt(v)
  19113. return nil
  19114. case employeeconfig.FieldUpdatedAt:
  19115. v, ok := value.(time.Time)
  19116. if !ok {
  19117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19118. }
  19119. m.SetUpdatedAt(v)
  19120. return nil
  19121. case employeeconfig.FieldDeletedAt:
  19122. v, ok := value.(time.Time)
  19123. if !ok {
  19124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19125. }
  19126. m.SetDeletedAt(v)
  19127. return nil
  19128. case employeeconfig.FieldStype:
  19129. v, ok := value.(string)
  19130. if !ok {
  19131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19132. }
  19133. m.SetStype(v)
  19134. return nil
  19135. case employeeconfig.FieldTitle:
  19136. v, ok := value.(string)
  19137. if !ok {
  19138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19139. }
  19140. m.SetTitle(v)
  19141. return nil
  19142. case employeeconfig.FieldPhoto:
  19143. v, ok := value.(string)
  19144. if !ok {
  19145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19146. }
  19147. m.SetPhoto(v)
  19148. return nil
  19149. case employeeconfig.FieldOrganizationID:
  19150. v, ok := value.(uint64)
  19151. if !ok {
  19152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19153. }
  19154. m.SetOrganizationID(v)
  19155. return nil
  19156. }
  19157. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  19158. }
  19159. // AddedFields returns all numeric fields that were incremented/decremented during
  19160. // this mutation.
  19161. func (m *EmployeeConfigMutation) AddedFields() []string {
  19162. var fields []string
  19163. if m.addorganization_id != nil {
  19164. fields = append(fields, employeeconfig.FieldOrganizationID)
  19165. }
  19166. return fields
  19167. }
  19168. // AddedField returns the numeric value that was incremented/decremented on a field
  19169. // with the given name. The second boolean return value indicates that this field
  19170. // was not set, or was not defined in the schema.
  19171. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  19172. switch name {
  19173. case employeeconfig.FieldOrganizationID:
  19174. return m.AddedOrganizationID()
  19175. }
  19176. return nil, false
  19177. }
  19178. // AddField adds the value to the field with the given name. It returns an error if
  19179. // the field is not defined in the schema, or if the type mismatched the field
  19180. // type.
  19181. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  19182. switch name {
  19183. case employeeconfig.FieldOrganizationID:
  19184. v, ok := value.(int64)
  19185. if !ok {
  19186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19187. }
  19188. m.AddOrganizationID(v)
  19189. return nil
  19190. }
  19191. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  19192. }
  19193. // ClearedFields returns all nullable fields that were cleared during this
  19194. // mutation.
  19195. func (m *EmployeeConfigMutation) ClearedFields() []string {
  19196. var fields []string
  19197. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  19198. fields = append(fields, employeeconfig.FieldDeletedAt)
  19199. }
  19200. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  19201. fields = append(fields, employeeconfig.FieldOrganizationID)
  19202. }
  19203. return fields
  19204. }
  19205. // FieldCleared returns a boolean indicating if a field with the given name was
  19206. // cleared in this mutation.
  19207. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  19208. _, ok := m.clearedFields[name]
  19209. return ok
  19210. }
  19211. // ClearField clears the value of the field with the given name. It returns an
  19212. // error if the field is not defined in the schema.
  19213. func (m *EmployeeConfigMutation) ClearField(name string) error {
  19214. switch name {
  19215. case employeeconfig.FieldDeletedAt:
  19216. m.ClearDeletedAt()
  19217. return nil
  19218. case employeeconfig.FieldOrganizationID:
  19219. m.ClearOrganizationID()
  19220. return nil
  19221. }
  19222. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  19223. }
  19224. // ResetField resets all changes in the mutation for the field with the given name.
  19225. // It returns an error if the field is not defined in the schema.
  19226. func (m *EmployeeConfigMutation) ResetField(name string) error {
  19227. switch name {
  19228. case employeeconfig.FieldCreatedAt:
  19229. m.ResetCreatedAt()
  19230. return nil
  19231. case employeeconfig.FieldUpdatedAt:
  19232. m.ResetUpdatedAt()
  19233. return nil
  19234. case employeeconfig.FieldDeletedAt:
  19235. m.ResetDeletedAt()
  19236. return nil
  19237. case employeeconfig.FieldStype:
  19238. m.ResetStype()
  19239. return nil
  19240. case employeeconfig.FieldTitle:
  19241. m.ResetTitle()
  19242. return nil
  19243. case employeeconfig.FieldPhoto:
  19244. m.ResetPhoto()
  19245. return nil
  19246. case employeeconfig.FieldOrganizationID:
  19247. m.ResetOrganizationID()
  19248. return nil
  19249. }
  19250. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  19251. }
  19252. // AddedEdges returns all edge names that were set/added in this mutation.
  19253. func (m *EmployeeConfigMutation) AddedEdges() []string {
  19254. edges := make([]string, 0, 0)
  19255. return edges
  19256. }
  19257. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19258. // name in this mutation.
  19259. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  19260. return nil
  19261. }
  19262. // RemovedEdges returns all edge names that were removed in this mutation.
  19263. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  19264. edges := make([]string, 0, 0)
  19265. return edges
  19266. }
  19267. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19268. // the given name in this mutation.
  19269. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  19270. return nil
  19271. }
  19272. // ClearedEdges returns all edge names that were cleared in this mutation.
  19273. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  19274. edges := make([]string, 0, 0)
  19275. return edges
  19276. }
  19277. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19278. // was cleared in this mutation.
  19279. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  19280. return false
  19281. }
  19282. // ClearEdge clears the value of the edge with the given name. It returns an error
  19283. // if that edge is not defined in the schema.
  19284. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  19285. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  19286. }
  19287. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19288. // It returns an error if the edge is not defined in the schema.
  19289. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  19290. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  19291. }
  19292. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  19293. type LabelMutation struct {
  19294. config
  19295. op Op
  19296. typ string
  19297. id *uint64
  19298. created_at *time.Time
  19299. updated_at *time.Time
  19300. status *uint8
  19301. addstatus *int8
  19302. _type *int
  19303. add_type *int
  19304. name *string
  19305. from *int
  19306. addfrom *int
  19307. mode *int
  19308. addmode *int
  19309. conditions *string
  19310. organization_id *uint64
  19311. addorganization_id *int64
  19312. clearedFields map[string]struct{}
  19313. label_relationships map[uint64]struct{}
  19314. removedlabel_relationships map[uint64]struct{}
  19315. clearedlabel_relationships bool
  19316. done bool
  19317. oldValue func(context.Context) (*Label, error)
  19318. predicates []predicate.Label
  19319. }
  19320. var _ ent.Mutation = (*LabelMutation)(nil)
  19321. // labelOption allows management of the mutation configuration using functional options.
  19322. type labelOption func(*LabelMutation)
  19323. // newLabelMutation creates new mutation for the Label entity.
  19324. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  19325. m := &LabelMutation{
  19326. config: c,
  19327. op: op,
  19328. typ: TypeLabel,
  19329. clearedFields: make(map[string]struct{}),
  19330. }
  19331. for _, opt := range opts {
  19332. opt(m)
  19333. }
  19334. return m
  19335. }
  19336. // withLabelID sets the ID field of the mutation.
  19337. func withLabelID(id uint64) labelOption {
  19338. return func(m *LabelMutation) {
  19339. var (
  19340. err error
  19341. once sync.Once
  19342. value *Label
  19343. )
  19344. m.oldValue = func(ctx context.Context) (*Label, error) {
  19345. once.Do(func() {
  19346. if m.done {
  19347. err = errors.New("querying old values post mutation is not allowed")
  19348. } else {
  19349. value, err = m.Client().Label.Get(ctx, id)
  19350. }
  19351. })
  19352. return value, err
  19353. }
  19354. m.id = &id
  19355. }
  19356. }
  19357. // withLabel sets the old Label of the mutation.
  19358. func withLabel(node *Label) labelOption {
  19359. return func(m *LabelMutation) {
  19360. m.oldValue = func(context.Context) (*Label, error) {
  19361. return node, nil
  19362. }
  19363. m.id = &node.ID
  19364. }
  19365. }
  19366. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19367. // executed in a transaction (ent.Tx), a transactional client is returned.
  19368. func (m LabelMutation) Client() *Client {
  19369. client := &Client{config: m.config}
  19370. client.init()
  19371. return client
  19372. }
  19373. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19374. // it returns an error otherwise.
  19375. func (m LabelMutation) Tx() (*Tx, error) {
  19376. if _, ok := m.driver.(*txDriver); !ok {
  19377. return nil, errors.New("ent: mutation is not running in a transaction")
  19378. }
  19379. tx := &Tx{config: m.config}
  19380. tx.init()
  19381. return tx, nil
  19382. }
  19383. // SetID sets the value of the id field. Note that this
  19384. // operation is only accepted on creation of Label entities.
  19385. func (m *LabelMutation) SetID(id uint64) {
  19386. m.id = &id
  19387. }
  19388. // ID returns the ID value in the mutation. Note that the ID is only available
  19389. // if it was provided to the builder or after it was returned from the database.
  19390. func (m *LabelMutation) ID() (id uint64, exists bool) {
  19391. if m.id == nil {
  19392. return
  19393. }
  19394. return *m.id, true
  19395. }
  19396. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19397. // That means, if the mutation is applied within a transaction with an isolation level such
  19398. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19399. // or updated by the mutation.
  19400. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  19401. switch {
  19402. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19403. id, exists := m.ID()
  19404. if exists {
  19405. return []uint64{id}, nil
  19406. }
  19407. fallthrough
  19408. case m.op.Is(OpUpdate | OpDelete):
  19409. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  19410. default:
  19411. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19412. }
  19413. }
  19414. // SetCreatedAt sets the "created_at" field.
  19415. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  19416. m.created_at = &t
  19417. }
  19418. // CreatedAt returns the value of the "created_at" field in the mutation.
  19419. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  19420. v := m.created_at
  19421. if v == nil {
  19422. return
  19423. }
  19424. return *v, true
  19425. }
  19426. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  19427. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19429. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19430. if !m.op.Is(OpUpdateOne) {
  19431. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19432. }
  19433. if m.id == nil || m.oldValue == nil {
  19434. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19435. }
  19436. oldValue, err := m.oldValue(ctx)
  19437. if err != nil {
  19438. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19439. }
  19440. return oldValue.CreatedAt, nil
  19441. }
  19442. // ResetCreatedAt resets all changes to the "created_at" field.
  19443. func (m *LabelMutation) ResetCreatedAt() {
  19444. m.created_at = nil
  19445. }
  19446. // SetUpdatedAt sets the "updated_at" field.
  19447. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  19448. m.updated_at = &t
  19449. }
  19450. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19451. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  19452. v := m.updated_at
  19453. if v == nil {
  19454. return
  19455. }
  19456. return *v, true
  19457. }
  19458. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  19459. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19461. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19462. if !m.op.Is(OpUpdateOne) {
  19463. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19464. }
  19465. if m.id == nil || m.oldValue == nil {
  19466. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19467. }
  19468. oldValue, err := m.oldValue(ctx)
  19469. if err != nil {
  19470. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19471. }
  19472. return oldValue.UpdatedAt, nil
  19473. }
  19474. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19475. func (m *LabelMutation) ResetUpdatedAt() {
  19476. m.updated_at = nil
  19477. }
  19478. // SetStatus sets the "status" field.
  19479. func (m *LabelMutation) SetStatus(u uint8) {
  19480. m.status = &u
  19481. m.addstatus = nil
  19482. }
  19483. // Status returns the value of the "status" field in the mutation.
  19484. func (m *LabelMutation) Status() (r uint8, exists bool) {
  19485. v := m.status
  19486. if v == nil {
  19487. return
  19488. }
  19489. return *v, true
  19490. }
  19491. // OldStatus returns the old "status" field's value of the Label entity.
  19492. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19494. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19495. if !m.op.Is(OpUpdateOne) {
  19496. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19497. }
  19498. if m.id == nil || m.oldValue == nil {
  19499. return v, errors.New("OldStatus requires an ID field in the mutation")
  19500. }
  19501. oldValue, err := m.oldValue(ctx)
  19502. if err != nil {
  19503. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19504. }
  19505. return oldValue.Status, nil
  19506. }
  19507. // AddStatus adds u to the "status" field.
  19508. func (m *LabelMutation) AddStatus(u int8) {
  19509. if m.addstatus != nil {
  19510. *m.addstatus += u
  19511. } else {
  19512. m.addstatus = &u
  19513. }
  19514. }
  19515. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19516. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  19517. v := m.addstatus
  19518. if v == nil {
  19519. return
  19520. }
  19521. return *v, true
  19522. }
  19523. // ClearStatus clears the value of the "status" field.
  19524. func (m *LabelMutation) ClearStatus() {
  19525. m.status = nil
  19526. m.addstatus = nil
  19527. m.clearedFields[label.FieldStatus] = struct{}{}
  19528. }
  19529. // StatusCleared returns if the "status" field was cleared in this mutation.
  19530. func (m *LabelMutation) StatusCleared() bool {
  19531. _, ok := m.clearedFields[label.FieldStatus]
  19532. return ok
  19533. }
  19534. // ResetStatus resets all changes to the "status" field.
  19535. func (m *LabelMutation) ResetStatus() {
  19536. m.status = nil
  19537. m.addstatus = nil
  19538. delete(m.clearedFields, label.FieldStatus)
  19539. }
  19540. // SetType sets the "type" field.
  19541. func (m *LabelMutation) SetType(i int) {
  19542. m._type = &i
  19543. m.add_type = nil
  19544. }
  19545. // GetType returns the value of the "type" field in the mutation.
  19546. func (m *LabelMutation) GetType() (r int, exists bool) {
  19547. v := m._type
  19548. if v == nil {
  19549. return
  19550. }
  19551. return *v, true
  19552. }
  19553. // OldType returns the old "type" field's value of the Label entity.
  19554. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19556. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  19557. if !m.op.Is(OpUpdateOne) {
  19558. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19559. }
  19560. if m.id == nil || m.oldValue == nil {
  19561. return v, errors.New("OldType requires an ID field in the mutation")
  19562. }
  19563. oldValue, err := m.oldValue(ctx)
  19564. if err != nil {
  19565. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19566. }
  19567. return oldValue.Type, nil
  19568. }
  19569. // AddType adds i to the "type" field.
  19570. func (m *LabelMutation) AddType(i int) {
  19571. if m.add_type != nil {
  19572. *m.add_type += i
  19573. } else {
  19574. m.add_type = &i
  19575. }
  19576. }
  19577. // AddedType returns the value that was added to the "type" field in this mutation.
  19578. func (m *LabelMutation) AddedType() (r int, exists bool) {
  19579. v := m.add_type
  19580. if v == nil {
  19581. return
  19582. }
  19583. return *v, true
  19584. }
  19585. // ResetType resets all changes to the "type" field.
  19586. func (m *LabelMutation) ResetType() {
  19587. m._type = nil
  19588. m.add_type = nil
  19589. }
  19590. // SetName sets the "name" field.
  19591. func (m *LabelMutation) SetName(s string) {
  19592. m.name = &s
  19593. }
  19594. // Name returns the value of the "name" field in the mutation.
  19595. func (m *LabelMutation) Name() (r string, exists bool) {
  19596. v := m.name
  19597. if v == nil {
  19598. return
  19599. }
  19600. return *v, true
  19601. }
  19602. // OldName returns the old "name" field's value of the Label entity.
  19603. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19605. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  19606. if !m.op.Is(OpUpdateOne) {
  19607. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19608. }
  19609. if m.id == nil || m.oldValue == nil {
  19610. return v, errors.New("OldName requires an ID field in the mutation")
  19611. }
  19612. oldValue, err := m.oldValue(ctx)
  19613. if err != nil {
  19614. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19615. }
  19616. return oldValue.Name, nil
  19617. }
  19618. // ResetName resets all changes to the "name" field.
  19619. func (m *LabelMutation) ResetName() {
  19620. m.name = nil
  19621. }
  19622. // SetFrom sets the "from" field.
  19623. func (m *LabelMutation) SetFrom(i int) {
  19624. m.from = &i
  19625. m.addfrom = nil
  19626. }
  19627. // From returns the value of the "from" field in the mutation.
  19628. func (m *LabelMutation) From() (r int, exists bool) {
  19629. v := m.from
  19630. if v == nil {
  19631. return
  19632. }
  19633. return *v, true
  19634. }
  19635. // OldFrom returns the old "from" field's value of the Label entity.
  19636. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19638. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  19639. if !m.op.Is(OpUpdateOne) {
  19640. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  19641. }
  19642. if m.id == nil || m.oldValue == nil {
  19643. return v, errors.New("OldFrom requires an ID field in the mutation")
  19644. }
  19645. oldValue, err := m.oldValue(ctx)
  19646. if err != nil {
  19647. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  19648. }
  19649. return oldValue.From, nil
  19650. }
  19651. // AddFrom adds i to the "from" field.
  19652. func (m *LabelMutation) AddFrom(i int) {
  19653. if m.addfrom != nil {
  19654. *m.addfrom += i
  19655. } else {
  19656. m.addfrom = &i
  19657. }
  19658. }
  19659. // AddedFrom returns the value that was added to the "from" field in this mutation.
  19660. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  19661. v := m.addfrom
  19662. if v == nil {
  19663. return
  19664. }
  19665. return *v, true
  19666. }
  19667. // ResetFrom resets all changes to the "from" field.
  19668. func (m *LabelMutation) ResetFrom() {
  19669. m.from = nil
  19670. m.addfrom = nil
  19671. }
  19672. // SetMode sets the "mode" field.
  19673. func (m *LabelMutation) SetMode(i int) {
  19674. m.mode = &i
  19675. m.addmode = nil
  19676. }
  19677. // Mode returns the value of the "mode" field in the mutation.
  19678. func (m *LabelMutation) Mode() (r int, exists bool) {
  19679. v := m.mode
  19680. if v == nil {
  19681. return
  19682. }
  19683. return *v, true
  19684. }
  19685. // OldMode returns the old "mode" field's value of the Label entity.
  19686. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19688. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  19689. if !m.op.Is(OpUpdateOne) {
  19690. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  19691. }
  19692. if m.id == nil || m.oldValue == nil {
  19693. return v, errors.New("OldMode requires an ID field in the mutation")
  19694. }
  19695. oldValue, err := m.oldValue(ctx)
  19696. if err != nil {
  19697. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  19698. }
  19699. return oldValue.Mode, nil
  19700. }
  19701. // AddMode adds i to the "mode" field.
  19702. func (m *LabelMutation) AddMode(i int) {
  19703. if m.addmode != nil {
  19704. *m.addmode += i
  19705. } else {
  19706. m.addmode = &i
  19707. }
  19708. }
  19709. // AddedMode returns the value that was added to the "mode" field in this mutation.
  19710. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  19711. v := m.addmode
  19712. if v == nil {
  19713. return
  19714. }
  19715. return *v, true
  19716. }
  19717. // ResetMode resets all changes to the "mode" field.
  19718. func (m *LabelMutation) ResetMode() {
  19719. m.mode = nil
  19720. m.addmode = nil
  19721. }
  19722. // SetConditions sets the "conditions" field.
  19723. func (m *LabelMutation) SetConditions(s string) {
  19724. m.conditions = &s
  19725. }
  19726. // Conditions returns the value of the "conditions" field in the mutation.
  19727. func (m *LabelMutation) Conditions() (r string, exists bool) {
  19728. v := m.conditions
  19729. if v == nil {
  19730. return
  19731. }
  19732. return *v, true
  19733. }
  19734. // OldConditions returns the old "conditions" field's value of the Label entity.
  19735. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19737. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  19738. if !m.op.Is(OpUpdateOne) {
  19739. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  19740. }
  19741. if m.id == nil || m.oldValue == nil {
  19742. return v, errors.New("OldConditions requires an ID field in the mutation")
  19743. }
  19744. oldValue, err := m.oldValue(ctx)
  19745. if err != nil {
  19746. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  19747. }
  19748. return oldValue.Conditions, nil
  19749. }
  19750. // ClearConditions clears the value of the "conditions" field.
  19751. func (m *LabelMutation) ClearConditions() {
  19752. m.conditions = nil
  19753. m.clearedFields[label.FieldConditions] = struct{}{}
  19754. }
  19755. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  19756. func (m *LabelMutation) ConditionsCleared() bool {
  19757. _, ok := m.clearedFields[label.FieldConditions]
  19758. return ok
  19759. }
  19760. // ResetConditions resets all changes to the "conditions" field.
  19761. func (m *LabelMutation) ResetConditions() {
  19762. m.conditions = nil
  19763. delete(m.clearedFields, label.FieldConditions)
  19764. }
  19765. // SetOrganizationID sets the "organization_id" field.
  19766. func (m *LabelMutation) SetOrganizationID(u uint64) {
  19767. m.organization_id = &u
  19768. m.addorganization_id = nil
  19769. }
  19770. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19771. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  19772. v := m.organization_id
  19773. if v == nil {
  19774. return
  19775. }
  19776. return *v, true
  19777. }
  19778. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  19779. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19781. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19782. if !m.op.Is(OpUpdateOne) {
  19783. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19784. }
  19785. if m.id == nil || m.oldValue == nil {
  19786. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19787. }
  19788. oldValue, err := m.oldValue(ctx)
  19789. if err != nil {
  19790. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19791. }
  19792. return oldValue.OrganizationID, nil
  19793. }
  19794. // AddOrganizationID adds u to the "organization_id" field.
  19795. func (m *LabelMutation) AddOrganizationID(u int64) {
  19796. if m.addorganization_id != nil {
  19797. *m.addorganization_id += u
  19798. } else {
  19799. m.addorganization_id = &u
  19800. }
  19801. }
  19802. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19803. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  19804. v := m.addorganization_id
  19805. if v == nil {
  19806. return
  19807. }
  19808. return *v, true
  19809. }
  19810. // ClearOrganizationID clears the value of the "organization_id" field.
  19811. func (m *LabelMutation) ClearOrganizationID() {
  19812. m.organization_id = nil
  19813. m.addorganization_id = nil
  19814. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  19815. }
  19816. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19817. func (m *LabelMutation) OrganizationIDCleared() bool {
  19818. _, ok := m.clearedFields[label.FieldOrganizationID]
  19819. return ok
  19820. }
  19821. // ResetOrganizationID resets all changes to the "organization_id" field.
  19822. func (m *LabelMutation) ResetOrganizationID() {
  19823. m.organization_id = nil
  19824. m.addorganization_id = nil
  19825. delete(m.clearedFields, label.FieldOrganizationID)
  19826. }
  19827. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  19828. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  19829. if m.label_relationships == nil {
  19830. m.label_relationships = make(map[uint64]struct{})
  19831. }
  19832. for i := range ids {
  19833. m.label_relationships[ids[i]] = struct{}{}
  19834. }
  19835. }
  19836. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  19837. func (m *LabelMutation) ClearLabelRelationships() {
  19838. m.clearedlabel_relationships = true
  19839. }
  19840. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  19841. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  19842. return m.clearedlabel_relationships
  19843. }
  19844. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  19845. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  19846. if m.removedlabel_relationships == nil {
  19847. m.removedlabel_relationships = make(map[uint64]struct{})
  19848. }
  19849. for i := range ids {
  19850. delete(m.label_relationships, ids[i])
  19851. m.removedlabel_relationships[ids[i]] = struct{}{}
  19852. }
  19853. }
  19854. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  19855. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  19856. for id := range m.removedlabel_relationships {
  19857. ids = append(ids, id)
  19858. }
  19859. return
  19860. }
  19861. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  19862. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  19863. for id := range m.label_relationships {
  19864. ids = append(ids, id)
  19865. }
  19866. return
  19867. }
  19868. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  19869. func (m *LabelMutation) ResetLabelRelationships() {
  19870. m.label_relationships = nil
  19871. m.clearedlabel_relationships = false
  19872. m.removedlabel_relationships = nil
  19873. }
  19874. // Where appends a list predicates to the LabelMutation builder.
  19875. func (m *LabelMutation) Where(ps ...predicate.Label) {
  19876. m.predicates = append(m.predicates, ps...)
  19877. }
  19878. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  19879. // users can use type-assertion to append predicates that do not depend on any generated package.
  19880. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  19881. p := make([]predicate.Label, len(ps))
  19882. for i := range ps {
  19883. p[i] = ps[i]
  19884. }
  19885. m.Where(p...)
  19886. }
  19887. // Op returns the operation name.
  19888. func (m *LabelMutation) Op() Op {
  19889. return m.op
  19890. }
  19891. // SetOp allows setting the mutation operation.
  19892. func (m *LabelMutation) SetOp(op Op) {
  19893. m.op = op
  19894. }
  19895. // Type returns the node type of this mutation (Label).
  19896. func (m *LabelMutation) Type() string {
  19897. return m.typ
  19898. }
  19899. // Fields returns all fields that were changed during this mutation. Note that in
  19900. // order to get all numeric fields that were incremented/decremented, call
  19901. // AddedFields().
  19902. func (m *LabelMutation) Fields() []string {
  19903. fields := make([]string, 0, 9)
  19904. if m.created_at != nil {
  19905. fields = append(fields, label.FieldCreatedAt)
  19906. }
  19907. if m.updated_at != nil {
  19908. fields = append(fields, label.FieldUpdatedAt)
  19909. }
  19910. if m.status != nil {
  19911. fields = append(fields, label.FieldStatus)
  19912. }
  19913. if m._type != nil {
  19914. fields = append(fields, label.FieldType)
  19915. }
  19916. if m.name != nil {
  19917. fields = append(fields, label.FieldName)
  19918. }
  19919. if m.from != nil {
  19920. fields = append(fields, label.FieldFrom)
  19921. }
  19922. if m.mode != nil {
  19923. fields = append(fields, label.FieldMode)
  19924. }
  19925. if m.conditions != nil {
  19926. fields = append(fields, label.FieldConditions)
  19927. }
  19928. if m.organization_id != nil {
  19929. fields = append(fields, label.FieldOrganizationID)
  19930. }
  19931. return fields
  19932. }
  19933. // Field returns the value of a field with the given name. The second boolean
  19934. // return value indicates that this field was not set, or was not defined in the
  19935. // schema.
  19936. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  19937. switch name {
  19938. case label.FieldCreatedAt:
  19939. return m.CreatedAt()
  19940. case label.FieldUpdatedAt:
  19941. return m.UpdatedAt()
  19942. case label.FieldStatus:
  19943. return m.Status()
  19944. case label.FieldType:
  19945. return m.GetType()
  19946. case label.FieldName:
  19947. return m.Name()
  19948. case label.FieldFrom:
  19949. return m.From()
  19950. case label.FieldMode:
  19951. return m.Mode()
  19952. case label.FieldConditions:
  19953. return m.Conditions()
  19954. case label.FieldOrganizationID:
  19955. return m.OrganizationID()
  19956. }
  19957. return nil, false
  19958. }
  19959. // OldField returns the old value of the field from the database. An error is
  19960. // returned if the mutation operation is not UpdateOne, or the query to the
  19961. // database failed.
  19962. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19963. switch name {
  19964. case label.FieldCreatedAt:
  19965. return m.OldCreatedAt(ctx)
  19966. case label.FieldUpdatedAt:
  19967. return m.OldUpdatedAt(ctx)
  19968. case label.FieldStatus:
  19969. return m.OldStatus(ctx)
  19970. case label.FieldType:
  19971. return m.OldType(ctx)
  19972. case label.FieldName:
  19973. return m.OldName(ctx)
  19974. case label.FieldFrom:
  19975. return m.OldFrom(ctx)
  19976. case label.FieldMode:
  19977. return m.OldMode(ctx)
  19978. case label.FieldConditions:
  19979. return m.OldConditions(ctx)
  19980. case label.FieldOrganizationID:
  19981. return m.OldOrganizationID(ctx)
  19982. }
  19983. return nil, fmt.Errorf("unknown Label field %s", name)
  19984. }
  19985. // SetField sets the value of a field with the given name. It returns an error if
  19986. // the field is not defined in the schema, or if the type mismatched the field
  19987. // type.
  19988. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  19989. switch name {
  19990. case label.FieldCreatedAt:
  19991. v, ok := value.(time.Time)
  19992. if !ok {
  19993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19994. }
  19995. m.SetCreatedAt(v)
  19996. return nil
  19997. case label.FieldUpdatedAt:
  19998. v, ok := value.(time.Time)
  19999. if !ok {
  20000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20001. }
  20002. m.SetUpdatedAt(v)
  20003. return nil
  20004. case label.FieldStatus:
  20005. v, ok := value.(uint8)
  20006. if !ok {
  20007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20008. }
  20009. m.SetStatus(v)
  20010. return nil
  20011. case label.FieldType:
  20012. v, ok := value.(int)
  20013. if !ok {
  20014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20015. }
  20016. m.SetType(v)
  20017. return nil
  20018. case label.FieldName:
  20019. v, ok := value.(string)
  20020. if !ok {
  20021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20022. }
  20023. m.SetName(v)
  20024. return nil
  20025. case label.FieldFrom:
  20026. v, ok := value.(int)
  20027. if !ok {
  20028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20029. }
  20030. m.SetFrom(v)
  20031. return nil
  20032. case label.FieldMode:
  20033. v, ok := value.(int)
  20034. if !ok {
  20035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20036. }
  20037. m.SetMode(v)
  20038. return nil
  20039. case label.FieldConditions:
  20040. v, ok := value.(string)
  20041. if !ok {
  20042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20043. }
  20044. m.SetConditions(v)
  20045. return nil
  20046. case label.FieldOrganizationID:
  20047. v, ok := value.(uint64)
  20048. if !ok {
  20049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20050. }
  20051. m.SetOrganizationID(v)
  20052. return nil
  20053. }
  20054. return fmt.Errorf("unknown Label field %s", name)
  20055. }
  20056. // AddedFields returns all numeric fields that were incremented/decremented during
  20057. // this mutation.
  20058. func (m *LabelMutation) AddedFields() []string {
  20059. var fields []string
  20060. if m.addstatus != nil {
  20061. fields = append(fields, label.FieldStatus)
  20062. }
  20063. if m.add_type != nil {
  20064. fields = append(fields, label.FieldType)
  20065. }
  20066. if m.addfrom != nil {
  20067. fields = append(fields, label.FieldFrom)
  20068. }
  20069. if m.addmode != nil {
  20070. fields = append(fields, label.FieldMode)
  20071. }
  20072. if m.addorganization_id != nil {
  20073. fields = append(fields, label.FieldOrganizationID)
  20074. }
  20075. return fields
  20076. }
  20077. // AddedField returns the numeric value that was incremented/decremented on a field
  20078. // with the given name. The second boolean return value indicates that this field
  20079. // was not set, or was not defined in the schema.
  20080. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  20081. switch name {
  20082. case label.FieldStatus:
  20083. return m.AddedStatus()
  20084. case label.FieldType:
  20085. return m.AddedType()
  20086. case label.FieldFrom:
  20087. return m.AddedFrom()
  20088. case label.FieldMode:
  20089. return m.AddedMode()
  20090. case label.FieldOrganizationID:
  20091. return m.AddedOrganizationID()
  20092. }
  20093. return nil, false
  20094. }
  20095. // AddField adds the value to the field with the given name. It returns an error if
  20096. // the field is not defined in the schema, or if the type mismatched the field
  20097. // type.
  20098. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  20099. switch name {
  20100. case label.FieldStatus:
  20101. v, ok := value.(int8)
  20102. if !ok {
  20103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20104. }
  20105. m.AddStatus(v)
  20106. return nil
  20107. case label.FieldType:
  20108. v, ok := value.(int)
  20109. if !ok {
  20110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20111. }
  20112. m.AddType(v)
  20113. return nil
  20114. case label.FieldFrom:
  20115. v, ok := value.(int)
  20116. if !ok {
  20117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20118. }
  20119. m.AddFrom(v)
  20120. return nil
  20121. case label.FieldMode:
  20122. v, ok := value.(int)
  20123. if !ok {
  20124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20125. }
  20126. m.AddMode(v)
  20127. return nil
  20128. case label.FieldOrganizationID:
  20129. v, ok := value.(int64)
  20130. if !ok {
  20131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20132. }
  20133. m.AddOrganizationID(v)
  20134. return nil
  20135. }
  20136. return fmt.Errorf("unknown Label numeric field %s", name)
  20137. }
  20138. // ClearedFields returns all nullable fields that were cleared during this
  20139. // mutation.
  20140. func (m *LabelMutation) ClearedFields() []string {
  20141. var fields []string
  20142. if m.FieldCleared(label.FieldStatus) {
  20143. fields = append(fields, label.FieldStatus)
  20144. }
  20145. if m.FieldCleared(label.FieldConditions) {
  20146. fields = append(fields, label.FieldConditions)
  20147. }
  20148. if m.FieldCleared(label.FieldOrganizationID) {
  20149. fields = append(fields, label.FieldOrganizationID)
  20150. }
  20151. return fields
  20152. }
  20153. // FieldCleared returns a boolean indicating if a field with the given name was
  20154. // cleared in this mutation.
  20155. func (m *LabelMutation) FieldCleared(name string) bool {
  20156. _, ok := m.clearedFields[name]
  20157. return ok
  20158. }
  20159. // ClearField clears the value of the field with the given name. It returns an
  20160. // error if the field is not defined in the schema.
  20161. func (m *LabelMutation) ClearField(name string) error {
  20162. switch name {
  20163. case label.FieldStatus:
  20164. m.ClearStatus()
  20165. return nil
  20166. case label.FieldConditions:
  20167. m.ClearConditions()
  20168. return nil
  20169. case label.FieldOrganizationID:
  20170. m.ClearOrganizationID()
  20171. return nil
  20172. }
  20173. return fmt.Errorf("unknown Label nullable field %s", name)
  20174. }
  20175. // ResetField resets all changes in the mutation for the field with the given name.
  20176. // It returns an error if the field is not defined in the schema.
  20177. func (m *LabelMutation) ResetField(name string) error {
  20178. switch name {
  20179. case label.FieldCreatedAt:
  20180. m.ResetCreatedAt()
  20181. return nil
  20182. case label.FieldUpdatedAt:
  20183. m.ResetUpdatedAt()
  20184. return nil
  20185. case label.FieldStatus:
  20186. m.ResetStatus()
  20187. return nil
  20188. case label.FieldType:
  20189. m.ResetType()
  20190. return nil
  20191. case label.FieldName:
  20192. m.ResetName()
  20193. return nil
  20194. case label.FieldFrom:
  20195. m.ResetFrom()
  20196. return nil
  20197. case label.FieldMode:
  20198. m.ResetMode()
  20199. return nil
  20200. case label.FieldConditions:
  20201. m.ResetConditions()
  20202. return nil
  20203. case label.FieldOrganizationID:
  20204. m.ResetOrganizationID()
  20205. return nil
  20206. }
  20207. return fmt.Errorf("unknown Label field %s", name)
  20208. }
  20209. // AddedEdges returns all edge names that were set/added in this mutation.
  20210. func (m *LabelMutation) AddedEdges() []string {
  20211. edges := make([]string, 0, 1)
  20212. if m.label_relationships != nil {
  20213. edges = append(edges, label.EdgeLabelRelationships)
  20214. }
  20215. return edges
  20216. }
  20217. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20218. // name in this mutation.
  20219. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  20220. switch name {
  20221. case label.EdgeLabelRelationships:
  20222. ids := make([]ent.Value, 0, len(m.label_relationships))
  20223. for id := range m.label_relationships {
  20224. ids = append(ids, id)
  20225. }
  20226. return ids
  20227. }
  20228. return nil
  20229. }
  20230. // RemovedEdges returns all edge names that were removed in this mutation.
  20231. func (m *LabelMutation) RemovedEdges() []string {
  20232. edges := make([]string, 0, 1)
  20233. if m.removedlabel_relationships != nil {
  20234. edges = append(edges, label.EdgeLabelRelationships)
  20235. }
  20236. return edges
  20237. }
  20238. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20239. // the given name in this mutation.
  20240. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  20241. switch name {
  20242. case label.EdgeLabelRelationships:
  20243. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  20244. for id := range m.removedlabel_relationships {
  20245. ids = append(ids, id)
  20246. }
  20247. return ids
  20248. }
  20249. return nil
  20250. }
  20251. // ClearedEdges returns all edge names that were cleared in this mutation.
  20252. func (m *LabelMutation) ClearedEdges() []string {
  20253. edges := make([]string, 0, 1)
  20254. if m.clearedlabel_relationships {
  20255. edges = append(edges, label.EdgeLabelRelationships)
  20256. }
  20257. return edges
  20258. }
  20259. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20260. // was cleared in this mutation.
  20261. func (m *LabelMutation) EdgeCleared(name string) bool {
  20262. switch name {
  20263. case label.EdgeLabelRelationships:
  20264. return m.clearedlabel_relationships
  20265. }
  20266. return false
  20267. }
  20268. // ClearEdge clears the value of the edge with the given name. It returns an error
  20269. // if that edge is not defined in the schema.
  20270. func (m *LabelMutation) ClearEdge(name string) error {
  20271. switch name {
  20272. }
  20273. return fmt.Errorf("unknown Label unique edge %s", name)
  20274. }
  20275. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20276. // It returns an error if the edge is not defined in the schema.
  20277. func (m *LabelMutation) ResetEdge(name string) error {
  20278. switch name {
  20279. case label.EdgeLabelRelationships:
  20280. m.ResetLabelRelationships()
  20281. return nil
  20282. }
  20283. return fmt.Errorf("unknown Label edge %s", name)
  20284. }
  20285. // LabelLogMutation represents an operation that mutates the LabelLog nodes in the graph.
  20286. type LabelLogMutation struct {
  20287. config
  20288. op Op
  20289. typ string
  20290. id *uint64
  20291. created_at *time.Time
  20292. updated_at *time.Time
  20293. label_name *string
  20294. label_id *int
  20295. addlabel_id *int
  20296. wx_id *string
  20297. organization_id *uint64
  20298. addorganization_id *int64
  20299. clearedFields map[string]struct{}
  20300. done bool
  20301. oldValue func(context.Context) (*LabelLog, error)
  20302. predicates []predicate.LabelLog
  20303. }
  20304. var _ ent.Mutation = (*LabelLogMutation)(nil)
  20305. // labellogOption allows management of the mutation configuration using functional options.
  20306. type labellogOption func(*LabelLogMutation)
  20307. // newLabelLogMutation creates new mutation for the LabelLog entity.
  20308. func newLabelLogMutation(c config, op Op, opts ...labellogOption) *LabelLogMutation {
  20309. m := &LabelLogMutation{
  20310. config: c,
  20311. op: op,
  20312. typ: TypeLabelLog,
  20313. clearedFields: make(map[string]struct{}),
  20314. }
  20315. for _, opt := range opts {
  20316. opt(m)
  20317. }
  20318. return m
  20319. }
  20320. // withLabelLogID sets the ID field of the mutation.
  20321. func withLabelLogID(id uint64) labellogOption {
  20322. return func(m *LabelLogMutation) {
  20323. var (
  20324. err error
  20325. once sync.Once
  20326. value *LabelLog
  20327. )
  20328. m.oldValue = func(ctx context.Context) (*LabelLog, error) {
  20329. once.Do(func() {
  20330. if m.done {
  20331. err = errors.New("querying old values post mutation is not allowed")
  20332. } else {
  20333. value, err = m.Client().LabelLog.Get(ctx, id)
  20334. }
  20335. })
  20336. return value, err
  20337. }
  20338. m.id = &id
  20339. }
  20340. }
  20341. // withLabelLog sets the old LabelLog of the mutation.
  20342. func withLabelLog(node *LabelLog) labellogOption {
  20343. return func(m *LabelLogMutation) {
  20344. m.oldValue = func(context.Context) (*LabelLog, error) {
  20345. return node, nil
  20346. }
  20347. m.id = &node.ID
  20348. }
  20349. }
  20350. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20351. // executed in a transaction (ent.Tx), a transactional client is returned.
  20352. func (m LabelLogMutation) Client() *Client {
  20353. client := &Client{config: m.config}
  20354. client.init()
  20355. return client
  20356. }
  20357. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20358. // it returns an error otherwise.
  20359. func (m LabelLogMutation) Tx() (*Tx, error) {
  20360. if _, ok := m.driver.(*txDriver); !ok {
  20361. return nil, errors.New("ent: mutation is not running in a transaction")
  20362. }
  20363. tx := &Tx{config: m.config}
  20364. tx.init()
  20365. return tx, nil
  20366. }
  20367. // SetID sets the value of the id field. Note that this
  20368. // operation is only accepted on creation of LabelLog entities.
  20369. func (m *LabelLogMutation) SetID(id uint64) {
  20370. m.id = &id
  20371. }
  20372. // ID returns the ID value in the mutation. Note that the ID is only available
  20373. // if it was provided to the builder or after it was returned from the database.
  20374. func (m *LabelLogMutation) ID() (id uint64, exists bool) {
  20375. if m.id == nil {
  20376. return
  20377. }
  20378. return *m.id, true
  20379. }
  20380. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20381. // That means, if the mutation is applied within a transaction with an isolation level such
  20382. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20383. // or updated by the mutation.
  20384. func (m *LabelLogMutation) IDs(ctx context.Context) ([]uint64, error) {
  20385. switch {
  20386. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20387. id, exists := m.ID()
  20388. if exists {
  20389. return []uint64{id}, nil
  20390. }
  20391. fallthrough
  20392. case m.op.Is(OpUpdate | OpDelete):
  20393. return m.Client().LabelLog.Query().Where(m.predicates...).IDs(ctx)
  20394. default:
  20395. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20396. }
  20397. }
  20398. // SetCreatedAt sets the "created_at" field.
  20399. func (m *LabelLogMutation) SetCreatedAt(t time.Time) {
  20400. m.created_at = &t
  20401. }
  20402. // CreatedAt returns the value of the "created_at" field in the mutation.
  20403. func (m *LabelLogMutation) CreatedAt() (r time.Time, exists bool) {
  20404. v := m.created_at
  20405. if v == nil {
  20406. return
  20407. }
  20408. return *v, true
  20409. }
  20410. // OldCreatedAt returns the old "created_at" field's value of the LabelLog entity.
  20411. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20413. func (m *LabelLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20414. if !m.op.Is(OpUpdateOne) {
  20415. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20416. }
  20417. if m.id == nil || m.oldValue == nil {
  20418. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20419. }
  20420. oldValue, err := m.oldValue(ctx)
  20421. if err != nil {
  20422. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20423. }
  20424. return oldValue.CreatedAt, nil
  20425. }
  20426. // ResetCreatedAt resets all changes to the "created_at" field.
  20427. func (m *LabelLogMutation) ResetCreatedAt() {
  20428. m.created_at = nil
  20429. }
  20430. // SetUpdatedAt sets the "updated_at" field.
  20431. func (m *LabelLogMutation) SetUpdatedAt(t time.Time) {
  20432. m.updated_at = &t
  20433. }
  20434. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20435. func (m *LabelLogMutation) UpdatedAt() (r time.Time, exists bool) {
  20436. v := m.updated_at
  20437. if v == nil {
  20438. return
  20439. }
  20440. return *v, true
  20441. }
  20442. // OldUpdatedAt returns the old "updated_at" field's value of the LabelLog entity.
  20443. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20445. func (m *LabelLogMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20446. if !m.op.Is(OpUpdateOne) {
  20447. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20448. }
  20449. if m.id == nil || m.oldValue == nil {
  20450. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20451. }
  20452. oldValue, err := m.oldValue(ctx)
  20453. if err != nil {
  20454. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20455. }
  20456. return oldValue.UpdatedAt, nil
  20457. }
  20458. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20459. func (m *LabelLogMutation) ResetUpdatedAt() {
  20460. m.updated_at = nil
  20461. }
  20462. // SetLabelName sets the "label_name" field.
  20463. func (m *LabelLogMutation) SetLabelName(s string) {
  20464. m.label_name = &s
  20465. }
  20466. // LabelName returns the value of the "label_name" field in the mutation.
  20467. func (m *LabelLogMutation) LabelName() (r string, exists bool) {
  20468. v := m.label_name
  20469. if v == nil {
  20470. return
  20471. }
  20472. return *v, true
  20473. }
  20474. // OldLabelName returns the old "label_name" field's value of the LabelLog entity.
  20475. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20477. func (m *LabelLogMutation) OldLabelName(ctx context.Context) (v string, err error) {
  20478. if !m.op.Is(OpUpdateOne) {
  20479. return v, errors.New("OldLabelName is only allowed on UpdateOne operations")
  20480. }
  20481. if m.id == nil || m.oldValue == nil {
  20482. return v, errors.New("OldLabelName requires an ID field in the mutation")
  20483. }
  20484. oldValue, err := m.oldValue(ctx)
  20485. if err != nil {
  20486. return v, fmt.Errorf("querying old value for OldLabelName: %w", err)
  20487. }
  20488. return oldValue.LabelName, nil
  20489. }
  20490. // ResetLabelName resets all changes to the "label_name" field.
  20491. func (m *LabelLogMutation) ResetLabelName() {
  20492. m.label_name = nil
  20493. }
  20494. // SetLabelID sets the "label_id" field.
  20495. func (m *LabelLogMutation) SetLabelID(i int) {
  20496. m.label_id = &i
  20497. m.addlabel_id = nil
  20498. }
  20499. // LabelID returns the value of the "label_id" field in the mutation.
  20500. func (m *LabelLogMutation) LabelID() (r int, exists bool) {
  20501. v := m.label_id
  20502. if v == nil {
  20503. return
  20504. }
  20505. return *v, true
  20506. }
  20507. // OldLabelID returns the old "label_id" field's value of the LabelLog entity.
  20508. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20510. func (m *LabelLogMutation) OldLabelID(ctx context.Context) (v int, err error) {
  20511. if !m.op.Is(OpUpdateOne) {
  20512. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  20513. }
  20514. if m.id == nil || m.oldValue == nil {
  20515. return v, errors.New("OldLabelID requires an ID field in the mutation")
  20516. }
  20517. oldValue, err := m.oldValue(ctx)
  20518. if err != nil {
  20519. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  20520. }
  20521. return oldValue.LabelID, nil
  20522. }
  20523. // AddLabelID adds i to the "label_id" field.
  20524. func (m *LabelLogMutation) AddLabelID(i int) {
  20525. if m.addlabel_id != nil {
  20526. *m.addlabel_id += i
  20527. } else {
  20528. m.addlabel_id = &i
  20529. }
  20530. }
  20531. // AddedLabelID returns the value that was added to the "label_id" field in this mutation.
  20532. func (m *LabelLogMutation) AddedLabelID() (r int, exists bool) {
  20533. v := m.addlabel_id
  20534. if v == nil {
  20535. return
  20536. }
  20537. return *v, true
  20538. }
  20539. // ResetLabelID resets all changes to the "label_id" field.
  20540. func (m *LabelLogMutation) ResetLabelID() {
  20541. m.label_id = nil
  20542. m.addlabel_id = nil
  20543. }
  20544. // SetWxID sets the "wx_id" field.
  20545. func (m *LabelLogMutation) SetWxID(s string) {
  20546. m.wx_id = &s
  20547. }
  20548. // WxID returns the value of the "wx_id" field in the mutation.
  20549. func (m *LabelLogMutation) WxID() (r string, exists bool) {
  20550. v := m.wx_id
  20551. if v == nil {
  20552. return
  20553. }
  20554. return *v, true
  20555. }
  20556. // OldWxID returns the old "wx_id" field's value of the LabelLog entity.
  20557. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20559. func (m *LabelLogMutation) OldWxID(ctx context.Context) (v string, err error) {
  20560. if !m.op.Is(OpUpdateOne) {
  20561. return v, errors.New("OldWxID is only allowed on UpdateOne operations")
  20562. }
  20563. if m.id == nil || m.oldValue == nil {
  20564. return v, errors.New("OldWxID requires an ID field in the mutation")
  20565. }
  20566. oldValue, err := m.oldValue(ctx)
  20567. if err != nil {
  20568. return v, fmt.Errorf("querying old value for OldWxID: %w", err)
  20569. }
  20570. return oldValue.WxID, nil
  20571. }
  20572. // ResetWxID resets all changes to the "wx_id" field.
  20573. func (m *LabelLogMutation) ResetWxID() {
  20574. m.wx_id = nil
  20575. }
  20576. // SetOrganizationID sets the "organization_id" field.
  20577. func (m *LabelLogMutation) SetOrganizationID(u uint64) {
  20578. m.organization_id = &u
  20579. m.addorganization_id = nil
  20580. }
  20581. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20582. func (m *LabelLogMutation) OrganizationID() (r uint64, exists bool) {
  20583. v := m.organization_id
  20584. if v == nil {
  20585. return
  20586. }
  20587. return *v, true
  20588. }
  20589. // OldOrganizationID returns the old "organization_id" field's value of the LabelLog entity.
  20590. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20592. func (m *LabelLogMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20593. if !m.op.Is(OpUpdateOne) {
  20594. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20595. }
  20596. if m.id == nil || m.oldValue == nil {
  20597. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20598. }
  20599. oldValue, err := m.oldValue(ctx)
  20600. if err != nil {
  20601. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20602. }
  20603. return oldValue.OrganizationID, nil
  20604. }
  20605. // AddOrganizationID adds u to the "organization_id" field.
  20606. func (m *LabelLogMutation) AddOrganizationID(u int64) {
  20607. if m.addorganization_id != nil {
  20608. *m.addorganization_id += u
  20609. } else {
  20610. m.addorganization_id = &u
  20611. }
  20612. }
  20613. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20614. func (m *LabelLogMutation) AddedOrganizationID() (r int64, exists bool) {
  20615. v := m.addorganization_id
  20616. if v == nil {
  20617. return
  20618. }
  20619. return *v, true
  20620. }
  20621. // ClearOrganizationID clears the value of the "organization_id" field.
  20622. func (m *LabelLogMutation) ClearOrganizationID() {
  20623. m.organization_id = nil
  20624. m.addorganization_id = nil
  20625. m.clearedFields[labellog.FieldOrganizationID] = struct{}{}
  20626. }
  20627. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20628. func (m *LabelLogMutation) OrganizationIDCleared() bool {
  20629. _, ok := m.clearedFields[labellog.FieldOrganizationID]
  20630. return ok
  20631. }
  20632. // ResetOrganizationID resets all changes to the "organization_id" field.
  20633. func (m *LabelLogMutation) ResetOrganizationID() {
  20634. m.organization_id = nil
  20635. m.addorganization_id = nil
  20636. delete(m.clearedFields, labellog.FieldOrganizationID)
  20637. }
  20638. // Where appends a list predicates to the LabelLogMutation builder.
  20639. func (m *LabelLogMutation) Where(ps ...predicate.LabelLog) {
  20640. m.predicates = append(m.predicates, ps...)
  20641. }
  20642. // WhereP appends storage-level predicates to the LabelLogMutation builder. Using this method,
  20643. // users can use type-assertion to append predicates that do not depend on any generated package.
  20644. func (m *LabelLogMutation) WhereP(ps ...func(*sql.Selector)) {
  20645. p := make([]predicate.LabelLog, len(ps))
  20646. for i := range ps {
  20647. p[i] = ps[i]
  20648. }
  20649. m.Where(p...)
  20650. }
  20651. // Op returns the operation name.
  20652. func (m *LabelLogMutation) Op() Op {
  20653. return m.op
  20654. }
  20655. // SetOp allows setting the mutation operation.
  20656. func (m *LabelLogMutation) SetOp(op Op) {
  20657. m.op = op
  20658. }
  20659. // Type returns the node type of this mutation (LabelLog).
  20660. func (m *LabelLogMutation) Type() string {
  20661. return m.typ
  20662. }
  20663. // Fields returns all fields that were changed during this mutation. Note that in
  20664. // order to get all numeric fields that were incremented/decremented, call
  20665. // AddedFields().
  20666. func (m *LabelLogMutation) Fields() []string {
  20667. fields := make([]string, 0, 6)
  20668. if m.created_at != nil {
  20669. fields = append(fields, labellog.FieldCreatedAt)
  20670. }
  20671. if m.updated_at != nil {
  20672. fields = append(fields, labellog.FieldUpdatedAt)
  20673. }
  20674. if m.label_name != nil {
  20675. fields = append(fields, labellog.FieldLabelName)
  20676. }
  20677. if m.label_id != nil {
  20678. fields = append(fields, labellog.FieldLabelID)
  20679. }
  20680. if m.wx_id != nil {
  20681. fields = append(fields, labellog.FieldWxID)
  20682. }
  20683. if m.organization_id != nil {
  20684. fields = append(fields, labellog.FieldOrganizationID)
  20685. }
  20686. return fields
  20687. }
  20688. // Field returns the value of a field with the given name. The second boolean
  20689. // return value indicates that this field was not set, or was not defined in the
  20690. // schema.
  20691. func (m *LabelLogMutation) Field(name string) (ent.Value, bool) {
  20692. switch name {
  20693. case labellog.FieldCreatedAt:
  20694. return m.CreatedAt()
  20695. case labellog.FieldUpdatedAt:
  20696. return m.UpdatedAt()
  20697. case labellog.FieldLabelName:
  20698. return m.LabelName()
  20699. case labellog.FieldLabelID:
  20700. return m.LabelID()
  20701. case labellog.FieldWxID:
  20702. return m.WxID()
  20703. case labellog.FieldOrganizationID:
  20704. return m.OrganizationID()
  20705. }
  20706. return nil, false
  20707. }
  20708. // OldField returns the old value of the field from the database. An error is
  20709. // returned if the mutation operation is not UpdateOne, or the query to the
  20710. // database failed.
  20711. func (m *LabelLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20712. switch name {
  20713. case labellog.FieldCreatedAt:
  20714. return m.OldCreatedAt(ctx)
  20715. case labellog.FieldUpdatedAt:
  20716. return m.OldUpdatedAt(ctx)
  20717. case labellog.FieldLabelName:
  20718. return m.OldLabelName(ctx)
  20719. case labellog.FieldLabelID:
  20720. return m.OldLabelID(ctx)
  20721. case labellog.FieldWxID:
  20722. return m.OldWxID(ctx)
  20723. case labellog.FieldOrganizationID:
  20724. return m.OldOrganizationID(ctx)
  20725. }
  20726. return nil, fmt.Errorf("unknown LabelLog field %s", name)
  20727. }
  20728. // SetField sets the value of a field with the given name. It returns an error if
  20729. // the field is not defined in the schema, or if the type mismatched the field
  20730. // type.
  20731. func (m *LabelLogMutation) SetField(name string, value ent.Value) error {
  20732. switch name {
  20733. case labellog.FieldCreatedAt:
  20734. v, ok := value.(time.Time)
  20735. if !ok {
  20736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20737. }
  20738. m.SetCreatedAt(v)
  20739. return nil
  20740. case labellog.FieldUpdatedAt:
  20741. v, ok := value.(time.Time)
  20742. if !ok {
  20743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20744. }
  20745. m.SetUpdatedAt(v)
  20746. return nil
  20747. case labellog.FieldLabelName:
  20748. v, ok := value.(string)
  20749. if !ok {
  20750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20751. }
  20752. m.SetLabelName(v)
  20753. return nil
  20754. case labellog.FieldLabelID:
  20755. v, ok := value.(int)
  20756. if !ok {
  20757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20758. }
  20759. m.SetLabelID(v)
  20760. return nil
  20761. case labellog.FieldWxID:
  20762. v, ok := value.(string)
  20763. if !ok {
  20764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20765. }
  20766. m.SetWxID(v)
  20767. return nil
  20768. case labellog.FieldOrganizationID:
  20769. v, ok := value.(uint64)
  20770. if !ok {
  20771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20772. }
  20773. m.SetOrganizationID(v)
  20774. return nil
  20775. }
  20776. return fmt.Errorf("unknown LabelLog field %s", name)
  20777. }
  20778. // AddedFields returns all numeric fields that were incremented/decremented during
  20779. // this mutation.
  20780. func (m *LabelLogMutation) AddedFields() []string {
  20781. var fields []string
  20782. if m.addlabel_id != nil {
  20783. fields = append(fields, labellog.FieldLabelID)
  20784. }
  20785. if m.addorganization_id != nil {
  20786. fields = append(fields, labellog.FieldOrganizationID)
  20787. }
  20788. return fields
  20789. }
  20790. // AddedField returns the numeric value that was incremented/decremented on a field
  20791. // with the given name. The second boolean return value indicates that this field
  20792. // was not set, or was not defined in the schema.
  20793. func (m *LabelLogMutation) AddedField(name string) (ent.Value, bool) {
  20794. switch name {
  20795. case labellog.FieldLabelID:
  20796. return m.AddedLabelID()
  20797. case labellog.FieldOrganizationID:
  20798. return m.AddedOrganizationID()
  20799. }
  20800. return nil, false
  20801. }
  20802. // AddField adds the value to the field with the given name. It returns an error if
  20803. // the field is not defined in the schema, or if the type mismatched the field
  20804. // type.
  20805. func (m *LabelLogMutation) AddField(name string, value ent.Value) error {
  20806. switch name {
  20807. case labellog.FieldLabelID:
  20808. v, ok := value.(int)
  20809. if !ok {
  20810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20811. }
  20812. m.AddLabelID(v)
  20813. return nil
  20814. case labellog.FieldOrganizationID:
  20815. v, ok := value.(int64)
  20816. if !ok {
  20817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20818. }
  20819. m.AddOrganizationID(v)
  20820. return nil
  20821. }
  20822. return fmt.Errorf("unknown LabelLog numeric field %s", name)
  20823. }
  20824. // ClearedFields returns all nullable fields that were cleared during this
  20825. // mutation.
  20826. func (m *LabelLogMutation) ClearedFields() []string {
  20827. var fields []string
  20828. if m.FieldCleared(labellog.FieldOrganizationID) {
  20829. fields = append(fields, labellog.FieldOrganizationID)
  20830. }
  20831. return fields
  20832. }
  20833. // FieldCleared returns a boolean indicating if a field with the given name was
  20834. // cleared in this mutation.
  20835. func (m *LabelLogMutation) FieldCleared(name string) bool {
  20836. _, ok := m.clearedFields[name]
  20837. return ok
  20838. }
  20839. // ClearField clears the value of the field with the given name. It returns an
  20840. // error if the field is not defined in the schema.
  20841. func (m *LabelLogMutation) ClearField(name string) error {
  20842. switch name {
  20843. case labellog.FieldOrganizationID:
  20844. m.ClearOrganizationID()
  20845. return nil
  20846. }
  20847. return fmt.Errorf("unknown LabelLog nullable field %s", name)
  20848. }
  20849. // ResetField resets all changes in the mutation for the field with the given name.
  20850. // It returns an error if the field is not defined in the schema.
  20851. func (m *LabelLogMutation) ResetField(name string) error {
  20852. switch name {
  20853. case labellog.FieldCreatedAt:
  20854. m.ResetCreatedAt()
  20855. return nil
  20856. case labellog.FieldUpdatedAt:
  20857. m.ResetUpdatedAt()
  20858. return nil
  20859. case labellog.FieldLabelName:
  20860. m.ResetLabelName()
  20861. return nil
  20862. case labellog.FieldLabelID:
  20863. m.ResetLabelID()
  20864. return nil
  20865. case labellog.FieldWxID:
  20866. m.ResetWxID()
  20867. return nil
  20868. case labellog.FieldOrganizationID:
  20869. m.ResetOrganizationID()
  20870. return nil
  20871. }
  20872. return fmt.Errorf("unknown LabelLog field %s", name)
  20873. }
  20874. // AddedEdges returns all edge names that were set/added in this mutation.
  20875. func (m *LabelLogMutation) AddedEdges() []string {
  20876. edges := make([]string, 0, 0)
  20877. return edges
  20878. }
  20879. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20880. // name in this mutation.
  20881. func (m *LabelLogMutation) AddedIDs(name string) []ent.Value {
  20882. return nil
  20883. }
  20884. // RemovedEdges returns all edge names that were removed in this mutation.
  20885. func (m *LabelLogMutation) RemovedEdges() []string {
  20886. edges := make([]string, 0, 0)
  20887. return edges
  20888. }
  20889. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20890. // the given name in this mutation.
  20891. func (m *LabelLogMutation) RemovedIDs(name string) []ent.Value {
  20892. return nil
  20893. }
  20894. // ClearedEdges returns all edge names that were cleared in this mutation.
  20895. func (m *LabelLogMutation) ClearedEdges() []string {
  20896. edges := make([]string, 0, 0)
  20897. return edges
  20898. }
  20899. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20900. // was cleared in this mutation.
  20901. func (m *LabelLogMutation) EdgeCleared(name string) bool {
  20902. return false
  20903. }
  20904. // ClearEdge clears the value of the edge with the given name. It returns an error
  20905. // if that edge is not defined in the schema.
  20906. func (m *LabelLogMutation) ClearEdge(name string) error {
  20907. return fmt.Errorf("unknown LabelLog unique edge %s", name)
  20908. }
  20909. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20910. // It returns an error if the edge is not defined in the schema.
  20911. func (m *LabelLogMutation) ResetEdge(name string) error {
  20912. return fmt.Errorf("unknown LabelLog edge %s", name)
  20913. }
  20914. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  20915. type LabelRelationshipMutation struct {
  20916. config
  20917. op Op
  20918. typ string
  20919. id *uint64
  20920. created_at *time.Time
  20921. updated_at *time.Time
  20922. status *uint8
  20923. addstatus *int8
  20924. organization_id *uint64
  20925. addorganization_id *int64
  20926. clearedFields map[string]struct{}
  20927. contacts *uint64
  20928. clearedcontacts bool
  20929. labels *uint64
  20930. clearedlabels bool
  20931. done bool
  20932. oldValue func(context.Context) (*LabelRelationship, error)
  20933. predicates []predicate.LabelRelationship
  20934. }
  20935. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  20936. // labelrelationshipOption allows management of the mutation configuration using functional options.
  20937. type labelrelationshipOption func(*LabelRelationshipMutation)
  20938. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  20939. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  20940. m := &LabelRelationshipMutation{
  20941. config: c,
  20942. op: op,
  20943. typ: TypeLabelRelationship,
  20944. clearedFields: make(map[string]struct{}),
  20945. }
  20946. for _, opt := range opts {
  20947. opt(m)
  20948. }
  20949. return m
  20950. }
  20951. // withLabelRelationshipID sets the ID field of the mutation.
  20952. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  20953. return func(m *LabelRelationshipMutation) {
  20954. var (
  20955. err error
  20956. once sync.Once
  20957. value *LabelRelationship
  20958. )
  20959. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  20960. once.Do(func() {
  20961. if m.done {
  20962. err = errors.New("querying old values post mutation is not allowed")
  20963. } else {
  20964. value, err = m.Client().LabelRelationship.Get(ctx, id)
  20965. }
  20966. })
  20967. return value, err
  20968. }
  20969. m.id = &id
  20970. }
  20971. }
  20972. // withLabelRelationship sets the old LabelRelationship of the mutation.
  20973. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  20974. return func(m *LabelRelationshipMutation) {
  20975. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  20976. return node, nil
  20977. }
  20978. m.id = &node.ID
  20979. }
  20980. }
  20981. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20982. // executed in a transaction (ent.Tx), a transactional client is returned.
  20983. func (m LabelRelationshipMutation) Client() *Client {
  20984. client := &Client{config: m.config}
  20985. client.init()
  20986. return client
  20987. }
  20988. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20989. // it returns an error otherwise.
  20990. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  20991. if _, ok := m.driver.(*txDriver); !ok {
  20992. return nil, errors.New("ent: mutation is not running in a transaction")
  20993. }
  20994. tx := &Tx{config: m.config}
  20995. tx.init()
  20996. return tx, nil
  20997. }
  20998. // SetID sets the value of the id field. Note that this
  20999. // operation is only accepted on creation of LabelRelationship entities.
  21000. func (m *LabelRelationshipMutation) SetID(id uint64) {
  21001. m.id = &id
  21002. }
  21003. // ID returns the ID value in the mutation. Note that the ID is only available
  21004. // if it was provided to the builder or after it was returned from the database.
  21005. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  21006. if m.id == nil {
  21007. return
  21008. }
  21009. return *m.id, true
  21010. }
  21011. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21012. // That means, if the mutation is applied within a transaction with an isolation level such
  21013. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21014. // or updated by the mutation.
  21015. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  21016. switch {
  21017. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21018. id, exists := m.ID()
  21019. if exists {
  21020. return []uint64{id}, nil
  21021. }
  21022. fallthrough
  21023. case m.op.Is(OpUpdate | OpDelete):
  21024. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  21025. default:
  21026. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21027. }
  21028. }
  21029. // SetCreatedAt sets the "created_at" field.
  21030. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  21031. m.created_at = &t
  21032. }
  21033. // CreatedAt returns the value of the "created_at" field in the mutation.
  21034. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  21035. v := m.created_at
  21036. if v == nil {
  21037. return
  21038. }
  21039. return *v, true
  21040. }
  21041. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  21042. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  21043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21044. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21045. if !m.op.Is(OpUpdateOne) {
  21046. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21047. }
  21048. if m.id == nil || m.oldValue == nil {
  21049. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21050. }
  21051. oldValue, err := m.oldValue(ctx)
  21052. if err != nil {
  21053. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21054. }
  21055. return oldValue.CreatedAt, nil
  21056. }
  21057. // ResetCreatedAt resets all changes to the "created_at" field.
  21058. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  21059. m.created_at = nil
  21060. }
  21061. // SetUpdatedAt sets the "updated_at" field.
  21062. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  21063. m.updated_at = &t
  21064. }
  21065. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21066. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  21067. v := m.updated_at
  21068. if v == nil {
  21069. return
  21070. }
  21071. return *v, true
  21072. }
  21073. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  21074. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  21075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21076. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21077. if !m.op.Is(OpUpdateOne) {
  21078. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21079. }
  21080. if m.id == nil || m.oldValue == nil {
  21081. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21082. }
  21083. oldValue, err := m.oldValue(ctx)
  21084. if err != nil {
  21085. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21086. }
  21087. return oldValue.UpdatedAt, nil
  21088. }
  21089. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21090. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  21091. m.updated_at = nil
  21092. }
  21093. // SetStatus sets the "status" field.
  21094. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  21095. m.status = &u
  21096. m.addstatus = nil
  21097. }
  21098. // Status returns the value of the "status" field in the mutation.
  21099. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  21100. v := m.status
  21101. if v == nil {
  21102. return
  21103. }
  21104. return *v, true
  21105. }
  21106. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  21107. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  21108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21109. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21110. if !m.op.Is(OpUpdateOne) {
  21111. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21112. }
  21113. if m.id == nil || m.oldValue == nil {
  21114. return v, errors.New("OldStatus requires an ID field in the mutation")
  21115. }
  21116. oldValue, err := m.oldValue(ctx)
  21117. if err != nil {
  21118. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21119. }
  21120. return oldValue.Status, nil
  21121. }
  21122. // AddStatus adds u to the "status" field.
  21123. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  21124. if m.addstatus != nil {
  21125. *m.addstatus += u
  21126. } else {
  21127. m.addstatus = &u
  21128. }
  21129. }
  21130. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21131. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  21132. v := m.addstatus
  21133. if v == nil {
  21134. return
  21135. }
  21136. return *v, true
  21137. }
  21138. // ClearStatus clears the value of the "status" field.
  21139. func (m *LabelRelationshipMutation) ClearStatus() {
  21140. m.status = nil
  21141. m.addstatus = nil
  21142. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  21143. }
  21144. // StatusCleared returns if the "status" field was cleared in this mutation.
  21145. func (m *LabelRelationshipMutation) StatusCleared() bool {
  21146. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  21147. return ok
  21148. }
  21149. // ResetStatus resets all changes to the "status" field.
  21150. func (m *LabelRelationshipMutation) ResetStatus() {
  21151. m.status = nil
  21152. m.addstatus = nil
  21153. delete(m.clearedFields, labelrelationship.FieldStatus)
  21154. }
  21155. // SetLabelID sets the "label_id" field.
  21156. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  21157. m.labels = &u
  21158. }
  21159. // LabelID returns the value of the "label_id" field in the mutation.
  21160. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  21161. v := m.labels
  21162. if v == nil {
  21163. return
  21164. }
  21165. return *v, true
  21166. }
  21167. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  21168. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  21169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21170. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  21171. if !m.op.Is(OpUpdateOne) {
  21172. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  21173. }
  21174. if m.id == nil || m.oldValue == nil {
  21175. return v, errors.New("OldLabelID requires an ID field in the mutation")
  21176. }
  21177. oldValue, err := m.oldValue(ctx)
  21178. if err != nil {
  21179. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  21180. }
  21181. return oldValue.LabelID, nil
  21182. }
  21183. // ResetLabelID resets all changes to the "label_id" field.
  21184. func (m *LabelRelationshipMutation) ResetLabelID() {
  21185. m.labels = nil
  21186. }
  21187. // SetContactID sets the "contact_id" field.
  21188. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  21189. m.contacts = &u
  21190. }
  21191. // ContactID returns the value of the "contact_id" field in the mutation.
  21192. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  21193. v := m.contacts
  21194. if v == nil {
  21195. return
  21196. }
  21197. return *v, true
  21198. }
  21199. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  21200. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  21201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21202. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  21203. if !m.op.Is(OpUpdateOne) {
  21204. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  21205. }
  21206. if m.id == nil || m.oldValue == nil {
  21207. return v, errors.New("OldContactID requires an ID field in the mutation")
  21208. }
  21209. oldValue, err := m.oldValue(ctx)
  21210. if err != nil {
  21211. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  21212. }
  21213. return oldValue.ContactID, nil
  21214. }
  21215. // ResetContactID resets all changes to the "contact_id" field.
  21216. func (m *LabelRelationshipMutation) ResetContactID() {
  21217. m.contacts = nil
  21218. }
  21219. // SetOrganizationID sets the "organization_id" field.
  21220. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  21221. m.organization_id = &u
  21222. m.addorganization_id = nil
  21223. }
  21224. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21225. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  21226. v := m.organization_id
  21227. if v == nil {
  21228. return
  21229. }
  21230. return *v, true
  21231. }
  21232. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  21233. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  21234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21235. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21236. if !m.op.Is(OpUpdateOne) {
  21237. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21238. }
  21239. if m.id == nil || m.oldValue == nil {
  21240. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21241. }
  21242. oldValue, err := m.oldValue(ctx)
  21243. if err != nil {
  21244. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21245. }
  21246. return oldValue.OrganizationID, nil
  21247. }
  21248. // AddOrganizationID adds u to the "organization_id" field.
  21249. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  21250. if m.addorganization_id != nil {
  21251. *m.addorganization_id += u
  21252. } else {
  21253. m.addorganization_id = &u
  21254. }
  21255. }
  21256. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21257. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  21258. v := m.addorganization_id
  21259. if v == nil {
  21260. return
  21261. }
  21262. return *v, true
  21263. }
  21264. // ClearOrganizationID clears the value of the "organization_id" field.
  21265. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  21266. m.organization_id = nil
  21267. m.addorganization_id = nil
  21268. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  21269. }
  21270. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21271. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  21272. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  21273. return ok
  21274. }
  21275. // ResetOrganizationID resets all changes to the "organization_id" field.
  21276. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  21277. m.organization_id = nil
  21278. m.addorganization_id = nil
  21279. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  21280. }
  21281. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  21282. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  21283. m.contacts = &id
  21284. }
  21285. // ClearContacts clears the "contacts" edge to the Contact entity.
  21286. func (m *LabelRelationshipMutation) ClearContacts() {
  21287. m.clearedcontacts = true
  21288. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  21289. }
  21290. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  21291. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  21292. return m.clearedcontacts
  21293. }
  21294. // ContactsID returns the "contacts" edge ID in the mutation.
  21295. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  21296. if m.contacts != nil {
  21297. return *m.contacts, true
  21298. }
  21299. return
  21300. }
  21301. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  21302. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21303. // ContactsID instead. It exists only for internal usage by the builders.
  21304. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  21305. if id := m.contacts; id != nil {
  21306. ids = append(ids, *id)
  21307. }
  21308. return
  21309. }
  21310. // ResetContacts resets all changes to the "contacts" edge.
  21311. func (m *LabelRelationshipMutation) ResetContacts() {
  21312. m.contacts = nil
  21313. m.clearedcontacts = false
  21314. }
  21315. // SetLabelsID sets the "labels" edge to the Label entity by id.
  21316. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  21317. m.labels = &id
  21318. }
  21319. // ClearLabels clears the "labels" edge to the Label entity.
  21320. func (m *LabelRelationshipMutation) ClearLabels() {
  21321. m.clearedlabels = true
  21322. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  21323. }
  21324. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  21325. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  21326. return m.clearedlabels
  21327. }
  21328. // LabelsID returns the "labels" edge ID in the mutation.
  21329. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  21330. if m.labels != nil {
  21331. return *m.labels, true
  21332. }
  21333. return
  21334. }
  21335. // LabelsIDs returns the "labels" edge IDs in the mutation.
  21336. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21337. // LabelsID instead. It exists only for internal usage by the builders.
  21338. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  21339. if id := m.labels; id != nil {
  21340. ids = append(ids, *id)
  21341. }
  21342. return
  21343. }
  21344. // ResetLabels resets all changes to the "labels" edge.
  21345. func (m *LabelRelationshipMutation) ResetLabels() {
  21346. m.labels = nil
  21347. m.clearedlabels = false
  21348. }
  21349. // Where appends a list predicates to the LabelRelationshipMutation builder.
  21350. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  21351. m.predicates = append(m.predicates, ps...)
  21352. }
  21353. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  21354. // users can use type-assertion to append predicates that do not depend on any generated package.
  21355. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  21356. p := make([]predicate.LabelRelationship, len(ps))
  21357. for i := range ps {
  21358. p[i] = ps[i]
  21359. }
  21360. m.Where(p...)
  21361. }
  21362. // Op returns the operation name.
  21363. func (m *LabelRelationshipMutation) Op() Op {
  21364. return m.op
  21365. }
  21366. // SetOp allows setting the mutation operation.
  21367. func (m *LabelRelationshipMutation) SetOp(op Op) {
  21368. m.op = op
  21369. }
  21370. // Type returns the node type of this mutation (LabelRelationship).
  21371. func (m *LabelRelationshipMutation) Type() string {
  21372. return m.typ
  21373. }
  21374. // Fields returns all fields that were changed during this mutation. Note that in
  21375. // order to get all numeric fields that were incremented/decremented, call
  21376. // AddedFields().
  21377. func (m *LabelRelationshipMutation) Fields() []string {
  21378. fields := make([]string, 0, 6)
  21379. if m.created_at != nil {
  21380. fields = append(fields, labelrelationship.FieldCreatedAt)
  21381. }
  21382. if m.updated_at != nil {
  21383. fields = append(fields, labelrelationship.FieldUpdatedAt)
  21384. }
  21385. if m.status != nil {
  21386. fields = append(fields, labelrelationship.FieldStatus)
  21387. }
  21388. if m.labels != nil {
  21389. fields = append(fields, labelrelationship.FieldLabelID)
  21390. }
  21391. if m.contacts != nil {
  21392. fields = append(fields, labelrelationship.FieldContactID)
  21393. }
  21394. if m.organization_id != nil {
  21395. fields = append(fields, labelrelationship.FieldOrganizationID)
  21396. }
  21397. return fields
  21398. }
  21399. // Field returns the value of a field with the given name. The second boolean
  21400. // return value indicates that this field was not set, or was not defined in the
  21401. // schema.
  21402. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  21403. switch name {
  21404. case labelrelationship.FieldCreatedAt:
  21405. return m.CreatedAt()
  21406. case labelrelationship.FieldUpdatedAt:
  21407. return m.UpdatedAt()
  21408. case labelrelationship.FieldStatus:
  21409. return m.Status()
  21410. case labelrelationship.FieldLabelID:
  21411. return m.LabelID()
  21412. case labelrelationship.FieldContactID:
  21413. return m.ContactID()
  21414. case labelrelationship.FieldOrganizationID:
  21415. return m.OrganizationID()
  21416. }
  21417. return nil, false
  21418. }
  21419. // OldField returns the old value of the field from the database. An error is
  21420. // returned if the mutation operation is not UpdateOne, or the query to the
  21421. // database failed.
  21422. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21423. switch name {
  21424. case labelrelationship.FieldCreatedAt:
  21425. return m.OldCreatedAt(ctx)
  21426. case labelrelationship.FieldUpdatedAt:
  21427. return m.OldUpdatedAt(ctx)
  21428. case labelrelationship.FieldStatus:
  21429. return m.OldStatus(ctx)
  21430. case labelrelationship.FieldLabelID:
  21431. return m.OldLabelID(ctx)
  21432. case labelrelationship.FieldContactID:
  21433. return m.OldContactID(ctx)
  21434. case labelrelationship.FieldOrganizationID:
  21435. return m.OldOrganizationID(ctx)
  21436. }
  21437. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  21438. }
  21439. // SetField sets the value of a field with the given name. It returns an error if
  21440. // the field is not defined in the schema, or if the type mismatched the field
  21441. // type.
  21442. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  21443. switch name {
  21444. case labelrelationship.FieldCreatedAt:
  21445. v, ok := value.(time.Time)
  21446. if !ok {
  21447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21448. }
  21449. m.SetCreatedAt(v)
  21450. return nil
  21451. case labelrelationship.FieldUpdatedAt:
  21452. v, ok := value.(time.Time)
  21453. if !ok {
  21454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21455. }
  21456. m.SetUpdatedAt(v)
  21457. return nil
  21458. case labelrelationship.FieldStatus:
  21459. v, ok := value.(uint8)
  21460. if !ok {
  21461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21462. }
  21463. m.SetStatus(v)
  21464. return nil
  21465. case labelrelationship.FieldLabelID:
  21466. v, ok := value.(uint64)
  21467. if !ok {
  21468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21469. }
  21470. m.SetLabelID(v)
  21471. return nil
  21472. case labelrelationship.FieldContactID:
  21473. v, ok := value.(uint64)
  21474. if !ok {
  21475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21476. }
  21477. m.SetContactID(v)
  21478. return nil
  21479. case labelrelationship.FieldOrganizationID:
  21480. v, ok := value.(uint64)
  21481. if !ok {
  21482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21483. }
  21484. m.SetOrganizationID(v)
  21485. return nil
  21486. }
  21487. return fmt.Errorf("unknown LabelRelationship field %s", name)
  21488. }
  21489. // AddedFields returns all numeric fields that were incremented/decremented during
  21490. // this mutation.
  21491. func (m *LabelRelationshipMutation) AddedFields() []string {
  21492. var fields []string
  21493. if m.addstatus != nil {
  21494. fields = append(fields, labelrelationship.FieldStatus)
  21495. }
  21496. if m.addorganization_id != nil {
  21497. fields = append(fields, labelrelationship.FieldOrganizationID)
  21498. }
  21499. return fields
  21500. }
  21501. // AddedField returns the numeric value that was incremented/decremented on a field
  21502. // with the given name. The second boolean return value indicates that this field
  21503. // was not set, or was not defined in the schema.
  21504. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  21505. switch name {
  21506. case labelrelationship.FieldStatus:
  21507. return m.AddedStatus()
  21508. case labelrelationship.FieldOrganizationID:
  21509. return m.AddedOrganizationID()
  21510. }
  21511. return nil, false
  21512. }
  21513. // AddField adds the value to the field with the given name. It returns an error if
  21514. // the field is not defined in the schema, or if the type mismatched the field
  21515. // type.
  21516. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  21517. switch name {
  21518. case labelrelationship.FieldStatus:
  21519. v, ok := value.(int8)
  21520. if !ok {
  21521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21522. }
  21523. m.AddStatus(v)
  21524. return nil
  21525. case labelrelationship.FieldOrganizationID:
  21526. v, ok := value.(int64)
  21527. if !ok {
  21528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21529. }
  21530. m.AddOrganizationID(v)
  21531. return nil
  21532. }
  21533. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  21534. }
  21535. // ClearedFields returns all nullable fields that were cleared during this
  21536. // mutation.
  21537. func (m *LabelRelationshipMutation) ClearedFields() []string {
  21538. var fields []string
  21539. if m.FieldCleared(labelrelationship.FieldStatus) {
  21540. fields = append(fields, labelrelationship.FieldStatus)
  21541. }
  21542. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  21543. fields = append(fields, labelrelationship.FieldOrganizationID)
  21544. }
  21545. return fields
  21546. }
  21547. // FieldCleared returns a boolean indicating if a field with the given name was
  21548. // cleared in this mutation.
  21549. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  21550. _, ok := m.clearedFields[name]
  21551. return ok
  21552. }
  21553. // ClearField clears the value of the field with the given name. It returns an
  21554. // error if the field is not defined in the schema.
  21555. func (m *LabelRelationshipMutation) ClearField(name string) error {
  21556. switch name {
  21557. case labelrelationship.FieldStatus:
  21558. m.ClearStatus()
  21559. return nil
  21560. case labelrelationship.FieldOrganizationID:
  21561. m.ClearOrganizationID()
  21562. return nil
  21563. }
  21564. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  21565. }
  21566. // ResetField resets all changes in the mutation for the field with the given name.
  21567. // It returns an error if the field is not defined in the schema.
  21568. func (m *LabelRelationshipMutation) ResetField(name string) error {
  21569. switch name {
  21570. case labelrelationship.FieldCreatedAt:
  21571. m.ResetCreatedAt()
  21572. return nil
  21573. case labelrelationship.FieldUpdatedAt:
  21574. m.ResetUpdatedAt()
  21575. return nil
  21576. case labelrelationship.FieldStatus:
  21577. m.ResetStatus()
  21578. return nil
  21579. case labelrelationship.FieldLabelID:
  21580. m.ResetLabelID()
  21581. return nil
  21582. case labelrelationship.FieldContactID:
  21583. m.ResetContactID()
  21584. return nil
  21585. case labelrelationship.FieldOrganizationID:
  21586. m.ResetOrganizationID()
  21587. return nil
  21588. }
  21589. return fmt.Errorf("unknown LabelRelationship field %s", name)
  21590. }
  21591. // AddedEdges returns all edge names that were set/added in this mutation.
  21592. func (m *LabelRelationshipMutation) AddedEdges() []string {
  21593. edges := make([]string, 0, 2)
  21594. if m.contacts != nil {
  21595. edges = append(edges, labelrelationship.EdgeContacts)
  21596. }
  21597. if m.labels != nil {
  21598. edges = append(edges, labelrelationship.EdgeLabels)
  21599. }
  21600. return edges
  21601. }
  21602. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21603. // name in this mutation.
  21604. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  21605. switch name {
  21606. case labelrelationship.EdgeContacts:
  21607. if id := m.contacts; id != nil {
  21608. return []ent.Value{*id}
  21609. }
  21610. case labelrelationship.EdgeLabels:
  21611. if id := m.labels; id != nil {
  21612. return []ent.Value{*id}
  21613. }
  21614. }
  21615. return nil
  21616. }
  21617. // RemovedEdges returns all edge names that were removed in this mutation.
  21618. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  21619. edges := make([]string, 0, 2)
  21620. return edges
  21621. }
  21622. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21623. // the given name in this mutation.
  21624. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  21625. return nil
  21626. }
  21627. // ClearedEdges returns all edge names that were cleared in this mutation.
  21628. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  21629. edges := make([]string, 0, 2)
  21630. if m.clearedcontacts {
  21631. edges = append(edges, labelrelationship.EdgeContacts)
  21632. }
  21633. if m.clearedlabels {
  21634. edges = append(edges, labelrelationship.EdgeLabels)
  21635. }
  21636. return edges
  21637. }
  21638. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21639. // was cleared in this mutation.
  21640. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  21641. switch name {
  21642. case labelrelationship.EdgeContacts:
  21643. return m.clearedcontacts
  21644. case labelrelationship.EdgeLabels:
  21645. return m.clearedlabels
  21646. }
  21647. return false
  21648. }
  21649. // ClearEdge clears the value of the edge with the given name. It returns an error
  21650. // if that edge is not defined in the schema.
  21651. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  21652. switch name {
  21653. case labelrelationship.EdgeContacts:
  21654. m.ClearContacts()
  21655. return nil
  21656. case labelrelationship.EdgeLabels:
  21657. m.ClearLabels()
  21658. return nil
  21659. }
  21660. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  21661. }
  21662. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21663. // It returns an error if the edge is not defined in the schema.
  21664. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  21665. switch name {
  21666. case labelrelationship.EdgeContacts:
  21667. m.ResetContacts()
  21668. return nil
  21669. case labelrelationship.EdgeLabels:
  21670. m.ResetLabels()
  21671. return nil
  21672. }
  21673. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  21674. }
  21675. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  21676. type LabelTaggingMutation struct {
  21677. config
  21678. op Op
  21679. typ string
  21680. id *uint64
  21681. created_at *time.Time
  21682. updated_at *time.Time
  21683. status *uint8
  21684. addstatus *int8
  21685. deleted_at *time.Time
  21686. organization_id *uint64
  21687. addorganization_id *int64
  21688. _type *int
  21689. add_type *int
  21690. conditions *string
  21691. action_label_add *[]uint64
  21692. appendaction_label_add []uint64
  21693. action_label_del *[]uint64
  21694. appendaction_label_del []uint64
  21695. clearedFields map[string]struct{}
  21696. done bool
  21697. oldValue func(context.Context) (*LabelTagging, error)
  21698. predicates []predicate.LabelTagging
  21699. }
  21700. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  21701. // labeltaggingOption allows management of the mutation configuration using functional options.
  21702. type labeltaggingOption func(*LabelTaggingMutation)
  21703. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  21704. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  21705. m := &LabelTaggingMutation{
  21706. config: c,
  21707. op: op,
  21708. typ: TypeLabelTagging,
  21709. clearedFields: make(map[string]struct{}),
  21710. }
  21711. for _, opt := range opts {
  21712. opt(m)
  21713. }
  21714. return m
  21715. }
  21716. // withLabelTaggingID sets the ID field of the mutation.
  21717. func withLabelTaggingID(id uint64) labeltaggingOption {
  21718. return func(m *LabelTaggingMutation) {
  21719. var (
  21720. err error
  21721. once sync.Once
  21722. value *LabelTagging
  21723. )
  21724. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  21725. once.Do(func() {
  21726. if m.done {
  21727. err = errors.New("querying old values post mutation is not allowed")
  21728. } else {
  21729. value, err = m.Client().LabelTagging.Get(ctx, id)
  21730. }
  21731. })
  21732. return value, err
  21733. }
  21734. m.id = &id
  21735. }
  21736. }
  21737. // withLabelTagging sets the old LabelTagging of the mutation.
  21738. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  21739. return func(m *LabelTaggingMutation) {
  21740. m.oldValue = func(context.Context) (*LabelTagging, error) {
  21741. return node, nil
  21742. }
  21743. m.id = &node.ID
  21744. }
  21745. }
  21746. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21747. // executed in a transaction (ent.Tx), a transactional client is returned.
  21748. func (m LabelTaggingMutation) Client() *Client {
  21749. client := &Client{config: m.config}
  21750. client.init()
  21751. return client
  21752. }
  21753. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21754. // it returns an error otherwise.
  21755. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  21756. if _, ok := m.driver.(*txDriver); !ok {
  21757. return nil, errors.New("ent: mutation is not running in a transaction")
  21758. }
  21759. tx := &Tx{config: m.config}
  21760. tx.init()
  21761. return tx, nil
  21762. }
  21763. // SetID sets the value of the id field. Note that this
  21764. // operation is only accepted on creation of LabelTagging entities.
  21765. func (m *LabelTaggingMutation) SetID(id uint64) {
  21766. m.id = &id
  21767. }
  21768. // ID returns the ID value in the mutation. Note that the ID is only available
  21769. // if it was provided to the builder or after it was returned from the database.
  21770. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  21771. if m.id == nil {
  21772. return
  21773. }
  21774. return *m.id, true
  21775. }
  21776. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21777. // That means, if the mutation is applied within a transaction with an isolation level such
  21778. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21779. // or updated by the mutation.
  21780. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  21781. switch {
  21782. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21783. id, exists := m.ID()
  21784. if exists {
  21785. return []uint64{id}, nil
  21786. }
  21787. fallthrough
  21788. case m.op.Is(OpUpdate | OpDelete):
  21789. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  21790. default:
  21791. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21792. }
  21793. }
  21794. // SetCreatedAt sets the "created_at" field.
  21795. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  21796. m.created_at = &t
  21797. }
  21798. // CreatedAt returns the value of the "created_at" field in the mutation.
  21799. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  21800. v := m.created_at
  21801. if v == nil {
  21802. return
  21803. }
  21804. return *v, true
  21805. }
  21806. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  21807. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21809. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21810. if !m.op.Is(OpUpdateOne) {
  21811. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21812. }
  21813. if m.id == nil || m.oldValue == nil {
  21814. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21815. }
  21816. oldValue, err := m.oldValue(ctx)
  21817. if err != nil {
  21818. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21819. }
  21820. return oldValue.CreatedAt, nil
  21821. }
  21822. // ResetCreatedAt resets all changes to the "created_at" field.
  21823. func (m *LabelTaggingMutation) ResetCreatedAt() {
  21824. m.created_at = nil
  21825. }
  21826. // SetUpdatedAt sets the "updated_at" field.
  21827. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  21828. m.updated_at = &t
  21829. }
  21830. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21831. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  21832. v := m.updated_at
  21833. if v == nil {
  21834. return
  21835. }
  21836. return *v, true
  21837. }
  21838. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  21839. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21841. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21842. if !m.op.Is(OpUpdateOne) {
  21843. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21844. }
  21845. if m.id == nil || m.oldValue == nil {
  21846. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21847. }
  21848. oldValue, err := m.oldValue(ctx)
  21849. if err != nil {
  21850. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21851. }
  21852. return oldValue.UpdatedAt, nil
  21853. }
  21854. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21855. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  21856. m.updated_at = nil
  21857. }
  21858. // SetStatus sets the "status" field.
  21859. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  21860. m.status = &u
  21861. m.addstatus = nil
  21862. }
  21863. // Status returns the value of the "status" field in the mutation.
  21864. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  21865. v := m.status
  21866. if v == nil {
  21867. return
  21868. }
  21869. return *v, true
  21870. }
  21871. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  21872. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21874. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21875. if !m.op.Is(OpUpdateOne) {
  21876. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21877. }
  21878. if m.id == nil || m.oldValue == nil {
  21879. return v, errors.New("OldStatus requires an ID field in the mutation")
  21880. }
  21881. oldValue, err := m.oldValue(ctx)
  21882. if err != nil {
  21883. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21884. }
  21885. return oldValue.Status, nil
  21886. }
  21887. // AddStatus adds u to the "status" field.
  21888. func (m *LabelTaggingMutation) AddStatus(u int8) {
  21889. if m.addstatus != nil {
  21890. *m.addstatus += u
  21891. } else {
  21892. m.addstatus = &u
  21893. }
  21894. }
  21895. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21896. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  21897. v := m.addstatus
  21898. if v == nil {
  21899. return
  21900. }
  21901. return *v, true
  21902. }
  21903. // ClearStatus clears the value of the "status" field.
  21904. func (m *LabelTaggingMutation) ClearStatus() {
  21905. m.status = nil
  21906. m.addstatus = nil
  21907. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  21908. }
  21909. // StatusCleared returns if the "status" field was cleared in this mutation.
  21910. func (m *LabelTaggingMutation) StatusCleared() bool {
  21911. _, ok := m.clearedFields[labeltagging.FieldStatus]
  21912. return ok
  21913. }
  21914. // ResetStatus resets all changes to the "status" field.
  21915. func (m *LabelTaggingMutation) ResetStatus() {
  21916. m.status = nil
  21917. m.addstatus = nil
  21918. delete(m.clearedFields, labeltagging.FieldStatus)
  21919. }
  21920. // SetDeletedAt sets the "deleted_at" field.
  21921. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  21922. m.deleted_at = &t
  21923. }
  21924. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21925. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  21926. v := m.deleted_at
  21927. if v == nil {
  21928. return
  21929. }
  21930. return *v, true
  21931. }
  21932. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  21933. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21935. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21936. if !m.op.Is(OpUpdateOne) {
  21937. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21938. }
  21939. if m.id == nil || m.oldValue == nil {
  21940. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21941. }
  21942. oldValue, err := m.oldValue(ctx)
  21943. if err != nil {
  21944. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21945. }
  21946. return oldValue.DeletedAt, nil
  21947. }
  21948. // ClearDeletedAt clears the value of the "deleted_at" field.
  21949. func (m *LabelTaggingMutation) ClearDeletedAt() {
  21950. m.deleted_at = nil
  21951. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  21952. }
  21953. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21954. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  21955. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  21956. return ok
  21957. }
  21958. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21959. func (m *LabelTaggingMutation) ResetDeletedAt() {
  21960. m.deleted_at = nil
  21961. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  21962. }
  21963. // SetOrganizationID sets the "organization_id" field.
  21964. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  21965. m.organization_id = &u
  21966. m.addorganization_id = nil
  21967. }
  21968. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21969. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  21970. v := m.organization_id
  21971. if v == nil {
  21972. return
  21973. }
  21974. return *v, true
  21975. }
  21976. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  21977. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21979. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21980. if !m.op.Is(OpUpdateOne) {
  21981. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21982. }
  21983. if m.id == nil || m.oldValue == nil {
  21984. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21985. }
  21986. oldValue, err := m.oldValue(ctx)
  21987. if err != nil {
  21988. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21989. }
  21990. return oldValue.OrganizationID, nil
  21991. }
  21992. // AddOrganizationID adds u to the "organization_id" field.
  21993. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  21994. if m.addorganization_id != nil {
  21995. *m.addorganization_id += u
  21996. } else {
  21997. m.addorganization_id = &u
  21998. }
  21999. }
  22000. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22001. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  22002. v := m.addorganization_id
  22003. if v == nil {
  22004. return
  22005. }
  22006. return *v, true
  22007. }
  22008. // ResetOrganizationID resets all changes to the "organization_id" field.
  22009. func (m *LabelTaggingMutation) ResetOrganizationID() {
  22010. m.organization_id = nil
  22011. m.addorganization_id = nil
  22012. }
  22013. // SetType sets the "type" field.
  22014. func (m *LabelTaggingMutation) SetType(i int) {
  22015. m._type = &i
  22016. m.add_type = nil
  22017. }
  22018. // GetType returns the value of the "type" field in the mutation.
  22019. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  22020. v := m._type
  22021. if v == nil {
  22022. return
  22023. }
  22024. return *v, true
  22025. }
  22026. // OldType returns the old "type" field's value of the LabelTagging entity.
  22027. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22029. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  22030. if !m.op.Is(OpUpdateOne) {
  22031. return v, errors.New("OldType is only allowed on UpdateOne operations")
  22032. }
  22033. if m.id == nil || m.oldValue == nil {
  22034. return v, errors.New("OldType requires an ID field in the mutation")
  22035. }
  22036. oldValue, err := m.oldValue(ctx)
  22037. if err != nil {
  22038. return v, fmt.Errorf("querying old value for OldType: %w", err)
  22039. }
  22040. return oldValue.Type, nil
  22041. }
  22042. // AddType adds i to the "type" field.
  22043. func (m *LabelTaggingMutation) AddType(i int) {
  22044. if m.add_type != nil {
  22045. *m.add_type += i
  22046. } else {
  22047. m.add_type = &i
  22048. }
  22049. }
  22050. // AddedType returns the value that was added to the "type" field in this mutation.
  22051. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  22052. v := m.add_type
  22053. if v == nil {
  22054. return
  22055. }
  22056. return *v, true
  22057. }
  22058. // ResetType resets all changes to the "type" field.
  22059. func (m *LabelTaggingMutation) ResetType() {
  22060. m._type = nil
  22061. m.add_type = nil
  22062. }
  22063. // SetConditions sets the "conditions" field.
  22064. func (m *LabelTaggingMutation) SetConditions(s string) {
  22065. m.conditions = &s
  22066. }
  22067. // Conditions returns the value of the "conditions" field in the mutation.
  22068. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  22069. v := m.conditions
  22070. if v == nil {
  22071. return
  22072. }
  22073. return *v, true
  22074. }
  22075. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  22076. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22078. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  22079. if !m.op.Is(OpUpdateOne) {
  22080. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  22081. }
  22082. if m.id == nil || m.oldValue == nil {
  22083. return v, errors.New("OldConditions requires an ID field in the mutation")
  22084. }
  22085. oldValue, err := m.oldValue(ctx)
  22086. if err != nil {
  22087. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  22088. }
  22089. return oldValue.Conditions, nil
  22090. }
  22091. // ResetConditions resets all changes to the "conditions" field.
  22092. func (m *LabelTaggingMutation) ResetConditions() {
  22093. m.conditions = nil
  22094. }
  22095. // SetActionLabelAdd sets the "action_label_add" field.
  22096. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  22097. m.action_label_add = &u
  22098. m.appendaction_label_add = nil
  22099. }
  22100. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22101. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22102. v := m.action_label_add
  22103. if v == nil {
  22104. return
  22105. }
  22106. return *v, true
  22107. }
  22108. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  22109. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22111. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22112. if !m.op.Is(OpUpdateOne) {
  22113. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22114. }
  22115. if m.id == nil || m.oldValue == nil {
  22116. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22117. }
  22118. oldValue, err := m.oldValue(ctx)
  22119. if err != nil {
  22120. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22121. }
  22122. return oldValue.ActionLabelAdd, nil
  22123. }
  22124. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22125. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  22126. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22127. }
  22128. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22129. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22130. if len(m.appendaction_label_add) == 0 {
  22131. return nil, false
  22132. }
  22133. return m.appendaction_label_add, true
  22134. }
  22135. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22136. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  22137. m.action_label_add = nil
  22138. m.appendaction_label_add = nil
  22139. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  22140. }
  22141. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22142. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  22143. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  22144. return ok
  22145. }
  22146. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22147. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  22148. m.action_label_add = nil
  22149. m.appendaction_label_add = nil
  22150. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  22151. }
  22152. // SetActionLabelDel sets the "action_label_del" field.
  22153. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  22154. m.action_label_del = &u
  22155. m.appendaction_label_del = nil
  22156. }
  22157. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22158. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  22159. v := m.action_label_del
  22160. if v == nil {
  22161. return
  22162. }
  22163. return *v, true
  22164. }
  22165. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  22166. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22168. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22169. if !m.op.Is(OpUpdateOne) {
  22170. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22171. }
  22172. if m.id == nil || m.oldValue == nil {
  22173. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22174. }
  22175. oldValue, err := m.oldValue(ctx)
  22176. if err != nil {
  22177. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22178. }
  22179. return oldValue.ActionLabelDel, nil
  22180. }
  22181. // AppendActionLabelDel adds u to the "action_label_del" field.
  22182. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  22183. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22184. }
  22185. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22186. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22187. if len(m.appendaction_label_del) == 0 {
  22188. return nil, false
  22189. }
  22190. return m.appendaction_label_del, true
  22191. }
  22192. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22193. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  22194. m.action_label_del = nil
  22195. m.appendaction_label_del = nil
  22196. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  22197. }
  22198. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22199. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  22200. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  22201. return ok
  22202. }
  22203. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22204. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  22205. m.action_label_del = nil
  22206. m.appendaction_label_del = nil
  22207. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  22208. }
  22209. // Where appends a list predicates to the LabelTaggingMutation builder.
  22210. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  22211. m.predicates = append(m.predicates, ps...)
  22212. }
  22213. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  22214. // users can use type-assertion to append predicates that do not depend on any generated package.
  22215. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  22216. p := make([]predicate.LabelTagging, len(ps))
  22217. for i := range ps {
  22218. p[i] = ps[i]
  22219. }
  22220. m.Where(p...)
  22221. }
  22222. // Op returns the operation name.
  22223. func (m *LabelTaggingMutation) Op() Op {
  22224. return m.op
  22225. }
  22226. // SetOp allows setting the mutation operation.
  22227. func (m *LabelTaggingMutation) SetOp(op Op) {
  22228. m.op = op
  22229. }
  22230. // Type returns the node type of this mutation (LabelTagging).
  22231. func (m *LabelTaggingMutation) Type() string {
  22232. return m.typ
  22233. }
  22234. // Fields returns all fields that were changed during this mutation. Note that in
  22235. // order to get all numeric fields that were incremented/decremented, call
  22236. // AddedFields().
  22237. func (m *LabelTaggingMutation) Fields() []string {
  22238. fields := make([]string, 0, 9)
  22239. if m.created_at != nil {
  22240. fields = append(fields, labeltagging.FieldCreatedAt)
  22241. }
  22242. if m.updated_at != nil {
  22243. fields = append(fields, labeltagging.FieldUpdatedAt)
  22244. }
  22245. if m.status != nil {
  22246. fields = append(fields, labeltagging.FieldStatus)
  22247. }
  22248. if m.deleted_at != nil {
  22249. fields = append(fields, labeltagging.FieldDeletedAt)
  22250. }
  22251. if m.organization_id != nil {
  22252. fields = append(fields, labeltagging.FieldOrganizationID)
  22253. }
  22254. if m._type != nil {
  22255. fields = append(fields, labeltagging.FieldType)
  22256. }
  22257. if m.conditions != nil {
  22258. fields = append(fields, labeltagging.FieldConditions)
  22259. }
  22260. if m.action_label_add != nil {
  22261. fields = append(fields, labeltagging.FieldActionLabelAdd)
  22262. }
  22263. if m.action_label_del != nil {
  22264. fields = append(fields, labeltagging.FieldActionLabelDel)
  22265. }
  22266. return fields
  22267. }
  22268. // Field returns the value of a field with the given name. The second boolean
  22269. // return value indicates that this field was not set, or was not defined in the
  22270. // schema.
  22271. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  22272. switch name {
  22273. case labeltagging.FieldCreatedAt:
  22274. return m.CreatedAt()
  22275. case labeltagging.FieldUpdatedAt:
  22276. return m.UpdatedAt()
  22277. case labeltagging.FieldStatus:
  22278. return m.Status()
  22279. case labeltagging.FieldDeletedAt:
  22280. return m.DeletedAt()
  22281. case labeltagging.FieldOrganizationID:
  22282. return m.OrganizationID()
  22283. case labeltagging.FieldType:
  22284. return m.GetType()
  22285. case labeltagging.FieldConditions:
  22286. return m.Conditions()
  22287. case labeltagging.FieldActionLabelAdd:
  22288. return m.ActionLabelAdd()
  22289. case labeltagging.FieldActionLabelDel:
  22290. return m.ActionLabelDel()
  22291. }
  22292. return nil, false
  22293. }
  22294. // OldField returns the old value of the field from the database. An error is
  22295. // returned if the mutation operation is not UpdateOne, or the query to the
  22296. // database failed.
  22297. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22298. switch name {
  22299. case labeltagging.FieldCreatedAt:
  22300. return m.OldCreatedAt(ctx)
  22301. case labeltagging.FieldUpdatedAt:
  22302. return m.OldUpdatedAt(ctx)
  22303. case labeltagging.FieldStatus:
  22304. return m.OldStatus(ctx)
  22305. case labeltagging.FieldDeletedAt:
  22306. return m.OldDeletedAt(ctx)
  22307. case labeltagging.FieldOrganizationID:
  22308. return m.OldOrganizationID(ctx)
  22309. case labeltagging.FieldType:
  22310. return m.OldType(ctx)
  22311. case labeltagging.FieldConditions:
  22312. return m.OldConditions(ctx)
  22313. case labeltagging.FieldActionLabelAdd:
  22314. return m.OldActionLabelAdd(ctx)
  22315. case labeltagging.FieldActionLabelDel:
  22316. return m.OldActionLabelDel(ctx)
  22317. }
  22318. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  22319. }
  22320. // SetField sets the value of a field with the given name. It returns an error if
  22321. // the field is not defined in the schema, or if the type mismatched the field
  22322. // type.
  22323. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  22324. switch name {
  22325. case labeltagging.FieldCreatedAt:
  22326. v, ok := value.(time.Time)
  22327. if !ok {
  22328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22329. }
  22330. m.SetCreatedAt(v)
  22331. return nil
  22332. case labeltagging.FieldUpdatedAt:
  22333. v, ok := value.(time.Time)
  22334. if !ok {
  22335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22336. }
  22337. m.SetUpdatedAt(v)
  22338. return nil
  22339. case labeltagging.FieldStatus:
  22340. v, ok := value.(uint8)
  22341. if !ok {
  22342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22343. }
  22344. m.SetStatus(v)
  22345. return nil
  22346. case labeltagging.FieldDeletedAt:
  22347. v, ok := value.(time.Time)
  22348. if !ok {
  22349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22350. }
  22351. m.SetDeletedAt(v)
  22352. return nil
  22353. case labeltagging.FieldOrganizationID:
  22354. v, ok := value.(uint64)
  22355. if !ok {
  22356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22357. }
  22358. m.SetOrganizationID(v)
  22359. return nil
  22360. case labeltagging.FieldType:
  22361. v, ok := value.(int)
  22362. if !ok {
  22363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22364. }
  22365. m.SetType(v)
  22366. return nil
  22367. case labeltagging.FieldConditions:
  22368. v, ok := value.(string)
  22369. if !ok {
  22370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22371. }
  22372. m.SetConditions(v)
  22373. return nil
  22374. case labeltagging.FieldActionLabelAdd:
  22375. v, ok := value.([]uint64)
  22376. if !ok {
  22377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22378. }
  22379. m.SetActionLabelAdd(v)
  22380. return nil
  22381. case labeltagging.FieldActionLabelDel:
  22382. v, ok := value.([]uint64)
  22383. if !ok {
  22384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22385. }
  22386. m.SetActionLabelDel(v)
  22387. return nil
  22388. }
  22389. return fmt.Errorf("unknown LabelTagging field %s", name)
  22390. }
  22391. // AddedFields returns all numeric fields that were incremented/decremented during
  22392. // this mutation.
  22393. func (m *LabelTaggingMutation) AddedFields() []string {
  22394. var fields []string
  22395. if m.addstatus != nil {
  22396. fields = append(fields, labeltagging.FieldStatus)
  22397. }
  22398. if m.addorganization_id != nil {
  22399. fields = append(fields, labeltagging.FieldOrganizationID)
  22400. }
  22401. if m.add_type != nil {
  22402. fields = append(fields, labeltagging.FieldType)
  22403. }
  22404. return fields
  22405. }
  22406. // AddedField returns the numeric value that was incremented/decremented on a field
  22407. // with the given name. The second boolean return value indicates that this field
  22408. // was not set, or was not defined in the schema.
  22409. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  22410. switch name {
  22411. case labeltagging.FieldStatus:
  22412. return m.AddedStatus()
  22413. case labeltagging.FieldOrganizationID:
  22414. return m.AddedOrganizationID()
  22415. case labeltagging.FieldType:
  22416. return m.AddedType()
  22417. }
  22418. return nil, false
  22419. }
  22420. // AddField adds the value to the field with the given name. It returns an error if
  22421. // the field is not defined in the schema, or if the type mismatched the field
  22422. // type.
  22423. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  22424. switch name {
  22425. case labeltagging.FieldStatus:
  22426. v, ok := value.(int8)
  22427. if !ok {
  22428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22429. }
  22430. m.AddStatus(v)
  22431. return nil
  22432. case labeltagging.FieldOrganizationID:
  22433. v, ok := value.(int64)
  22434. if !ok {
  22435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22436. }
  22437. m.AddOrganizationID(v)
  22438. return nil
  22439. case labeltagging.FieldType:
  22440. v, ok := value.(int)
  22441. if !ok {
  22442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22443. }
  22444. m.AddType(v)
  22445. return nil
  22446. }
  22447. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  22448. }
  22449. // ClearedFields returns all nullable fields that were cleared during this
  22450. // mutation.
  22451. func (m *LabelTaggingMutation) ClearedFields() []string {
  22452. var fields []string
  22453. if m.FieldCleared(labeltagging.FieldStatus) {
  22454. fields = append(fields, labeltagging.FieldStatus)
  22455. }
  22456. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  22457. fields = append(fields, labeltagging.FieldDeletedAt)
  22458. }
  22459. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  22460. fields = append(fields, labeltagging.FieldActionLabelAdd)
  22461. }
  22462. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  22463. fields = append(fields, labeltagging.FieldActionLabelDel)
  22464. }
  22465. return fields
  22466. }
  22467. // FieldCleared returns a boolean indicating if a field with the given name was
  22468. // cleared in this mutation.
  22469. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  22470. _, ok := m.clearedFields[name]
  22471. return ok
  22472. }
  22473. // ClearField clears the value of the field with the given name. It returns an
  22474. // error if the field is not defined in the schema.
  22475. func (m *LabelTaggingMutation) ClearField(name string) error {
  22476. switch name {
  22477. case labeltagging.FieldStatus:
  22478. m.ClearStatus()
  22479. return nil
  22480. case labeltagging.FieldDeletedAt:
  22481. m.ClearDeletedAt()
  22482. return nil
  22483. case labeltagging.FieldActionLabelAdd:
  22484. m.ClearActionLabelAdd()
  22485. return nil
  22486. case labeltagging.FieldActionLabelDel:
  22487. m.ClearActionLabelDel()
  22488. return nil
  22489. }
  22490. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  22491. }
  22492. // ResetField resets all changes in the mutation for the field with the given name.
  22493. // It returns an error if the field is not defined in the schema.
  22494. func (m *LabelTaggingMutation) ResetField(name string) error {
  22495. switch name {
  22496. case labeltagging.FieldCreatedAt:
  22497. m.ResetCreatedAt()
  22498. return nil
  22499. case labeltagging.FieldUpdatedAt:
  22500. m.ResetUpdatedAt()
  22501. return nil
  22502. case labeltagging.FieldStatus:
  22503. m.ResetStatus()
  22504. return nil
  22505. case labeltagging.FieldDeletedAt:
  22506. m.ResetDeletedAt()
  22507. return nil
  22508. case labeltagging.FieldOrganizationID:
  22509. m.ResetOrganizationID()
  22510. return nil
  22511. case labeltagging.FieldType:
  22512. m.ResetType()
  22513. return nil
  22514. case labeltagging.FieldConditions:
  22515. m.ResetConditions()
  22516. return nil
  22517. case labeltagging.FieldActionLabelAdd:
  22518. m.ResetActionLabelAdd()
  22519. return nil
  22520. case labeltagging.FieldActionLabelDel:
  22521. m.ResetActionLabelDel()
  22522. return nil
  22523. }
  22524. return fmt.Errorf("unknown LabelTagging field %s", name)
  22525. }
  22526. // AddedEdges returns all edge names that were set/added in this mutation.
  22527. func (m *LabelTaggingMutation) AddedEdges() []string {
  22528. edges := make([]string, 0, 0)
  22529. return edges
  22530. }
  22531. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22532. // name in this mutation.
  22533. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  22534. return nil
  22535. }
  22536. // RemovedEdges returns all edge names that were removed in this mutation.
  22537. func (m *LabelTaggingMutation) RemovedEdges() []string {
  22538. edges := make([]string, 0, 0)
  22539. return edges
  22540. }
  22541. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22542. // the given name in this mutation.
  22543. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  22544. return nil
  22545. }
  22546. // ClearedEdges returns all edge names that were cleared in this mutation.
  22547. func (m *LabelTaggingMutation) ClearedEdges() []string {
  22548. edges := make([]string, 0, 0)
  22549. return edges
  22550. }
  22551. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22552. // was cleared in this mutation.
  22553. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  22554. return false
  22555. }
  22556. // ClearEdge clears the value of the edge with the given name. It returns an error
  22557. // if that edge is not defined in the schema.
  22558. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  22559. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  22560. }
  22561. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22562. // It returns an error if the edge is not defined in the schema.
  22563. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  22564. return fmt.Errorf("unknown LabelTagging edge %s", name)
  22565. }
  22566. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  22567. type MessageMutation struct {
  22568. config
  22569. op Op
  22570. typ string
  22571. id *int
  22572. wx_wxid *string
  22573. wxid *string
  22574. content *string
  22575. clearedFields map[string]struct{}
  22576. done bool
  22577. oldValue func(context.Context) (*Message, error)
  22578. predicates []predicate.Message
  22579. }
  22580. var _ ent.Mutation = (*MessageMutation)(nil)
  22581. // messageOption allows management of the mutation configuration using functional options.
  22582. type messageOption func(*MessageMutation)
  22583. // newMessageMutation creates new mutation for the Message entity.
  22584. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  22585. m := &MessageMutation{
  22586. config: c,
  22587. op: op,
  22588. typ: TypeMessage,
  22589. clearedFields: make(map[string]struct{}),
  22590. }
  22591. for _, opt := range opts {
  22592. opt(m)
  22593. }
  22594. return m
  22595. }
  22596. // withMessageID sets the ID field of the mutation.
  22597. func withMessageID(id int) messageOption {
  22598. return func(m *MessageMutation) {
  22599. var (
  22600. err error
  22601. once sync.Once
  22602. value *Message
  22603. )
  22604. m.oldValue = func(ctx context.Context) (*Message, error) {
  22605. once.Do(func() {
  22606. if m.done {
  22607. err = errors.New("querying old values post mutation is not allowed")
  22608. } else {
  22609. value, err = m.Client().Message.Get(ctx, id)
  22610. }
  22611. })
  22612. return value, err
  22613. }
  22614. m.id = &id
  22615. }
  22616. }
  22617. // withMessage sets the old Message of the mutation.
  22618. func withMessage(node *Message) messageOption {
  22619. return func(m *MessageMutation) {
  22620. m.oldValue = func(context.Context) (*Message, error) {
  22621. return node, nil
  22622. }
  22623. m.id = &node.ID
  22624. }
  22625. }
  22626. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22627. // executed in a transaction (ent.Tx), a transactional client is returned.
  22628. func (m MessageMutation) Client() *Client {
  22629. client := &Client{config: m.config}
  22630. client.init()
  22631. return client
  22632. }
  22633. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22634. // it returns an error otherwise.
  22635. func (m MessageMutation) Tx() (*Tx, error) {
  22636. if _, ok := m.driver.(*txDriver); !ok {
  22637. return nil, errors.New("ent: mutation is not running in a transaction")
  22638. }
  22639. tx := &Tx{config: m.config}
  22640. tx.init()
  22641. return tx, nil
  22642. }
  22643. // ID returns the ID value in the mutation. Note that the ID is only available
  22644. // if it was provided to the builder or after it was returned from the database.
  22645. func (m *MessageMutation) ID() (id int, exists bool) {
  22646. if m.id == nil {
  22647. return
  22648. }
  22649. return *m.id, true
  22650. }
  22651. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22652. // That means, if the mutation is applied within a transaction with an isolation level such
  22653. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22654. // or updated by the mutation.
  22655. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  22656. switch {
  22657. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22658. id, exists := m.ID()
  22659. if exists {
  22660. return []int{id}, nil
  22661. }
  22662. fallthrough
  22663. case m.op.Is(OpUpdate | OpDelete):
  22664. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  22665. default:
  22666. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22667. }
  22668. }
  22669. // SetWxWxid sets the "wx_wxid" field.
  22670. func (m *MessageMutation) SetWxWxid(s string) {
  22671. m.wx_wxid = &s
  22672. }
  22673. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  22674. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  22675. v := m.wx_wxid
  22676. if v == nil {
  22677. return
  22678. }
  22679. return *v, true
  22680. }
  22681. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  22682. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  22683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22684. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  22685. if !m.op.Is(OpUpdateOne) {
  22686. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  22687. }
  22688. if m.id == nil || m.oldValue == nil {
  22689. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  22690. }
  22691. oldValue, err := m.oldValue(ctx)
  22692. if err != nil {
  22693. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  22694. }
  22695. return oldValue.WxWxid, nil
  22696. }
  22697. // ClearWxWxid clears the value of the "wx_wxid" field.
  22698. func (m *MessageMutation) ClearWxWxid() {
  22699. m.wx_wxid = nil
  22700. m.clearedFields[message.FieldWxWxid] = struct{}{}
  22701. }
  22702. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  22703. func (m *MessageMutation) WxWxidCleared() bool {
  22704. _, ok := m.clearedFields[message.FieldWxWxid]
  22705. return ok
  22706. }
  22707. // ResetWxWxid resets all changes to the "wx_wxid" field.
  22708. func (m *MessageMutation) ResetWxWxid() {
  22709. m.wx_wxid = nil
  22710. delete(m.clearedFields, message.FieldWxWxid)
  22711. }
  22712. // SetWxid sets the "wxid" field.
  22713. func (m *MessageMutation) SetWxid(s string) {
  22714. m.wxid = &s
  22715. }
  22716. // Wxid returns the value of the "wxid" field in the mutation.
  22717. func (m *MessageMutation) Wxid() (r string, exists bool) {
  22718. v := m.wxid
  22719. if v == nil {
  22720. return
  22721. }
  22722. return *v, true
  22723. }
  22724. // OldWxid returns the old "wxid" field's value of the Message entity.
  22725. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  22726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22727. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  22728. if !m.op.Is(OpUpdateOne) {
  22729. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  22730. }
  22731. if m.id == nil || m.oldValue == nil {
  22732. return v, errors.New("OldWxid requires an ID field in the mutation")
  22733. }
  22734. oldValue, err := m.oldValue(ctx)
  22735. if err != nil {
  22736. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  22737. }
  22738. return oldValue.Wxid, nil
  22739. }
  22740. // ResetWxid resets all changes to the "wxid" field.
  22741. func (m *MessageMutation) ResetWxid() {
  22742. m.wxid = nil
  22743. }
  22744. // SetContent sets the "content" field.
  22745. func (m *MessageMutation) SetContent(s string) {
  22746. m.content = &s
  22747. }
  22748. // Content returns the value of the "content" field in the mutation.
  22749. func (m *MessageMutation) Content() (r string, exists bool) {
  22750. v := m.content
  22751. if v == nil {
  22752. return
  22753. }
  22754. return *v, true
  22755. }
  22756. // OldContent returns the old "content" field's value of the Message entity.
  22757. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  22758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22759. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  22760. if !m.op.Is(OpUpdateOne) {
  22761. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  22762. }
  22763. if m.id == nil || m.oldValue == nil {
  22764. return v, errors.New("OldContent requires an ID field in the mutation")
  22765. }
  22766. oldValue, err := m.oldValue(ctx)
  22767. if err != nil {
  22768. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  22769. }
  22770. return oldValue.Content, nil
  22771. }
  22772. // ResetContent resets all changes to the "content" field.
  22773. func (m *MessageMutation) ResetContent() {
  22774. m.content = nil
  22775. }
  22776. // Where appends a list predicates to the MessageMutation builder.
  22777. func (m *MessageMutation) Where(ps ...predicate.Message) {
  22778. m.predicates = append(m.predicates, ps...)
  22779. }
  22780. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  22781. // users can use type-assertion to append predicates that do not depend on any generated package.
  22782. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  22783. p := make([]predicate.Message, len(ps))
  22784. for i := range ps {
  22785. p[i] = ps[i]
  22786. }
  22787. m.Where(p...)
  22788. }
  22789. // Op returns the operation name.
  22790. func (m *MessageMutation) Op() Op {
  22791. return m.op
  22792. }
  22793. // SetOp allows setting the mutation operation.
  22794. func (m *MessageMutation) SetOp(op Op) {
  22795. m.op = op
  22796. }
  22797. // Type returns the node type of this mutation (Message).
  22798. func (m *MessageMutation) Type() string {
  22799. return m.typ
  22800. }
  22801. // Fields returns all fields that were changed during this mutation. Note that in
  22802. // order to get all numeric fields that were incremented/decremented, call
  22803. // AddedFields().
  22804. func (m *MessageMutation) Fields() []string {
  22805. fields := make([]string, 0, 3)
  22806. if m.wx_wxid != nil {
  22807. fields = append(fields, message.FieldWxWxid)
  22808. }
  22809. if m.wxid != nil {
  22810. fields = append(fields, message.FieldWxid)
  22811. }
  22812. if m.content != nil {
  22813. fields = append(fields, message.FieldContent)
  22814. }
  22815. return fields
  22816. }
  22817. // Field returns the value of a field with the given name. The second boolean
  22818. // return value indicates that this field was not set, or was not defined in the
  22819. // schema.
  22820. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  22821. switch name {
  22822. case message.FieldWxWxid:
  22823. return m.WxWxid()
  22824. case message.FieldWxid:
  22825. return m.Wxid()
  22826. case message.FieldContent:
  22827. return m.Content()
  22828. }
  22829. return nil, false
  22830. }
  22831. // OldField returns the old value of the field from the database. An error is
  22832. // returned if the mutation operation is not UpdateOne, or the query to the
  22833. // database failed.
  22834. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22835. switch name {
  22836. case message.FieldWxWxid:
  22837. return m.OldWxWxid(ctx)
  22838. case message.FieldWxid:
  22839. return m.OldWxid(ctx)
  22840. case message.FieldContent:
  22841. return m.OldContent(ctx)
  22842. }
  22843. return nil, fmt.Errorf("unknown Message field %s", name)
  22844. }
  22845. // SetField sets the value of a field with the given name. It returns an error if
  22846. // the field is not defined in the schema, or if the type mismatched the field
  22847. // type.
  22848. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  22849. switch name {
  22850. case message.FieldWxWxid:
  22851. v, ok := value.(string)
  22852. if !ok {
  22853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22854. }
  22855. m.SetWxWxid(v)
  22856. return nil
  22857. case message.FieldWxid:
  22858. v, ok := value.(string)
  22859. if !ok {
  22860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22861. }
  22862. m.SetWxid(v)
  22863. return nil
  22864. case message.FieldContent:
  22865. v, ok := value.(string)
  22866. if !ok {
  22867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22868. }
  22869. m.SetContent(v)
  22870. return nil
  22871. }
  22872. return fmt.Errorf("unknown Message field %s", name)
  22873. }
  22874. // AddedFields returns all numeric fields that were incremented/decremented during
  22875. // this mutation.
  22876. func (m *MessageMutation) AddedFields() []string {
  22877. return nil
  22878. }
  22879. // AddedField returns the numeric value that was incremented/decremented on a field
  22880. // with the given name. The second boolean return value indicates that this field
  22881. // was not set, or was not defined in the schema.
  22882. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  22883. return nil, false
  22884. }
  22885. // AddField adds the value to the field with the given name. It returns an error if
  22886. // the field is not defined in the schema, or if the type mismatched the field
  22887. // type.
  22888. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  22889. switch name {
  22890. }
  22891. return fmt.Errorf("unknown Message numeric field %s", name)
  22892. }
  22893. // ClearedFields returns all nullable fields that were cleared during this
  22894. // mutation.
  22895. func (m *MessageMutation) ClearedFields() []string {
  22896. var fields []string
  22897. if m.FieldCleared(message.FieldWxWxid) {
  22898. fields = append(fields, message.FieldWxWxid)
  22899. }
  22900. return fields
  22901. }
  22902. // FieldCleared returns a boolean indicating if a field with the given name was
  22903. // cleared in this mutation.
  22904. func (m *MessageMutation) FieldCleared(name string) bool {
  22905. _, ok := m.clearedFields[name]
  22906. return ok
  22907. }
  22908. // ClearField clears the value of the field with the given name. It returns an
  22909. // error if the field is not defined in the schema.
  22910. func (m *MessageMutation) ClearField(name string) error {
  22911. switch name {
  22912. case message.FieldWxWxid:
  22913. m.ClearWxWxid()
  22914. return nil
  22915. }
  22916. return fmt.Errorf("unknown Message nullable field %s", name)
  22917. }
  22918. // ResetField resets all changes in the mutation for the field with the given name.
  22919. // It returns an error if the field is not defined in the schema.
  22920. func (m *MessageMutation) ResetField(name string) error {
  22921. switch name {
  22922. case message.FieldWxWxid:
  22923. m.ResetWxWxid()
  22924. return nil
  22925. case message.FieldWxid:
  22926. m.ResetWxid()
  22927. return nil
  22928. case message.FieldContent:
  22929. m.ResetContent()
  22930. return nil
  22931. }
  22932. return fmt.Errorf("unknown Message field %s", name)
  22933. }
  22934. // AddedEdges returns all edge names that were set/added in this mutation.
  22935. func (m *MessageMutation) AddedEdges() []string {
  22936. edges := make([]string, 0, 0)
  22937. return edges
  22938. }
  22939. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22940. // name in this mutation.
  22941. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  22942. return nil
  22943. }
  22944. // RemovedEdges returns all edge names that were removed in this mutation.
  22945. func (m *MessageMutation) RemovedEdges() []string {
  22946. edges := make([]string, 0, 0)
  22947. return edges
  22948. }
  22949. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22950. // the given name in this mutation.
  22951. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  22952. return nil
  22953. }
  22954. // ClearedEdges returns all edge names that were cleared in this mutation.
  22955. func (m *MessageMutation) ClearedEdges() []string {
  22956. edges := make([]string, 0, 0)
  22957. return edges
  22958. }
  22959. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22960. // was cleared in this mutation.
  22961. func (m *MessageMutation) EdgeCleared(name string) bool {
  22962. return false
  22963. }
  22964. // ClearEdge clears the value of the edge with the given name. It returns an error
  22965. // if that edge is not defined in the schema.
  22966. func (m *MessageMutation) ClearEdge(name string) error {
  22967. return fmt.Errorf("unknown Message unique edge %s", name)
  22968. }
  22969. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22970. // It returns an error if the edge is not defined in the schema.
  22971. func (m *MessageMutation) ResetEdge(name string) error {
  22972. return fmt.Errorf("unknown Message edge %s", name)
  22973. }
  22974. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  22975. type MessageRecordsMutation struct {
  22976. config
  22977. op Op
  22978. typ string
  22979. id *uint64
  22980. created_at *time.Time
  22981. updated_at *time.Time
  22982. status *uint8
  22983. addstatus *int8
  22984. bot_wxid *string
  22985. contact_type *int
  22986. addcontact_type *int
  22987. contact_wxid *string
  22988. content_type *int
  22989. addcontent_type *int
  22990. content *string
  22991. meta *custom_types.Meta
  22992. error_detail *string
  22993. send_time *time.Time
  22994. source_type *int
  22995. addsource_type *int
  22996. organization_id *uint64
  22997. addorganization_id *int64
  22998. clearedFields map[string]struct{}
  22999. sop_stage *uint64
  23000. clearedsop_stage bool
  23001. sop_node *uint64
  23002. clearedsop_node bool
  23003. message_contact *uint64
  23004. clearedmessage_contact bool
  23005. done bool
  23006. oldValue func(context.Context) (*MessageRecords, error)
  23007. predicates []predicate.MessageRecords
  23008. }
  23009. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  23010. // messagerecordsOption allows management of the mutation configuration using functional options.
  23011. type messagerecordsOption func(*MessageRecordsMutation)
  23012. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  23013. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  23014. m := &MessageRecordsMutation{
  23015. config: c,
  23016. op: op,
  23017. typ: TypeMessageRecords,
  23018. clearedFields: make(map[string]struct{}),
  23019. }
  23020. for _, opt := range opts {
  23021. opt(m)
  23022. }
  23023. return m
  23024. }
  23025. // withMessageRecordsID sets the ID field of the mutation.
  23026. func withMessageRecordsID(id uint64) messagerecordsOption {
  23027. return func(m *MessageRecordsMutation) {
  23028. var (
  23029. err error
  23030. once sync.Once
  23031. value *MessageRecords
  23032. )
  23033. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  23034. once.Do(func() {
  23035. if m.done {
  23036. err = errors.New("querying old values post mutation is not allowed")
  23037. } else {
  23038. value, err = m.Client().MessageRecords.Get(ctx, id)
  23039. }
  23040. })
  23041. return value, err
  23042. }
  23043. m.id = &id
  23044. }
  23045. }
  23046. // withMessageRecords sets the old MessageRecords of the mutation.
  23047. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  23048. return func(m *MessageRecordsMutation) {
  23049. m.oldValue = func(context.Context) (*MessageRecords, error) {
  23050. return node, nil
  23051. }
  23052. m.id = &node.ID
  23053. }
  23054. }
  23055. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23056. // executed in a transaction (ent.Tx), a transactional client is returned.
  23057. func (m MessageRecordsMutation) Client() *Client {
  23058. client := &Client{config: m.config}
  23059. client.init()
  23060. return client
  23061. }
  23062. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23063. // it returns an error otherwise.
  23064. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  23065. if _, ok := m.driver.(*txDriver); !ok {
  23066. return nil, errors.New("ent: mutation is not running in a transaction")
  23067. }
  23068. tx := &Tx{config: m.config}
  23069. tx.init()
  23070. return tx, nil
  23071. }
  23072. // SetID sets the value of the id field. Note that this
  23073. // operation is only accepted on creation of MessageRecords entities.
  23074. func (m *MessageRecordsMutation) SetID(id uint64) {
  23075. m.id = &id
  23076. }
  23077. // ID returns the ID value in the mutation. Note that the ID is only available
  23078. // if it was provided to the builder or after it was returned from the database.
  23079. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  23080. if m.id == nil {
  23081. return
  23082. }
  23083. return *m.id, true
  23084. }
  23085. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23086. // That means, if the mutation is applied within a transaction with an isolation level such
  23087. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23088. // or updated by the mutation.
  23089. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  23090. switch {
  23091. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23092. id, exists := m.ID()
  23093. if exists {
  23094. return []uint64{id}, nil
  23095. }
  23096. fallthrough
  23097. case m.op.Is(OpUpdate | OpDelete):
  23098. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  23099. default:
  23100. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23101. }
  23102. }
  23103. // SetCreatedAt sets the "created_at" field.
  23104. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  23105. m.created_at = &t
  23106. }
  23107. // CreatedAt returns the value of the "created_at" field in the mutation.
  23108. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  23109. v := m.created_at
  23110. if v == nil {
  23111. return
  23112. }
  23113. return *v, true
  23114. }
  23115. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  23116. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23118. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23119. if !m.op.Is(OpUpdateOne) {
  23120. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23121. }
  23122. if m.id == nil || m.oldValue == nil {
  23123. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23124. }
  23125. oldValue, err := m.oldValue(ctx)
  23126. if err != nil {
  23127. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23128. }
  23129. return oldValue.CreatedAt, nil
  23130. }
  23131. // ResetCreatedAt resets all changes to the "created_at" field.
  23132. func (m *MessageRecordsMutation) ResetCreatedAt() {
  23133. m.created_at = nil
  23134. }
  23135. // SetUpdatedAt sets the "updated_at" field.
  23136. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  23137. m.updated_at = &t
  23138. }
  23139. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23140. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  23141. v := m.updated_at
  23142. if v == nil {
  23143. return
  23144. }
  23145. return *v, true
  23146. }
  23147. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  23148. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23150. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23151. if !m.op.Is(OpUpdateOne) {
  23152. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23153. }
  23154. if m.id == nil || m.oldValue == nil {
  23155. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23156. }
  23157. oldValue, err := m.oldValue(ctx)
  23158. if err != nil {
  23159. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23160. }
  23161. return oldValue.UpdatedAt, nil
  23162. }
  23163. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23164. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  23165. m.updated_at = nil
  23166. }
  23167. // SetStatus sets the "status" field.
  23168. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  23169. m.status = &u
  23170. m.addstatus = nil
  23171. }
  23172. // Status returns the value of the "status" field in the mutation.
  23173. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  23174. v := m.status
  23175. if v == nil {
  23176. return
  23177. }
  23178. return *v, true
  23179. }
  23180. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  23181. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23183. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23184. if !m.op.Is(OpUpdateOne) {
  23185. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23186. }
  23187. if m.id == nil || m.oldValue == nil {
  23188. return v, errors.New("OldStatus requires an ID field in the mutation")
  23189. }
  23190. oldValue, err := m.oldValue(ctx)
  23191. if err != nil {
  23192. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23193. }
  23194. return oldValue.Status, nil
  23195. }
  23196. // AddStatus adds u to the "status" field.
  23197. func (m *MessageRecordsMutation) AddStatus(u int8) {
  23198. if m.addstatus != nil {
  23199. *m.addstatus += u
  23200. } else {
  23201. m.addstatus = &u
  23202. }
  23203. }
  23204. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23205. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  23206. v := m.addstatus
  23207. if v == nil {
  23208. return
  23209. }
  23210. return *v, true
  23211. }
  23212. // ClearStatus clears the value of the "status" field.
  23213. func (m *MessageRecordsMutation) ClearStatus() {
  23214. m.status = nil
  23215. m.addstatus = nil
  23216. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  23217. }
  23218. // StatusCleared returns if the "status" field was cleared in this mutation.
  23219. func (m *MessageRecordsMutation) StatusCleared() bool {
  23220. _, ok := m.clearedFields[messagerecords.FieldStatus]
  23221. return ok
  23222. }
  23223. // ResetStatus resets all changes to the "status" field.
  23224. func (m *MessageRecordsMutation) ResetStatus() {
  23225. m.status = nil
  23226. m.addstatus = nil
  23227. delete(m.clearedFields, messagerecords.FieldStatus)
  23228. }
  23229. // SetBotWxid sets the "bot_wxid" field.
  23230. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  23231. m.bot_wxid = &s
  23232. }
  23233. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  23234. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  23235. v := m.bot_wxid
  23236. if v == nil {
  23237. return
  23238. }
  23239. return *v, true
  23240. }
  23241. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  23242. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23244. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  23245. if !m.op.Is(OpUpdateOne) {
  23246. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  23247. }
  23248. if m.id == nil || m.oldValue == nil {
  23249. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  23250. }
  23251. oldValue, err := m.oldValue(ctx)
  23252. if err != nil {
  23253. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  23254. }
  23255. return oldValue.BotWxid, nil
  23256. }
  23257. // ResetBotWxid resets all changes to the "bot_wxid" field.
  23258. func (m *MessageRecordsMutation) ResetBotWxid() {
  23259. m.bot_wxid = nil
  23260. }
  23261. // SetContactID sets the "contact_id" field.
  23262. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  23263. m.message_contact = &u
  23264. }
  23265. // ContactID returns the value of the "contact_id" field in the mutation.
  23266. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  23267. v := m.message_contact
  23268. if v == nil {
  23269. return
  23270. }
  23271. return *v, true
  23272. }
  23273. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  23274. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23276. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  23277. if !m.op.Is(OpUpdateOne) {
  23278. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  23279. }
  23280. if m.id == nil || m.oldValue == nil {
  23281. return v, errors.New("OldContactID requires an ID field in the mutation")
  23282. }
  23283. oldValue, err := m.oldValue(ctx)
  23284. if err != nil {
  23285. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  23286. }
  23287. return oldValue.ContactID, nil
  23288. }
  23289. // ClearContactID clears the value of the "contact_id" field.
  23290. func (m *MessageRecordsMutation) ClearContactID() {
  23291. m.message_contact = nil
  23292. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  23293. }
  23294. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  23295. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  23296. _, ok := m.clearedFields[messagerecords.FieldContactID]
  23297. return ok
  23298. }
  23299. // ResetContactID resets all changes to the "contact_id" field.
  23300. func (m *MessageRecordsMutation) ResetContactID() {
  23301. m.message_contact = nil
  23302. delete(m.clearedFields, messagerecords.FieldContactID)
  23303. }
  23304. // SetContactType sets the "contact_type" field.
  23305. func (m *MessageRecordsMutation) SetContactType(i int) {
  23306. m.contact_type = &i
  23307. m.addcontact_type = nil
  23308. }
  23309. // ContactType returns the value of the "contact_type" field in the mutation.
  23310. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  23311. v := m.contact_type
  23312. if v == nil {
  23313. return
  23314. }
  23315. return *v, true
  23316. }
  23317. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  23318. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23320. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  23321. if !m.op.Is(OpUpdateOne) {
  23322. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  23323. }
  23324. if m.id == nil || m.oldValue == nil {
  23325. return v, errors.New("OldContactType requires an ID field in the mutation")
  23326. }
  23327. oldValue, err := m.oldValue(ctx)
  23328. if err != nil {
  23329. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  23330. }
  23331. return oldValue.ContactType, nil
  23332. }
  23333. // AddContactType adds i to the "contact_type" field.
  23334. func (m *MessageRecordsMutation) AddContactType(i int) {
  23335. if m.addcontact_type != nil {
  23336. *m.addcontact_type += i
  23337. } else {
  23338. m.addcontact_type = &i
  23339. }
  23340. }
  23341. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  23342. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  23343. v := m.addcontact_type
  23344. if v == nil {
  23345. return
  23346. }
  23347. return *v, true
  23348. }
  23349. // ResetContactType resets all changes to the "contact_type" field.
  23350. func (m *MessageRecordsMutation) ResetContactType() {
  23351. m.contact_type = nil
  23352. m.addcontact_type = nil
  23353. }
  23354. // SetContactWxid sets the "contact_wxid" field.
  23355. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  23356. m.contact_wxid = &s
  23357. }
  23358. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  23359. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  23360. v := m.contact_wxid
  23361. if v == nil {
  23362. return
  23363. }
  23364. return *v, true
  23365. }
  23366. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  23367. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23369. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  23370. if !m.op.Is(OpUpdateOne) {
  23371. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  23372. }
  23373. if m.id == nil || m.oldValue == nil {
  23374. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  23375. }
  23376. oldValue, err := m.oldValue(ctx)
  23377. if err != nil {
  23378. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  23379. }
  23380. return oldValue.ContactWxid, nil
  23381. }
  23382. // ResetContactWxid resets all changes to the "contact_wxid" field.
  23383. func (m *MessageRecordsMutation) ResetContactWxid() {
  23384. m.contact_wxid = nil
  23385. }
  23386. // SetContentType sets the "content_type" field.
  23387. func (m *MessageRecordsMutation) SetContentType(i int) {
  23388. m.content_type = &i
  23389. m.addcontent_type = nil
  23390. }
  23391. // ContentType returns the value of the "content_type" field in the mutation.
  23392. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  23393. v := m.content_type
  23394. if v == nil {
  23395. return
  23396. }
  23397. return *v, true
  23398. }
  23399. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  23400. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23402. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  23403. if !m.op.Is(OpUpdateOne) {
  23404. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  23405. }
  23406. if m.id == nil || m.oldValue == nil {
  23407. return v, errors.New("OldContentType requires an ID field in the mutation")
  23408. }
  23409. oldValue, err := m.oldValue(ctx)
  23410. if err != nil {
  23411. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  23412. }
  23413. return oldValue.ContentType, nil
  23414. }
  23415. // AddContentType adds i to the "content_type" field.
  23416. func (m *MessageRecordsMutation) AddContentType(i int) {
  23417. if m.addcontent_type != nil {
  23418. *m.addcontent_type += i
  23419. } else {
  23420. m.addcontent_type = &i
  23421. }
  23422. }
  23423. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  23424. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  23425. v := m.addcontent_type
  23426. if v == nil {
  23427. return
  23428. }
  23429. return *v, true
  23430. }
  23431. // ResetContentType resets all changes to the "content_type" field.
  23432. func (m *MessageRecordsMutation) ResetContentType() {
  23433. m.content_type = nil
  23434. m.addcontent_type = nil
  23435. }
  23436. // SetContent sets the "content" field.
  23437. func (m *MessageRecordsMutation) SetContent(s string) {
  23438. m.content = &s
  23439. }
  23440. // Content returns the value of the "content" field in the mutation.
  23441. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  23442. v := m.content
  23443. if v == nil {
  23444. return
  23445. }
  23446. return *v, true
  23447. }
  23448. // OldContent returns the old "content" field's value of the MessageRecords entity.
  23449. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23451. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  23452. if !m.op.Is(OpUpdateOne) {
  23453. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  23454. }
  23455. if m.id == nil || m.oldValue == nil {
  23456. return v, errors.New("OldContent requires an ID field in the mutation")
  23457. }
  23458. oldValue, err := m.oldValue(ctx)
  23459. if err != nil {
  23460. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  23461. }
  23462. return oldValue.Content, nil
  23463. }
  23464. // ResetContent resets all changes to the "content" field.
  23465. func (m *MessageRecordsMutation) ResetContent() {
  23466. m.content = nil
  23467. }
  23468. // SetMeta sets the "meta" field.
  23469. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  23470. m.meta = &ct
  23471. }
  23472. // Meta returns the value of the "meta" field in the mutation.
  23473. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  23474. v := m.meta
  23475. if v == nil {
  23476. return
  23477. }
  23478. return *v, true
  23479. }
  23480. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  23481. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23483. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  23484. if !m.op.Is(OpUpdateOne) {
  23485. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  23486. }
  23487. if m.id == nil || m.oldValue == nil {
  23488. return v, errors.New("OldMeta requires an ID field in the mutation")
  23489. }
  23490. oldValue, err := m.oldValue(ctx)
  23491. if err != nil {
  23492. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  23493. }
  23494. return oldValue.Meta, nil
  23495. }
  23496. // ClearMeta clears the value of the "meta" field.
  23497. func (m *MessageRecordsMutation) ClearMeta() {
  23498. m.meta = nil
  23499. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  23500. }
  23501. // MetaCleared returns if the "meta" field was cleared in this mutation.
  23502. func (m *MessageRecordsMutation) MetaCleared() bool {
  23503. _, ok := m.clearedFields[messagerecords.FieldMeta]
  23504. return ok
  23505. }
  23506. // ResetMeta resets all changes to the "meta" field.
  23507. func (m *MessageRecordsMutation) ResetMeta() {
  23508. m.meta = nil
  23509. delete(m.clearedFields, messagerecords.FieldMeta)
  23510. }
  23511. // SetErrorDetail sets the "error_detail" field.
  23512. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  23513. m.error_detail = &s
  23514. }
  23515. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  23516. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  23517. v := m.error_detail
  23518. if v == nil {
  23519. return
  23520. }
  23521. return *v, true
  23522. }
  23523. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  23524. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23526. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  23527. if !m.op.Is(OpUpdateOne) {
  23528. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  23529. }
  23530. if m.id == nil || m.oldValue == nil {
  23531. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  23532. }
  23533. oldValue, err := m.oldValue(ctx)
  23534. if err != nil {
  23535. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  23536. }
  23537. return oldValue.ErrorDetail, nil
  23538. }
  23539. // ResetErrorDetail resets all changes to the "error_detail" field.
  23540. func (m *MessageRecordsMutation) ResetErrorDetail() {
  23541. m.error_detail = nil
  23542. }
  23543. // SetSendTime sets the "send_time" field.
  23544. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  23545. m.send_time = &t
  23546. }
  23547. // SendTime returns the value of the "send_time" field in the mutation.
  23548. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  23549. v := m.send_time
  23550. if v == nil {
  23551. return
  23552. }
  23553. return *v, true
  23554. }
  23555. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  23556. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23558. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  23559. if !m.op.Is(OpUpdateOne) {
  23560. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  23561. }
  23562. if m.id == nil || m.oldValue == nil {
  23563. return v, errors.New("OldSendTime requires an ID field in the mutation")
  23564. }
  23565. oldValue, err := m.oldValue(ctx)
  23566. if err != nil {
  23567. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  23568. }
  23569. return oldValue.SendTime, nil
  23570. }
  23571. // ClearSendTime clears the value of the "send_time" field.
  23572. func (m *MessageRecordsMutation) ClearSendTime() {
  23573. m.send_time = nil
  23574. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  23575. }
  23576. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  23577. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  23578. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  23579. return ok
  23580. }
  23581. // ResetSendTime resets all changes to the "send_time" field.
  23582. func (m *MessageRecordsMutation) ResetSendTime() {
  23583. m.send_time = nil
  23584. delete(m.clearedFields, messagerecords.FieldSendTime)
  23585. }
  23586. // SetSourceType sets the "source_type" field.
  23587. func (m *MessageRecordsMutation) SetSourceType(i int) {
  23588. m.source_type = &i
  23589. m.addsource_type = nil
  23590. }
  23591. // SourceType returns the value of the "source_type" field in the mutation.
  23592. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  23593. v := m.source_type
  23594. if v == nil {
  23595. return
  23596. }
  23597. return *v, true
  23598. }
  23599. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  23600. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23602. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  23603. if !m.op.Is(OpUpdateOne) {
  23604. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  23605. }
  23606. if m.id == nil || m.oldValue == nil {
  23607. return v, errors.New("OldSourceType requires an ID field in the mutation")
  23608. }
  23609. oldValue, err := m.oldValue(ctx)
  23610. if err != nil {
  23611. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  23612. }
  23613. return oldValue.SourceType, nil
  23614. }
  23615. // AddSourceType adds i to the "source_type" field.
  23616. func (m *MessageRecordsMutation) AddSourceType(i int) {
  23617. if m.addsource_type != nil {
  23618. *m.addsource_type += i
  23619. } else {
  23620. m.addsource_type = &i
  23621. }
  23622. }
  23623. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  23624. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  23625. v := m.addsource_type
  23626. if v == nil {
  23627. return
  23628. }
  23629. return *v, true
  23630. }
  23631. // ResetSourceType resets all changes to the "source_type" field.
  23632. func (m *MessageRecordsMutation) ResetSourceType() {
  23633. m.source_type = nil
  23634. m.addsource_type = nil
  23635. }
  23636. // SetSourceID sets the "source_id" field.
  23637. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  23638. m.sop_stage = &u
  23639. }
  23640. // SourceID returns the value of the "source_id" field in the mutation.
  23641. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  23642. v := m.sop_stage
  23643. if v == nil {
  23644. return
  23645. }
  23646. return *v, true
  23647. }
  23648. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  23649. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23651. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  23652. if !m.op.Is(OpUpdateOne) {
  23653. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  23654. }
  23655. if m.id == nil || m.oldValue == nil {
  23656. return v, errors.New("OldSourceID requires an ID field in the mutation")
  23657. }
  23658. oldValue, err := m.oldValue(ctx)
  23659. if err != nil {
  23660. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  23661. }
  23662. return oldValue.SourceID, nil
  23663. }
  23664. // ClearSourceID clears the value of the "source_id" field.
  23665. func (m *MessageRecordsMutation) ClearSourceID() {
  23666. m.sop_stage = nil
  23667. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  23668. }
  23669. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  23670. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  23671. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  23672. return ok
  23673. }
  23674. // ResetSourceID resets all changes to the "source_id" field.
  23675. func (m *MessageRecordsMutation) ResetSourceID() {
  23676. m.sop_stage = nil
  23677. delete(m.clearedFields, messagerecords.FieldSourceID)
  23678. }
  23679. // SetSubSourceID sets the "sub_source_id" field.
  23680. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  23681. m.sop_node = &u
  23682. }
  23683. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  23684. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  23685. v := m.sop_node
  23686. if v == nil {
  23687. return
  23688. }
  23689. return *v, true
  23690. }
  23691. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  23692. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23694. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  23695. if !m.op.Is(OpUpdateOne) {
  23696. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  23697. }
  23698. if m.id == nil || m.oldValue == nil {
  23699. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  23700. }
  23701. oldValue, err := m.oldValue(ctx)
  23702. if err != nil {
  23703. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  23704. }
  23705. return oldValue.SubSourceID, nil
  23706. }
  23707. // ClearSubSourceID clears the value of the "sub_source_id" field.
  23708. func (m *MessageRecordsMutation) ClearSubSourceID() {
  23709. m.sop_node = nil
  23710. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  23711. }
  23712. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  23713. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  23714. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  23715. return ok
  23716. }
  23717. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  23718. func (m *MessageRecordsMutation) ResetSubSourceID() {
  23719. m.sop_node = nil
  23720. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  23721. }
  23722. // SetOrganizationID sets the "organization_id" field.
  23723. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  23724. m.organization_id = &u
  23725. m.addorganization_id = nil
  23726. }
  23727. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23728. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  23729. v := m.organization_id
  23730. if v == nil {
  23731. return
  23732. }
  23733. return *v, true
  23734. }
  23735. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  23736. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23738. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23739. if !m.op.Is(OpUpdateOne) {
  23740. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23741. }
  23742. if m.id == nil || m.oldValue == nil {
  23743. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23744. }
  23745. oldValue, err := m.oldValue(ctx)
  23746. if err != nil {
  23747. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23748. }
  23749. return oldValue.OrganizationID, nil
  23750. }
  23751. // AddOrganizationID adds u to the "organization_id" field.
  23752. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  23753. if m.addorganization_id != nil {
  23754. *m.addorganization_id += u
  23755. } else {
  23756. m.addorganization_id = &u
  23757. }
  23758. }
  23759. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23760. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  23761. v := m.addorganization_id
  23762. if v == nil {
  23763. return
  23764. }
  23765. return *v, true
  23766. }
  23767. // ClearOrganizationID clears the value of the "organization_id" field.
  23768. func (m *MessageRecordsMutation) ClearOrganizationID() {
  23769. m.organization_id = nil
  23770. m.addorganization_id = nil
  23771. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  23772. }
  23773. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23774. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  23775. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  23776. return ok
  23777. }
  23778. // ResetOrganizationID resets all changes to the "organization_id" field.
  23779. func (m *MessageRecordsMutation) ResetOrganizationID() {
  23780. m.organization_id = nil
  23781. m.addorganization_id = nil
  23782. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  23783. }
  23784. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  23785. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  23786. m.sop_stage = &id
  23787. }
  23788. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  23789. func (m *MessageRecordsMutation) ClearSopStage() {
  23790. m.clearedsop_stage = true
  23791. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  23792. }
  23793. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  23794. func (m *MessageRecordsMutation) SopStageCleared() bool {
  23795. return m.SourceIDCleared() || m.clearedsop_stage
  23796. }
  23797. // SopStageID returns the "sop_stage" edge ID in the mutation.
  23798. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  23799. if m.sop_stage != nil {
  23800. return *m.sop_stage, true
  23801. }
  23802. return
  23803. }
  23804. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  23805. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23806. // SopStageID instead. It exists only for internal usage by the builders.
  23807. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  23808. if id := m.sop_stage; id != nil {
  23809. ids = append(ids, *id)
  23810. }
  23811. return
  23812. }
  23813. // ResetSopStage resets all changes to the "sop_stage" edge.
  23814. func (m *MessageRecordsMutation) ResetSopStage() {
  23815. m.sop_stage = nil
  23816. m.clearedsop_stage = false
  23817. }
  23818. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  23819. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  23820. m.sop_node = &id
  23821. }
  23822. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  23823. func (m *MessageRecordsMutation) ClearSopNode() {
  23824. m.clearedsop_node = true
  23825. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  23826. }
  23827. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  23828. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  23829. return m.SubSourceIDCleared() || m.clearedsop_node
  23830. }
  23831. // SopNodeID returns the "sop_node" edge ID in the mutation.
  23832. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  23833. if m.sop_node != nil {
  23834. return *m.sop_node, true
  23835. }
  23836. return
  23837. }
  23838. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  23839. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23840. // SopNodeID instead. It exists only for internal usage by the builders.
  23841. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  23842. if id := m.sop_node; id != nil {
  23843. ids = append(ids, *id)
  23844. }
  23845. return
  23846. }
  23847. // ResetSopNode resets all changes to the "sop_node" edge.
  23848. func (m *MessageRecordsMutation) ResetSopNode() {
  23849. m.sop_node = nil
  23850. m.clearedsop_node = false
  23851. }
  23852. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  23853. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  23854. m.message_contact = &id
  23855. }
  23856. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  23857. func (m *MessageRecordsMutation) ClearMessageContact() {
  23858. m.clearedmessage_contact = true
  23859. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  23860. }
  23861. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  23862. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  23863. return m.ContactIDCleared() || m.clearedmessage_contact
  23864. }
  23865. // MessageContactID returns the "message_contact" edge ID in the mutation.
  23866. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  23867. if m.message_contact != nil {
  23868. return *m.message_contact, true
  23869. }
  23870. return
  23871. }
  23872. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  23873. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23874. // MessageContactID instead. It exists only for internal usage by the builders.
  23875. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  23876. if id := m.message_contact; id != nil {
  23877. ids = append(ids, *id)
  23878. }
  23879. return
  23880. }
  23881. // ResetMessageContact resets all changes to the "message_contact" edge.
  23882. func (m *MessageRecordsMutation) ResetMessageContact() {
  23883. m.message_contact = nil
  23884. m.clearedmessage_contact = false
  23885. }
  23886. // Where appends a list predicates to the MessageRecordsMutation builder.
  23887. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  23888. m.predicates = append(m.predicates, ps...)
  23889. }
  23890. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  23891. // users can use type-assertion to append predicates that do not depend on any generated package.
  23892. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  23893. p := make([]predicate.MessageRecords, len(ps))
  23894. for i := range ps {
  23895. p[i] = ps[i]
  23896. }
  23897. m.Where(p...)
  23898. }
  23899. // Op returns the operation name.
  23900. func (m *MessageRecordsMutation) Op() Op {
  23901. return m.op
  23902. }
  23903. // SetOp allows setting the mutation operation.
  23904. func (m *MessageRecordsMutation) SetOp(op Op) {
  23905. m.op = op
  23906. }
  23907. // Type returns the node type of this mutation (MessageRecords).
  23908. func (m *MessageRecordsMutation) Type() string {
  23909. return m.typ
  23910. }
  23911. // Fields returns all fields that were changed during this mutation. Note that in
  23912. // order to get all numeric fields that were incremented/decremented, call
  23913. // AddedFields().
  23914. func (m *MessageRecordsMutation) Fields() []string {
  23915. fields := make([]string, 0, 16)
  23916. if m.created_at != nil {
  23917. fields = append(fields, messagerecords.FieldCreatedAt)
  23918. }
  23919. if m.updated_at != nil {
  23920. fields = append(fields, messagerecords.FieldUpdatedAt)
  23921. }
  23922. if m.status != nil {
  23923. fields = append(fields, messagerecords.FieldStatus)
  23924. }
  23925. if m.bot_wxid != nil {
  23926. fields = append(fields, messagerecords.FieldBotWxid)
  23927. }
  23928. if m.message_contact != nil {
  23929. fields = append(fields, messagerecords.FieldContactID)
  23930. }
  23931. if m.contact_type != nil {
  23932. fields = append(fields, messagerecords.FieldContactType)
  23933. }
  23934. if m.contact_wxid != nil {
  23935. fields = append(fields, messagerecords.FieldContactWxid)
  23936. }
  23937. if m.content_type != nil {
  23938. fields = append(fields, messagerecords.FieldContentType)
  23939. }
  23940. if m.content != nil {
  23941. fields = append(fields, messagerecords.FieldContent)
  23942. }
  23943. if m.meta != nil {
  23944. fields = append(fields, messagerecords.FieldMeta)
  23945. }
  23946. if m.error_detail != nil {
  23947. fields = append(fields, messagerecords.FieldErrorDetail)
  23948. }
  23949. if m.send_time != nil {
  23950. fields = append(fields, messagerecords.FieldSendTime)
  23951. }
  23952. if m.source_type != nil {
  23953. fields = append(fields, messagerecords.FieldSourceType)
  23954. }
  23955. if m.sop_stage != nil {
  23956. fields = append(fields, messagerecords.FieldSourceID)
  23957. }
  23958. if m.sop_node != nil {
  23959. fields = append(fields, messagerecords.FieldSubSourceID)
  23960. }
  23961. if m.organization_id != nil {
  23962. fields = append(fields, messagerecords.FieldOrganizationID)
  23963. }
  23964. return fields
  23965. }
  23966. // Field returns the value of a field with the given name. The second boolean
  23967. // return value indicates that this field was not set, or was not defined in the
  23968. // schema.
  23969. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  23970. switch name {
  23971. case messagerecords.FieldCreatedAt:
  23972. return m.CreatedAt()
  23973. case messagerecords.FieldUpdatedAt:
  23974. return m.UpdatedAt()
  23975. case messagerecords.FieldStatus:
  23976. return m.Status()
  23977. case messagerecords.FieldBotWxid:
  23978. return m.BotWxid()
  23979. case messagerecords.FieldContactID:
  23980. return m.ContactID()
  23981. case messagerecords.FieldContactType:
  23982. return m.ContactType()
  23983. case messagerecords.FieldContactWxid:
  23984. return m.ContactWxid()
  23985. case messagerecords.FieldContentType:
  23986. return m.ContentType()
  23987. case messagerecords.FieldContent:
  23988. return m.Content()
  23989. case messagerecords.FieldMeta:
  23990. return m.Meta()
  23991. case messagerecords.FieldErrorDetail:
  23992. return m.ErrorDetail()
  23993. case messagerecords.FieldSendTime:
  23994. return m.SendTime()
  23995. case messagerecords.FieldSourceType:
  23996. return m.SourceType()
  23997. case messagerecords.FieldSourceID:
  23998. return m.SourceID()
  23999. case messagerecords.FieldSubSourceID:
  24000. return m.SubSourceID()
  24001. case messagerecords.FieldOrganizationID:
  24002. return m.OrganizationID()
  24003. }
  24004. return nil, false
  24005. }
  24006. // OldField returns the old value of the field from the database. An error is
  24007. // returned if the mutation operation is not UpdateOne, or the query to the
  24008. // database failed.
  24009. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24010. switch name {
  24011. case messagerecords.FieldCreatedAt:
  24012. return m.OldCreatedAt(ctx)
  24013. case messagerecords.FieldUpdatedAt:
  24014. return m.OldUpdatedAt(ctx)
  24015. case messagerecords.FieldStatus:
  24016. return m.OldStatus(ctx)
  24017. case messagerecords.FieldBotWxid:
  24018. return m.OldBotWxid(ctx)
  24019. case messagerecords.FieldContactID:
  24020. return m.OldContactID(ctx)
  24021. case messagerecords.FieldContactType:
  24022. return m.OldContactType(ctx)
  24023. case messagerecords.FieldContactWxid:
  24024. return m.OldContactWxid(ctx)
  24025. case messagerecords.FieldContentType:
  24026. return m.OldContentType(ctx)
  24027. case messagerecords.FieldContent:
  24028. return m.OldContent(ctx)
  24029. case messagerecords.FieldMeta:
  24030. return m.OldMeta(ctx)
  24031. case messagerecords.FieldErrorDetail:
  24032. return m.OldErrorDetail(ctx)
  24033. case messagerecords.FieldSendTime:
  24034. return m.OldSendTime(ctx)
  24035. case messagerecords.FieldSourceType:
  24036. return m.OldSourceType(ctx)
  24037. case messagerecords.FieldSourceID:
  24038. return m.OldSourceID(ctx)
  24039. case messagerecords.FieldSubSourceID:
  24040. return m.OldSubSourceID(ctx)
  24041. case messagerecords.FieldOrganizationID:
  24042. return m.OldOrganizationID(ctx)
  24043. }
  24044. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  24045. }
  24046. // SetField sets the value of a field with the given name. It returns an error if
  24047. // the field is not defined in the schema, or if the type mismatched the field
  24048. // type.
  24049. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  24050. switch name {
  24051. case messagerecords.FieldCreatedAt:
  24052. v, ok := value.(time.Time)
  24053. if !ok {
  24054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24055. }
  24056. m.SetCreatedAt(v)
  24057. return nil
  24058. case messagerecords.FieldUpdatedAt:
  24059. v, ok := value.(time.Time)
  24060. if !ok {
  24061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24062. }
  24063. m.SetUpdatedAt(v)
  24064. return nil
  24065. case messagerecords.FieldStatus:
  24066. v, ok := value.(uint8)
  24067. if !ok {
  24068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24069. }
  24070. m.SetStatus(v)
  24071. return nil
  24072. case messagerecords.FieldBotWxid:
  24073. v, ok := value.(string)
  24074. if !ok {
  24075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24076. }
  24077. m.SetBotWxid(v)
  24078. return nil
  24079. case messagerecords.FieldContactID:
  24080. v, ok := value.(uint64)
  24081. if !ok {
  24082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24083. }
  24084. m.SetContactID(v)
  24085. return nil
  24086. case messagerecords.FieldContactType:
  24087. v, ok := value.(int)
  24088. if !ok {
  24089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24090. }
  24091. m.SetContactType(v)
  24092. return nil
  24093. case messagerecords.FieldContactWxid:
  24094. v, ok := value.(string)
  24095. if !ok {
  24096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24097. }
  24098. m.SetContactWxid(v)
  24099. return nil
  24100. case messagerecords.FieldContentType:
  24101. v, ok := value.(int)
  24102. if !ok {
  24103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24104. }
  24105. m.SetContentType(v)
  24106. return nil
  24107. case messagerecords.FieldContent:
  24108. v, ok := value.(string)
  24109. if !ok {
  24110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24111. }
  24112. m.SetContent(v)
  24113. return nil
  24114. case messagerecords.FieldMeta:
  24115. v, ok := value.(custom_types.Meta)
  24116. if !ok {
  24117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24118. }
  24119. m.SetMeta(v)
  24120. return nil
  24121. case messagerecords.FieldErrorDetail:
  24122. v, ok := value.(string)
  24123. if !ok {
  24124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24125. }
  24126. m.SetErrorDetail(v)
  24127. return nil
  24128. case messagerecords.FieldSendTime:
  24129. v, ok := value.(time.Time)
  24130. if !ok {
  24131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24132. }
  24133. m.SetSendTime(v)
  24134. return nil
  24135. case messagerecords.FieldSourceType:
  24136. v, ok := value.(int)
  24137. if !ok {
  24138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24139. }
  24140. m.SetSourceType(v)
  24141. return nil
  24142. case messagerecords.FieldSourceID:
  24143. v, ok := value.(uint64)
  24144. if !ok {
  24145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24146. }
  24147. m.SetSourceID(v)
  24148. return nil
  24149. case messagerecords.FieldSubSourceID:
  24150. v, ok := value.(uint64)
  24151. if !ok {
  24152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24153. }
  24154. m.SetSubSourceID(v)
  24155. return nil
  24156. case messagerecords.FieldOrganizationID:
  24157. v, ok := value.(uint64)
  24158. if !ok {
  24159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24160. }
  24161. m.SetOrganizationID(v)
  24162. return nil
  24163. }
  24164. return fmt.Errorf("unknown MessageRecords field %s", name)
  24165. }
  24166. // AddedFields returns all numeric fields that were incremented/decremented during
  24167. // this mutation.
  24168. func (m *MessageRecordsMutation) AddedFields() []string {
  24169. var fields []string
  24170. if m.addstatus != nil {
  24171. fields = append(fields, messagerecords.FieldStatus)
  24172. }
  24173. if m.addcontact_type != nil {
  24174. fields = append(fields, messagerecords.FieldContactType)
  24175. }
  24176. if m.addcontent_type != nil {
  24177. fields = append(fields, messagerecords.FieldContentType)
  24178. }
  24179. if m.addsource_type != nil {
  24180. fields = append(fields, messagerecords.FieldSourceType)
  24181. }
  24182. if m.addorganization_id != nil {
  24183. fields = append(fields, messagerecords.FieldOrganizationID)
  24184. }
  24185. return fields
  24186. }
  24187. // AddedField returns the numeric value that was incremented/decremented on a field
  24188. // with the given name. The second boolean return value indicates that this field
  24189. // was not set, or was not defined in the schema.
  24190. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  24191. switch name {
  24192. case messagerecords.FieldStatus:
  24193. return m.AddedStatus()
  24194. case messagerecords.FieldContactType:
  24195. return m.AddedContactType()
  24196. case messagerecords.FieldContentType:
  24197. return m.AddedContentType()
  24198. case messagerecords.FieldSourceType:
  24199. return m.AddedSourceType()
  24200. case messagerecords.FieldOrganizationID:
  24201. return m.AddedOrganizationID()
  24202. }
  24203. return nil, false
  24204. }
  24205. // AddField adds the value to the field with the given name. It returns an error if
  24206. // the field is not defined in the schema, or if the type mismatched the field
  24207. // type.
  24208. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  24209. switch name {
  24210. case messagerecords.FieldStatus:
  24211. v, ok := value.(int8)
  24212. if !ok {
  24213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24214. }
  24215. m.AddStatus(v)
  24216. return nil
  24217. case messagerecords.FieldContactType:
  24218. v, ok := value.(int)
  24219. if !ok {
  24220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24221. }
  24222. m.AddContactType(v)
  24223. return nil
  24224. case messagerecords.FieldContentType:
  24225. v, ok := value.(int)
  24226. if !ok {
  24227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24228. }
  24229. m.AddContentType(v)
  24230. return nil
  24231. case messagerecords.FieldSourceType:
  24232. v, ok := value.(int)
  24233. if !ok {
  24234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24235. }
  24236. m.AddSourceType(v)
  24237. return nil
  24238. case messagerecords.FieldOrganizationID:
  24239. v, ok := value.(int64)
  24240. if !ok {
  24241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24242. }
  24243. m.AddOrganizationID(v)
  24244. return nil
  24245. }
  24246. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  24247. }
  24248. // ClearedFields returns all nullable fields that were cleared during this
  24249. // mutation.
  24250. func (m *MessageRecordsMutation) ClearedFields() []string {
  24251. var fields []string
  24252. if m.FieldCleared(messagerecords.FieldStatus) {
  24253. fields = append(fields, messagerecords.FieldStatus)
  24254. }
  24255. if m.FieldCleared(messagerecords.FieldContactID) {
  24256. fields = append(fields, messagerecords.FieldContactID)
  24257. }
  24258. if m.FieldCleared(messagerecords.FieldMeta) {
  24259. fields = append(fields, messagerecords.FieldMeta)
  24260. }
  24261. if m.FieldCleared(messagerecords.FieldSendTime) {
  24262. fields = append(fields, messagerecords.FieldSendTime)
  24263. }
  24264. if m.FieldCleared(messagerecords.FieldSourceID) {
  24265. fields = append(fields, messagerecords.FieldSourceID)
  24266. }
  24267. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  24268. fields = append(fields, messagerecords.FieldSubSourceID)
  24269. }
  24270. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  24271. fields = append(fields, messagerecords.FieldOrganizationID)
  24272. }
  24273. return fields
  24274. }
  24275. // FieldCleared returns a boolean indicating if a field with the given name was
  24276. // cleared in this mutation.
  24277. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  24278. _, ok := m.clearedFields[name]
  24279. return ok
  24280. }
  24281. // ClearField clears the value of the field with the given name. It returns an
  24282. // error if the field is not defined in the schema.
  24283. func (m *MessageRecordsMutation) ClearField(name string) error {
  24284. switch name {
  24285. case messagerecords.FieldStatus:
  24286. m.ClearStatus()
  24287. return nil
  24288. case messagerecords.FieldContactID:
  24289. m.ClearContactID()
  24290. return nil
  24291. case messagerecords.FieldMeta:
  24292. m.ClearMeta()
  24293. return nil
  24294. case messagerecords.FieldSendTime:
  24295. m.ClearSendTime()
  24296. return nil
  24297. case messagerecords.FieldSourceID:
  24298. m.ClearSourceID()
  24299. return nil
  24300. case messagerecords.FieldSubSourceID:
  24301. m.ClearSubSourceID()
  24302. return nil
  24303. case messagerecords.FieldOrganizationID:
  24304. m.ClearOrganizationID()
  24305. return nil
  24306. }
  24307. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  24308. }
  24309. // ResetField resets all changes in the mutation for the field with the given name.
  24310. // It returns an error if the field is not defined in the schema.
  24311. func (m *MessageRecordsMutation) ResetField(name string) error {
  24312. switch name {
  24313. case messagerecords.FieldCreatedAt:
  24314. m.ResetCreatedAt()
  24315. return nil
  24316. case messagerecords.FieldUpdatedAt:
  24317. m.ResetUpdatedAt()
  24318. return nil
  24319. case messagerecords.FieldStatus:
  24320. m.ResetStatus()
  24321. return nil
  24322. case messagerecords.FieldBotWxid:
  24323. m.ResetBotWxid()
  24324. return nil
  24325. case messagerecords.FieldContactID:
  24326. m.ResetContactID()
  24327. return nil
  24328. case messagerecords.FieldContactType:
  24329. m.ResetContactType()
  24330. return nil
  24331. case messagerecords.FieldContactWxid:
  24332. m.ResetContactWxid()
  24333. return nil
  24334. case messagerecords.FieldContentType:
  24335. m.ResetContentType()
  24336. return nil
  24337. case messagerecords.FieldContent:
  24338. m.ResetContent()
  24339. return nil
  24340. case messagerecords.FieldMeta:
  24341. m.ResetMeta()
  24342. return nil
  24343. case messagerecords.FieldErrorDetail:
  24344. m.ResetErrorDetail()
  24345. return nil
  24346. case messagerecords.FieldSendTime:
  24347. m.ResetSendTime()
  24348. return nil
  24349. case messagerecords.FieldSourceType:
  24350. m.ResetSourceType()
  24351. return nil
  24352. case messagerecords.FieldSourceID:
  24353. m.ResetSourceID()
  24354. return nil
  24355. case messagerecords.FieldSubSourceID:
  24356. m.ResetSubSourceID()
  24357. return nil
  24358. case messagerecords.FieldOrganizationID:
  24359. m.ResetOrganizationID()
  24360. return nil
  24361. }
  24362. return fmt.Errorf("unknown MessageRecords field %s", name)
  24363. }
  24364. // AddedEdges returns all edge names that were set/added in this mutation.
  24365. func (m *MessageRecordsMutation) AddedEdges() []string {
  24366. edges := make([]string, 0, 3)
  24367. if m.sop_stage != nil {
  24368. edges = append(edges, messagerecords.EdgeSopStage)
  24369. }
  24370. if m.sop_node != nil {
  24371. edges = append(edges, messagerecords.EdgeSopNode)
  24372. }
  24373. if m.message_contact != nil {
  24374. edges = append(edges, messagerecords.EdgeMessageContact)
  24375. }
  24376. return edges
  24377. }
  24378. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24379. // name in this mutation.
  24380. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  24381. switch name {
  24382. case messagerecords.EdgeSopStage:
  24383. if id := m.sop_stage; id != nil {
  24384. return []ent.Value{*id}
  24385. }
  24386. case messagerecords.EdgeSopNode:
  24387. if id := m.sop_node; id != nil {
  24388. return []ent.Value{*id}
  24389. }
  24390. case messagerecords.EdgeMessageContact:
  24391. if id := m.message_contact; id != nil {
  24392. return []ent.Value{*id}
  24393. }
  24394. }
  24395. return nil
  24396. }
  24397. // RemovedEdges returns all edge names that were removed in this mutation.
  24398. func (m *MessageRecordsMutation) RemovedEdges() []string {
  24399. edges := make([]string, 0, 3)
  24400. return edges
  24401. }
  24402. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24403. // the given name in this mutation.
  24404. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  24405. return nil
  24406. }
  24407. // ClearedEdges returns all edge names that were cleared in this mutation.
  24408. func (m *MessageRecordsMutation) ClearedEdges() []string {
  24409. edges := make([]string, 0, 3)
  24410. if m.clearedsop_stage {
  24411. edges = append(edges, messagerecords.EdgeSopStage)
  24412. }
  24413. if m.clearedsop_node {
  24414. edges = append(edges, messagerecords.EdgeSopNode)
  24415. }
  24416. if m.clearedmessage_contact {
  24417. edges = append(edges, messagerecords.EdgeMessageContact)
  24418. }
  24419. return edges
  24420. }
  24421. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24422. // was cleared in this mutation.
  24423. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  24424. switch name {
  24425. case messagerecords.EdgeSopStage:
  24426. return m.clearedsop_stage
  24427. case messagerecords.EdgeSopNode:
  24428. return m.clearedsop_node
  24429. case messagerecords.EdgeMessageContact:
  24430. return m.clearedmessage_contact
  24431. }
  24432. return false
  24433. }
  24434. // ClearEdge clears the value of the edge with the given name. It returns an error
  24435. // if that edge is not defined in the schema.
  24436. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  24437. switch name {
  24438. case messagerecords.EdgeSopStage:
  24439. m.ClearSopStage()
  24440. return nil
  24441. case messagerecords.EdgeSopNode:
  24442. m.ClearSopNode()
  24443. return nil
  24444. case messagerecords.EdgeMessageContact:
  24445. m.ClearMessageContact()
  24446. return nil
  24447. }
  24448. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  24449. }
  24450. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24451. // It returns an error if the edge is not defined in the schema.
  24452. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  24453. switch name {
  24454. case messagerecords.EdgeSopStage:
  24455. m.ResetSopStage()
  24456. return nil
  24457. case messagerecords.EdgeSopNode:
  24458. m.ResetSopNode()
  24459. return nil
  24460. case messagerecords.EdgeMessageContact:
  24461. m.ResetMessageContact()
  24462. return nil
  24463. }
  24464. return fmt.Errorf("unknown MessageRecords edge %s", name)
  24465. }
  24466. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  24467. type MsgMutation struct {
  24468. config
  24469. op Op
  24470. typ string
  24471. id *uint64
  24472. created_at *time.Time
  24473. updated_at *time.Time
  24474. deleted_at *time.Time
  24475. status *uint8
  24476. addstatus *int8
  24477. fromwxid *string
  24478. toid *string
  24479. msgtype *int32
  24480. addmsgtype *int32
  24481. msg *string
  24482. batch_no *string
  24483. cc *string
  24484. phone *string
  24485. clearedFields map[string]struct{}
  24486. done bool
  24487. oldValue func(context.Context) (*Msg, error)
  24488. predicates []predicate.Msg
  24489. }
  24490. var _ ent.Mutation = (*MsgMutation)(nil)
  24491. // msgOption allows management of the mutation configuration using functional options.
  24492. type msgOption func(*MsgMutation)
  24493. // newMsgMutation creates new mutation for the Msg entity.
  24494. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  24495. m := &MsgMutation{
  24496. config: c,
  24497. op: op,
  24498. typ: TypeMsg,
  24499. clearedFields: make(map[string]struct{}),
  24500. }
  24501. for _, opt := range opts {
  24502. opt(m)
  24503. }
  24504. return m
  24505. }
  24506. // withMsgID sets the ID field of the mutation.
  24507. func withMsgID(id uint64) msgOption {
  24508. return func(m *MsgMutation) {
  24509. var (
  24510. err error
  24511. once sync.Once
  24512. value *Msg
  24513. )
  24514. m.oldValue = func(ctx context.Context) (*Msg, error) {
  24515. once.Do(func() {
  24516. if m.done {
  24517. err = errors.New("querying old values post mutation is not allowed")
  24518. } else {
  24519. value, err = m.Client().Msg.Get(ctx, id)
  24520. }
  24521. })
  24522. return value, err
  24523. }
  24524. m.id = &id
  24525. }
  24526. }
  24527. // withMsg sets the old Msg of the mutation.
  24528. func withMsg(node *Msg) msgOption {
  24529. return func(m *MsgMutation) {
  24530. m.oldValue = func(context.Context) (*Msg, error) {
  24531. return node, nil
  24532. }
  24533. m.id = &node.ID
  24534. }
  24535. }
  24536. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24537. // executed in a transaction (ent.Tx), a transactional client is returned.
  24538. func (m MsgMutation) Client() *Client {
  24539. client := &Client{config: m.config}
  24540. client.init()
  24541. return client
  24542. }
  24543. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24544. // it returns an error otherwise.
  24545. func (m MsgMutation) Tx() (*Tx, error) {
  24546. if _, ok := m.driver.(*txDriver); !ok {
  24547. return nil, errors.New("ent: mutation is not running in a transaction")
  24548. }
  24549. tx := &Tx{config: m.config}
  24550. tx.init()
  24551. return tx, nil
  24552. }
  24553. // SetID sets the value of the id field. Note that this
  24554. // operation is only accepted on creation of Msg entities.
  24555. func (m *MsgMutation) SetID(id uint64) {
  24556. m.id = &id
  24557. }
  24558. // ID returns the ID value in the mutation. Note that the ID is only available
  24559. // if it was provided to the builder or after it was returned from the database.
  24560. func (m *MsgMutation) ID() (id uint64, exists bool) {
  24561. if m.id == nil {
  24562. return
  24563. }
  24564. return *m.id, true
  24565. }
  24566. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24567. // That means, if the mutation is applied within a transaction with an isolation level such
  24568. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24569. // or updated by the mutation.
  24570. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  24571. switch {
  24572. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24573. id, exists := m.ID()
  24574. if exists {
  24575. return []uint64{id}, nil
  24576. }
  24577. fallthrough
  24578. case m.op.Is(OpUpdate | OpDelete):
  24579. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  24580. default:
  24581. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24582. }
  24583. }
  24584. // SetCreatedAt sets the "created_at" field.
  24585. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  24586. m.created_at = &t
  24587. }
  24588. // CreatedAt returns the value of the "created_at" field in the mutation.
  24589. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  24590. v := m.created_at
  24591. if v == nil {
  24592. return
  24593. }
  24594. return *v, true
  24595. }
  24596. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  24597. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24599. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24600. if !m.op.Is(OpUpdateOne) {
  24601. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24602. }
  24603. if m.id == nil || m.oldValue == nil {
  24604. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24605. }
  24606. oldValue, err := m.oldValue(ctx)
  24607. if err != nil {
  24608. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24609. }
  24610. return oldValue.CreatedAt, nil
  24611. }
  24612. // ResetCreatedAt resets all changes to the "created_at" field.
  24613. func (m *MsgMutation) ResetCreatedAt() {
  24614. m.created_at = nil
  24615. }
  24616. // SetUpdatedAt sets the "updated_at" field.
  24617. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  24618. m.updated_at = &t
  24619. }
  24620. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24621. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  24622. v := m.updated_at
  24623. if v == nil {
  24624. return
  24625. }
  24626. return *v, true
  24627. }
  24628. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  24629. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24631. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24632. if !m.op.Is(OpUpdateOne) {
  24633. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24634. }
  24635. if m.id == nil || m.oldValue == nil {
  24636. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24637. }
  24638. oldValue, err := m.oldValue(ctx)
  24639. if err != nil {
  24640. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24641. }
  24642. return oldValue.UpdatedAt, nil
  24643. }
  24644. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24645. func (m *MsgMutation) ResetUpdatedAt() {
  24646. m.updated_at = nil
  24647. }
  24648. // SetDeletedAt sets the "deleted_at" field.
  24649. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  24650. m.deleted_at = &t
  24651. }
  24652. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24653. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  24654. v := m.deleted_at
  24655. if v == nil {
  24656. return
  24657. }
  24658. return *v, true
  24659. }
  24660. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  24661. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24663. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24664. if !m.op.Is(OpUpdateOne) {
  24665. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24666. }
  24667. if m.id == nil || m.oldValue == nil {
  24668. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24669. }
  24670. oldValue, err := m.oldValue(ctx)
  24671. if err != nil {
  24672. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24673. }
  24674. return oldValue.DeletedAt, nil
  24675. }
  24676. // ClearDeletedAt clears the value of the "deleted_at" field.
  24677. func (m *MsgMutation) ClearDeletedAt() {
  24678. m.deleted_at = nil
  24679. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  24680. }
  24681. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24682. func (m *MsgMutation) DeletedAtCleared() bool {
  24683. _, ok := m.clearedFields[msg.FieldDeletedAt]
  24684. return ok
  24685. }
  24686. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24687. func (m *MsgMutation) ResetDeletedAt() {
  24688. m.deleted_at = nil
  24689. delete(m.clearedFields, msg.FieldDeletedAt)
  24690. }
  24691. // SetStatus sets the "status" field.
  24692. func (m *MsgMutation) SetStatus(u uint8) {
  24693. m.status = &u
  24694. m.addstatus = nil
  24695. }
  24696. // Status returns the value of the "status" field in the mutation.
  24697. func (m *MsgMutation) Status() (r uint8, exists bool) {
  24698. v := m.status
  24699. if v == nil {
  24700. return
  24701. }
  24702. return *v, true
  24703. }
  24704. // OldStatus returns the old "status" field's value of the Msg entity.
  24705. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24707. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24708. if !m.op.Is(OpUpdateOne) {
  24709. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24710. }
  24711. if m.id == nil || m.oldValue == nil {
  24712. return v, errors.New("OldStatus requires an ID field in the mutation")
  24713. }
  24714. oldValue, err := m.oldValue(ctx)
  24715. if err != nil {
  24716. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24717. }
  24718. return oldValue.Status, nil
  24719. }
  24720. // AddStatus adds u to the "status" field.
  24721. func (m *MsgMutation) AddStatus(u int8) {
  24722. if m.addstatus != nil {
  24723. *m.addstatus += u
  24724. } else {
  24725. m.addstatus = &u
  24726. }
  24727. }
  24728. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24729. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  24730. v := m.addstatus
  24731. if v == nil {
  24732. return
  24733. }
  24734. return *v, true
  24735. }
  24736. // ClearStatus clears the value of the "status" field.
  24737. func (m *MsgMutation) ClearStatus() {
  24738. m.status = nil
  24739. m.addstatus = nil
  24740. m.clearedFields[msg.FieldStatus] = struct{}{}
  24741. }
  24742. // StatusCleared returns if the "status" field was cleared in this mutation.
  24743. func (m *MsgMutation) StatusCleared() bool {
  24744. _, ok := m.clearedFields[msg.FieldStatus]
  24745. return ok
  24746. }
  24747. // ResetStatus resets all changes to the "status" field.
  24748. func (m *MsgMutation) ResetStatus() {
  24749. m.status = nil
  24750. m.addstatus = nil
  24751. delete(m.clearedFields, msg.FieldStatus)
  24752. }
  24753. // SetFromwxid sets the "fromwxid" field.
  24754. func (m *MsgMutation) SetFromwxid(s string) {
  24755. m.fromwxid = &s
  24756. }
  24757. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  24758. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  24759. v := m.fromwxid
  24760. if v == nil {
  24761. return
  24762. }
  24763. return *v, true
  24764. }
  24765. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  24766. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24768. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  24769. if !m.op.Is(OpUpdateOne) {
  24770. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  24771. }
  24772. if m.id == nil || m.oldValue == nil {
  24773. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  24774. }
  24775. oldValue, err := m.oldValue(ctx)
  24776. if err != nil {
  24777. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  24778. }
  24779. return oldValue.Fromwxid, nil
  24780. }
  24781. // ClearFromwxid clears the value of the "fromwxid" field.
  24782. func (m *MsgMutation) ClearFromwxid() {
  24783. m.fromwxid = nil
  24784. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  24785. }
  24786. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  24787. func (m *MsgMutation) FromwxidCleared() bool {
  24788. _, ok := m.clearedFields[msg.FieldFromwxid]
  24789. return ok
  24790. }
  24791. // ResetFromwxid resets all changes to the "fromwxid" field.
  24792. func (m *MsgMutation) ResetFromwxid() {
  24793. m.fromwxid = nil
  24794. delete(m.clearedFields, msg.FieldFromwxid)
  24795. }
  24796. // SetToid sets the "toid" field.
  24797. func (m *MsgMutation) SetToid(s string) {
  24798. m.toid = &s
  24799. }
  24800. // Toid returns the value of the "toid" field in the mutation.
  24801. func (m *MsgMutation) Toid() (r string, exists bool) {
  24802. v := m.toid
  24803. if v == nil {
  24804. return
  24805. }
  24806. return *v, true
  24807. }
  24808. // OldToid returns the old "toid" field's value of the Msg entity.
  24809. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24811. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  24812. if !m.op.Is(OpUpdateOne) {
  24813. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  24814. }
  24815. if m.id == nil || m.oldValue == nil {
  24816. return v, errors.New("OldToid requires an ID field in the mutation")
  24817. }
  24818. oldValue, err := m.oldValue(ctx)
  24819. if err != nil {
  24820. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  24821. }
  24822. return oldValue.Toid, nil
  24823. }
  24824. // ClearToid clears the value of the "toid" field.
  24825. func (m *MsgMutation) ClearToid() {
  24826. m.toid = nil
  24827. m.clearedFields[msg.FieldToid] = struct{}{}
  24828. }
  24829. // ToidCleared returns if the "toid" field was cleared in this mutation.
  24830. func (m *MsgMutation) ToidCleared() bool {
  24831. _, ok := m.clearedFields[msg.FieldToid]
  24832. return ok
  24833. }
  24834. // ResetToid resets all changes to the "toid" field.
  24835. func (m *MsgMutation) ResetToid() {
  24836. m.toid = nil
  24837. delete(m.clearedFields, msg.FieldToid)
  24838. }
  24839. // SetMsgtype sets the "msgtype" field.
  24840. func (m *MsgMutation) SetMsgtype(i int32) {
  24841. m.msgtype = &i
  24842. m.addmsgtype = nil
  24843. }
  24844. // Msgtype returns the value of the "msgtype" field in the mutation.
  24845. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  24846. v := m.msgtype
  24847. if v == nil {
  24848. return
  24849. }
  24850. return *v, true
  24851. }
  24852. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  24853. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24855. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  24856. if !m.op.Is(OpUpdateOne) {
  24857. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  24858. }
  24859. if m.id == nil || m.oldValue == nil {
  24860. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  24861. }
  24862. oldValue, err := m.oldValue(ctx)
  24863. if err != nil {
  24864. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  24865. }
  24866. return oldValue.Msgtype, nil
  24867. }
  24868. // AddMsgtype adds i to the "msgtype" field.
  24869. func (m *MsgMutation) AddMsgtype(i int32) {
  24870. if m.addmsgtype != nil {
  24871. *m.addmsgtype += i
  24872. } else {
  24873. m.addmsgtype = &i
  24874. }
  24875. }
  24876. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  24877. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  24878. v := m.addmsgtype
  24879. if v == nil {
  24880. return
  24881. }
  24882. return *v, true
  24883. }
  24884. // ClearMsgtype clears the value of the "msgtype" field.
  24885. func (m *MsgMutation) ClearMsgtype() {
  24886. m.msgtype = nil
  24887. m.addmsgtype = nil
  24888. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  24889. }
  24890. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  24891. func (m *MsgMutation) MsgtypeCleared() bool {
  24892. _, ok := m.clearedFields[msg.FieldMsgtype]
  24893. return ok
  24894. }
  24895. // ResetMsgtype resets all changes to the "msgtype" field.
  24896. func (m *MsgMutation) ResetMsgtype() {
  24897. m.msgtype = nil
  24898. m.addmsgtype = nil
  24899. delete(m.clearedFields, msg.FieldMsgtype)
  24900. }
  24901. // SetMsg sets the "msg" field.
  24902. func (m *MsgMutation) SetMsg(s string) {
  24903. m.msg = &s
  24904. }
  24905. // Msg returns the value of the "msg" field in the mutation.
  24906. func (m *MsgMutation) Msg() (r string, exists bool) {
  24907. v := m.msg
  24908. if v == nil {
  24909. return
  24910. }
  24911. return *v, true
  24912. }
  24913. // OldMsg returns the old "msg" field's value of the Msg entity.
  24914. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24916. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  24917. if !m.op.Is(OpUpdateOne) {
  24918. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  24919. }
  24920. if m.id == nil || m.oldValue == nil {
  24921. return v, errors.New("OldMsg requires an ID field in the mutation")
  24922. }
  24923. oldValue, err := m.oldValue(ctx)
  24924. if err != nil {
  24925. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  24926. }
  24927. return oldValue.Msg, nil
  24928. }
  24929. // ClearMsg clears the value of the "msg" field.
  24930. func (m *MsgMutation) ClearMsg() {
  24931. m.msg = nil
  24932. m.clearedFields[msg.FieldMsg] = struct{}{}
  24933. }
  24934. // MsgCleared returns if the "msg" field was cleared in this mutation.
  24935. func (m *MsgMutation) MsgCleared() bool {
  24936. _, ok := m.clearedFields[msg.FieldMsg]
  24937. return ok
  24938. }
  24939. // ResetMsg resets all changes to the "msg" field.
  24940. func (m *MsgMutation) ResetMsg() {
  24941. m.msg = nil
  24942. delete(m.clearedFields, msg.FieldMsg)
  24943. }
  24944. // SetBatchNo sets the "batch_no" field.
  24945. func (m *MsgMutation) SetBatchNo(s string) {
  24946. m.batch_no = &s
  24947. }
  24948. // BatchNo returns the value of the "batch_no" field in the mutation.
  24949. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  24950. v := m.batch_no
  24951. if v == nil {
  24952. return
  24953. }
  24954. return *v, true
  24955. }
  24956. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  24957. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24959. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  24960. if !m.op.Is(OpUpdateOne) {
  24961. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  24962. }
  24963. if m.id == nil || m.oldValue == nil {
  24964. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  24965. }
  24966. oldValue, err := m.oldValue(ctx)
  24967. if err != nil {
  24968. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  24969. }
  24970. return oldValue.BatchNo, nil
  24971. }
  24972. // ClearBatchNo clears the value of the "batch_no" field.
  24973. func (m *MsgMutation) ClearBatchNo() {
  24974. m.batch_no = nil
  24975. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  24976. }
  24977. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  24978. func (m *MsgMutation) BatchNoCleared() bool {
  24979. _, ok := m.clearedFields[msg.FieldBatchNo]
  24980. return ok
  24981. }
  24982. // ResetBatchNo resets all changes to the "batch_no" field.
  24983. func (m *MsgMutation) ResetBatchNo() {
  24984. m.batch_no = nil
  24985. delete(m.clearedFields, msg.FieldBatchNo)
  24986. }
  24987. // SetCc sets the "cc" field.
  24988. func (m *MsgMutation) SetCc(s string) {
  24989. m.cc = &s
  24990. }
  24991. // Cc returns the value of the "cc" field in the mutation.
  24992. func (m *MsgMutation) Cc() (r string, exists bool) {
  24993. v := m.cc
  24994. if v == nil {
  24995. return
  24996. }
  24997. return *v, true
  24998. }
  24999. // OldCc returns the old "cc" field's value of the Msg entity.
  25000. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25002. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  25003. if !m.op.Is(OpUpdateOne) {
  25004. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  25005. }
  25006. if m.id == nil || m.oldValue == nil {
  25007. return v, errors.New("OldCc requires an ID field in the mutation")
  25008. }
  25009. oldValue, err := m.oldValue(ctx)
  25010. if err != nil {
  25011. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  25012. }
  25013. return oldValue.Cc, nil
  25014. }
  25015. // ResetCc resets all changes to the "cc" field.
  25016. func (m *MsgMutation) ResetCc() {
  25017. m.cc = nil
  25018. }
  25019. // SetPhone sets the "phone" field.
  25020. func (m *MsgMutation) SetPhone(s string) {
  25021. m.phone = &s
  25022. }
  25023. // Phone returns the value of the "phone" field in the mutation.
  25024. func (m *MsgMutation) Phone() (r string, exists bool) {
  25025. v := m.phone
  25026. if v == nil {
  25027. return
  25028. }
  25029. return *v, true
  25030. }
  25031. // OldPhone returns the old "phone" field's value of the Msg entity.
  25032. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25034. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  25035. if !m.op.Is(OpUpdateOne) {
  25036. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  25037. }
  25038. if m.id == nil || m.oldValue == nil {
  25039. return v, errors.New("OldPhone requires an ID field in the mutation")
  25040. }
  25041. oldValue, err := m.oldValue(ctx)
  25042. if err != nil {
  25043. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  25044. }
  25045. return oldValue.Phone, nil
  25046. }
  25047. // ResetPhone resets all changes to the "phone" field.
  25048. func (m *MsgMutation) ResetPhone() {
  25049. m.phone = nil
  25050. }
  25051. // Where appends a list predicates to the MsgMutation builder.
  25052. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  25053. m.predicates = append(m.predicates, ps...)
  25054. }
  25055. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  25056. // users can use type-assertion to append predicates that do not depend on any generated package.
  25057. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  25058. p := make([]predicate.Msg, len(ps))
  25059. for i := range ps {
  25060. p[i] = ps[i]
  25061. }
  25062. m.Where(p...)
  25063. }
  25064. // Op returns the operation name.
  25065. func (m *MsgMutation) Op() Op {
  25066. return m.op
  25067. }
  25068. // SetOp allows setting the mutation operation.
  25069. func (m *MsgMutation) SetOp(op Op) {
  25070. m.op = op
  25071. }
  25072. // Type returns the node type of this mutation (Msg).
  25073. func (m *MsgMutation) Type() string {
  25074. return m.typ
  25075. }
  25076. // Fields returns all fields that were changed during this mutation. Note that in
  25077. // order to get all numeric fields that were incremented/decremented, call
  25078. // AddedFields().
  25079. func (m *MsgMutation) Fields() []string {
  25080. fields := make([]string, 0, 11)
  25081. if m.created_at != nil {
  25082. fields = append(fields, msg.FieldCreatedAt)
  25083. }
  25084. if m.updated_at != nil {
  25085. fields = append(fields, msg.FieldUpdatedAt)
  25086. }
  25087. if m.deleted_at != nil {
  25088. fields = append(fields, msg.FieldDeletedAt)
  25089. }
  25090. if m.status != nil {
  25091. fields = append(fields, msg.FieldStatus)
  25092. }
  25093. if m.fromwxid != nil {
  25094. fields = append(fields, msg.FieldFromwxid)
  25095. }
  25096. if m.toid != nil {
  25097. fields = append(fields, msg.FieldToid)
  25098. }
  25099. if m.msgtype != nil {
  25100. fields = append(fields, msg.FieldMsgtype)
  25101. }
  25102. if m.msg != nil {
  25103. fields = append(fields, msg.FieldMsg)
  25104. }
  25105. if m.batch_no != nil {
  25106. fields = append(fields, msg.FieldBatchNo)
  25107. }
  25108. if m.cc != nil {
  25109. fields = append(fields, msg.FieldCc)
  25110. }
  25111. if m.phone != nil {
  25112. fields = append(fields, msg.FieldPhone)
  25113. }
  25114. return fields
  25115. }
  25116. // Field returns the value of a field with the given name. The second boolean
  25117. // return value indicates that this field was not set, or was not defined in the
  25118. // schema.
  25119. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  25120. switch name {
  25121. case msg.FieldCreatedAt:
  25122. return m.CreatedAt()
  25123. case msg.FieldUpdatedAt:
  25124. return m.UpdatedAt()
  25125. case msg.FieldDeletedAt:
  25126. return m.DeletedAt()
  25127. case msg.FieldStatus:
  25128. return m.Status()
  25129. case msg.FieldFromwxid:
  25130. return m.Fromwxid()
  25131. case msg.FieldToid:
  25132. return m.Toid()
  25133. case msg.FieldMsgtype:
  25134. return m.Msgtype()
  25135. case msg.FieldMsg:
  25136. return m.Msg()
  25137. case msg.FieldBatchNo:
  25138. return m.BatchNo()
  25139. case msg.FieldCc:
  25140. return m.Cc()
  25141. case msg.FieldPhone:
  25142. return m.Phone()
  25143. }
  25144. return nil, false
  25145. }
  25146. // OldField returns the old value of the field from the database. An error is
  25147. // returned if the mutation operation is not UpdateOne, or the query to the
  25148. // database failed.
  25149. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25150. switch name {
  25151. case msg.FieldCreatedAt:
  25152. return m.OldCreatedAt(ctx)
  25153. case msg.FieldUpdatedAt:
  25154. return m.OldUpdatedAt(ctx)
  25155. case msg.FieldDeletedAt:
  25156. return m.OldDeletedAt(ctx)
  25157. case msg.FieldStatus:
  25158. return m.OldStatus(ctx)
  25159. case msg.FieldFromwxid:
  25160. return m.OldFromwxid(ctx)
  25161. case msg.FieldToid:
  25162. return m.OldToid(ctx)
  25163. case msg.FieldMsgtype:
  25164. return m.OldMsgtype(ctx)
  25165. case msg.FieldMsg:
  25166. return m.OldMsg(ctx)
  25167. case msg.FieldBatchNo:
  25168. return m.OldBatchNo(ctx)
  25169. case msg.FieldCc:
  25170. return m.OldCc(ctx)
  25171. case msg.FieldPhone:
  25172. return m.OldPhone(ctx)
  25173. }
  25174. return nil, fmt.Errorf("unknown Msg field %s", name)
  25175. }
  25176. // SetField sets the value of a field with the given name. It returns an error if
  25177. // the field is not defined in the schema, or if the type mismatched the field
  25178. // type.
  25179. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  25180. switch name {
  25181. case msg.FieldCreatedAt:
  25182. v, ok := value.(time.Time)
  25183. if !ok {
  25184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25185. }
  25186. m.SetCreatedAt(v)
  25187. return nil
  25188. case msg.FieldUpdatedAt:
  25189. v, ok := value.(time.Time)
  25190. if !ok {
  25191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25192. }
  25193. m.SetUpdatedAt(v)
  25194. return nil
  25195. case msg.FieldDeletedAt:
  25196. v, ok := value.(time.Time)
  25197. if !ok {
  25198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25199. }
  25200. m.SetDeletedAt(v)
  25201. return nil
  25202. case msg.FieldStatus:
  25203. v, ok := value.(uint8)
  25204. if !ok {
  25205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25206. }
  25207. m.SetStatus(v)
  25208. return nil
  25209. case msg.FieldFromwxid:
  25210. v, ok := value.(string)
  25211. if !ok {
  25212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25213. }
  25214. m.SetFromwxid(v)
  25215. return nil
  25216. case msg.FieldToid:
  25217. v, ok := value.(string)
  25218. if !ok {
  25219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25220. }
  25221. m.SetToid(v)
  25222. return nil
  25223. case msg.FieldMsgtype:
  25224. v, ok := value.(int32)
  25225. if !ok {
  25226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25227. }
  25228. m.SetMsgtype(v)
  25229. return nil
  25230. case msg.FieldMsg:
  25231. v, ok := value.(string)
  25232. if !ok {
  25233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25234. }
  25235. m.SetMsg(v)
  25236. return nil
  25237. case msg.FieldBatchNo:
  25238. v, ok := value.(string)
  25239. if !ok {
  25240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25241. }
  25242. m.SetBatchNo(v)
  25243. return nil
  25244. case msg.FieldCc:
  25245. v, ok := value.(string)
  25246. if !ok {
  25247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25248. }
  25249. m.SetCc(v)
  25250. return nil
  25251. case msg.FieldPhone:
  25252. v, ok := value.(string)
  25253. if !ok {
  25254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25255. }
  25256. m.SetPhone(v)
  25257. return nil
  25258. }
  25259. return fmt.Errorf("unknown Msg field %s", name)
  25260. }
  25261. // AddedFields returns all numeric fields that were incremented/decremented during
  25262. // this mutation.
  25263. func (m *MsgMutation) AddedFields() []string {
  25264. var fields []string
  25265. if m.addstatus != nil {
  25266. fields = append(fields, msg.FieldStatus)
  25267. }
  25268. if m.addmsgtype != nil {
  25269. fields = append(fields, msg.FieldMsgtype)
  25270. }
  25271. return fields
  25272. }
  25273. // AddedField returns the numeric value that was incremented/decremented on a field
  25274. // with the given name. The second boolean return value indicates that this field
  25275. // was not set, or was not defined in the schema.
  25276. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  25277. switch name {
  25278. case msg.FieldStatus:
  25279. return m.AddedStatus()
  25280. case msg.FieldMsgtype:
  25281. return m.AddedMsgtype()
  25282. }
  25283. return nil, false
  25284. }
  25285. // AddField adds the value to the field with the given name. It returns an error if
  25286. // the field is not defined in the schema, or if the type mismatched the field
  25287. // type.
  25288. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  25289. switch name {
  25290. case msg.FieldStatus:
  25291. v, ok := value.(int8)
  25292. if !ok {
  25293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25294. }
  25295. m.AddStatus(v)
  25296. return nil
  25297. case msg.FieldMsgtype:
  25298. v, ok := value.(int32)
  25299. if !ok {
  25300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25301. }
  25302. m.AddMsgtype(v)
  25303. return nil
  25304. }
  25305. return fmt.Errorf("unknown Msg numeric field %s", name)
  25306. }
  25307. // ClearedFields returns all nullable fields that were cleared during this
  25308. // mutation.
  25309. func (m *MsgMutation) ClearedFields() []string {
  25310. var fields []string
  25311. if m.FieldCleared(msg.FieldDeletedAt) {
  25312. fields = append(fields, msg.FieldDeletedAt)
  25313. }
  25314. if m.FieldCleared(msg.FieldStatus) {
  25315. fields = append(fields, msg.FieldStatus)
  25316. }
  25317. if m.FieldCleared(msg.FieldFromwxid) {
  25318. fields = append(fields, msg.FieldFromwxid)
  25319. }
  25320. if m.FieldCleared(msg.FieldToid) {
  25321. fields = append(fields, msg.FieldToid)
  25322. }
  25323. if m.FieldCleared(msg.FieldMsgtype) {
  25324. fields = append(fields, msg.FieldMsgtype)
  25325. }
  25326. if m.FieldCleared(msg.FieldMsg) {
  25327. fields = append(fields, msg.FieldMsg)
  25328. }
  25329. if m.FieldCleared(msg.FieldBatchNo) {
  25330. fields = append(fields, msg.FieldBatchNo)
  25331. }
  25332. return fields
  25333. }
  25334. // FieldCleared returns a boolean indicating if a field with the given name was
  25335. // cleared in this mutation.
  25336. func (m *MsgMutation) FieldCleared(name string) bool {
  25337. _, ok := m.clearedFields[name]
  25338. return ok
  25339. }
  25340. // ClearField clears the value of the field with the given name. It returns an
  25341. // error if the field is not defined in the schema.
  25342. func (m *MsgMutation) ClearField(name string) error {
  25343. switch name {
  25344. case msg.FieldDeletedAt:
  25345. m.ClearDeletedAt()
  25346. return nil
  25347. case msg.FieldStatus:
  25348. m.ClearStatus()
  25349. return nil
  25350. case msg.FieldFromwxid:
  25351. m.ClearFromwxid()
  25352. return nil
  25353. case msg.FieldToid:
  25354. m.ClearToid()
  25355. return nil
  25356. case msg.FieldMsgtype:
  25357. m.ClearMsgtype()
  25358. return nil
  25359. case msg.FieldMsg:
  25360. m.ClearMsg()
  25361. return nil
  25362. case msg.FieldBatchNo:
  25363. m.ClearBatchNo()
  25364. return nil
  25365. }
  25366. return fmt.Errorf("unknown Msg nullable field %s", name)
  25367. }
  25368. // ResetField resets all changes in the mutation for the field with the given name.
  25369. // It returns an error if the field is not defined in the schema.
  25370. func (m *MsgMutation) ResetField(name string) error {
  25371. switch name {
  25372. case msg.FieldCreatedAt:
  25373. m.ResetCreatedAt()
  25374. return nil
  25375. case msg.FieldUpdatedAt:
  25376. m.ResetUpdatedAt()
  25377. return nil
  25378. case msg.FieldDeletedAt:
  25379. m.ResetDeletedAt()
  25380. return nil
  25381. case msg.FieldStatus:
  25382. m.ResetStatus()
  25383. return nil
  25384. case msg.FieldFromwxid:
  25385. m.ResetFromwxid()
  25386. return nil
  25387. case msg.FieldToid:
  25388. m.ResetToid()
  25389. return nil
  25390. case msg.FieldMsgtype:
  25391. m.ResetMsgtype()
  25392. return nil
  25393. case msg.FieldMsg:
  25394. m.ResetMsg()
  25395. return nil
  25396. case msg.FieldBatchNo:
  25397. m.ResetBatchNo()
  25398. return nil
  25399. case msg.FieldCc:
  25400. m.ResetCc()
  25401. return nil
  25402. case msg.FieldPhone:
  25403. m.ResetPhone()
  25404. return nil
  25405. }
  25406. return fmt.Errorf("unknown Msg field %s", name)
  25407. }
  25408. // AddedEdges returns all edge names that were set/added in this mutation.
  25409. func (m *MsgMutation) AddedEdges() []string {
  25410. edges := make([]string, 0, 0)
  25411. return edges
  25412. }
  25413. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25414. // name in this mutation.
  25415. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  25416. return nil
  25417. }
  25418. // RemovedEdges returns all edge names that were removed in this mutation.
  25419. func (m *MsgMutation) RemovedEdges() []string {
  25420. edges := make([]string, 0, 0)
  25421. return edges
  25422. }
  25423. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25424. // the given name in this mutation.
  25425. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  25426. return nil
  25427. }
  25428. // ClearedEdges returns all edge names that were cleared in this mutation.
  25429. func (m *MsgMutation) ClearedEdges() []string {
  25430. edges := make([]string, 0, 0)
  25431. return edges
  25432. }
  25433. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25434. // was cleared in this mutation.
  25435. func (m *MsgMutation) EdgeCleared(name string) bool {
  25436. return false
  25437. }
  25438. // ClearEdge clears the value of the edge with the given name. It returns an error
  25439. // if that edge is not defined in the schema.
  25440. func (m *MsgMutation) ClearEdge(name string) error {
  25441. return fmt.Errorf("unknown Msg unique edge %s", name)
  25442. }
  25443. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25444. // It returns an error if the edge is not defined in the schema.
  25445. func (m *MsgMutation) ResetEdge(name string) error {
  25446. return fmt.Errorf("unknown Msg edge %s", name)
  25447. }
  25448. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  25449. type PayRechargeMutation struct {
  25450. config
  25451. op Op
  25452. typ string
  25453. id *uint64
  25454. created_at *time.Time
  25455. updated_at *time.Time
  25456. deleted_at *time.Time
  25457. user_id *string
  25458. number *float32
  25459. addnumber *float32
  25460. status *int
  25461. addstatus *int
  25462. money *float32
  25463. addmoney *float32
  25464. out_trade_no *string
  25465. organization_id *uint64
  25466. addorganization_id *int64
  25467. clearedFields map[string]struct{}
  25468. done bool
  25469. oldValue func(context.Context) (*PayRecharge, error)
  25470. predicates []predicate.PayRecharge
  25471. }
  25472. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  25473. // payrechargeOption allows management of the mutation configuration using functional options.
  25474. type payrechargeOption func(*PayRechargeMutation)
  25475. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  25476. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  25477. m := &PayRechargeMutation{
  25478. config: c,
  25479. op: op,
  25480. typ: TypePayRecharge,
  25481. clearedFields: make(map[string]struct{}),
  25482. }
  25483. for _, opt := range opts {
  25484. opt(m)
  25485. }
  25486. return m
  25487. }
  25488. // withPayRechargeID sets the ID field of the mutation.
  25489. func withPayRechargeID(id uint64) payrechargeOption {
  25490. return func(m *PayRechargeMutation) {
  25491. var (
  25492. err error
  25493. once sync.Once
  25494. value *PayRecharge
  25495. )
  25496. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  25497. once.Do(func() {
  25498. if m.done {
  25499. err = errors.New("querying old values post mutation is not allowed")
  25500. } else {
  25501. value, err = m.Client().PayRecharge.Get(ctx, id)
  25502. }
  25503. })
  25504. return value, err
  25505. }
  25506. m.id = &id
  25507. }
  25508. }
  25509. // withPayRecharge sets the old PayRecharge of the mutation.
  25510. func withPayRecharge(node *PayRecharge) payrechargeOption {
  25511. return func(m *PayRechargeMutation) {
  25512. m.oldValue = func(context.Context) (*PayRecharge, error) {
  25513. return node, nil
  25514. }
  25515. m.id = &node.ID
  25516. }
  25517. }
  25518. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25519. // executed in a transaction (ent.Tx), a transactional client is returned.
  25520. func (m PayRechargeMutation) Client() *Client {
  25521. client := &Client{config: m.config}
  25522. client.init()
  25523. return client
  25524. }
  25525. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25526. // it returns an error otherwise.
  25527. func (m PayRechargeMutation) Tx() (*Tx, error) {
  25528. if _, ok := m.driver.(*txDriver); !ok {
  25529. return nil, errors.New("ent: mutation is not running in a transaction")
  25530. }
  25531. tx := &Tx{config: m.config}
  25532. tx.init()
  25533. return tx, nil
  25534. }
  25535. // SetID sets the value of the id field. Note that this
  25536. // operation is only accepted on creation of PayRecharge entities.
  25537. func (m *PayRechargeMutation) SetID(id uint64) {
  25538. m.id = &id
  25539. }
  25540. // ID returns the ID value in the mutation. Note that the ID is only available
  25541. // if it was provided to the builder or after it was returned from the database.
  25542. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  25543. if m.id == nil {
  25544. return
  25545. }
  25546. return *m.id, true
  25547. }
  25548. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25549. // That means, if the mutation is applied within a transaction with an isolation level such
  25550. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25551. // or updated by the mutation.
  25552. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  25553. switch {
  25554. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25555. id, exists := m.ID()
  25556. if exists {
  25557. return []uint64{id}, nil
  25558. }
  25559. fallthrough
  25560. case m.op.Is(OpUpdate | OpDelete):
  25561. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  25562. default:
  25563. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25564. }
  25565. }
  25566. // SetCreatedAt sets the "created_at" field.
  25567. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  25568. m.created_at = &t
  25569. }
  25570. // CreatedAt returns the value of the "created_at" field in the mutation.
  25571. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  25572. v := m.created_at
  25573. if v == nil {
  25574. return
  25575. }
  25576. return *v, true
  25577. }
  25578. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  25579. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25581. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25582. if !m.op.Is(OpUpdateOne) {
  25583. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25584. }
  25585. if m.id == nil || m.oldValue == nil {
  25586. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25587. }
  25588. oldValue, err := m.oldValue(ctx)
  25589. if err != nil {
  25590. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25591. }
  25592. return oldValue.CreatedAt, nil
  25593. }
  25594. // ResetCreatedAt resets all changes to the "created_at" field.
  25595. func (m *PayRechargeMutation) ResetCreatedAt() {
  25596. m.created_at = nil
  25597. }
  25598. // SetUpdatedAt sets the "updated_at" field.
  25599. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  25600. m.updated_at = &t
  25601. }
  25602. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25603. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  25604. v := m.updated_at
  25605. if v == nil {
  25606. return
  25607. }
  25608. return *v, true
  25609. }
  25610. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  25611. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25613. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25614. if !m.op.Is(OpUpdateOne) {
  25615. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25616. }
  25617. if m.id == nil || m.oldValue == nil {
  25618. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25619. }
  25620. oldValue, err := m.oldValue(ctx)
  25621. if err != nil {
  25622. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25623. }
  25624. return oldValue.UpdatedAt, nil
  25625. }
  25626. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25627. func (m *PayRechargeMutation) ResetUpdatedAt() {
  25628. m.updated_at = nil
  25629. }
  25630. // SetDeletedAt sets the "deleted_at" field.
  25631. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  25632. m.deleted_at = &t
  25633. }
  25634. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25635. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  25636. v := m.deleted_at
  25637. if v == nil {
  25638. return
  25639. }
  25640. return *v, true
  25641. }
  25642. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  25643. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25645. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25646. if !m.op.Is(OpUpdateOne) {
  25647. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25648. }
  25649. if m.id == nil || m.oldValue == nil {
  25650. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25651. }
  25652. oldValue, err := m.oldValue(ctx)
  25653. if err != nil {
  25654. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25655. }
  25656. return oldValue.DeletedAt, nil
  25657. }
  25658. // ClearDeletedAt clears the value of the "deleted_at" field.
  25659. func (m *PayRechargeMutation) ClearDeletedAt() {
  25660. m.deleted_at = nil
  25661. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  25662. }
  25663. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25664. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  25665. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  25666. return ok
  25667. }
  25668. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25669. func (m *PayRechargeMutation) ResetDeletedAt() {
  25670. m.deleted_at = nil
  25671. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  25672. }
  25673. // SetUserID sets the "user_id" field.
  25674. func (m *PayRechargeMutation) SetUserID(s string) {
  25675. m.user_id = &s
  25676. }
  25677. // UserID returns the value of the "user_id" field in the mutation.
  25678. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  25679. v := m.user_id
  25680. if v == nil {
  25681. return
  25682. }
  25683. return *v, true
  25684. }
  25685. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  25686. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25688. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  25689. if !m.op.Is(OpUpdateOne) {
  25690. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  25691. }
  25692. if m.id == nil || m.oldValue == nil {
  25693. return v, errors.New("OldUserID requires an ID field in the mutation")
  25694. }
  25695. oldValue, err := m.oldValue(ctx)
  25696. if err != nil {
  25697. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  25698. }
  25699. return oldValue.UserID, nil
  25700. }
  25701. // ResetUserID resets all changes to the "user_id" field.
  25702. func (m *PayRechargeMutation) ResetUserID() {
  25703. m.user_id = nil
  25704. }
  25705. // SetNumber sets the "number" field.
  25706. func (m *PayRechargeMutation) SetNumber(f float32) {
  25707. m.number = &f
  25708. m.addnumber = nil
  25709. }
  25710. // Number returns the value of the "number" field in the mutation.
  25711. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  25712. v := m.number
  25713. if v == nil {
  25714. return
  25715. }
  25716. return *v, true
  25717. }
  25718. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  25719. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25721. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  25722. if !m.op.Is(OpUpdateOne) {
  25723. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  25724. }
  25725. if m.id == nil || m.oldValue == nil {
  25726. return v, errors.New("OldNumber requires an ID field in the mutation")
  25727. }
  25728. oldValue, err := m.oldValue(ctx)
  25729. if err != nil {
  25730. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  25731. }
  25732. return oldValue.Number, nil
  25733. }
  25734. // AddNumber adds f to the "number" field.
  25735. func (m *PayRechargeMutation) AddNumber(f float32) {
  25736. if m.addnumber != nil {
  25737. *m.addnumber += f
  25738. } else {
  25739. m.addnumber = &f
  25740. }
  25741. }
  25742. // AddedNumber returns the value that was added to the "number" field in this mutation.
  25743. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  25744. v := m.addnumber
  25745. if v == nil {
  25746. return
  25747. }
  25748. return *v, true
  25749. }
  25750. // ResetNumber resets all changes to the "number" field.
  25751. func (m *PayRechargeMutation) ResetNumber() {
  25752. m.number = nil
  25753. m.addnumber = nil
  25754. }
  25755. // SetStatus sets the "status" field.
  25756. func (m *PayRechargeMutation) SetStatus(i int) {
  25757. m.status = &i
  25758. m.addstatus = nil
  25759. }
  25760. // Status returns the value of the "status" field in the mutation.
  25761. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  25762. v := m.status
  25763. if v == nil {
  25764. return
  25765. }
  25766. return *v, true
  25767. }
  25768. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  25769. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25771. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  25772. if !m.op.Is(OpUpdateOne) {
  25773. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25774. }
  25775. if m.id == nil || m.oldValue == nil {
  25776. return v, errors.New("OldStatus requires an ID field in the mutation")
  25777. }
  25778. oldValue, err := m.oldValue(ctx)
  25779. if err != nil {
  25780. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25781. }
  25782. return oldValue.Status, nil
  25783. }
  25784. // AddStatus adds i to the "status" field.
  25785. func (m *PayRechargeMutation) AddStatus(i int) {
  25786. if m.addstatus != nil {
  25787. *m.addstatus += i
  25788. } else {
  25789. m.addstatus = &i
  25790. }
  25791. }
  25792. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25793. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  25794. v := m.addstatus
  25795. if v == nil {
  25796. return
  25797. }
  25798. return *v, true
  25799. }
  25800. // ClearStatus clears the value of the "status" field.
  25801. func (m *PayRechargeMutation) ClearStatus() {
  25802. m.status = nil
  25803. m.addstatus = nil
  25804. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  25805. }
  25806. // StatusCleared returns if the "status" field was cleared in this mutation.
  25807. func (m *PayRechargeMutation) StatusCleared() bool {
  25808. _, ok := m.clearedFields[payrecharge.FieldStatus]
  25809. return ok
  25810. }
  25811. // ResetStatus resets all changes to the "status" field.
  25812. func (m *PayRechargeMutation) ResetStatus() {
  25813. m.status = nil
  25814. m.addstatus = nil
  25815. delete(m.clearedFields, payrecharge.FieldStatus)
  25816. }
  25817. // SetMoney sets the "money" field.
  25818. func (m *PayRechargeMutation) SetMoney(f float32) {
  25819. m.money = &f
  25820. m.addmoney = nil
  25821. }
  25822. // Money returns the value of the "money" field in the mutation.
  25823. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  25824. v := m.money
  25825. if v == nil {
  25826. return
  25827. }
  25828. return *v, true
  25829. }
  25830. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  25831. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25833. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  25834. if !m.op.Is(OpUpdateOne) {
  25835. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  25836. }
  25837. if m.id == nil || m.oldValue == nil {
  25838. return v, errors.New("OldMoney requires an ID field in the mutation")
  25839. }
  25840. oldValue, err := m.oldValue(ctx)
  25841. if err != nil {
  25842. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  25843. }
  25844. return oldValue.Money, nil
  25845. }
  25846. // AddMoney adds f to the "money" field.
  25847. func (m *PayRechargeMutation) AddMoney(f float32) {
  25848. if m.addmoney != nil {
  25849. *m.addmoney += f
  25850. } else {
  25851. m.addmoney = &f
  25852. }
  25853. }
  25854. // AddedMoney returns the value that was added to the "money" field in this mutation.
  25855. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  25856. v := m.addmoney
  25857. if v == nil {
  25858. return
  25859. }
  25860. return *v, true
  25861. }
  25862. // ClearMoney clears the value of the "money" field.
  25863. func (m *PayRechargeMutation) ClearMoney() {
  25864. m.money = nil
  25865. m.addmoney = nil
  25866. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  25867. }
  25868. // MoneyCleared returns if the "money" field was cleared in this mutation.
  25869. func (m *PayRechargeMutation) MoneyCleared() bool {
  25870. _, ok := m.clearedFields[payrecharge.FieldMoney]
  25871. return ok
  25872. }
  25873. // ResetMoney resets all changes to the "money" field.
  25874. func (m *PayRechargeMutation) ResetMoney() {
  25875. m.money = nil
  25876. m.addmoney = nil
  25877. delete(m.clearedFields, payrecharge.FieldMoney)
  25878. }
  25879. // SetOutTradeNo sets the "out_trade_no" field.
  25880. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  25881. m.out_trade_no = &s
  25882. }
  25883. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  25884. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  25885. v := m.out_trade_no
  25886. if v == nil {
  25887. return
  25888. }
  25889. return *v, true
  25890. }
  25891. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  25892. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25894. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  25895. if !m.op.Is(OpUpdateOne) {
  25896. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  25897. }
  25898. if m.id == nil || m.oldValue == nil {
  25899. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  25900. }
  25901. oldValue, err := m.oldValue(ctx)
  25902. if err != nil {
  25903. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  25904. }
  25905. return oldValue.OutTradeNo, nil
  25906. }
  25907. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  25908. func (m *PayRechargeMutation) ClearOutTradeNo() {
  25909. m.out_trade_no = nil
  25910. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  25911. }
  25912. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  25913. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  25914. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  25915. return ok
  25916. }
  25917. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  25918. func (m *PayRechargeMutation) ResetOutTradeNo() {
  25919. m.out_trade_no = nil
  25920. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  25921. }
  25922. // SetOrganizationID sets the "organization_id" field.
  25923. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  25924. m.organization_id = &u
  25925. m.addorganization_id = nil
  25926. }
  25927. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25928. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  25929. v := m.organization_id
  25930. if v == nil {
  25931. return
  25932. }
  25933. return *v, true
  25934. }
  25935. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  25936. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25938. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25939. if !m.op.Is(OpUpdateOne) {
  25940. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25941. }
  25942. if m.id == nil || m.oldValue == nil {
  25943. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25944. }
  25945. oldValue, err := m.oldValue(ctx)
  25946. if err != nil {
  25947. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25948. }
  25949. return oldValue.OrganizationID, nil
  25950. }
  25951. // AddOrganizationID adds u to the "organization_id" field.
  25952. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  25953. if m.addorganization_id != nil {
  25954. *m.addorganization_id += u
  25955. } else {
  25956. m.addorganization_id = &u
  25957. }
  25958. }
  25959. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25960. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  25961. v := m.addorganization_id
  25962. if v == nil {
  25963. return
  25964. }
  25965. return *v, true
  25966. }
  25967. // ResetOrganizationID resets all changes to the "organization_id" field.
  25968. func (m *PayRechargeMutation) ResetOrganizationID() {
  25969. m.organization_id = nil
  25970. m.addorganization_id = nil
  25971. }
  25972. // Where appends a list predicates to the PayRechargeMutation builder.
  25973. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  25974. m.predicates = append(m.predicates, ps...)
  25975. }
  25976. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  25977. // users can use type-assertion to append predicates that do not depend on any generated package.
  25978. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  25979. p := make([]predicate.PayRecharge, len(ps))
  25980. for i := range ps {
  25981. p[i] = ps[i]
  25982. }
  25983. m.Where(p...)
  25984. }
  25985. // Op returns the operation name.
  25986. func (m *PayRechargeMutation) Op() Op {
  25987. return m.op
  25988. }
  25989. // SetOp allows setting the mutation operation.
  25990. func (m *PayRechargeMutation) SetOp(op Op) {
  25991. m.op = op
  25992. }
  25993. // Type returns the node type of this mutation (PayRecharge).
  25994. func (m *PayRechargeMutation) Type() string {
  25995. return m.typ
  25996. }
  25997. // Fields returns all fields that were changed during this mutation. Note that in
  25998. // order to get all numeric fields that were incremented/decremented, call
  25999. // AddedFields().
  26000. func (m *PayRechargeMutation) Fields() []string {
  26001. fields := make([]string, 0, 9)
  26002. if m.created_at != nil {
  26003. fields = append(fields, payrecharge.FieldCreatedAt)
  26004. }
  26005. if m.updated_at != nil {
  26006. fields = append(fields, payrecharge.FieldUpdatedAt)
  26007. }
  26008. if m.deleted_at != nil {
  26009. fields = append(fields, payrecharge.FieldDeletedAt)
  26010. }
  26011. if m.user_id != nil {
  26012. fields = append(fields, payrecharge.FieldUserID)
  26013. }
  26014. if m.number != nil {
  26015. fields = append(fields, payrecharge.FieldNumber)
  26016. }
  26017. if m.status != nil {
  26018. fields = append(fields, payrecharge.FieldStatus)
  26019. }
  26020. if m.money != nil {
  26021. fields = append(fields, payrecharge.FieldMoney)
  26022. }
  26023. if m.out_trade_no != nil {
  26024. fields = append(fields, payrecharge.FieldOutTradeNo)
  26025. }
  26026. if m.organization_id != nil {
  26027. fields = append(fields, payrecharge.FieldOrganizationID)
  26028. }
  26029. return fields
  26030. }
  26031. // Field returns the value of a field with the given name. The second boolean
  26032. // return value indicates that this field was not set, or was not defined in the
  26033. // schema.
  26034. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  26035. switch name {
  26036. case payrecharge.FieldCreatedAt:
  26037. return m.CreatedAt()
  26038. case payrecharge.FieldUpdatedAt:
  26039. return m.UpdatedAt()
  26040. case payrecharge.FieldDeletedAt:
  26041. return m.DeletedAt()
  26042. case payrecharge.FieldUserID:
  26043. return m.UserID()
  26044. case payrecharge.FieldNumber:
  26045. return m.Number()
  26046. case payrecharge.FieldStatus:
  26047. return m.Status()
  26048. case payrecharge.FieldMoney:
  26049. return m.Money()
  26050. case payrecharge.FieldOutTradeNo:
  26051. return m.OutTradeNo()
  26052. case payrecharge.FieldOrganizationID:
  26053. return m.OrganizationID()
  26054. }
  26055. return nil, false
  26056. }
  26057. // OldField returns the old value of the field from the database. An error is
  26058. // returned if the mutation operation is not UpdateOne, or the query to the
  26059. // database failed.
  26060. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26061. switch name {
  26062. case payrecharge.FieldCreatedAt:
  26063. return m.OldCreatedAt(ctx)
  26064. case payrecharge.FieldUpdatedAt:
  26065. return m.OldUpdatedAt(ctx)
  26066. case payrecharge.FieldDeletedAt:
  26067. return m.OldDeletedAt(ctx)
  26068. case payrecharge.FieldUserID:
  26069. return m.OldUserID(ctx)
  26070. case payrecharge.FieldNumber:
  26071. return m.OldNumber(ctx)
  26072. case payrecharge.FieldStatus:
  26073. return m.OldStatus(ctx)
  26074. case payrecharge.FieldMoney:
  26075. return m.OldMoney(ctx)
  26076. case payrecharge.FieldOutTradeNo:
  26077. return m.OldOutTradeNo(ctx)
  26078. case payrecharge.FieldOrganizationID:
  26079. return m.OldOrganizationID(ctx)
  26080. }
  26081. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  26082. }
  26083. // SetField sets the value of a field with the given name. It returns an error if
  26084. // the field is not defined in the schema, or if the type mismatched the field
  26085. // type.
  26086. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  26087. switch name {
  26088. case payrecharge.FieldCreatedAt:
  26089. v, ok := value.(time.Time)
  26090. if !ok {
  26091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26092. }
  26093. m.SetCreatedAt(v)
  26094. return nil
  26095. case payrecharge.FieldUpdatedAt:
  26096. v, ok := value.(time.Time)
  26097. if !ok {
  26098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26099. }
  26100. m.SetUpdatedAt(v)
  26101. return nil
  26102. case payrecharge.FieldDeletedAt:
  26103. v, ok := value.(time.Time)
  26104. if !ok {
  26105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26106. }
  26107. m.SetDeletedAt(v)
  26108. return nil
  26109. case payrecharge.FieldUserID:
  26110. v, ok := value.(string)
  26111. if !ok {
  26112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26113. }
  26114. m.SetUserID(v)
  26115. return nil
  26116. case payrecharge.FieldNumber:
  26117. v, ok := value.(float32)
  26118. if !ok {
  26119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26120. }
  26121. m.SetNumber(v)
  26122. return nil
  26123. case payrecharge.FieldStatus:
  26124. v, ok := value.(int)
  26125. if !ok {
  26126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26127. }
  26128. m.SetStatus(v)
  26129. return nil
  26130. case payrecharge.FieldMoney:
  26131. v, ok := value.(float32)
  26132. if !ok {
  26133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26134. }
  26135. m.SetMoney(v)
  26136. return nil
  26137. case payrecharge.FieldOutTradeNo:
  26138. v, ok := value.(string)
  26139. if !ok {
  26140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26141. }
  26142. m.SetOutTradeNo(v)
  26143. return nil
  26144. case payrecharge.FieldOrganizationID:
  26145. v, ok := value.(uint64)
  26146. if !ok {
  26147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26148. }
  26149. m.SetOrganizationID(v)
  26150. return nil
  26151. }
  26152. return fmt.Errorf("unknown PayRecharge field %s", name)
  26153. }
  26154. // AddedFields returns all numeric fields that were incremented/decremented during
  26155. // this mutation.
  26156. func (m *PayRechargeMutation) AddedFields() []string {
  26157. var fields []string
  26158. if m.addnumber != nil {
  26159. fields = append(fields, payrecharge.FieldNumber)
  26160. }
  26161. if m.addstatus != nil {
  26162. fields = append(fields, payrecharge.FieldStatus)
  26163. }
  26164. if m.addmoney != nil {
  26165. fields = append(fields, payrecharge.FieldMoney)
  26166. }
  26167. if m.addorganization_id != nil {
  26168. fields = append(fields, payrecharge.FieldOrganizationID)
  26169. }
  26170. return fields
  26171. }
  26172. // AddedField returns the numeric value that was incremented/decremented on a field
  26173. // with the given name. The second boolean return value indicates that this field
  26174. // was not set, or was not defined in the schema.
  26175. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  26176. switch name {
  26177. case payrecharge.FieldNumber:
  26178. return m.AddedNumber()
  26179. case payrecharge.FieldStatus:
  26180. return m.AddedStatus()
  26181. case payrecharge.FieldMoney:
  26182. return m.AddedMoney()
  26183. case payrecharge.FieldOrganizationID:
  26184. return m.AddedOrganizationID()
  26185. }
  26186. return nil, false
  26187. }
  26188. // AddField adds the value to the field with the given name. It returns an error if
  26189. // the field is not defined in the schema, or if the type mismatched the field
  26190. // type.
  26191. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  26192. switch name {
  26193. case payrecharge.FieldNumber:
  26194. v, ok := value.(float32)
  26195. if !ok {
  26196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26197. }
  26198. m.AddNumber(v)
  26199. return nil
  26200. case payrecharge.FieldStatus:
  26201. v, ok := value.(int)
  26202. if !ok {
  26203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26204. }
  26205. m.AddStatus(v)
  26206. return nil
  26207. case payrecharge.FieldMoney:
  26208. v, ok := value.(float32)
  26209. if !ok {
  26210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26211. }
  26212. m.AddMoney(v)
  26213. return nil
  26214. case payrecharge.FieldOrganizationID:
  26215. v, ok := value.(int64)
  26216. if !ok {
  26217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26218. }
  26219. m.AddOrganizationID(v)
  26220. return nil
  26221. }
  26222. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  26223. }
  26224. // ClearedFields returns all nullable fields that were cleared during this
  26225. // mutation.
  26226. func (m *PayRechargeMutation) ClearedFields() []string {
  26227. var fields []string
  26228. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  26229. fields = append(fields, payrecharge.FieldDeletedAt)
  26230. }
  26231. if m.FieldCleared(payrecharge.FieldStatus) {
  26232. fields = append(fields, payrecharge.FieldStatus)
  26233. }
  26234. if m.FieldCleared(payrecharge.FieldMoney) {
  26235. fields = append(fields, payrecharge.FieldMoney)
  26236. }
  26237. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  26238. fields = append(fields, payrecharge.FieldOutTradeNo)
  26239. }
  26240. return fields
  26241. }
  26242. // FieldCleared returns a boolean indicating if a field with the given name was
  26243. // cleared in this mutation.
  26244. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  26245. _, ok := m.clearedFields[name]
  26246. return ok
  26247. }
  26248. // ClearField clears the value of the field with the given name. It returns an
  26249. // error if the field is not defined in the schema.
  26250. func (m *PayRechargeMutation) ClearField(name string) error {
  26251. switch name {
  26252. case payrecharge.FieldDeletedAt:
  26253. m.ClearDeletedAt()
  26254. return nil
  26255. case payrecharge.FieldStatus:
  26256. m.ClearStatus()
  26257. return nil
  26258. case payrecharge.FieldMoney:
  26259. m.ClearMoney()
  26260. return nil
  26261. case payrecharge.FieldOutTradeNo:
  26262. m.ClearOutTradeNo()
  26263. return nil
  26264. }
  26265. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  26266. }
  26267. // ResetField resets all changes in the mutation for the field with the given name.
  26268. // It returns an error if the field is not defined in the schema.
  26269. func (m *PayRechargeMutation) ResetField(name string) error {
  26270. switch name {
  26271. case payrecharge.FieldCreatedAt:
  26272. m.ResetCreatedAt()
  26273. return nil
  26274. case payrecharge.FieldUpdatedAt:
  26275. m.ResetUpdatedAt()
  26276. return nil
  26277. case payrecharge.FieldDeletedAt:
  26278. m.ResetDeletedAt()
  26279. return nil
  26280. case payrecharge.FieldUserID:
  26281. m.ResetUserID()
  26282. return nil
  26283. case payrecharge.FieldNumber:
  26284. m.ResetNumber()
  26285. return nil
  26286. case payrecharge.FieldStatus:
  26287. m.ResetStatus()
  26288. return nil
  26289. case payrecharge.FieldMoney:
  26290. m.ResetMoney()
  26291. return nil
  26292. case payrecharge.FieldOutTradeNo:
  26293. m.ResetOutTradeNo()
  26294. return nil
  26295. case payrecharge.FieldOrganizationID:
  26296. m.ResetOrganizationID()
  26297. return nil
  26298. }
  26299. return fmt.Errorf("unknown PayRecharge field %s", name)
  26300. }
  26301. // AddedEdges returns all edge names that were set/added in this mutation.
  26302. func (m *PayRechargeMutation) AddedEdges() []string {
  26303. edges := make([]string, 0, 0)
  26304. return edges
  26305. }
  26306. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26307. // name in this mutation.
  26308. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  26309. return nil
  26310. }
  26311. // RemovedEdges returns all edge names that were removed in this mutation.
  26312. func (m *PayRechargeMutation) RemovedEdges() []string {
  26313. edges := make([]string, 0, 0)
  26314. return edges
  26315. }
  26316. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26317. // the given name in this mutation.
  26318. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  26319. return nil
  26320. }
  26321. // ClearedEdges returns all edge names that were cleared in this mutation.
  26322. func (m *PayRechargeMutation) ClearedEdges() []string {
  26323. edges := make([]string, 0, 0)
  26324. return edges
  26325. }
  26326. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26327. // was cleared in this mutation.
  26328. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  26329. return false
  26330. }
  26331. // ClearEdge clears the value of the edge with the given name. It returns an error
  26332. // if that edge is not defined in the schema.
  26333. func (m *PayRechargeMutation) ClearEdge(name string) error {
  26334. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  26335. }
  26336. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26337. // It returns an error if the edge is not defined in the schema.
  26338. func (m *PayRechargeMutation) ResetEdge(name string) error {
  26339. return fmt.Errorf("unknown PayRecharge edge %s", name)
  26340. }
  26341. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  26342. type ServerMutation struct {
  26343. config
  26344. op Op
  26345. typ string
  26346. id *uint64
  26347. created_at *time.Time
  26348. updated_at *time.Time
  26349. status *uint8
  26350. addstatus *int8
  26351. deleted_at *time.Time
  26352. name *string
  26353. public_ip *string
  26354. private_ip *string
  26355. admin_port *string
  26356. clearedFields map[string]struct{}
  26357. wxs map[uint64]struct{}
  26358. removedwxs map[uint64]struct{}
  26359. clearedwxs bool
  26360. done bool
  26361. oldValue func(context.Context) (*Server, error)
  26362. predicates []predicate.Server
  26363. }
  26364. var _ ent.Mutation = (*ServerMutation)(nil)
  26365. // serverOption allows management of the mutation configuration using functional options.
  26366. type serverOption func(*ServerMutation)
  26367. // newServerMutation creates new mutation for the Server entity.
  26368. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  26369. m := &ServerMutation{
  26370. config: c,
  26371. op: op,
  26372. typ: TypeServer,
  26373. clearedFields: make(map[string]struct{}),
  26374. }
  26375. for _, opt := range opts {
  26376. opt(m)
  26377. }
  26378. return m
  26379. }
  26380. // withServerID sets the ID field of the mutation.
  26381. func withServerID(id uint64) serverOption {
  26382. return func(m *ServerMutation) {
  26383. var (
  26384. err error
  26385. once sync.Once
  26386. value *Server
  26387. )
  26388. m.oldValue = func(ctx context.Context) (*Server, error) {
  26389. once.Do(func() {
  26390. if m.done {
  26391. err = errors.New("querying old values post mutation is not allowed")
  26392. } else {
  26393. value, err = m.Client().Server.Get(ctx, id)
  26394. }
  26395. })
  26396. return value, err
  26397. }
  26398. m.id = &id
  26399. }
  26400. }
  26401. // withServer sets the old Server of the mutation.
  26402. func withServer(node *Server) serverOption {
  26403. return func(m *ServerMutation) {
  26404. m.oldValue = func(context.Context) (*Server, error) {
  26405. return node, nil
  26406. }
  26407. m.id = &node.ID
  26408. }
  26409. }
  26410. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26411. // executed in a transaction (ent.Tx), a transactional client is returned.
  26412. func (m ServerMutation) Client() *Client {
  26413. client := &Client{config: m.config}
  26414. client.init()
  26415. return client
  26416. }
  26417. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26418. // it returns an error otherwise.
  26419. func (m ServerMutation) Tx() (*Tx, error) {
  26420. if _, ok := m.driver.(*txDriver); !ok {
  26421. return nil, errors.New("ent: mutation is not running in a transaction")
  26422. }
  26423. tx := &Tx{config: m.config}
  26424. tx.init()
  26425. return tx, nil
  26426. }
  26427. // SetID sets the value of the id field. Note that this
  26428. // operation is only accepted on creation of Server entities.
  26429. func (m *ServerMutation) SetID(id uint64) {
  26430. m.id = &id
  26431. }
  26432. // ID returns the ID value in the mutation. Note that the ID is only available
  26433. // if it was provided to the builder or after it was returned from the database.
  26434. func (m *ServerMutation) ID() (id uint64, exists bool) {
  26435. if m.id == nil {
  26436. return
  26437. }
  26438. return *m.id, true
  26439. }
  26440. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26441. // That means, if the mutation is applied within a transaction with an isolation level such
  26442. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26443. // or updated by the mutation.
  26444. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  26445. switch {
  26446. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26447. id, exists := m.ID()
  26448. if exists {
  26449. return []uint64{id}, nil
  26450. }
  26451. fallthrough
  26452. case m.op.Is(OpUpdate | OpDelete):
  26453. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  26454. default:
  26455. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26456. }
  26457. }
  26458. // SetCreatedAt sets the "created_at" field.
  26459. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  26460. m.created_at = &t
  26461. }
  26462. // CreatedAt returns the value of the "created_at" field in the mutation.
  26463. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  26464. v := m.created_at
  26465. if v == nil {
  26466. return
  26467. }
  26468. return *v, true
  26469. }
  26470. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  26471. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26473. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26474. if !m.op.Is(OpUpdateOne) {
  26475. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26476. }
  26477. if m.id == nil || m.oldValue == nil {
  26478. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26479. }
  26480. oldValue, err := m.oldValue(ctx)
  26481. if err != nil {
  26482. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26483. }
  26484. return oldValue.CreatedAt, nil
  26485. }
  26486. // ResetCreatedAt resets all changes to the "created_at" field.
  26487. func (m *ServerMutation) ResetCreatedAt() {
  26488. m.created_at = nil
  26489. }
  26490. // SetUpdatedAt sets the "updated_at" field.
  26491. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  26492. m.updated_at = &t
  26493. }
  26494. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26495. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  26496. v := m.updated_at
  26497. if v == nil {
  26498. return
  26499. }
  26500. return *v, true
  26501. }
  26502. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  26503. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26505. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26506. if !m.op.Is(OpUpdateOne) {
  26507. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26508. }
  26509. if m.id == nil || m.oldValue == nil {
  26510. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26511. }
  26512. oldValue, err := m.oldValue(ctx)
  26513. if err != nil {
  26514. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26515. }
  26516. return oldValue.UpdatedAt, nil
  26517. }
  26518. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26519. func (m *ServerMutation) ResetUpdatedAt() {
  26520. m.updated_at = nil
  26521. }
  26522. // SetStatus sets the "status" field.
  26523. func (m *ServerMutation) SetStatus(u uint8) {
  26524. m.status = &u
  26525. m.addstatus = nil
  26526. }
  26527. // Status returns the value of the "status" field in the mutation.
  26528. func (m *ServerMutation) Status() (r uint8, exists bool) {
  26529. v := m.status
  26530. if v == nil {
  26531. return
  26532. }
  26533. return *v, true
  26534. }
  26535. // OldStatus returns the old "status" field's value of the Server entity.
  26536. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26538. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26539. if !m.op.Is(OpUpdateOne) {
  26540. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26541. }
  26542. if m.id == nil || m.oldValue == nil {
  26543. return v, errors.New("OldStatus requires an ID field in the mutation")
  26544. }
  26545. oldValue, err := m.oldValue(ctx)
  26546. if err != nil {
  26547. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26548. }
  26549. return oldValue.Status, nil
  26550. }
  26551. // AddStatus adds u to the "status" field.
  26552. func (m *ServerMutation) AddStatus(u int8) {
  26553. if m.addstatus != nil {
  26554. *m.addstatus += u
  26555. } else {
  26556. m.addstatus = &u
  26557. }
  26558. }
  26559. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26560. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  26561. v := m.addstatus
  26562. if v == nil {
  26563. return
  26564. }
  26565. return *v, true
  26566. }
  26567. // ClearStatus clears the value of the "status" field.
  26568. func (m *ServerMutation) ClearStatus() {
  26569. m.status = nil
  26570. m.addstatus = nil
  26571. m.clearedFields[server.FieldStatus] = struct{}{}
  26572. }
  26573. // StatusCleared returns if the "status" field was cleared in this mutation.
  26574. func (m *ServerMutation) StatusCleared() bool {
  26575. _, ok := m.clearedFields[server.FieldStatus]
  26576. return ok
  26577. }
  26578. // ResetStatus resets all changes to the "status" field.
  26579. func (m *ServerMutation) ResetStatus() {
  26580. m.status = nil
  26581. m.addstatus = nil
  26582. delete(m.clearedFields, server.FieldStatus)
  26583. }
  26584. // SetDeletedAt sets the "deleted_at" field.
  26585. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  26586. m.deleted_at = &t
  26587. }
  26588. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26589. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  26590. v := m.deleted_at
  26591. if v == nil {
  26592. return
  26593. }
  26594. return *v, true
  26595. }
  26596. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  26597. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26599. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26600. if !m.op.Is(OpUpdateOne) {
  26601. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26602. }
  26603. if m.id == nil || m.oldValue == nil {
  26604. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26605. }
  26606. oldValue, err := m.oldValue(ctx)
  26607. if err != nil {
  26608. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26609. }
  26610. return oldValue.DeletedAt, nil
  26611. }
  26612. // ClearDeletedAt clears the value of the "deleted_at" field.
  26613. func (m *ServerMutation) ClearDeletedAt() {
  26614. m.deleted_at = nil
  26615. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  26616. }
  26617. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26618. func (m *ServerMutation) DeletedAtCleared() bool {
  26619. _, ok := m.clearedFields[server.FieldDeletedAt]
  26620. return ok
  26621. }
  26622. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26623. func (m *ServerMutation) ResetDeletedAt() {
  26624. m.deleted_at = nil
  26625. delete(m.clearedFields, server.FieldDeletedAt)
  26626. }
  26627. // SetName sets the "name" field.
  26628. func (m *ServerMutation) SetName(s string) {
  26629. m.name = &s
  26630. }
  26631. // Name returns the value of the "name" field in the mutation.
  26632. func (m *ServerMutation) Name() (r string, exists bool) {
  26633. v := m.name
  26634. if v == nil {
  26635. return
  26636. }
  26637. return *v, true
  26638. }
  26639. // OldName returns the old "name" field's value of the Server entity.
  26640. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26642. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  26643. if !m.op.Is(OpUpdateOne) {
  26644. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26645. }
  26646. if m.id == nil || m.oldValue == nil {
  26647. return v, errors.New("OldName requires an ID field in the mutation")
  26648. }
  26649. oldValue, err := m.oldValue(ctx)
  26650. if err != nil {
  26651. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26652. }
  26653. return oldValue.Name, nil
  26654. }
  26655. // ResetName resets all changes to the "name" field.
  26656. func (m *ServerMutation) ResetName() {
  26657. m.name = nil
  26658. }
  26659. // SetPublicIP sets the "public_ip" field.
  26660. func (m *ServerMutation) SetPublicIP(s string) {
  26661. m.public_ip = &s
  26662. }
  26663. // PublicIP returns the value of the "public_ip" field in the mutation.
  26664. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  26665. v := m.public_ip
  26666. if v == nil {
  26667. return
  26668. }
  26669. return *v, true
  26670. }
  26671. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  26672. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26674. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  26675. if !m.op.Is(OpUpdateOne) {
  26676. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  26677. }
  26678. if m.id == nil || m.oldValue == nil {
  26679. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  26680. }
  26681. oldValue, err := m.oldValue(ctx)
  26682. if err != nil {
  26683. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  26684. }
  26685. return oldValue.PublicIP, nil
  26686. }
  26687. // ResetPublicIP resets all changes to the "public_ip" field.
  26688. func (m *ServerMutation) ResetPublicIP() {
  26689. m.public_ip = nil
  26690. }
  26691. // SetPrivateIP sets the "private_ip" field.
  26692. func (m *ServerMutation) SetPrivateIP(s string) {
  26693. m.private_ip = &s
  26694. }
  26695. // PrivateIP returns the value of the "private_ip" field in the mutation.
  26696. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  26697. v := m.private_ip
  26698. if v == nil {
  26699. return
  26700. }
  26701. return *v, true
  26702. }
  26703. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  26704. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26706. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  26707. if !m.op.Is(OpUpdateOne) {
  26708. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  26709. }
  26710. if m.id == nil || m.oldValue == nil {
  26711. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  26712. }
  26713. oldValue, err := m.oldValue(ctx)
  26714. if err != nil {
  26715. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  26716. }
  26717. return oldValue.PrivateIP, nil
  26718. }
  26719. // ResetPrivateIP resets all changes to the "private_ip" field.
  26720. func (m *ServerMutation) ResetPrivateIP() {
  26721. m.private_ip = nil
  26722. }
  26723. // SetAdminPort sets the "admin_port" field.
  26724. func (m *ServerMutation) SetAdminPort(s string) {
  26725. m.admin_port = &s
  26726. }
  26727. // AdminPort returns the value of the "admin_port" field in the mutation.
  26728. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  26729. v := m.admin_port
  26730. if v == nil {
  26731. return
  26732. }
  26733. return *v, true
  26734. }
  26735. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  26736. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26738. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  26739. if !m.op.Is(OpUpdateOne) {
  26740. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  26741. }
  26742. if m.id == nil || m.oldValue == nil {
  26743. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  26744. }
  26745. oldValue, err := m.oldValue(ctx)
  26746. if err != nil {
  26747. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  26748. }
  26749. return oldValue.AdminPort, nil
  26750. }
  26751. // ResetAdminPort resets all changes to the "admin_port" field.
  26752. func (m *ServerMutation) ResetAdminPort() {
  26753. m.admin_port = nil
  26754. }
  26755. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  26756. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  26757. if m.wxs == nil {
  26758. m.wxs = make(map[uint64]struct{})
  26759. }
  26760. for i := range ids {
  26761. m.wxs[ids[i]] = struct{}{}
  26762. }
  26763. }
  26764. // ClearWxs clears the "wxs" edge to the Wx entity.
  26765. func (m *ServerMutation) ClearWxs() {
  26766. m.clearedwxs = true
  26767. }
  26768. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  26769. func (m *ServerMutation) WxsCleared() bool {
  26770. return m.clearedwxs
  26771. }
  26772. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  26773. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  26774. if m.removedwxs == nil {
  26775. m.removedwxs = make(map[uint64]struct{})
  26776. }
  26777. for i := range ids {
  26778. delete(m.wxs, ids[i])
  26779. m.removedwxs[ids[i]] = struct{}{}
  26780. }
  26781. }
  26782. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  26783. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  26784. for id := range m.removedwxs {
  26785. ids = append(ids, id)
  26786. }
  26787. return
  26788. }
  26789. // WxsIDs returns the "wxs" edge IDs in the mutation.
  26790. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  26791. for id := range m.wxs {
  26792. ids = append(ids, id)
  26793. }
  26794. return
  26795. }
  26796. // ResetWxs resets all changes to the "wxs" edge.
  26797. func (m *ServerMutation) ResetWxs() {
  26798. m.wxs = nil
  26799. m.clearedwxs = false
  26800. m.removedwxs = nil
  26801. }
  26802. // Where appends a list predicates to the ServerMutation builder.
  26803. func (m *ServerMutation) Where(ps ...predicate.Server) {
  26804. m.predicates = append(m.predicates, ps...)
  26805. }
  26806. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  26807. // users can use type-assertion to append predicates that do not depend on any generated package.
  26808. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  26809. p := make([]predicate.Server, len(ps))
  26810. for i := range ps {
  26811. p[i] = ps[i]
  26812. }
  26813. m.Where(p...)
  26814. }
  26815. // Op returns the operation name.
  26816. func (m *ServerMutation) Op() Op {
  26817. return m.op
  26818. }
  26819. // SetOp allows setting the mutation operation.
  26820. func (m *ServerMutation) SetOp(op Op) {
  26821. m.op = op
  26822. }
  26823. // Type returns the node type of this mutation (Server).
  26824. func (m *ServerMutation) Type() string {
  26825. return m.typ
  26826. }
  26827. // Fields returns all fields that were changed during this mutation. Note that in
  26828. // order to get all numeric fields that were incremented/decremented, call
  26829. // AddedFields().
  26830. func (m *ServerMutation) Fields() []string {
  26831. fields := make([]string, 0, 8)
  26832. if m.created_at != nil {
  26833. fields = append(fields, server.FieldCreatedAt)
  26834. }
  26835. if m.updated_at != nil {
  26836. fields = append(fields, server.FieldUpdatedAt)
  26837. }
  26838. if m.status != nil {
  26839. fields = append(fields, server.FieldStatus)
  26840. }
  26841. if m.deleted_at != nil {
  26842. fields = append(fields, server.FieldDeletedAt)
  26843. }
  26844. if m.name != nil {
  26845. fields = append(fields, server.FieldName)
  26846. }
  26847. if m.public_ip != nil {
  26848. fields = append(fields, server.FieldPublicIP)
  26849. }
  26850. if m.private_ip != nil {
  26851. fields = append(fields, server.FieldPrivateIP)
  26852. }
  26853. if m.admin_port != nil {
  26854. fields = append(fields, server.FieldAdminPort)
  26855. }
  26856. return fields
  26857. }
  26858. // Field returns the value of a field with the given name. The second boolean
  26859. // return value indicates that this field was not set, or was not defined in the
  26860. // schema.
  26861. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  26862. switch name {
  26863. case server.FieldCreatedAt:
  26864. return m.CreatedAt()
  26865. case server.FieldUpdatedAt:
  26866. return m.UpdatedAt()
  26867. case server.FieldStatus:
  26868. return m.Status()
  26869. case server.FieldDeletedAt:
  26870. return m.DeletedAt()
  26871. case server.FieldName:
  26872. return m.Name()
  26873. case server.FieldPublicIP:
  26874. return m.PublicIP()
  26875. case server.FieldPrivateIP:
  26876. return m.PrivateIP()
  26877. case server.FieldAdminPort:
  26878. return m.AdminPort()
  26879. }
  26880. return nil, false
  26881. }
  26882. // OldField returns the old value of the field from the database. An error is
  26883. // returned if the mutation operation is not UpdateOne, or the query to the
  26884. // database failed.
  26885. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26886. switch name {
  26887. case server.FieldCreatedAt:
  26888. return m.OldCreatedAt(ctx)
  26889. case server.FieldUpdatedAt:
  26890. return m.OldUpdatedAt(ctx)
  26891. case server.FieldStatus:
  26892. return m.OldStatus(ctx)
  26893. case server.FieldDeletedAt:
  26894. return m.OldDeletedAt(ctx)
  26895. case server.FieldName:
  26896. return m.OldName(ctx)
  26897. case server.FieldPublicIP:
  26898. return m.OldPublicIP(ctx)
  26899. case server.FieldPrivateIP:
  26900. return m.OldPrivateIP(ctx)
  26901. case server.FieldAdminPort:
  26902. return m.OldAdminPort(ctx)
  26903. }
  26904. return nil, fmt.Errorf("unknown Server field %s", name)
  26905. }
  26906. // SetField sets the value of a field with the given name. It returns an error if
  26907. // the field is not defined in the schema, or if the type mismatched the field
  26908. // type.
  26909. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  26910. switch name {
  26911. case server.FieldCreatedAt:
  26912. v, ok := value.(time.Time)
  26913. if !ok {
  26914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26915. }
  26916. m.SetCreatedAt(v)
  26917. return nil
  26918. case server.FieldUpdatedAt:
  26919. v, ok := value.(time.Time)
  26920. if !ok {
  26921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26922. }
  26923. m.SetUpdatedAt(v)
  26924. return nil
  26925. case server.FieldStatus:
  26926. v, ok := value.(uint8)
  26927. if !ok {
  26928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26929. }
  26930. m.SetStatus(v)
  26931. return nil
  26932. case server.FieldDeletedAt:
  26933. v, ok := value.(time.Time)
  26934. if !ok {
  26935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26936. }
  26937. m.SetDeletedAt(v)
  26938. return nil
  26939. case server.FieldName:
  26940. v, ok := value.(string)
  26941. if !ok {
  26942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26943. }
  26944. m.SetName(v)
  26945. return nil
  26946. case server.FieldPublicIP:
  26947. v, ok := value.(string)
  26948. if !ok {
  26949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26950. }
  26951. m.SetPublicIP(v)
  26952. return nil
  26953. case server.FieldPrivateIP:
  26954. v, ok := value.(string)
  26955. if !ok {
  26956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26957. }
  26958. m.SetPrivateIP(v)
  26959. return nil
  26960. case server.FieldAdminPort:
  26961. v, ok := value.(string)
  26962. if !ok {
  26963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26964. }
  26965. m.SetAdminPort(v)
  26966. return nil
  26967. }
  26968. return fmt.Errorf("unknown Server field %s", name)
  26969. }
  26970. // AddedFields returns all numeric fields that were incremented/decremented during
  26971. // this mutation.
  26972. func (m *ServerMutation) AddedFields() []string {
  26973. var fields []string
  26974. if m.addstatus != nil {
  26975. fields = append(fields, server.FieldStatus)
  26976. }
  26977. return fields
  26978. }
  26979. // AddedField returns the numeric value that was incremented/decremented on a field
  26980. // with the given name. The second boolean return value indicates that this field
  26981. // was not set, or was not defined in the schema.
  26982. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  26983. switch name {
  26984. case server.FieldStatus:
  26985. return m.AddedStatus()
  26986. }
  26987. return nil, false
  26988. }
  26989. // AddField adds the value to the field with the given name. It returns an error if
  26990. // the field is not defined in the schema, or if the type mismatched the field
  26991. // type.
  26992. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  26993. switch name {
  26994. case server.FieldStatus:
  26995. v, ok := value.(int8)
  26996. if !ok {
  26997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26998. }
  26999. m.AddStatus(v)
  27000. return nil
  27001. }
  27002. return fmt.Errorf("unknown Server numeric field %s", name)
  27003. }
  27004. // ClearedFields returns all nullable fields that were cleared during this
  27005. // mutation.
  27006. func (m *ServerMutation) ClearedFields() []string {
  27007. var fields []string
  27008. if m.FieldCleared(server.FieldStatus) {
  27009. fields = append(fields, server.FieldStatus)
  27010. }
  27011. if m.FieldCleared(server.FieldDeletedAt) {
  27012. fields = append(fields, server.FieldDeletedAt)
  27013. }
  27014. return fields
  27015. }
  27016. // FieldCleared returns a boolean indicating if a field with the given name was
  27017. // cleared in this mutation.
  27018. func (m *ServerMutation) FieldCleared(name string) bool {
  27019. _, ok := m.clearedFields[name]
  27020. return ok
  27021. }
  27022. // ClearField clears the value of the field with the given name. It returns an
  27023. // error if the field is not defined in the schema.
  27024. func (m *ServerMutation) ClearField(name string) error {
  27025. switch name {
  27026. case server.FieldStatus:
  27027. m.ClearStatus()
  27028. return nil
  27029. case server.FieldDeletedAt:
  27030. m.ClearDeletedAt()
  27031. return nil
  27032. }
  27033. return fmt.Errorf("unknown Server nullable field %s", name)
  27034. }
  27035. // ResetField resets all changes in the mutation for the field with the given name.
  27036. // It returns an error if the field is not defined in the schema.
  27037. func (m *ServerMutation) ResetField(name string) error {
  27038. switch name {
  27039. case server.FieldCreatedAt:
  27040. m.ResetCreatedAt()
  27041. return nil
  27042. case server.FieldUpdatedAt:
  27043. m.ResetUpdatedAt()
  27044. return nil
  27045. case server.FieldStatus:
  27046. m.ResetStatus()
  27047. return nil
  27048. case server.FieldDeletedAt:
  27049. m.ResetDeletedAt()
  27050. return nil
  27051. case server.FieldName:
  27052. m.ResetName()
  27053. return nil
  27054. case server.FieldPublicIP:
  27055. m.ResetPublicIP()
  27056. return nil
  27057. case server.FieldPrivateIP:
  27058. m.ResetPrivateIP()
  27059. return nil
  27060. case server.FieldAdminPort:
  27061. m.ResetAdminPort()
  27062. return nil
  27063. }
  27064. return fmt.Errorf("unknown Server field %s", name)
  27065. }
  27066. // AddedEdges returns all edge names that were set/added in this mutation.
  27067. func (m *ServerMutation) AddedEdges() []string {
  27068. edges := make([]string, 0, 1)
  27069. if m.wxs != nil {
  27070. edges = append(edges, server.EdgeWxs)
  27071. }
  27072. return edges
  27073. }
  27074. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27075. // name in this mutation.
  27076. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  27077. switch name {
  27078. case server.EdgeWxs:
  27079. ids := make([]ent.Value, 0, len(m.wxs))
  27080. for id := range m.wxs {
  27081. ids = append(ids, id)
  27082. }
  27083. return ids
  27084. }
  27085. return nil
  27086. }
  27087. // RemovedEdges returns all edge names that were removed in this mutation.
  27088. func (m *ServerMutation) RemovedEdges() []string {
  27089. edges := make([]string, 0, 1)
  27090. if m.removedwxs != nil {
  27091. edges = append(edges, server.EdgeWxs)
  27092. }
  27093. return edges
  27094. }
  27095. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27096. // the given name in this mutation.
  27097. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  27098. switch name {
  27099. case server.EdgeWxs:
  27100. ids := make([]ent.Value, 0, len(m.removedwxs))
  27101. for id := range m.removedwxs {
  27102. ids = append(ids, id)
  27103. }
  27104. return ids
  27105. }
  27106. return nil
  27107. }
  27108. // ClearedEdges returns all edge names that were cleared in this mutation.
  27109. func (m *ServerMutation) ClearedEdges() []string {
  27110. edges := make([]string, 0, 1)
  27111. if m.clearedwxs {
  27112. edges = append(edges, server.EdgeWxs)
  27113. }
  27114. return edges
  27115. }
  27116. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27117. // was cleared in this mutation.
  27118. func (m *ServerMutation) EdgeCleared(name string) bool {
  27119. switch name {
  27120. case server.EdgeWxs:
  27121. return m.clearedwxs
  27122. }
  27123. return false
  27124. }
  27125. // ClearEdge clears the value of the edge with the given name. It returns an error
  27126. // if that edge is not defined in the schema.
  27127. func (m *ServerMutation) ClearEdge(name string) error {
  27128. switch name {
  27129. }
  27130. return fmt.Errorf("unknown Server unique edge %s", name)
  27131. }
  27132. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27133. // It returns an error if the edge is not defined in the schema.
  27134. func (m *ServerMutation) ResetEdge(name string) error {
  27135. switch name {
  27136. case server.EdgeWxs:
  27137. m.ResetWxs()
  27138. return nil
  27139. }
  27140. return fmt.Errorf("unknown Server edge %s", name)
  27141. }
  27142. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  27143. type SopNodeMutation struct {
  27144. config
  27145. op Op
  27146. typ string
  27147. id *uint64
  27148. created_at *time.Time
  27149. updated_at *time.Time
  27150. status *uint8
  27151. addstatus *int8
  27152. deleted_at *time.Time
  27153. parent_id *uint64
  27154. addparent_id *int64
  27155. name *string
  27156. condition_type *int
  27157. addcondition_type *int
  27158. condition_list *[]string
  27159. appendcondition_list []string
  27160. no_reply_condition *uint64
  27161. addno_reply_condition *int64
  27162. no_reply_unit *string
  27163. action_message *[]custom_types.Action
  27164. appendaction_message []custom_types.Action
  27165. action_label_add *[]uint64
  27166. appendaction_label_add []uint64
  27167. action_label_del *[]uint64
  27168. appendaction_label_del []uint64
  27169. action_forward **custom_types.ActionForward
  27170. clearedFields map[string]struct{}
  27171. sop_stage *uint64
  27172. clearedsop_stage bool
  27173. node_messages map[uint64]struct{}
  27174. removednode_messages map[uint64]struct{}
  27175. clearednode_messages bool
  27176. done bool
  27177. oldValue func(context.Context) (*SopNode, error)
  27178. predicates []predicate.SopNode
  27179. }
  27180. var _ ent.Mutation = (*SopNodeMutation)(nil)
  27181. // sopnodeOption allows management of the mutation configuration using functional options.
  27182. type sopnodeOption func(*SopNodeMutation)
  27183. // newSopNodeMutation creates new mutation for the SopNode entity.
  27184. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  27185. m := &SopNodeMutation{
  27186. config: c,
  27187. op: op,
  27188. typ: TypeSopNode,
  27189. clearedFields: make(map[string]struct{}),
  27190. }
  27191. for _, opt := range opts {
  27192. opt(m)
  27193. }
  27194. return m
  27195. }
  27196. // withSopNodeID sets the ID field of the mutation.
  27197. func withSopNodeID(id uint64) sopnodeOption {
  27198. return func(m *SopNodeMutation) {
  27199. var (
  27200. err error
  27201. once sync.Once
  27202. value *SopNode
  27203. )
  27204. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  27205. once.Do(func() {
  27206. if m.done {
  27207. err = errors.New("querying old values post mutation is not allowed")
  27208. } else {
  27209. value, err = m.Client().SopNode.Get(ctx, id)
  27210. }
  27211. })
  27212. return value, err
  27213. }
  27214. m.id = &id
  27215. }
  27216. }
  27217. // withSopNode sets the old SopNode of the mutation.
  27218. func withSopNode(node *SopNode) sopnodeOption {
  27219. return func(m *SopNodeMutation) {
  27220. m.oldValue = func(context.Context) (*SopNode, error) {
  27221. return node, nil
  27222. }
  27223. m.id = &node.ID
  27224. }
  27225. }
  27226. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27227. // executed in a transaction (ent.Tx), a transactional client is returned.
  27228. func (m SopNodeMutation) Client() *Client {
  27229. client := &Client{config: m.config}
  27230. client.init()
  27231. return client
  27232. }
  27233. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27234. // it returns an error otherwise.
  27235. func (m SopNodeMutation) Tx() (*Tx, error) {
  27236. if _, ok := m.driver.(*txDriver); !ok {
  27237. return nil, errors.New("ent: mutation is not running in a transaction")
  27238. }
  27239. tx := &Tx{config: m.config}
  27240. tx.init()
  27241. return tx, nil
  27242. }
  27243. // SetID sets the value of the id field. Note that this
  27244. // operation is only accepted on creation of SopNode entities.
  27245. func (m *SopNodeMutation) SetID(id uint64) {
  27246. m.id = &id
  27247. }
  27248. // ID returns the ID value in the mutation. Note that the ID is only available
  27249. // if it was provided to the builder or after it was returned from the database.
  27250. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  27251. if m.id == nil {
  27252. return
  27253. }
  27254. return *m.id, true
  27255. }
  27256. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27257. // That means, if the mutation is applied within a transaction with an isolation level such
  27258. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27259. // or updated by the mutation.
  27260. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  27261. switch {
  27262. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27263. id, exists := m.ID()
  27264. if exists {
  27265. return []uint64{id}, nil
  27266. }
  27267. fallthrough
  27268. case m.op.Is(OpUpdate | OpDelete):
  27269. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  27270. default:
  27271. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27272. }
  27273. }
  27274. // SetCreatedAt sets the "created_at" field.
  27275. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  27276. m.created_at = &t
  27277. }
  27278. // CreatedAt returns the value of the "created_at" field in the mutation.
  27279. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  27280. v := m.created_at
  27281. if v == nil {
  27282. return
  27283. }
  27284. return *v, true
  27285. }
  27286. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  27287. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27289. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27290. if !m.op.Is(OpUpdateOne) {
  27291. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27292. }
  27293. if m.id == nil || m.oldValue == nil {
  27294. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27295. }
  27296. oldValue, err := m.oldValue(ctx)
  27297. if err != nil {
  27298. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27299. }
  27300. return oldValue.CreatedAt, nil
  27301. }
  27302. // ResetCreatedAt resets all changes to the "created_at" field.
  27303. func (m *SopNodeMutation) ResetCreatedAt() {
  27304. m.created_at = nil
  27305. }
  27306. // SetUpdatedAt sets the "updated_at" field.
  27307. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  27308. m.updated_at = &t
  27309. }
  27310. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27311. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  27312. v := m.updated_at
  27313. if v == nil {
  27314. return
  27315. }
  27316. return *v, true
  27317. }
  27318. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  27319. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27321. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27322. if !m.op.Is(OpUpdateOne) {
  27323. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27324. }
  27325. if m.id == nil || m.oldValue == nil {
  27326. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27327. }
  27328. oldValue, err := m.oldValue(ctx)
  27329. if err != nil {
  27330. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27331. }
  27332. return oldValue.UpdatedAt, nil
  27333. }
  27334. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27335. func (m *SopNodeMutation) ResetUpdatedAt() {
  27336. m.updated_at = nil
  27337. }
  27338. // SetStatus sets the "status" field.
  27339. func (m *SopNodeMutation) SetStatus(u uint8) {
  27340. m.status = &u
  27341. m.addstatus = nil
  27342. }
  27343. // Status returns the value of the "status" field in the mutation.
  27344. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  27345. v := m.status
  27346. if v == nil {
  27347. return
  27348. }
  27349. return *v, true
  27350. }
  27351. // OldStatus returns the old "status" field's value of the SopNode entity.
  27352. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27354. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27355. if !m.op.Is(OpUpdateOne) {
  27356. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27357. }
  27358. if m.id == nil || m.oldValue == nil {
  27359. return v, errors.New("OldStatus requires an ID field in the mutation")
  27360. }
  27361. oldValue, err := m.oldValue(ctx)
  27362. if err != nil {
  27363. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27364. }
  27365. return oldValue.Status, nil
  27366. }
  27367. // AddStatus adds u to the "status" field.
  27368. func (m *SopNodeMutation) AddStatus(u int8) {
  27369. if m.addstatus != nil {
  27370. *m.addstatus += u
  27371. } else {
  27372. m.addstatus = &u
  27373. }
  27374. }
  27375. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27376. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  27377. v := m.addstatus
  27378. if v == nil {
  27379. return
  27380. }
  27381. return *v, true
  27382. }
  27383. // ClearStatus clears the value of the "status" field.
  27384. func (m *SopNodeMutation) ClearStatus() {
  27385. m.status = nil
  27386. m.addstatus = nil
  27387. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  27388. }
  27389. // StatusCleared returns if the "status" field was cleared in this mutation.
  27390. func (m *SopNodeMutation) StatusCleared() bool {
  27391. _, ok := m.clearedFields[sopnode.FieldStatus]
  27392. return ok
  27393. }
  27394. // ResetStatus resets all changes to the "status" field.
  27395. func (m *SopNodeMutation) ResetStatus() {
  27396. m.status = nil
  27397. m.addstatus = nil
  27398. delete(m.clearedFields, sopnode.FieldStatus)
  27399. }
  27400. // SetDeletedAt sets the "deleted_at" field.
  27401. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  27402. m.deleted_at = &t
  27403. }
  27404. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27405. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  27406. v := m.deleted_at
  27407. if v == nil {
  27408. return
  27409. }
  27410. return *v, true
  27411. }
  27412. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  27413. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27415. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27416. if !m.op.Is(OpUpdateOne) {
  27417. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27418. }
  27419. if m.id == nil || m.oldValue == nil {
  27420. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27421. }
  27422. oldValue, err := m.oldValue(ctx)
  27423. if err != nil {
  27424. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27425. }
  27426. return oldValue.DeletedAt, nil
  27427. }
  27428. // ClearDeletedAt clears the value of the "deleted_at" field.
  27429. func (m *SopNodeMutation) ClearDeletedAt() {
  27430. m.deleted_at = nil
  27431. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  27432. }
  27433. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27434. func (m *SopNodeMutation) DeletedAtCleared() bool {
  27435. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  27436. return ok
  27437. }
  27438. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27439. func (m *SopNodeMutation) ResetDeletedAt() {
  27440. m.deleted_at = nil
  27441. delete(m.clearedFields, sopnode.FieldDeletedAt)
  27442. }
  27443. // SetStageID sets the "stage_id" field.
  27444. func (m *SopNodeMutation) SetStageID(u uint64) {
  27445. m.sop_stage = &u
  27446. }
  27447. // StageID returns the value of the "stage_id" field in the mutation.
  27448. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  27449. v := m.sop_stage
  27450. if v == nil {
  27451. return
  27452. }
  27453. return *v, true
  27454. }
  27455. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  27456. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27458. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  27459. if !m.op.Is(OpUpdateOne) {
  27460. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  27461. }
  27462. if m.id == nil || m.oldValue == nil {
  27463. return v, errors.New("OldStageID requires an ID field in the mutation")
  27464. }
  27465. oldValue, err := m.oldValue(ctx)
  27466. if err != nil {
  27467. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  27468. }
  27469. return oldValue.StageID, nil
  27470. }
  27471. // ResetStageID resets all changes to the "stage_id" field.
  27472. func (m *SopNodeMutation) ResetStageID() {
  27473. m.sop_stage = nil
  27474. }
  27475. // SetParentID sets the "parent_id" field.
  27476. func (m *SopNodeMutation) SetParentID(u uint64) {
  27477. m.parent_id = &u
  27478. m.addparent_id = nil
  27479. }
  27480. // ParentID returns the value of the "parent_id" field in the mutation.
  27481. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  27482. v := m.parent_id
  27483. if v == nil {
  27484. return
  27485. }
  27486. return *v, true
  27487. }
  27488. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  27489. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27491. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  27492. if !m.op.Is(OpUpdateOne) {
  27493. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  27494. }
  27495. if m.id == nil || m.oldValue == nil {
  27496. return v, errors.New("OldParentID requires an ID field in the mutation")
  27497. }
  27498. oldValue, err := m.oldValue(ctx)
  27499. if err != nil {
  27500. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  27501. }
  27502. return oldValue.ParentID, nil
  27503. }
  27504. // AddParentID adds u to the "parent_id" field.
  27505. func (m *SopNodeMutation) AddParentID(u int64) {
  27506. if m.addparent_id != nil {
  27507. *m.addparent_id += u
  27508. } else {
  27509. m.addparent_id = &u
  27510. }
  27511. }
  27512. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  27513. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  27514. v := m.addparent_id
  27515. if v == nil {
  27516. return
  27517. }
  27518. return *v, true
  27519. }
  27520. // ResetParentID resets all changes to the "parent_id" field.
  27521. func (m *SopNodeMutation) ResetParentID() {
  27522. m.parent_id = nil
  27523. m.addparent_id = nil
  27524. }
  27525. // SetName sets the "name" field.
  27526. func (m *SopNodeMutation) SetName(s string) {
  27527. m.name = &s
  27528. }
  27529. // Name returns the value of the "name" field in the mutation.
  27530. func (m *SopNodeMutation) Name() (r string, exists bool) {
  27531. v := m.name
  27532. if v == nil {
  27533. return
  27534. }
  27535. return *v, true
  27536. }
  27537. // OldName returns the old "name" field's value of the SopNode entity.
  27538. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27540. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  27541. if !m.op.Is(OpUpdateOne) {
  27542. return v, errors.New("OldName is only allowed on UpdateOne operations")
  27543. }
  27544. if m.id == nil || m.oldValue == nil {
  27545. return v, errors.New("OldName requires an ID field in the mutation")
  27546. }
  27547. oldValue, err := m.oldValue(ctx)
  27548. if err != nil {
  27549. return v, fmt.Errorf("querying old value for OldName: %w", err)
  27550. }
  27551. return oldValue.Name, nil
  27552. }
  27553. // ResetName resets all changes to the "name" field.
  27554. func (m *SopNodeMutation) ResetName() {
  27555. m.name = nil
  27556. }
  27557. // SetConditionType sets the "condition_type" field.
  27558. func (m *SopNodeMutation) SetConditionType(i int) {
  27559. m.condition_type = &i
  27560. m.addcondition_type = nil
  27561. }
  27562. // ConditionType returns the value of the "condition_type" field in the mutation.
  27563. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  27564. v := m.condition_type
  27565. if v == nil {
  27566. return
  27567. }
  27568. return *v, true
  27569. }
  27570. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  27571. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27573. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  27574. if !m.op.Is(OpUpdateOne) {
  27575. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  27576. }
  27577. if m.id == nil || m.oldValue == nil {
  27578. return v, errors.New("OldConditionType requires an ID field in the mutation")
  27579. }
  27580. oldValue, err := m.oldValue(ctx)
  27581. if err != nil {
  27582. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  27583. }
  27584. return oldValue.ConditionType, nil
  27585. }
  27586. // AddConditionType adds i to the "condition_type" field.
  27587. func (m *SopNodeMutation) AddConditionType(i int) {
  27588. if m.addcondition_type != nil {
  27589. *m.addcondition_type += i
  27590. } else {
  27591. m.addcondition_type = &i
  27592. }
  27593. }
  27594. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  27595. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  27596. v := m.addcondition_type
  27597. if v == nil {
  27598. return
  27599. }
  27600. return *v, true
  27601. }
  27602. // ResetConditionType resets all changes to the "condition_type" field.
  27603. func (m *SopNodeMutation) ResetConditionType() {
  27604. m.condition_type = nil
  27605. m.addcondition_type = nil
  27606. }
  27607. // SetConditionList sets the "condition_list" field.
  27608. func (m *SopNodeMutation) SetConditionList(s []string) {
  27609. m.condition_list = &s
  27610. m.appendcondition_list = nil
  27611. }
  27612. // ConditionList returns the value of the "condition_list" field in the mutation.
  27613. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  27614. v := m.condition_list
  27615. if v == nil {
  27616. return
  27617. }
  27618. return *v, true
  27619. }
  27620. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  27621. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27623. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  27624. if !m.op.Is(OpUpdateOne) {
  27625. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  27626. }
  27627. if m.id == nil || m.oldValue == nil {
  27628. return v, errors.New("OldConditionList requires an ID field in the mutation")
  27629. }
  27630. oldValue, err := m.oldValue(ctx)
  27631. if err != nil {
  27632. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  27633. }
  27634. return oldValue.ConditionList, nil
  27635. }
  27636. // AppendConditionList adds s to the "condition_list" field.
  27637. func (m *SopNodeMutation) AppendConditionList(s []string) {
  27638. m.appendcondition_list = append(m.appendcondition_list, s...)
  27639. }
  27640. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  27641. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  27642. if len(m.appendcondition_list) == 0 {
  27643. return nil, false
  27644. }
  27645. return m.appendcondition_list, true
  27646. }
  27647. // ClearConditionList clears the value of the "condition_list" field.
  27648. func (m *SopNodeMutation) ClearConditionList() {
  27649. m.condition_list = nil
  27650. m.appendcondition_list = nil
  27651. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  27652. }
  27653. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  27654. func (m *SopNodeMutation) ConditionListCleared() bool {
  27655. _, ok := m.clearedFields[sopnode.FieldConditionList]
  27656. return ok
  27657. }
  27658. // ResetConditionList resets all changes to the "condition_list" field.
  27659. func (m *SopNodeMutation) ResetConditionList() {
  27660. m.condition_list = nil
  27661. m.appendcondition_list = nil
  27662. delete(m.clearedFields, sopnode.FieldConditionList)
  27663. }
  27664. // SetNoReplyCondition sets the "no_reply_condition" field.
  27665. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  27666. m.no_reply_condition = &u
  27667. m.addno_reply_condition = nil
  27668. }
  27669. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  27670. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  27671. v := m.no_reply_condition
  27672. if v == nil {
  27673. return
  27674. }
  27675. return *v, true
  27676. }
  27677. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  27678. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27680. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  27681. if !m.op.Is(OpUpdateOne) {
  27682. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  27683. }
  27684. if m.id == nil || m.oldValue == nil {
  27685. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  27686. }
  27687. oldValue, err := m.oldValue(ctx)
  27688. if err != nil {
  27689. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  27690. }
  27691. return oldValue.NoReplyCondition, nil
  27692. }
  27693. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  27694. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  27695. if m.addno_reply_condition != nil {
  27696. *m.addno_reply_condition += u
  27697. } else {
  27698. m.addno_reply_condition = &u
  27699. }
  27700. }
  27701. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  27702. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  27703. v := m.addno_reply_condition
  27704. if v == nil {
  27705. return
  27706. }
  27707. return *v, true
  27708. }
  27709. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  27710. func (m *SopNodeMutation) ResetNoReplyCondition() {
  27711. m.no_reply_condition = nil
  27712. m.addno_reply_condition = nil
  27713. }
  27714. // SetNoReplyUnit sets the "no_reply_unit" field.
  27715. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  27716. m.no_reply_unit = &s
  27717. }
  27718. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  27719. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  27720. v := m.no_reply_unit
  27721. if v == nil {
  27722. return
  27723. }
  27724. return *v, true
  27725. }
  27726. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  27727. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27729. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  27730. if !m.op.Is(OpUpdateOne) {
  27731. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  27732. }
  27733. if m.id == nil || m.oldValue == nil {
  27734. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  27735. }
  27736. oldValue, err := m.oldValue(ctx)
  27737. if err != nil {
  27738. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  27739. }
  27740. return oldValue.NoReplyUnit, nil
  27741. }
  27742. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  27743. func (m *SopNodeMutation) ResetNoReplyUnit() {
  27744. m.no_reply_unit = nil
  27745. }
  27746. // SetActionMessage sets the "action_message" field.
  27747. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  27748. m.action_message = &ct
  27749. m.appendaction_message = nil
  27750. }
  27751. // ActionMessage returns the value of the "action_message" field in the mutation.
  27752. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  27753. v := m.action_message
  27754. if v == nil {
  27755. return
  27756. }
  27757. return *v, true
  27758. }
  27759. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  27760. // If the SopNode 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 *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  27763. if !m.op.Is(OpUpdateOne) {
  27764. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  27765. }
  27766. if m.id == nil || m.oldValue == nil {
  27767. return v, errors.New("OldActionMessage 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 OldActionMessage: %w", err)
  27772. }
  27773. return oldValue.ActionMessage, nil
  27774. }
  27775. // AppendActionMessage adds ct to the "action_message" field.
  27776. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  27777. m.appendaction_message = append(m.appendaction_message, ct...)
  27778. }
  27779. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  27780. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  27781. if len(m.appendaction_message) == 0 {
  27782. return nil, false
  27783. }
  27784. return m.appendaction_message, true
  27785. }
  27786. // ClearActionMessage clears the value of the "action_message" field.
  27787. func (m *SopNodeMutation) ClearActionMessage() {
  27788. m.action_message = nil
  27789. m.appendaction_message = nil
  27790. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  27791. }
  27792. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  27793. func (m *SopNodeMutation) ActionMessageCleared() bool {
  27794. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  27795. return ok
  27796. }
  27797. // ResetActionMessage resets all changes to the "action_message" field.
  27798. func (m *SopNodeMutation) ResetActionMessage() {
  27799. m.action_message = nil
  27800. m.appendaction_message = nil
  27801. delete(m.clearedFields, sopnode.FieldActionMessage)
  27802. }
  27803. // SetActionLabelAdd sets the "action_label_add" field.
  27804. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  27805. m.action_label_add = &u
  27806. m.appendaction_label_add = nil
  27807. }
  27808. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  27809. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  27810. v := m.action_label_add
  27811. if v == nil {
  27812. return
  27813. }
  27814. return *v, true
  27815. }
  27816. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  27817. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27819. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  27820. if !m.op.Is(OpUpdateOne) {
  27821. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  27822. }
  27823. if m.id == nil || m.oldValue == nil {
  27824. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  27825. }
  27826. oldValue, err := m.oldValue(ctx)
  27827. if err != nil {
  27828. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  27829. }
  27830. return oldValue.ActionLabelAdd, nil
  27831. }
  27832. // AppendActionLabelAdd adds u to the "action_label_add" field.
  27833. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  27834. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  27835. }
  27836. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  27837. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  27838. if len(m.appendaction_label_add) == 0 {
  27839. return nil, false
  27840. }
  27841. return m.appendaction_label_add, true
  27842. }
  27843. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  27844. func (m *SopNodeMutation) ClearActionLabelAdd() {
  27845. m.action_label_add = nil
  27846. m.appendaction_label_add = nil
  27847. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  27848. }
  27849. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  27850. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  27851. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  27852. return ok
  27853. }
  27854. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  27855. func (m *SopNodeMutation) ResetActionLabelAdd() {
  27856. m.action_label_add = nil
  27857. m.appendaction_label_add = nil
  27858. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  27859. }
  27860. // SetActionLabelDel sets the "action_label_del" field.
  27861. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  27862. m.action_label_del = &u
  27863. m.appendaction_label_del = nil
  27864. }
  27865. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  27866. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  27867. v := m.action_label_del
  27868. if v == nil {
  27869. return
  27870. }
  27871. return *v, true
  27872. }
  27873. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  27874. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27876. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  27877. if !m.op.Is(OpUpdateOne) {
  27878. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  27879. }
  27880. if m.id == nil || m.oldValue == nil {
  27881. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  27882. }
  27883. oldValue, err := m.oldValue(ctx)
  27884. if err != nil {
  27885. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  27886. }
  27887. return oldValue.ActionLabelDel, nil
  27888. }
  27889. // AppendActionLabelDel adds u to the "action_label_del" field.
  27890. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  27891. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  27892. }
  27893. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  27894. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  27895. if len(m.appendaction_label_del) == 0 {
  27896. return nil, false
  27897. }
  27898. return m.appendaction_label_del, true
  27899. }
  27900. // ClearActionLabelDel clears the value of the "action_label_del" field.
  27901. func (m *SopNodeMutation) ClearActionLabelDel() {
  27902. m.action_label_del = nil
  27903. m.appendaction_label_del = nil
  27904. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  27905. }
  27906. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  27907. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  27908. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  27909. return ok
  27910. }
  27911. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  27912. func (m *SopNodeMutation) ResetActionLabelDel() {
  27913. m.action_label_del = nil
  27914. m.appendaction_label_del = nil
  27915. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  27916. }
  27917. // SetActionForward sets the "action_forward" field.
  27918. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  27919. m.action_forward = &ctf
  27920. }
  27921. // ActionForward returns the value of the "action_forward" field in the mutation.
  27922. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  27923. v := m.action_forward
  27924. if v == nil {
  27925. return
  27926. }
  27927. return *v, true
  27928. }
  27929. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  27930. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27932. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  27933. if !m.op.Is(OpUpdateOne) {
  27934. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  27935. }
  27936. if m.id == nil || m.oldValue == nil {
  27937. return v, errors.New("OldActionForward requires an ID field in the mutation")
  27938. }
  27939. oldValue, err := m.oldValue(ctx)
  27940. if err != nil {
  27941. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  27942. }
  27943. return oldValue.ActionForward, nil
  27944. }
  27945. // ClearActionForward clears the value of the "action_forward" field.
  27946. func (m *SopNodeMutation) ClearActionForward() {
  27947. m.action_forward = nil
  27948. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  27949. }
  27950. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  27951. func (m *SopNodeMutation) ActionForwardCleared() bool {
  27952. _, ok := m.clearedFields[sopnode.FieldActionForward]
  27953. return ok
  27954. }
  27955. // ResetActionForward resets all changes to the "action_forward" field.
  27956. func (m *SopNodeMutation) ResetActionForward() {
  27957. m.action_forward = nil
  27958. delete(m.clearedFields, sopnode.FieldActionForward)
  27959. }
  27960. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  27961. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  27962. m.sop_stage = &id
  27963. }
  27964. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  27965. func (m *SopNodeMutation) ClearSopStage() {
  27966. m.clearedsop_stage = true
  27967. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  27968. }
  27969. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  27970. func (m *SopNodeMutation) SopStageCleared() bool {
  27971. return m.clearedsop_stage
  27972. }
  27973. // SopStageID returns the "sop_stage" edge ID in the mutation.
  27974. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  27975. if m.sop_stage != nil {
  27976. return *m.sop_stage, true
  27977. }
  27978. return
  27979. }
  27980. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  27981. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27982. // SopStageID instead. It exists only for internal usage by the builders.
  27983. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  27984. if id := m.sop_stage; id != nil {
  27985. ids = append(ids, *id)
  27986. }
  27987. return
  27988. }
  27989. // ResetSopStage resets all changes to the "sop_stage" edge.
  27990. func (m *SopNodeMutation) ResetSopStage() {
  27991. m.sop_stage = nil
  27992. m.clearedsop_stage = false
  27993. }
  27994. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  27995. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  27996. if m.node_messages == nil {
  27997. m.node_messages = make(map[uint64]struct{})
  27998. }
  27999. for i := range ids {
  28000. m.node_messages[ids[i]] = struct{}{}
  28001. }
  28002. }
  28003. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  28004. func (m *SopNodeMutation) ClearNodeMessages() {
  28005. m.clearednode_messages = true
  28006. }
  28007. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  28008. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  28009. return m.clearednode_messages
  28010. }
  28011. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  28012. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  28013. if m.removednode_messages == nil {
  28014. m.removednode_messages = make(map[uint64]struct{})
  28015. }
  28016. for i := range ids {
  28017. delete(m.node_messages, ids[i])
  28018. m.removednode_messages[ids[i]] = struct{}{}
  28019. }
  28020. }
  28021. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  28022. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  28023. for id := range m.removednode_messages {
  28024. ids = append(ids, id)
  28025. }
  28026. return
  28027. }
  28028. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  28029. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  28030. for id := range m.node_messages {
  28031. ids = append(ids, id)
  28032. }
  28033. return
  28034. }
  28035. // ResetNodeMessages resets all changes to the "node_messages" edge.
  28036. func (m *SopNodeMutation) ResetNodeMessages() {
  28037. m.node_messages = nil
  28038. m.clearednode_messages = false
  28039. m.removednode_messages = nil
  28040. }
  28041. // Where appends a list predicates to the SopNodeMutation builder.
  28042. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  28043. m.predicates = append(m.predicates, ps...)
  28044. }
  28045. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  28046. // users can use type-assertion to append predicates that do not depend on any generated package.
  28047. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  28048. p := make([]predicate.SopNode, len(ps))
  28049. for i := range ps {
  28050. p[i] = ps[i]
  28051. }
  28052. m.Where(p...)
  28053. }
  28054. // Op returns the operation name.
  28055. func (m *SopNodeMutation) Op() Op {
  28056. return m.op
  28057. }
  28058. // SetOp allows setting the mutation operation.
  28059. func (m *SopNodeMutation) SetOp(op Op) {
  28060. m.op = op
  28061. }
  28062. // Type returns the node type of this mutation (SopNode).
  28063. func (m *SopNodeMutation) Type() string {
  28064. return m.typ
  28065. }
  28066. // Fields returns all fields that were changed during this mutation. Note that in
  28067. // order to get all numeric fields that were incremented/decremented, call
  28068. // AddedFields().
  28069. func (m *SopNodeMutation) Fields() []string {
  28070. fields := make([]string, 0, 15)
  28071. if m.created_at != nil {
  28072. fields = append(fields, sopnode.FieldCreatedAt)
  28073. }
  28074. if m.updated_at != nil {
  28075. fields = append(fields, sopnode.FieldUpdatedAt)
  28076. }
  28077. if m.status != nil {
  28078. fields = append(fields, sopnode.FieldStatus)
  28079. }
  28080. if m.deleted_at != nil {
  28081. fields = append(fields, sopnode.FieldDeletedAt)
  28082. }
  28083. if m.sop_stage != nil {
  28084. fields = append(fields, sopnode.FieldStageID)
  28085. }
  28086. if m.parent_id != nil {
  28087. fields = append(fields, sopnode.FieldParentID)
  28088. }
  28089. if m.name != nil {
  28090. fields = append(fields, sopnode.FieldName)
  28091. }
  28092. if m.condition_type != nil {
  28093. fields = append(fields, sopnode.FieldConditionType)
  28094. }
  28095. if m.condition_list != nil {
  28096. fields = append(fields, sopnode.FieldConditionList)
  28097. }
  28098. if m.no_reply_condition != nil {
  28099. fields = append(fields, sopnode.FieldNoReplyCondition)
  28100. }
  28101. if m.no_reply_unit != nil {
  28102. fields = append(fields, sopnode.FieldNoReplyUnit)
  28103. }
  28104. if m.action_message != nil {
  28105. fields = append(fields, sopnode.FieldActionMessage)
  28106. }
  28107. if m.action_label_add != nil {
  28108. fields = append(fields, sopnode.FieldActionLabelAdd)
  28109. }
  28110. if m.action_label_del != nil {
  28111. fields = append(fields, sopnode.FieldActionLabelDel)
  28112. }
  28113. if m.action_forward != nil {
  28114. fields = append(fields, sopnode.FieldActionForward)
  28115. }
  28116. return fields
  28117. }
  28118. // Field returns the value of a field with the given name. The second boolean
  28119. // return value indicates that this field was not set, or was not defined in the
  28120. // schema.
  28121. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  28122. switch name {
  28123. case sopnode.FieldCreatedAt:
  28124. return m.CreatedAt()
  28125. case sopnode.FieldUpdatedAt:
  28126. return m.UpdatedAt()
  28127. case sopnode.FieldStatus:
  28128. return m.Status()
  28129. case sopnode.FieldDeletedAt:
  28130. return m.DeletedAt()
  28131. case sopnode.FieldStageID:
  28132. return m.StageID()
  28133. case sopnode.FieldParentID:
  28134. return m.ParentID()
  28135. case sopnode.FieldName:
  28136. return m.Name()
  28137. case sopnode.FieldConditionType:
  28138. return m.ConditionType()
  28139. case sopnode.FieldConditionList:
  28140. return m.ConditionList()
  28141. case sopnode.FieldNoReplyCondition:
  28142. return m.NoReplyCondition()
  28143. case sopnode.FieldNoReplyUnit:
  28144. return m.NoReplyUnit()
  28145. case sopnode.FieldActionMessage:
  28146. return m.ActionMessage()
  28147. case sopnode.FieldActionLabelAdd:
  28148. return m.ActionLabelAdd()
  28149. case sopnode.FieldActionLabelDel:
  28150. return m.ActionLabelDel()
  28151. case sopnode.FieldActionForward:
  28152. return m.ActionForward()
  28153. }
  28154. return nil, false
  28155. }
  28156. // OldField returns the old value of the field from the database. An error is
  28157. // returned if the mutation operation is not UpdateOne, or the query to the
  28158. // database failed.
  28159. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28160. switch name {
  28161. case sopnode.FieldCreatedAt:
  28162. return m.OldCreatedAt(ctx)
  28163. case sopnode.FieldUpdatedAt:
  28164. return m.OldUpdatedAt(ctx)
  28165. case sopnode.FieldStatus:
  28166. return m.OldStatus(ctx)
  28167. case sopnode.FieldDeletedAt:
  28168. return m.OldDeletedAt(ctx)
  28169. case sopnode.FieldStageID:
  28170. return m.OldStageID(ctx)
  28171. case sopnode.FieldParentID:
  28172. return m.OldParentID(ctx)
  28173. case sopnode.FieldName:
  28174. return m.OldName(ctx)
  28175. case sopnode.FieldConditionType:
  28176. return m.OldConditionType(ctx)
  28177. case sopnode.FieldConditionList:
  28178. return m.OldConditionList(ctx)
  28179. case sopnode.FieldNoReplyCondition:
  28180. return m.OldNoReplyCondition(ctx)
  28181. case sopnode.FieldNoReplyUnit:
  28182. return m.OldNoReplyUnit(ctx)
  28183. case sopnode.FieldActionMessage:
  28184. return m.OldActionMessage(ctx)
  28185. case sopnode.FieldActionLabelAdd:
  28186. return m.OldActionLabelAdd(ctx)
  28187. case sopnode.FieldActionLabelDel:
  28188. return m.OldActionLabelDel(ctx)
  28189. case sopnode.FieldActionForward:
  28190. return m.OldActionForward(ctx)
  28191. }
  28192. return nil, fmt.Errorf("unknown SopNode field %s", name)
  28193. }
  28194. // SetField sets the value of a field with the given name. It returns an error if
  28195. // the field is not defined in the schema, or if the type mismatched the field
  28196. // type.
  28197. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  28198. switch name {
  28199. case sopnode.FieldCreatedAt:
  28200. v, ok := value.(time.Time)
  28201. if !ok {
  28202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28203. }
  28204. m.SetCreatedAt(v)
  28205. return nil
  28206. case sopnode.FieldUpdatedAt:
  28207. v, ok := value.(time.Time)
  28208. if !ok {
  28209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28210. }
  28211. m.SetUpdatedAt(v)
  28212. return nil
  28213. case sopnode.FieldStatus:
  28214. v, ok := value.(uint8)
  28215. if !ok {
  28216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28217. }
  28218. m.SetStatus(v)
  28219. return nil
  28220. case sopnode.FieldDeletedAt:
  28221. v, ok := value.(time.Time)
  28222. if !ok {
  28223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28224. }
  28225. m.SetDeletedAt(v)
  28226. return nil
  28227. case sopnode.FieldStageID:
  28228. v, ok := value.(uint64)
  28229. if !ok {
  28230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28231. }
  28232. m.SetStageID(v)
  28233. return nil
  28234. case sopnode.FieldParentID:
  28235. v, ok := value.(uint64)
  28236. if !ok {
  28237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28238. }
  28239. m.SetParentID(v)
  28240. return nil
  28241. case sopnode.FieldName:
  28242. v, ok := value.(string)
  28243. if !ok {
  28244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28245. }
  28246. m.SetName(v)
  28247. return nil
  28248. case sopnode.FieldConditionType:
  28249. v, ok := value.(int)
  28250. if !ok {
  28251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28252. }
  28253. m.SetConditionType(v)
  28254. return nil
  28255. case sopnode.FieldConditionList:
  28256. v, ok := value.([]string)
  28257. if !ok {
  28258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28259. }
  28260. m.SetConditionList(v)
  28261. return nil
  28262. case sopnode.FieldNoReplyCondition:
  28263. v, ok := value.(uint64)
  28264. if !ok {
  28265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28266. }
  28267. m.SetNoReplyCondition(v)
  28268. return nil
  28269. case sopnode.FieldNoReplyUnit:
  28270. v, ok := value.(string)
  28271. if !ok {
  28272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28273. }
  28274. m.SetNoReplyUnit(v)
  28275. return nil
  28276. case sopnode.FieldActionMessage:
  28277. v, ok := value.([]custom_types.Action)
  28278. if !ok {
  28279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28280. }
  28281. m.SetActionMessage(v)
  28282. return nil
  28283. case sopnode.FieldActionLabelAdd:
  28284. v, ok := value.([]uint64)
  28285. if !ok {
  28286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28287. }
  28288. m.SetActionLabelAdd(v)
  28289. return nil
  28290. case sopnode.FieldActionLabelDel:
  28291. v, ok := value.([]uint64)
  28292. if !ok {
  28293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28294. }
  28295. m.SetActionLabelDel(v)
  28296. return nil
  28297. case sopnode.FieldActionForward:
  28298. v, ok := value.(*custom_types.ActionForward)
  28299. if !ok {
  28300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28301. }
  28302. m.SetActionForward(v)
  28303. return nil
  28304. }
  28305. return fmt.Errorf("unknown SopNode field %s", name)
  28306. }
  28307. // AddedFields returns all numeric fields that were incremented/decremented during
  28308. // this mutation.
  28309. func (m *SopNodeMutation) AddedFields() []string {
  28310. var fields []string
  28311. if m.addstatus != nil {
  28312. fields = append(fields, sopnode.FieldStatus)
  28313. }
  28314. if m.addparent_id != nil {
  28315. fields = append(fields, sopnode.FieldParentID)
  28316. }
  28317. if m.addcondition_type != nil {
  28318. fields = append(fields, sopnode.FieldConditionType)
  28319. }
  28320. if m.addno_reply_condition != nil {
  28321. fields = append(fields, sopnode.FieldNoReplyCondition)
  28322. }
  28323. return fields
  28324. }
  28325. // AddedField returns the numeric value that was incremented/decremented on a field
  28326. // with the given name. The second boolean return value indicates that this field
  28327. // was not set, or was not defined in the schema.
  28328. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  28329. switch name {
  28330. case sopnode.FieldStatus:
  28331. return m.AddedStatus()
  28332. case sopnode.FieldParentID:
  28333. return m.AddedParentID()
  28334. case sopnode.FieldConditionType:
  28335. return m.AddedConditionType()
  28336. case sopnode.FieldNoReplyCondition:
  28337. return m.AddedNoReplyCondition()
  28338. }
  28339. return nil, false
  28340. }
  28341. // AddField adds the value to the field with the given name. It returns an error if
  28342. // the field is not defined in the schema, or if the type mismatched the field
  28343. // type.
  28344. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  28345. switch name {
  28346. case sopnode.FieldStatus:
  28347. v, ok := value.(int8)
  28348. if !ok {
  28349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28350. }
  28351. m.AddStatus(v)
  28352. return nil
  28353. case sopnode.FieldParentID:
  28354. v, ok := value.(int64)
  28355. if !ok {
  28356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28357. }
  28358. m.AddParentID(v)
  28359. return nil
  28360. case sopnode.FieldConditionType:
  28361. v, ok := value.(int)
  28362. if !ok {
  28363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28364. }
  28365. m.AddConditionType(v)
  28366. return nil
  28367. case sopnode.FieldNoReplyCondition:
  28368. v, ok := value.(int64)
  28369. if !ok {
  28370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28371. }
  28372. m.AddNoReplyCondition(v)
  28373. return nil
  28374. }
  28375. return fmt.Errorf("unknown SopNode numeric field %s", name)
  28376. }
  28377. // ClearedFields returns all nullable fields that were cleared during this
  28378. // mutation.
  28379. func (m *SopNodeMutation) ClearedFields() []string {
  28380. var fields []string
  28381. if m.FieldCleared(sopnode.FieldStatus) {
  28382. fields = append(fields, sopnode.FieldStatus)
  28383. }
  28384. if m.FieldCleared(sopnode.FieldDeletedAt) {
  28385. fields = append(fields, sopnode.FieldDeletedAt)
  28386. }
  28387. if m.FieldCleared(sopnode.FieldConditionList) {
  28388. fields = append(fields, sopnode.FieldConditionList)
  28389. }
  28390. if m.FieldCleared(sopnode.FieldActionMessage) {
  28391. fields = append(fields, sopnode.FieldActionMessage)
  28392. }
  28393. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  28394. fields = append(fields, sopnode.FieldActionLabelAdd)
  28395. }
  28396. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  28397. fields = append(fields, sopnode.FieldActionLabelDel)
  28398. }
  28399. if m.FieldCleared(sopnode.FieldActionForward) {
  28400. fields = append(fields, sopnode.FieldActionForward)
  28401. }
  28402. return fields
  28403. }
  28404. // FieldCleared returns a boolean indicating if a field with the given name was
  28405. // cleared in this mutation.
  28406. func (m *SopNodeMutation) FieldCleared(name string) bool {
  28407. _, ok := m.clearedFields[name]
  28408. return ok
  28409. }
  28410. // ClearField clears the value of the field with the given name. It returns an
  28411. // error if the field is not defined in the schema.
  28412. func (m *SopNodeMutation) ClearField(name string) error {
  28413. switch name {
  28414. case sopnode.FieldStatus:
  28415. m.ClearStatus()
  28416. return nil
  28417. case sopnode.FieldDeletedAt:
  28418. m.ClearDeletedAt()
  28419. return nil
  28420. case sopnode.FieldConditionList:
  28421. m.ClearConditionList()
  28422. return nil
  28423. case sopnode.FieldActionMessage:
  28424. m.ClearActionMessage()
  28425. return nil
  28426. case sopnode.FieldActionLabelAdd:
  28427. m.ClearActionLabelAdd()
  28428. return nil
  28429. case sopnode.FieldActionLabelDel:
  28430. m.ClearActionLabelDel()
  28431. return nil
  28432. case sopnode.FieldActionForward:
  28433. m.ClearActionForward()
  28434. return nil
  28435. }
  28436. return fmt.Errorf("unknown SopNode nullable field %s", name)
  28437. }
  28438. // ResetField resets all changes in the mutation for the field with the given name.
  28439. // It returns an error if the field is not defined in the schema.
  28440. func (m *SopNodeMutation) ResetField(name string) error {
  28441. switch name {
  28442. case sopnode.FieldCreatedAt:
  28443. m.ResetCreatedAt()
  28444. return nil
  28445. case sopnode.FieldUpdatedAt:
  28446. m.ResetUpdatedAt()
  28447. return nil
  28448. case sopnode.FieldStatus:
  28449. m.ResetStatus()
  28450. return nil
  28451. case sopnode.FieldDeletedAt:
  28452. m.ResetDeletedAt()
  28453. return nil
  28454. case sopnode.FieldStageID:
  28455. m.ResetStageID()
  28456. return nil
  28457. case sopnode.FieldParentID:
  28458. m.ResetParentID()
  28459. return nil
  28460. case sopnode.FieldName:
  28461. m.ResetName()
  28462. return nil
  28463. case sopnode.FieldConditionType:
  28464. m.ResetConditionType()
  28465. return nil
  28466. case sopnode.FieldConditionList:
  28467. m.ResetConditionList()
  28468. return nil
  28469. case sopnode.FieldNoReplyCondition:
  28470. m.ResetNoReplyCondition()
  28471. return nil
  28472. case sopnode.FieldNoReplyUnit:
  28473. m.ResetNoReplyUnit()
  28474. return nil
  28475. case sopnode.FieldActionMessage:
  28476. m.ResetActionMessage()
  28477. return nil
  28478. case sopnode.FieldActionLabelAdd:
  28479. m.ResetActionLabelAdd()
  28480. return nil
  28481. case sopnode.FieldActionLabelDel:
  28482. m.ResetActionLabelDel()
  28483. return nil
  28484. case sopnode.FieldActionForward:
  28485. m.ResetActionForward()
  28486. return nil
  28487. }
  28488. return fmt.Errorf("unknown SopNode field %s", name)
  28489. }
  28490. // AddedEdges returns all edge names that were set/added in this mutation.
  28491. func (m *SopNodeMutation) AddedEdges() []string {
  28492. edges := make([]string, 0, 2)
  28493. if m.sop_stage != nil {
  28494. edges = append(edges, sopnode.EdgeSopStage)
  28495. }
  28496. if m.node_messages != nil {
  28497. edges = append(edges, sopnode.EdgeNodeMessages)
  28498. }
  28499. return edges
  28500. }
  28501. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28502. // name in this mutation.
  28503. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  28504. switch name {
  28505. case sopnode.EdgeSopStage:
  28506. if id := m.sop_stage; id != nil {
  28507. return []ent.Value{*id}
  28508. }
  28509. case sopnode.EdgeNodeMessages:
  28510. ids := make([]ent.Value, 0, len(m.node_messages))
  28511. for id := range m.node_messages {
  28512. ids = append(ids, id)
  28513. }
  28514. return ids
  28515. }
  28516. return nil
  28517. }
  28518. // RemovedEdges returns all edge names that were removed in this mutation.
  28519. func (m *SopNodeMutation) RemovedEdges() []string {
  28520. edges := make([]string, 0, 2)
  28521. if m.removednode_messages != nil {
  28522. edges = append(edges, sopnode.EdgeNodeMessages)
  28523. }
  28524. return edges
  28525. }
  28526. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28527. // the given name in this mutation.
  28528. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  28529. switch name {
  28530. case sopnode.EdgeNodeMessages:
  28531. ids := make([]ent.Value, 0, len(m.removednode_messages))
  28532. for id := range m.removednode_messages {
  28533. ids = append(ids, id)
  28534. }
  28535. return ids
  28536. }
  28537. return nil
  28538. }
  28539. // ClearedEdges returns all edge names that were cleared in this mutation.
  28540. func (m *SopNodeMutation) ClearedEdges() []string {
  28541. edges := make([]string, 0, 2)
  28542. if m.clearedsop_stage {
  28543. edges = append(edges, sopnode.EdgeSopStage)
  28544. }
  28545. if m.clearednode_messages {
  28546. edges = append(edges, sopnode.EdgeNodeMessages)
  28547. }
  28548. return edges
  28549. }
  28550. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28551. // was cleared in this mutation.
  28552. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  28553. switch name {
  28554. case sopnode.EdgeSopStage:
  28555. return m.clearedsop_stage
  28556. case sopnode.EdgeNodeMessages:
  28557. return m.clearednode_messages
  28558. }
  28559. return false
  28560. }
  28561. // ClearEdge clears the value of the edge with the given name. It returns an error
  28562. // if that edge is not defined in the schema.
  28563. func (m *SopNodeMutation) ClearEdge(name string) error {
  28564. switch name {
  28565. case sopnode.EdgeSopStage:
  28566. m.ClearSopStage()
  28567. return nil
  28568. }
  28569. return fmt.Errorf("unknown SopNode unique edge %s", name)
  28570. }
  28571. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28572. // It returns an error if the edge is not defined in the schema.
  28573. func (m *SopNodeMutation) ResetEdge(name string) error {
  28574. switch name {
  28575. case sopnode.EdgeSopStage:
  28576. m.ResetSopStage()
  28577. return nil
  28578. case sopnode.EdgeNodeMessages:
  28579. m.ResetNodeMessages()
  28580. return nil
  28581. }
  28582. return fmt.Errorf("unknown SopNode edge %s", name)
  28583. }
  28584. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  28585. type SopStageMutation struct {
  28586. config
  28587. op Op
  28588. typ string
  28589. id *uint64
  28590. created_at *time.Time
  28591. updated_at *time.Time
  28592. status *uint8
  28593. addstatus *int8
  28594. deleted_at *time.Time
  28595. name *string
  28596. condition_type *int
  28597. addcondition_type *int
  28598. condition_operator *int
  28599. addcondition_operator *int
  28600. condition_list *[]custom_types.Condition
  28601. appendcondition_list []custom_types.Condition
  28602. action_message *[]custom_types.Action
  28603. appendaction_message []custom_types.Action
  28604. action_label_add *[]uint64
  28605. appendaction_label_add []uint64
  28606. action_label_del *[]uint64
  28607. appendaction_label_del []uint64
  28608. action_forward **custom_types.ActionForward
  28609. index_sort *int
  28610. addindex_sort *int
  28611. clearedFields map[string]struct{}
  28612. sop_task *uint64
  28613. clearedsop_task bool
  28614. stage_nodes map[uint64]struct{}
  28615. removedstage_nodes map[uint64]struct{}
  28616. clearedstage_nodes bool
  28617. stage_messages map[uint64]struct{}
  28618. removedstage_messages map[uint64]struct{}
  28619. clearedstage_messages bool
  28620. done bool
  28621. oldValue func(context.Context) (*SopStage, error)
  28622. predicates []predicate.SopStage
  28623. }
  28624. var _ ent.Mutation = (*SopStageMutation)(nil)
  28625. // sopstageOption allows management of the mutation configuration using functional options.
  28626. type sopstageOption func(*SopStageMutation)
  28627. // newSopStageMutation creates new mutation for the SopStage entity.
  28628. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  28629. m := &SopStageMutation{
  28630. config: c,
  28631. op: op,
  28632. typ: TypeSopStage,
  28633. clearedFields: make(map[string]struct{}),
  28634. }
  28635. for _, opt := range opts {
  28636. opt(m)
  28637. }
  28638. return m
  28639. }
  28640. // withSopStageID sets the ID field of the mutation.
  28641. func withSopStageID(id uint64) sopstageOption {
  28642. return func(m *SopStageMutation) {
  28643. var (
  28644. err error
  28645. once sync.Once
  28646. value *SopStage
  28647. )
  28648. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  28649. once.Do(func() {
  28650. if m.done {
  28651. err = errors.New("querying old values post mutation is not allowed")
  28652. } else {
  28653. value, err = m.Client().SopStage.Get(ctx, id)
  28654. }
  28655. })
  28656. return value, err
  28657. }
  28658. m.id = &id
  28659. }
  28660. }
  28661. // withSopStage sets the old SopStage of the mutation.
  28662. func withSopStage(node *SopStage) sopstageOption {
  28663. return func(m *SopStageMutation) {
  28664. m.oldValue = func(context.Context) (*SopStage, error) {
  28665. return node, nil
  28666. }
  28667. m.id = &node.ID
  28668. }
  28669. }
  28670. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28671. // executed in a transaction (ent.Tx), a transactional client is returned.
  28672. func (m SopStageMutation) Client() *Client {
  28673. client := &Client{config: m.config}
  28674. client.init()
  28675. return client
  28676. }
  28677. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28678. // it returns an error otherwise.
  28679. func (m SopStageMutation) Tx() (*Tx, error) {
  28680. if _, ok := m.driver.(*txDriver); !ok {
  28681. return nil, errors.New("ent: mutation is not running in a transaction")
  28682. }
  28683. tx := &Tx{config: m.config}
  28684. tx.init()
  28685. return tx, nil
  28686. }
  28687. // SetID sets the value of the id field. Note that this
  28688. // operation is only accepted on creation of SopStage entities.
  28689. func (m *SopStageMutation) SetID(id uint64) {
  28690. m.id = &id
  28691. }
  28692. // ID returns the ID value in the mutation. Note that the ID is only available
  28693. // if it was provided to the builder or after it was returned from the database.
  28694. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  28695. if m.id == nil {
  28696. return
  28697. }
  28698. return *m.id, true
  28699. }
  28700. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28701. // That means, if the mutation is applied within a transaction with an isolation level such
  28702. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28703. // or updated by the mutation.
  28704. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  28705. switch {
  28706. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28707. id, exists := m.ID()
  28708. if exists {
  28709. return []uint64{id}, nil
  28710. }
  28711. fallthrough
  28712. case m.op.Is(OpUpdate | OpDelete):
  28713. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  28714. default:
  28715. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28716. }
  28717. }
  28718. // SetCreatedAt sets the "created_at" field.
  28719. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  28720. m.created_at = &t
  28721. }
  28722. // CreatedAt returns the value of the "created_at" field in the mutation.
  28723. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  28724. v := m.created_at
  28725. if v == nil {
  28726. return
  28727. }
  28728. return *v, true
  28729. }
  28730. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  28731. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28733. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28734. if !m.op.Is(OpUpdateOne) {
  28735. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28736. }
  28737. if m.id == nil || m.oldValue == nil {
  28738. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28739. }
  28740. oldValue, err := m.oldValue(ctx)
  28741. if err != nil {
  28742. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28743. }
  28744. return oldValue.CreatedAt, nil
  28745. }
  28746. // ResetCreatedAt resets all changes to the "created_at" field.
  28747. func (m *SopStageMutation) ResetCreatedAt() {
  28748. m.created_at = nil
  28749. }
  28750. // SetUpdatedAt sets the "updated_at" field.
  28751. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  28752. m.updated_at = &t
  28753. }
  28754. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28755. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  28756. v := m.updated_at
  28757. if v == nil {
  28758. return
  28759. }
  28760. return *v, true
  28761. }
  28762. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  28763. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28765. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28766. if !m.op.Is(OpUpdateOne) {
  28767. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28768. }
  28769. if m.id == nil || m.oldValue == nil {
  28770. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28771. }
  28772. oldValue, err := m.oldValue(ctx)
  28773. if err != nil {
  28774. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28775. }
  28776. return oldValue.UpdatedAt, nil
  28777. }
  28778. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28779. func (m *SopStageMutation) ResetUpdatedAt() {
  28780. m.updated_at = nil
  28781. }
  28782. // SetStatus sets the "status" field.
  28783. func (m *SopStageMutation) SetStatus(u uint8) {
  28784. m.status = &u
  28785. m.addstatus = nil
  28786. }
  28787. // Status returns the value of the "status" field in the mutation.
  28788. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  28789. v := m.status
  28790. if v == nil {
  28791. return
  28792. }
  28793. return *v, true
  28794. }
  28795. // OldStatus returns the old "status" field's value of the SopStage entity.
  28796. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28798. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28799. if !m.op.Is(OpUpdateOne) {
  28800. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28801. }
  28802. if m.id == nil || m.oldValue == nil {
  28803. return v, errors.New("OldStatus requires an ID field in the mutation")
  28804. }
  28805. oldValue, err := m.oldValue(ctx)
  28806. if err != nil {
  28807. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28808. }
  28809. return oldValue.Status, nil
  28810. }
  28811. // AddStatus adds u to the "status" field.
  28812. func (m *SopStageMutation) AddStatus(u int8) {
  28813. if m.addstatus != nil {
  28814. *m.addstatus += u
  28815. } else {
  28816. m.addstatus = &u
  28817. }
  28818. }
  28819. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28820. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  28821. v := m.addstatus
  28822. if v == nil {
  28823. return
  28824. }
  28825. return *v, true
  28826. }
  28827. // ClearStatus clears the value of the "status" field.
  28828. func (m *SopStageMutation) ClearStatus() {
  28829. m.status = nil
  28830. m.addstatus = nil
  28831. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  28832. }
  28833. // StatusCleared returns if the "status" field was cleared in this mutation.
  28834. func (m *SopStageMutation) StatusCleared() bool {
  28835. _, ok := m.clearedFields[sopstage.FieldStatus]
  28836. return ok
  28837. }
  28838. // ResetStatus resets all changes to the "status" field.
  28839. func (m *SopStageMutation) ResetStatus() {
  28840. m.status = nil
  28841. m.addstatus = nil
  28842. delete(m.clearedFields, sopstage.FieldStatus)
  28843. }
  28844. // SetDeletedAt sets the "deleted_at" field.
  28845. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  28846. m.deleted_at = &t
  28847. }
  28848. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28849. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  28850. v := m.deleted_at
  28851. if v == nil {
  28852. return
  28853. }
  28854. return *v, true
  28855. }
  28856. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  28857. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28859. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28860. if !m.op.Is(OpUpdateOne) {
  28861. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28862. }
  28863. if m.id == nil || m.oldValue == nil {
  28864. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28865. }
  28866. oldValue, err := m.oldValue(ctx)
  28867. if err != nil {
  28868. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28869. }
  28870. return oldValue.DeletedAt, nil
  28871. }
  28872. // ClearDeletedAt clears the value of the "deleted_at" field.
  28873. func (m *SopStageMutation) ClearDeletedAt() {
  28874. m.deleted_at = nil
  28875. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  28876. }
  28877. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28878. func (m *SopStageMutation) DeletedAtCleared() bool {
  28879. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  28880. return ok
  28881. }
  28882. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28883. func (m *SopStageMutation) ResetDeletedAt() {
  28884. m.deleted_at = nil
  28885. delete(m.clearedFields, sopstage.FieldDeletedAt)
  28886. }
  28887. // SetTaskID sets the "task_id" field.
  28888. func (m *SopStageMutation) SetTaskID(u uint64) {
  28889. m.sop_task = &u
  28890. }
  28891. // TaskID returns the value of the "task_id" field in the mutation.
  28892. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  28893. v := m.sop_task
  28894. if v == nil {
  28895. return
  28896. }
  28897. return *v, true
  28898. }
  28899. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  28900. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28902. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  28903. if !m.op.Is(OpUpdateOne) {
  28904. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  28905. }
  28906. if m.id == nil || m.oldValue == nil {
  28907. return v, errors.New("OldTaskID requires an ID field in the mutation")
  28908. }
  28909. oldValue, err := m.oldValue(ctx)
  28910. if err != nil {
  28911. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  28912. }
  28913. return oldValue.TaskID, nil
  28914. }
  28915. // ResetTaskID resets all changes to the "task_id" field.
  28916. func (m *SopStageMutation) ResetTaskID() {
  28917. m.sop_task = nil
  28918. }
  28919. // SetName sets the "name" field.
  28920. func (m *SopStageMutation) SetName(s string) {
  28921. m.name = &s
  28922. }
  28923. // Name returns the value of the "name" field in the mutation.
  28924. func (m *SopStageMutation) Name() (r string, exists bool) {
  28925. v := m.name
  28926. if v == nil {
  28927. return
  28928. }
  28929. return *v, true
  28930. }
  28931. // OldName returns the old "name" field's value of the SopStage entity.
  28932. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28934. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  28935. if !m.op.Is(OpUpdateOne) {
  28936. return v, errors.New("OldName is only allowed on UpdateOne operations")
  28937. }
  28938. if m.id == nil || m.oldValue == nil {
  28939. return v, errors.New("OldName requires an ID field in the mutation")
  28940. }
  28941. oldValue, err := m.oldValue(ctx)
  28942. if err != nil {
  28943. return v, fmt.Errorf("querying old value for OldName: %w", err)
  28944. }
  28945. return oldValue.Name, nil
  28946. }
  28947. // ResetName resets all changes to the "name" field.
  28948. func (m *SopStageMutation) ResetName() {
  28949. m.name = nil
  28950. }
  28951. // SetConditionType sets the "condition_type" field.
  28952. func (m *SopStageMutation) SetConditionType(i int) {
  28953. m.condition_type = &i
  28954. m.addcondition_type = nil
  28955. }
  28956. // ConditionType returns the value of the "condition_type" field in the mutation.
  28957. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  28958. v := m.condition_type
  28959. if v == nil {
  28960. return
  28961. }
  28962. return *v, true
  28963. }
  28964. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  28965. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28967. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  28968. if !m.op.Is(OpUpdateOne) {
  28969. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  28970. }
  28971. if m.id == nil || m.oldValue == nil {
  28972. return v, errors.New("OldConditionType requires an ID field in the mutation")
  28973. }
  28974. oldValue, err := m.oldValue(ctx)
  28975. if err != nil {
  28976. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  28977. }
  28978. return oldValue.ConditionType, nil
  28979. }
  28980. // AddConditionType adds i to the "condition_type" field.
  28981. func (m *SopStageMutation) AddConditionType(i int) {
  28982. if m.addcondition_type != nil {
  28983. *m.addcondition_type += i
  28984. } else {
  28985. m.addcondition_type = &i
  28986. }
  28987. }
  28988. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  28989. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  28990. v := m.addcondition_type
  28991. if v == nil {
  28992. return
  28993. }
  28994. return *v, true
  28995. }
  28996. // ResetConditionType resets all changes to the "condition_type" field.
  28997. func (m *SopStageMutation) ResetConditionType() {
  28998. m.condition_type = nil
  28999. m.addcondition_type = nil
  29000. }
  29001. // SetConditionOperator sets the "condition_operator" field.
  29002. func (m *SopStageMutation) SetConditionOperator(i int) {
  29003. m.condition_operator = &i
  29004. m.addcondition_operator = nil
  29005. }
  29006. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  29007. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  29008. v := m.condition_operator
  29009. if v == nil {
  29010. return
  29011. }
  29012. return *v, true
  29013. }
  29014. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  29015. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29017. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  29018. if !m.op.Is(OpUpdateOne) {
  29019. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  29020. }
  29021. if m.id == nil || m.oldValue == nil {
  29022. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  29023. }
  29024. oldValue, err := m.oldValue(ctx)
  29025. if err != nil {
  29026. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  29027. }
  29028. return oldValue.ConditionOperator, nil
  29029. }
  29030. // AddConditionOperator adds i to the "condition_operator" field.
  29031. func (m *SopStageMutation) AddConditionOperator(i int) {
  29032. if m.addcondition_operator != nil {
  29033. *m.addcondition_operator += i
  29034. } else {
  29035. m.addcondition_operator = &i
  29036. }
  29037. }
  29038. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  29039. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  29040. v := m.addcondition_operator
  29041. if v == nil {
  29042. return
  29043. }
  29044. return *v, true
  29045. }
  29046. // ResetConditionOperator resets all changes to the "condition_operator" field.
  29047. func (m *SopStageMutation) ResetConditionOperator() {
  29048. m.condition_operator = nil
  29049. m.addcondition_operator = nil
  29050. }
  29051. // SetConditionList sets the "condition_list" field.
  29052. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  29053. m.condition_list = &ct
  29054. m.appendcondition_list = nil
  29055. }
  29056. // ConditionList returns the value of the "condition_list" field in the mutation.
  29057. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  29058. v := m.condition_list
  29059. if v == nil {
  29060. return
  29061. }
  29062. return *v, true
  29063. }
  29064. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  29065. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29067. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  29068. if !m.op.Is(OpUpdateOne) {
  29069. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  29070. }
  29071. if m.id == nil || m.oldValue == nil {
  29072. return v, errors.New("OldConditionList requires an ID field in the mutation")
  29073. }
  29074. oldValue, err := m.oldValue(ctx)
  29075. if err != nil {
  29076. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  29077. }
  29078. return oldValue.ConditionList, nil
  29079. }
  29080. // AppendConditionList adds ct to the "condition_list" field.
  29081. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  29082. m.appendcondition_list = append(m.appendcondition_list, ct...)
  29083. }
  29084. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  29085. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  29086. if len(m.appendcondition_list) == 0 {
  29087. return nil, false
  29088. }
  29089. return m.appendcondition_list, true
  29090. }
  29091. // ResetConditionList resets all changes to the "condition_list" field.
  29092. func (m *SopStageMutation) ResetConditionList() {
  29093. m.condition_list = nil
  29094. m.appendcondition_list = nil
  29095. }
  29096. // SetActionMessage sets the "action_message" field.
  29097. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  29098. m.action_message = &ct
  29099. m.appendaction_message = nil
  29100. }
  29101. // ActionMessage returns the value of the "action_message" field in the mutation.
  29102. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  29103. v := m.action_message
  29104. if v == nil {
  29105. return
  29106. }
  29107. return *v, true
  29108. }
  29109. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  29110. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29112. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  29113. if !m.op.Is(OpUpdateOne) {
  29114. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  29115. }
  29116. if m.id == nil || m.oldValue == nil {
  29117. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  29118. }
  29119. oldValue, err := m.oldValue(ctx)
  29120. if err != nil {
  29121. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  29122. }
  29123. return oldValue.ActionMessage, nil
  29124. }
  29125. // AppendActionMessage adds ct to the "action_message" field.
  29126. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  29127. m.appendaction_message = append(m.appendaction_message, ct...)
  29128. }
  29129. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  29130. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  29131. if len(m.appendaction_message) == 0 {
  29132. return nil, false
  29133. }
  29134. return m.appendaction_message, true
  29135. }
  29136. // ClearActionMessage clears the value of the "action_message" field.
  29137. func (m *SopStageMutation) ClearActionMessage() {
  29138. m.action_message = nil
  29139. m.appendaction_message = nil
  29140. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  29141. }
  29142. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  29143. func (m *SopStageMutation) ActionMessageCleared() bool {
  29144. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  29145. return ok
  29146. }
  29147. // ResetActionMessage resets all changes to the "action_message" field.
  29148. func (m *SopStageMutation) ResetActionMessage() {
  29149. m.action_message = nil
  29150. m.appendaction_message = nil
  29151. delete(m.clearedFields, sopstage.FieldActionMessage)
  29152. }
  29153. // SetActionLabelAdd sets the "action_label_add" field.
  29154. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  29155. m.action_label_add = &u
  29156. m.appendaction_label_add = nil
  29157. }
  29158. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  29159. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  29160. v := m.action_label_add
  29161. if v == nil {
  29162. return
  29163. }
  29164. return *v, true
  29165. }
  29166. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  29167. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29169. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  29170. if !m.op.Is(OpUpdateOne) {
  29171. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  29172. }
  29173. if m.id == nil || m.oldValue == nil {
  29174. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  29175. }
  29176. oldValue, err := m.oldValue(ctx)
  29177. if err != nil {
  29178. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  29179. }
  29180. return oldValue.ActionLabelAdd, nil
  29181. }
  29182. // AppendActionLabelAdd adds u to the "action_label_add" field.
  29183. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  29184. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  29185. }
  29186. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  29187. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  29188. if len(m.appendaction_label_add) == 0 {
  29189. return nil, false
  29190. }
  29191. return m.appendaction_label_add, true
  29192. }
  29193. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  29194. func (m *SopStageMutation) ClearActionLabelAdd() {
  29195. m.action_label_add = nil
  29196. m.appendaction_label_add = nil
  29197. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  29198. }
  29199. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  29200. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  29201. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  29202. return ok
  29203. }
  29204. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  29205. func (m *SopStageMutation) ResetActionLabelAdd() {
  29206. m.action_label_add = nil
  29207. m.appendaction_label_add = nil
  29208. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  29209. }
  29210. // SetActionLabelDel sets the "action_label_del" field.
  29211. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  29212. m.action_label_del = &u
  29213. m.appendaction_label_del = nil
  29214. }
  29215. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  29216. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  29217. v := m.action_label_del
  29218. if v == nil {
  29219. return
  29220. }
  29221. return *v, true
  29222. }
  29223. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  29224. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29226. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  29227. if !m.op.Is(OpUpdateOne) {
  29228. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  29229. }
  29230. if m.id == nil || m.oldValue == nil {
  29231. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  29232. }
  29233. oldValue, err := m.oldValue(ctx)
  29234. if err != nil {
  29235. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  29236. }
  29237. return oldValue.ActionLabelDel, nil
  29238. }
  29239. // AppendActionLabelDel adds u to the "action_label_del" field.
  29240. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  29241. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  29242. }
  29243. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  29244. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  29245. if len(m.appendaction_label_del) == 0 {
  29246. return nil, false
  29247. }
  29248. return m.appendaction_label_del, true
  29249. }
  29250. // ClearActionLabelDel clears the value of the "action_label_del" field.
  29251. func (m *SopStageMutation) ClearActionLabelDel() {
  29252. m.action_label_del = nil
  29253. m.appendaction_label_del = nil
  29254. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  29255. }
  29256. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  29257. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  29258. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  29259. return ok
  29260. }
  29261. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  29262. func (m *SopStageMutation) ResetActionLabelDel() {
  29263. m.action_label_del = nil
  29264. m.appendaction_label_del = nil
  29265. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  29266. }
  29267. // SetActionForward sets the "action_forward" field.
  29268. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  29269. m.action_forward = &ctf
  29270. }
  29271. // ActionForward returns the value of the "action_forward" field in the mutation.
  29272. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  29273. v := m.action_forward
  29274. if v == nil {
  29275. return
  29276. }
  29277. return *v, true
  29278. }
  29279. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  29280. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29282. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  29283. if !m.op.Is(OpUpdateOne) {
  29284. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  29285. }
  29286. if m.id == nil || m.oldValue == nil {
  29287. return v, errors.New("OldActionForward requires an ID field in the mutation")
  29288. }
  29289. oldValue, err := m.oldValue(ctx)
  29290. if err != nil {
  29291. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  29292. }
  29293. return oldValue.ActionForward, nil
  29294. }
  29295. // ClearActionForward clears the value of the "action_forward" field.
  29296. func (m *SopStageMutation) ClearActionForward() {
  29297. m.action_forward = nil
  29298. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  29299. }
  29300. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  29301. func (m *SopStageMutation) ActionForwardCleared() bool {
  29302. _, ok := m.clearedFields[sopstage.FieldActionForward]
  29303. return ok
  29304. }
  29305. // ResetActionForward resets all changes to the "action_forward" field.
  29306. func (m *SopStageMutation) ResetActionForward() {
  29307. m.action_forward = nil
  29308. delete(m.clearedFields, sopstage.FieldActionForward)
  29309. }
  29310. // SetIndexSort sets the "index_sort" field.
  29311. func (m *SopStageMutation) SetIndexSort(i int) {
  29312. m.index_sort = &i
  29313. m.addindex_sort = nil
  29314. }
  29315. // IndexSort returns the value of the "index_sort" field in the mutation.
  29316. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  29317. v := m.index_sort
  29318. if v == nil {
  29319. return
  29320. }
  29321. return *v, true
  29322. }
  29323. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  29324. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29326. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  29327. if !m.op.Is(OpUpdateOne) {
  29328. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  29329. }
  29330. if m.id == nil || m.oldValue == nil {
  29331. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  29332. }
  29333. oldValue, err := m.oldValue(ctx)
  29334. if err != nil {
  29335. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  29336. }
  29337. return oldValue.IndexSort, nil
  29338. }
  29339. // AddIndexSort adds i to the "index_sort" field.
  29340. func (m *SopStageMutation) AddIndexSort(i int) {
  29341. if m.addindex_sort != nil {
  29342. *m.addindex_sort += i
  29343. } else {
  29344. m.addindex_sort = &i
  29345. }
  29346. }
  29347. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  29348. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  29349. v := m.addindex_sort
  29350. if v == nil {
  29351. return
  29352. }
  29353. return *v, true
  29354. }
  29355. // ClearIndexSort clears the value of the "index_sort" field.
  29356. func (m *SopStageMutation) ClearIndexSort() {
  29357. m.index_sort = nil
  29358. m.addindex_sort = nil
  29359. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  29360. }
  29361. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  29362. func (m *SopStageMutation) IndexSortCleared() bool {
  29363. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  29364. return ok
  29365. }
  29366. // ResetIndexSort resets all changes to the "index_sort" field.
  29367. func (m *SopStageMutation) ResetIndexSort() {
  29368. m.index_sort = nil
  29369. m.addindex_sort = nil
  29370. delete(m.clearedFields, sopstage.FieldIndexSort)
  29371. }
  29372. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  29373. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  29374. m.sop_task = &id
  29375. }
  29376. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  29377. func (m *SopStageMutation) ClearSopTask() {
  29378. m.clearedsop_task = true
  29379. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  29380. }
  29381. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  29382. func (m *SopStageMutation) SopTaskCleared() bool {
  29383. return m.clearedsop_task
  29384. }
  29385. // SopTaskID returns the "sop_task" edge ID in the mutation.
  29386. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  29387. if m.sop_task != nil {
  29388. return *m.sop_task, true
  29389. }
  29390. return
  29391. }
  29392. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  29393. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29394. // SopTaskID instead. It exists only for internal usage by the builders.
  29395. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  29396. if id := m.sop_task; id != nil {
  29397. ids = append(ids, *id)
  29398. }
  29399. return
  29400. }
  29401. // ResetSopTask resets all changes to the "sop_task" edge.
  29402. func (m *SopStageMutation) ResetSopTask() {
  29403. m.sop_task = nil
  29404. m.clearedsop_task = false
  29405. }
  29406. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  29407. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  29408. if m.stage_nodes == nil {
  29409. m.stage_nodes = make(map[uint64]struct{})
  29410. }
  29411. for i := range ids {
  29412. m.stage_nodes[ids[i]] = struct{}{}
  29413. }
  29414. }
  29415. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  29416. func (m *SopStageMutation) ClearStageNodes() {
  29417. m.clearedstage_nodes = true
  29418. }
  29419. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  29420. func (m *SopStageMutation) StageNodesCleared() bool {
  29421. return m.clearedstage_nodes
  29422. }
  29423. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  29424. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  29425. if m.removedstage_nodes == nil {
  29426. m.removedstage_nodes = make(map[uint64]struct{})
  29427. }
  29428. for i := range ids {
  29429. delete(m.stage_nodes, ids[i])
  29430. m.removedstage_nodes[ids[i]] = struct{}{}
  29431. }
  29432. }
  29433. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  29434. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  29435. for id := range m.removedstage_nodes {
  29436. ids = append(ids, id)
  29437. }
  29438. return
  29439. }
  29440. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  29441. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  29442. for id := range m.stage_nodes {
  29443. ids = append(ids, id)
  29444. }
  29445. return
  29446. }
  29447. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  29448. func (m *SopStageMutation) ResetStageNodes() {
  29449. m.stage_nodes = nil
  29450. m.clearedstage_nodes = false
  29451. m.removedstage_nodes = nil
  29452. }
  29453. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  29454. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  29455. if m.stage_messages == nil {
  29456. m.stage_messages = make(map[uint64]struct{})
  29457. }
  29458. for i := range ids {
  29459. m.stage_messages[ids[i]] = struct{}{}
  29460. }
  29461. }
  29462. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  29463. func (m *SopStageMutation) ClearStageMessages() {
  29464. m.clearedstage_messages = true
  29465. }
  29466. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  29467. func (m *SopStageMutation) StageMessagesCleared() bool {
  29468. return m.clearedstage_messages
  29469. }
  29470. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  29471. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  29472. if m.removedstage_messages == nil {
  29473. m.removedstage_messages = make(map[uint64]struct{})
  29474. }
  29475. for i := range ids {
  29476. delete(m.stage_messages, ids[i])
  29477. m.removedstage_messages[ids[i]] = struct{}{}
  29478. }
  29479. }
  29480. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  29481. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  29482. for id := range m.removedstage_messages {
  29483. ids = append(ids, id)
  29484. }
  29485. return
  29486. }
  29487. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  29488. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  29489. for id := range m.stage_messages {
  29490. ids = append(ids, id)
  29491. }
  29492. return
  29493. }
  29494. // ResetStageMessages resets all changes to the "stage_messages" edge.
  29495. func (m *SopStageMutation) ResetStageMessages() {
  29496. m.stage_messages = nil
  29497. m.clearedstage_messages = false
  29498. m.removedstage_messages = nil
  29499. }
  29500. // Where appends a list predicates to the SopStageMutation builder.
  29501. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  29502. m.predicates = append(m.predicates, ps...)
  29503. }
  29504. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  29505. // users can use type-assertion to append predicates that do not depend on any generated package.
  29506. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  29507. p := make([]predicate.SopStage, len(ps))
  29508. for i := range ps {
  29509. p[i] = ps[i]
  29510. }
  29511. m.Where(p...)
  29512. }
  29513. // Op returns the operation name.
  29514. func (m *SopStageMutation) Op() Op {
  29515. return m.op
  29516. }
  29517. // SetOp allows setting the mutation operation.
  29518. func (m *SopStageMutation) SetOp(op Op) {
  29519. m.op = op
  29520. }
  29521. // Type returns the node type of this mutation (SopStage).
  29522. func (m *SopStageMutation) Type() string {
  29523. return m.typ
  29524. }
  29525. // Fields returns all fields that were changed during this mutation. Note that in
  29526. // order to get all numeric fields that were incremented/decremented, call
  29527. // AddedFields().
  29528. func (m *SopStageMutation) Fields() []string {
  29529. fields := make([]string, 0, 14)
  29530. if m.created_at != nil {
  29531. fields = append(fields, sopstage.FieldCreatedAt)
  29532. }
  29533. if m.updated_at != nil {
  29534. fields = append(fields, sopstage.FieldUpdatedAt)
  29535. }
  29536. if m.status != nil {
  29537. fields = append(fields, sopstage.FieldStatus)
  29538. }
  29539. if m.deleted_at != nil {
  29540. fields = append(fields, sopstage.FieldDeletedAt)
  29541. }
  29542. if m.sop_task != nil {
  29543. fields = append(fields, sopstage.FieldTaskID)
  29544. }
  29545. if m.name != nil {
  29546. fields = append(fields, sopstage.FieldName)
  29547. }
  29548. if m.condition_type != nil {
  29549. fields = append(fields, sopstage.FieldConditionType)
  29550. }
  29551. if m.condition_operator != nil {
  29552. fields = append(fields, sopstage.FieldConditionOperator)
  29553. }
  29554. if m.condition_list != nil {
  29555. fields = append(fields, sopstage.FieldConditionList)
  29556. }
  29557. if m.action_message != nil {
  29558. fields = append(fields, sopstage.FieldActionMessage)
  29559. }
  29560. if m.action_label_add != nil {
  29561. fields = append(fields, sopstage.FieldActionLabelAdd)
  29562. }
  29563. if m.action_label_del != nil {
  29564. fields = append(fields, sopstage.FieldActionLabelDel)
  29565. }
  29566. if m.action_forward != nil {
  29567. fields = append(fields, sopstage.FieldActionForward)
  29568. }
  29569. if m.index_sort != nil {
  29570. fields = append(fields, sopstage.FieldIndexSort)
  29571. }
  29572. return fields
  29573. }
  29574. // Field returns the value of a field with the given name. The second boolean
  29575. // return value indicates that this field was not set, or was not defined in the
  29576. // schema.
  29577. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  29578. switch name {
  29579. case sopstage.FieldCreatedAt:
  29580. return m.CreatedAt()
  29581. case sopstage.FieldUpdatedAt:
  29582. return m.UpdatedAt()
  29583. case sopstage.FieldStatus:
  29584. return m.Status()
  29585. case sopstage.FieldDeletedAt:
  29586. return m.DeletedAt()
  29587. case sopstage.FieldTaskID:
  29588. return m.TaskID()
  29589. case sopstage.FieldName:
  29590. return m.Name()
  29591. case sopstage.FieldConditionType:
  29592. return m.ConditionType()
  29593. case sopstage.FieldConditionOperator:
  29594. return m.ConditionOperator()
  29595. case sopstage.FieldConditionList:
  29596. return m.ConditionList()
  29597. case sopstage.FieldActionMessage:
  29598. return m.ActionMessage()
  29599. case sopstage.FieldActionLabelAdd:
  29600. return m.ActionLabelAdd()
  29601. case sopstage.FieldActionLabelDel:
  29602. return m.ActionLabelDel()
  29603. case sopstage.FieldActionForward:
  29604. return m.ActionForward()
  29605. case sopstage.FieldIndexSort:
  29606. return m.IndexSort()
  29607. }
  29608. return nil, false
  29609. }
  29610. // OldField returns the old value of the field from the database. An error is
  29611. // returned if the mutation operation is not UpdateOne, or the query to the
  29612. // database failed.
  29613. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29614. switch name {
  29615. case sopstage.FieldCreatedAt:
  29616. return m.OldCreatedAt(ctx)
  29617. case sopstage.FieldUpdatedAt:
  29618. return m.OldUpdatedAt(ctx)
  29619. case sopstage.FieldStatus:
  29620. return m.OldStatus(ctx)
  29621. case sopstage.FieldDeletedAt:
  29622. return m.OldDeletedAt(ctx)
  29623. case sopstage.FieldTaskID:
  29624. return m.OldTaskID(ctx)
  29625. case sopstage.FieldName:
  29626. return m.OldName(ctx)
  29627. case sopstage.FieldConditionType:
  29628. return m.OldConditionType(ctx)
  29629. case sopstage.FieldConditionOperator:
  29630. return m.OldConditionOperator(ctx)
  29631. case sopstage.FieldConditionList:
  29632. return m.OldConditionList(ctx)
  29633. case sopstage.FieldActionMessage:
  29634. return m.OldActionMessage(ctx)
  29635. case sopstage.FieldActionLabelAdd:
  29636. return m.OldActionLabelAdd(ctx)
  29637. case sopstage.FieldActionLabelDel:
  29638. return m.OldActionLabelDel(ctx)
  29639. case sopstage.FieldActionForward:
  29640. return m.OldActionForward(ctx)
  29641. case sopstage.FieldIndexSort:
  29642. return m.OldIndexSort(ctx)
  29643. }
  29644. return nil, fmt.Errorf("unknown SopStage field %s", name)
  29645. }
  29646. // SetField sets the value of a field with the given name. It returns an error if
  29647. // the field is not defined in the schema, or if the type mismatched the field
  29648. // type.
  29649. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  29650. switch name {
  29651. case sopstage.FieldCreatedAt:
  29652. v, ok := value.(time.Time)
  29653. if !ok {
  29654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29655. }
  29656. m.SetCreatedAt(v)
  29657. return nil
  29658. case sopstage.FieldUpdatedAt:
  29659. v, ok := value.(time.Time)
  29660. if !ok {
  29661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29662. }
  29663. m.SetUpdatedAt(v)
  29664. return nil
  29665. case sopstage.FieldStatus:
  29666. v, ok := value.(uint8)
  29667. if !ok {
  29668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29669. }
  29670. m.SetStatus(v)
  29671. return nil
  29672. case sopstage.FieldDeletedAt:
  29673. v, ok := value.(time.Time)
  29674. if !ok {
  29675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29676. }
  29677. m.SetDeletedAt(v)
  29678. return nil
  29679. case sopstage.FieldTaskID:
  29680. v, ok := value.(uint64)
  29681. if !ok {
  29682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29683. }
  29684. m.SetTaskID(v)
  29685. return nil
  29686. case sopstage.FieldName:
  29687. v, ok := value.(string)
  29688. if !ok {
  29689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29690. }
  29691. m.SetName(v)
  29692. return nil
  29693. case sopstage.FieldConditionType:
  29694. v, ok := value.(int)
  29695. if !ok {
  29696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29697. }
  29698. m.SetConditionType(v)
  29699. return nil
  29700. case sopstage.FieldConditionOperator:
  29701. v, ok := value.(int)
  29702. if !ok {
  29703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29704. }
  29705. m.SetConditionOperator(v)
  29706. return nil
  29707. case sopstage.FieldConditionList:
  29708. v, ok := value.([]custom_types.Condition)
  29709. if !ok {
  29710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29711. }
  29712. m.SetConditionList(v)
  29713. return nil
  29714. case sopstage.FieldActionMessage:
  29715. v, ok := value.([]custom_types.Action)
  29716. if !ok {
  29717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29718. }
  29719. m.SetActionMessage(v)
  29720. return nil
  29721. case sopstage.FieldActionLabelAdd:
  29722. v, ok := value.([]uint64)
  29723. if !ok {
  29724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29725. }
  29726. m.SetActionLabelAdd(v)
  29727. return nil
  29728. case sopstage.FieldActionLabelDel:
  29729. v, ok := value.([]uint64)
  29730. if !ok {
  29731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29732. }
  29733. m.SetActionLabelDel(v)
  29734. return nil
  29735. case sopstage.FieldActionForward:
  29736. v, ok := value.(*custom_types.ActionForward)
  29737. if !ok {
  29738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29739. }
  29740. m.SetActionForward(v)
  29741. return nil
  29742. case sopstage.FieldIndexSort:
  29743. v, ok := value.(int)
  29744. if !ok {
  29745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29746. }
  29747. m.SetIndexSort(v)
  29748. return nil
  29749. }
  29750. return fmt.Errorf("unknown SopStage field %s", name)
  29751. }
  29752. // AddedFields returns all numeric fields that were incremented/decremented during
  29753. // this mutation.
  29754. func (m *SopStageMutation) AddedFields() []string {
  29755. var fields []string
  29756. if m.addstatus != nil {
  29757. fields = append(fields, sopstage.FieldStatus)
  29758. }
  29759. if m.addcondition_type != nil {
  29760. fields = append(fields, sopstage.FieldConditionType)
  29761. }
  29762. if m.addcondition_operator != nil {
  29763. fields = append(fields, sopstage.FieldConditionOperator)
  29764. }
  29765. if m.addindex_sort != nil {
  29766. fields = append(fields, sopstage.FieldIndexSort)
  29767. }
  29768. return fields
  29769. }
  29770. // AddedField returns the numeric value that was incremented/decremented on a field
  29771. // with the given name. The second boolean return value indicates that this field
  29772. // was not set, or was not defined in the schema.
  29773. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  29774. switch name {
  29775. case sopstage.FieldStatus:
  29776. return m.AddedStatus()
  29777. case sopstage.FieldConditionType:
  29778. return m.AddedConditionType()
  29779. case sopstage.FieldConditionOperator:
  29780. return m.AddedConditionOperator()
  29781. case sopstage.FieldIndexSort:
  29782. return m.AddedIndexSort()
  29783. }
  29784. return nil, false
  29785. }
  29786. // AddField adds the value to the field with the given name. It returns an error if
  29787. // the field is not defined in the schema, or if the type mismatched the field
  29788. // type.
  29789. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  29790. switch name {
  29791. case sopstage.FieldStatus:
  29792. v, ok := value.(int8)
  29793. if !ok {
  29794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29795. }
  29796. m.AddStatus(v)
  29797. return nil
  29798. case sopstage.FieldConditionType:
  29799. v, ok := value.(int)
  29800. if !ok {
  29801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29802. }
  29803. m.AddConditionType(v)
  29804. return nil
  29805. case sopstage.FieldConditionOperator:
  29806. v, ok := value.(int)
  29807. if !ok {
  29808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29809. }
  29810. m.AddConditionOperator(v)
  29811. return nil
  29812. case sopstage.FieldIndexSort:
  29813. v, ok := value.(int)
  29814. if !ok {
  29815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29816. }
  29817. m.AddIndexSort(v)
  29818. return nil
  29819. }
  29820. return fmt.Errorf("unknown SopStage numeric field %s", name)
  29821. }
  29822. // ClearedFields returns all nullable fields that were cleared during this
  29823. // mutation.
  29824. func (m *SopStageMutation) ClearedFields() []string {
  29825. var fields []string
  29826. if m.FieldCleared(sopstage.FieldStatus) {
  29827. fields = append(fields, sopstage.FieldStatus)
  29828. }
  29829. if m.FieldCleared(sopstage.FieldDeletedAt) {
  29830. fields = append(fields, sopstage.FieldDeletedAt)
  29831. }
  29832. if m.FieldCleared(sopstage.FieldActionMessage) {
  29833. fields = append(fields, sopstage.FieldActionMessage)
  29834. }
  29835. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  29836. fields = append(fields, sopstage.FieldActionLabelAdd)
  29837. }
  29838. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  29839. fields = append(fields, sopstage.FieldActionLabelDel)
  29840. }
  29841. if m.FieldCleared(sopstage.FieldActionForward) {
  29842. fields = append(fields, sopstage.FieldActionForward)
  29843. }
  29844. if m.FieldCleared(sopstage.FieldIndexSort) {
  29845. fields = append(fields, sopstage.FieldIndexSort)
  29846. }
  29847. return fields
  29848. }
  29849. // FieldCleared returns a boolean indicating if a field with the given name was
  29850. // cleared in this mutation.
  29851. func (m *SopStageMutation) FieldCleared(name string) bool {
  29852. _, ok := m.clearedFields[name]
  29853. return ok
  29854. }
  29855. // ClearField clears the value of the field with the given name. It returns an
  29856. // error if the field is not defined in the schema.
  29857. func (m *SopStageMutation) ClearField(name string) error {
  29858. switch name {
  29859. case sopstage.FieldStatus:
  29860. m.ClearStatus()
  29861. return nil
  29862. case sopstage.FieldDeletedAt:
  29863. m.ClearDeletedAt()
  29864. return nil
  29865. case sopstage.FieldActionMessage:
  29866. m.ClearActionMessage()
  29867. return nil
  29868. case sopstage.FieldActionLabelAdd:
  29869. m.ClearActionLabelAdd()
  29870. return nil
  29871. case sopstage.FieldActionLabelDel:
  29872. m.ClearActionLabelDel()
  29873. return nil
  29874. case sopstage.FieldActionForward:
  29875. m.ClearActionForward()
  29876. return nil
  29877. case sopstage.FieldIndexSort:
  29878. m.ClearIndexSort()
  29879. return nil
  29880. }
  29881. return fmt.Errorf("unknown SopStage nullable field %s", name)
  29882. }
  29883. // ResetField resets all changes in the mutation for the field with the given name.
  29884. // It returns an error if the field is not defined in the schema.
  29885. func (m *SopStageMutation) ResetField(name string) error {
  29886. switch name {
  29887. case sopstage.FieldCreatedAt:
  29888. m.ResetCreatedAt()
  29889. return nil
  29890. case sopstage.FieldUpdatedAt:
  29891. m.ResetUpdatedAt()
  29892. return nil
  29893. case sopstage.FieldStatus:
  29894. m.ResetStatus()
  29895. return nil
  29896. case sopstage.FieldDeletedAt:
  29897. m.ResetDeletedAt()
  29898. return nil
  29899. case sopstage.FieldTaskID:
  29900. m.ResetTaskID()
  29901. return nil
  29902. case sopstage.FieldName:
  29903. m.ResetName()
  29904. return nil
  29905. case sopstage.FieldConditionType:
  29906. m.ResetConditionType()
  29907. return nil
  29908. case sopstage.FieldConditionOperator:
  29909. m.ResetConditionOperator()
  29910. return nil
  29911. case sopstage.FieldConditionList:
  29912. m.ResetConditionList()
  29913. return nil
  29914. case sopstage.FieldActionMessage:
  29915. m.ResetActionMessage()
  29916. return nil
  29917. case sopstage.FieldActionLabelAdd:
  29918. m.ResetActionLabelAdd()
  29919. return nil
  29920. case sopstage.FieldActionLabelDel:
  29921. m.ResetActionLabelDel()
  29922. return nil
  29923. case sopstage.FieldActionForward:
  29924. m.ResetActionForward()
  29925. return nil
  29926. case sopstage.FieldIndexSort:
  29927. m.ResetIndexSort()
  29928. return nil
  29929. }
  29930. return fmt.Errorf("unknown SopStage field %s", name)
  29931. }
  29932. // AddedEdges returns all edge names that were set/added in this mutation.
  29933. func (m *SopStageMutation) AddedEdges() []string {
  29934. edges := make([]string, 0, 3)
  29935. if m.sop_task != nil {
  29936. edges = append(edges, sopstage.EdgeSopTask)
  29937. }
  29938. if m.stage_nodes != nil {
  29939. edges = append(edges, sopstage.EdgeStageNodes)
  29940. }
  29941. if m.stage_messages != nil {
  29942. edges = append(edges, sopstage.EdgeStageMessages)
  29943. }
  29944. return edges
  29945. }
  29946. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29947. // name in this mutation.
  29948. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  29949. switch name {
  29950. case sopstage.EdgeSopTask:
  29951. if id := m.sop_task; id != nil {
  29952. return []ent.Value{*id}
  29953. }
  29954. case sopstage.EdgeStageNodes:
  29955. ids := make([]ent.Value, 0, len(m.stage_nodes))
  29956. for id := range m.stage_nodes {
  29957. ids = append(ids, id)
  29958. }
  29959. return ids
  29960. case sopstage.EdgeStageMessages:
  29961. ids := make([]ent.Value, 0, len(m.stage_messages))
  29962. for id := range m.stage_messages {
  29963. ids = append(ids, id)
  29964. }
  29965. return ids
  29966. }
  29967. return nil
  29968. }
  29969. // RemovedEdges returns all edge names that were removed in this mutation.
  29970. func (m *SopStageMutation) RemovedEdges() []string {
  29971. edges := make([]string, 0, 3)
  29972. if m.removedstage_nodes != nil {
  29973. edges = append(edges, sopstage.EdgeStageNodes)
  29974. }
  29975. if m.removedstage_messages != nil {
  29976. edges = append(edges, sopstage.EdgeStageMessages)
  29977. }
  29978. return edges
  29979. }
  29980. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29981. // the given name in this mutation.
  29982. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  29983. switch name {
  29984. case sopstage.EdgeStageNodes:
  29985. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  29986. for id := range m.removedstage_nodes {
  29987. ids = append(ids, id)
  29988. }
  29989. return ids
  29990. case sopstage.EdgeStageMessages:
  29991. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  29992. for id := range m.removedstage_messages {
  29993. ids = append(ids, id)
  29994. }
  29995. return ids
  29996. }
  29997. return nil
  29998. }
  29999. // ClearedEdges returns all edge names that were cleared in this mutation.
  30000. func (m *SopStageMutation) ClearedEdges() []string {
  30001. edges := make([]string, 0, 3)
  30002. if m.clearedsop_task {
  30003. edges = append(edges, sopstage.EdgeSopTask)
  30004. }
  30005. if m.clearedstage_nodes {
  30006. edges = append(edges, sopstage.EdgeStageNodes)
  30007. }
  30008. if m.clearedstage_messages {
  30009. edges = append(edges, sopstage.EdgeStageMessages)
  30010. }
  30011. return edges
  30012. }
  30013. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30014. // was cleared in this mutation.
  30015. func (m *SopStageMutation) EdgeCleared(name string) bool {
  30016. switch name {
  30017. case sopstage.EdgeSopTask:
  30018. return m.clearedsop_task
  30019. case sopstage.EdgeStageNodes:
  30020. return m.clearedstage_nodes
  30021. case sopstage.EdgeStageMessages:
  30022. return m.clearedstage_messages
  30023. }
  30024. return false
  30025. }
  30026. // ClearEdge clears the value of the edge with the given name. It returns an error
  30027. // if that edge is not defined in the schema.
  30028. func (m *SopStageMutation) ClearEdge(name string) error {
  30029. switch name {
  30030. case sopstage.EdgeSopTask:
  30031. m.ClearSopTask()
  30032. return nil
  30033. }
  30034. return fmt.Errorf("unknown SopStage unique edge %s", name)
  30035. }
  30036. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30037. // It returns an error if the edge is not defined in the schema.
  30038. func (m *SopStageMutation) ResetEdge(name string) error {
  30039. switch name {
  30040. case sopstage.EdgeSopTask:
  30041. m.ResetSopTask()
  30042. return nil
  30043. case sopstage.EdgeStageNodes:
  30044. m.ResetStageNodes()
  30045. return nil
  30046. case sopstage.EdgeStageMessages:
  30047. m.ResetStageMessages()
  30048. return nil
  30049. }
  30050. return fmt.Errorf("unknown SopStage edge %s", name)
  30051. }
  30052. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  30053. type SopTaskMutation struct {
  30054. config
  30055. op Op
  30056. typ string
  30057. id *uint64
  30058. created_at *time.Time
  30059. updated_at *time.Time
  30060. status *uint8
  30061. addstatus *int8
  30062. deleted_at *time.Time
  30063. name *string
  30064. bot_wxid_list *[]string
  30065. appendbot_wxid_list []string
  30066. _type *int
  30067. add_type *int
  30068. plan_start_time *time.Time
  30069. plan_end_time *time.Time
  30070. creator_id *string
  30071. organization_id *uint64
  30072. addorganization_id *int64
  30073. token *[]string
  30074. appendtoken []string
  30075. clearedFields map[string]struct{}
  30076. task_stages map[uint64]struct{}
  30077. removedtask_stages map[uint64]struct{}
  30078. clearedtask_stages bool
  30079. done bool
  30080. oldValue func(context.Context) (*SopTask, error)
  30081. predicates []predicate.SopTask
  30082. }
  30083. var _ ent.Mutation = (*SopTaskMutation)(nil)
  30084. // soptaskOption allows management of the mutation configuration using functional options.
  30085. type soptaskOption func(*SopTaskMutation)
  30086. // newSopTaskMutation creates new mutation for the SopTask entity.
  30087. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  30088. m := &SopTaskMutation{
  30089. config: c,
  30090. op: op,
  30091. typ: TypeSopTask,
  30092. clearedFields: make(map[string]struct{}),
  30093. }
  30094. for _, opt := range opts {
  30095. opt(m)
  30096. }
  30097. return m
  30098. }
  30099. // withSopTaskID sets the ID field of the mutation.
  30100. func withSopTaskID(id uint64) soptaskOption {
  30101. return func(m *SopTaskMutation) {
  30102. var (
  30103. err error
  30104. once sync.Once
  30105. value *SopTask
  30106. )
  30107. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  30108. once.Do(func() {
  30109. if m.done {
  30110. err = errors.New("querying old values post mutation is not allowed")
  30111. } else {
  30112. value, err = m.Client().SopTask.Get(ctx, id)
  30113. }
  30114. })
  30115. return value, err
  30116. }
  30117. m.id = &id
  30118. }
  30119. }
  30120. // withSopTask sets the old SopTask of the mutation.
  30121. func withSopTask(node *SopTask) soptaskOption {
  30122. return func(m *SopTaskMutation) {
  30123. m.oldValue = func(context.Context) (*SopTask, error) {
  30124. return node, nil
  30125. }
  30126. m.id = &node.ID
  30127. }
  30128. }
  30129. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30130. // executed in a transaction (ent.Tx), a transactional client is returned.
  30131. func (m SopTaskMutation) Client() *Client {
  30132. client := &Client{config: m.config}
  30133. client.init()
  30134. return client
  30135. }
  30136. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30137. // it returns an error otherwise.
  30138. func (m SopTaskMutation) Tx() (*Tx, error) {
  30139. if _, ok := m.driver.(*txDriver); !ok {
  30140. return nil, errors.New("ent: mutation is not running in a transaction")
  30141. }
  30142. tx := &Tx{config: m.config}
  30143. tx.init()
  30144. return tx, nil
  30145. }
  30146. // SetID sets the value of the id field. Note that this
  30147. // operation is only accepted on creation of SopTask entities.
  30148. func (m *SopTaskMutation) SetID(id uint64) {
  30149. m.id = &id
  30150. }
  30151. // ID returns the ID value in the mutation. Note that the ID is only available
  30152. // if it was provided to the builder or after it was returned from the database.
  30153. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  30154. if m.id == nil {
  30155. return
  30156. }
  30157. return *m.id, true
  30158. }
  30159. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30160. // That means, if the mutation is applied within a transaction with an isolation level such
  30161. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30162. // or updated by the mutation.
  30163. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  30164. switch {
  30165. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30166. id, exists := m.ID()
  30167. if exists {
  30168. return []uint64{id}, nil
  30169. }
  30170. fallthrough
  30171. case m.op.Is(OpUpdate | OpDelete):
  30172. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  30173. default:
  30174. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30175. }
  30176. }
  30177. // SetCreatedAt sets the "created_at" field.
  30178. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  30179. m.created_at = &t
  30180. }
  30181. // CreatedAt returns the value of the "created_at" field in the mutation.
  30182. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  30183. v := m.created_at
  30184. if v == nil {
  30185. return
  30186. }
  30187. return *v, true
  30188. }
  30189. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  30190. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30192. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30193. if !m.op.Is(OpUpdateOne) {
  30194. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30195. }
  30196. if m.id == nil || m.oldValue == nil {
  30197. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30198. }
  30199. oldValue, err := m.oldValue(ctx)
  30200. if err != nil {
  30201. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30202. }
  30203. return oldValue.CreatedAt, nil
  30204. }
  30205. // ResetCreatedAt resets all changes to the "created_at" field.
  30206. func (m *SopTaskMutation) ResetCreatedAt() {
  30207. m.created_at = nil
  30208. }
  30209. // SetUpdatedAt sets the "updated_at" field.
  30210. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  30211. m.updated_at = &t
  30212. }
  30213. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30214. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  30215. v := m.updated_at
  30216. if v == nil {
  30217. return
  30218. }
  30219. return *v, true
  30220. }
  30221. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  30222. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30224. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30225. if !m.op.Is(OpUpdateOne) {
  30226. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30227. }
  30228. if m.id == nil || m.oldValue == nil {
  30229. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30230. }
  30231. oldValue, err := m.oldValue(ctx)
  30232. if err != nil {
  30233. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30234. }
  30235. return oldValue.UpdatedAt, nil
  30236. }
  30237. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30238. func (m *SopTaskMutation) ResetUpdatedAt() {
  30239. m.updated_at = nil
  30240. }
  30241. // SetStatus sets the "status" field.
  30242. func (m *SopTaskMutation) SetStatus(u uint8) {
  30243. m.status = &u
  30244. m.addstatus = nil
  30245. }
  30246. // Status returns the value of the "status" field in the mutation.
  30247. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  30248. v := m.status
  30249. if v == nil {
  30250. return
  30251. }
  30252. return *v, true
  30253. }
  30254. // OldStatus returns the old "status" field's value of the SopTask entity.
  30255. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30257. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30258. if !m.op.Is(OpUpdateOne) {
  30259. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30260. }
  30261. if m.id == nil || m.oldValue == nil {
  30262. return v, errors.New("OldStatus requires an ID field in the mutation")
  30263. }
  30264. oldValue, err := m.oldValue(ctx)
  30265. if err != nil {
  30266. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30267. }
  30268. return oldValue.Status, nil
  30269. }
  30270. // AddStatus adds u to the "status" field.
  30271. func (m *SopTaskMutation) AddStatus(u int8) {
  30272. if m.addstatus != nil {
  30273. *m.addstatus += u
  30274. } else {
  30275. m.addstatus = &u
  30276. }
  30277. }
  30278. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30279. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  30280. v := m.addstatus
  30281. if v == nil {
  30282. return
  30283. }
  30284. return *v, true
  30285. }
  30286. // ClearStatus clears the value of the "status" field.
  30287. func (m *SopTaskMutation) ClearStatus() {
  30288. m.status = nil
  30289. m.addstatus = nil
  30290. m.clearedFields[soptask.FieldStatus] = struct{}{}
  30291. }
  30292. // StatusCleared returns if the "status" field was cleared in this mutation.
  30293. func (m *SopTaskMutation) StatusCleared() bool {
  30294. _, ok := m.clearedFields[soptask.FieldStatus]
  30295. return ok
  30296. }
  30297. // ResetStatus resets all changes to the "status" field.
  30298. func (m *SopTaskMutation) ResetStatus() {
  30299. m.status = nil
  30300. m.addstatus = nil
  30301. delete(m.clearedFields, soptask.FieldStatus)
  30302. }
  30303. // SetDeletedAt sets the "deleted_at" field.
  30304. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  30305. m.deleted_at = &t
  30306. }
  30307. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30308. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  30309. v := m.deleted_at
  30310. if v == nil {
  30311. return
  30312. }
  30313. return *v, true
  30314. }
  30315. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  30316. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30318. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30319. if !m.op.Is(OpUpdateOne) {
  30320. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30321. }
  30322. if m.id == nil || m.oldValue == nil {
  30323. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30324. }
  30325. oldValue, err := m.oldValue(ctx)
  30326. if err != nil {
  30327. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30328. }
  30329. return oldValue.DeletedAt, nil
  30330. }
  30331. // ClearDeletedAt clears the value of the "deleted_at" field.
  30332. func (m *SopTaskMutation) ClearDeletedAt() {
  30333. m.deleted_at = nil
  30334. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  30335. }
  30336. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30337. func (m *SopTaskMutation) DeletedAtCleared() bool {
  30338. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  30339. return ok
  30340. }
  30341. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30342. func (m *SopTaskMutation) ResetDeletedAt() {
  30343. m.deleted_at = nil
  30344. delete(m.clearedFields, soptask.FieldDeletedAt)
  30345. }
  30346. // SetName sets the "name" field.
  30347. func (m *SopTaskMutation) SetName(s string) {
  30348. m.name = &s
  30349. }
  30350. // Name returns the value of the "name" field in the mutation.
  30351. func (m *SopTaskMutation) Name() (r string, exists bool) {
  30352. v := m.name
  30353. if v == nil {
  30354. return
  30355. }
  30356. return *v, true
  30357. }
  30358. // OldName returns the old "name" field's value of the SopTask entity.
  30359. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30361. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  30362. if !m.op.Is(OpUpdateOne) {
  30363. return v, errors.New("OldName is only allowed on UpdateOne operations")
  30364. }
  30365. if m.id == nil || m.oldValue == nil {
  30366. return v, errors.New("OldName requires an ID field in the mutation")
  30367. }
  30368. oldValue, err := m.oldValue(ctx)
  30369. if err != nil {
  30370. return v, fmt.Errorf("querying old value for OldName: %w", err)
  30371. }
  30372. return oldValue.Name, nil
  30373. }
  30374. // ResetName resets all changes to the "name" field.
  30375. func (m *SopTaskMutation) ResetName() {
  30376. m.name = nil
  30377. }
  30378. // SetBotWxidList sets the "bot_wxid_list" field.
  30379. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  30380. m.bot_wxid_list = &s
  30381. m.appendbot_wxid_list = nil
  30382. }
  30383. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  30384. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  30385. v := m.bot_wxid_list
  30386. if v == nil {
  30387. return
  30388. }
  30389. return *v, true
  30390. }
  30391. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  30392. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30394. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  30395. if !m.op.Is(OpUpdateOne) {
  30396. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  30397. }
  30398. if m.id == nil || m.oldValue == nil {
  30399. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  30400. }
  30401. oldValue, err := m.oldValue(ctx)
  30402. if err != nil {
  30403. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  30404. }
  30405. return oldValue.BotWxidList, nil
  30406. }
  30407. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  30408. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  30409. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  30410. }
  30411. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  30412. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  30413. if len(m.appendbot_wxid_list) == 0 {
  30414. return nil, false
  30415. }
  30416. return m.appendbot_wxid_list, true
  30417. }
  30418. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  30419. func (m *SopTaskMutation) ClearBotWxidList() {
  30420. m.bot_wxid_list = nil
  30421. m.appendbot_wxid_list = nil
  30422. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  30423. }
  30424. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  30425. func (m *SopTaskMutation) BotWxidListCleared() bool {
  30426. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  30427. return ok
  30428. }
  30429. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  30430. func (m *SopTaskMutation) ResetBotWxidList() {
  30431. m.bot_wxid_list = nil
  30432. m.appendbot_wxid_list = nil
  30433. delete(m.clearedFields, soptask.FieldBotWxidList)
  30434. }
  30435. // SetType sets the "type" field.
  30436. func (m *SopTaskMutation) SetType(i int) {
  30437. m._type = &i
  30438. m.add_type = nil
  30439. }
  30440. // GetType returns the value of the "type" field in the mutation.
  30441. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  30442. v := m._type
  30443. if v == nil {
  30444. return
  30445. }
  30446. return *v, true
  30447. }
  30448. // OldType returns the old "type" field's value of the SopTask entity.
  30449. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30451. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  30452. if !m.op.Is(OpUpdateOne) {
  30453. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30454. }
  30455. if m.id == nil || m.oldValue == nil {
  30456. return v, errors.New("OldType requires an ID field in the mutation")
  30457. }
  30458. oldValue, err := m.oldValue(ctx)
  30459. if err != nil {
  30460. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30461. }
  30462. return oldValue.Type, nil
  30463. }
  30464. // AddType adds i to the "type" field.
  30465. func (m *SopTaskMutation) AddType(i int) {
  30466. if m.add_type != nil {
  30467. *m.add_type += i
  30468. } else {
  30469. m.add_type = &i
  30470. }
  30471. }
  30472. // AddedType returns the value that was added to the "type" field in this mutation.
  30473. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  30474. v := m.add_type
  30475. if v == nil {
  30476. return
  30477. }
  30478. return *v, true
  30479. }
  30480. // ResetType resets all changes to the "type" field.
  30481. func (m *SopTaskMutation) ResetType() {
  30482. m._type = nil
  30483. m.add_type = nil
  30484. }
  30485. // SetPlanStartTime sets the "plan_start_time" field.
  30486. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  30487. m.plan_start_time = &t
  30488. }
  30489. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  30490. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  30491. v := m.plan_start_time
  30492. if v == nil {
  30493. return
  30494. }
  30495. return *v, true
  30496. }
  30497. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  30498. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30500. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  30501. if !m.op.Is(OpUpdateOne) {
  30502. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  30503. }
  30504. if m.id == nil || m.oldValue == nil {
  30505. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  30506. }
  30507. oldValue, err := m.oldValue(ctx)
  30508. if err != nil {
  30509. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  30510. }
  30511. return oldValue.PlanStartTime, nil
  30512. }
  30513. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  30514. func (m *SopTaskMutation) ClearPlanStartTime() {
  30515. m.plan_start_time = nil
  30516. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  30517. }
  30518. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  30519. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  30520. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  30521. return ok
  30522. }
  30523. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  30524. func (m *SopTaskMutation) ResetPlanStartTime() {
  30525. m.plan_start_time = nil
  30526. delete(m.clearedFields, soptask.FieldPlanStartTime)
  30527. }
  30528. // SetPlanEndTime sets the "plan_end_time" field.
  30529. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  30530. m.plan_end_time = &t
  30531. }
  30532. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  30533. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  30534. v := m.plan_end_time
  30535. if v == nil {
  30536. return
  30537. }
  30538. return *v, true
  30539. }
  30540. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  30541. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30543. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  30544. if !m.op.Is(OpUpdateOne) {
  30545. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  30546. }
  30547. if m.id == nil || m.oldValue == nil {
  30548. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  30549. }
  30550. oldValue, err := m.oldValue(ctx)
  30551. if err != nil {
  30552. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  30553. }
  30554. return oldValue.PlanEndTime, nil
  30555. }
  30556. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  30557. func (m *SopTaskMutation) ClearPlanEndTime() {
  30558. m.plan_end_time = nil
  30559. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  30560. }
  30561. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  30562. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  30563. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  30564. return ok
  30565. }
  30566. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  30567. func (m *SopTaskMutation) ResetPlanEndTime() {
  30568. m.plan_end_time = nil
  30569. delete(m.clearedFields, soptask.FieldPlanEndTime)
  30570. }
  30571. // SetCreatorID sets the "creator_id" field.
  30572. func (m *SopTaskMutation) SetCreatorID(s string) {
  30573. m.creator_id = &s
  30574. }
  30575. // CreatorID returns the value of the "creator_id" field in the mutation.
  30576. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  30577. v := m.creator_id
  30578. if v == nil {
  30579. return
  30580. }
  30581. return *v, true
  30582. }
  30583. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  30584. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30586. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  30587. if !m.op.Is(OpUpdateOne) {
  30588. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  30589. }
  30590. if m.id == nil || m.oldValue == nil {
  30591. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  30592. }
  30593. oldValue, err := m.oldValue(ctx)
  30594. if err != nil {
  30595. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  30596. }
  30597. return oldValue.CreatorID, nil
  30598. }
  30599. // ClearCreatorID clears the value of the "creator_id" field.
  30600. func (m *SopTaskMutation) ClearCreatorID() {
  30601. m.creator_id = nil
  30602. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  30603. }
  30604. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  30605. func (m *SopTaskMutation) CreatorIDCleared() bool {
  30606. _, ok := m.clearedFields[soptask.FieldCreatorID]
  30607. return ok
  30608. }
  30609. // ResetCreatorID resets all changes to the "creator_id" field.
  30610. func (m *SopTaskMutation) ResetCreatorID() {
  30611. m.creator_id = nil
  30612. delete(m.clearedFields, soptask.FieldCreatorID)
  30613. }
  30614. // SetOrganizationID sets the "organization_id" field.
  30615. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  30616. m.organization_id = &u
  30617. m.addorganization_id = nil
  30618. }
  30619. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30620. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  30621. v := m.organization_id
  30622. if v == nil {
  30623. return
  30624. }
  30625. return *v, true
  30626. }
  30627. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  30628. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30630. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30631. if !m.op.Is(OpUpdateOne) {
  30632. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30633. }
  30634. if m.id == nil || m.oldValue == nil {
  30635. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30636. }
  30637. oldValue, err := m.oldValue(ctx)
  30638. if err != nil {
  30639. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30640. }
  30641. return oldValue.OrganizationID, nil
  30642. }
  30643. // AddOrganizationID adds u to the "organization_id" field.
  30644. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  30645. if m.addorganization_id != nil {
  30646. *m.addorganization_id += u
  30647. } else {
  30648. m.addorganization_id = &u
  30649. }
  30650. }
  30651. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30652. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  30653. v := m.addorganization_id
  30654. if v == nil {
  30655. return
  30656. }
  30657. return *v, true
  30658. }
  30659. // ClearOrganizationID clears the value of the "organization_id" field.
  30660. func (m *SopTaskMutation) ClearOrganizationID() {
  30661. m.organization_id = nil
  30662. m.addorganization_id = nil
  30663. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  30664. }
  30665. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30666. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  30667. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  30668. return ok
  30669. }
  30670. // ResetOrganizationID resets all changes to the "organization_id" field.
  30671. func (m *SopTaskMutation) ResetOrganizationID() {
  30672. m.organization_id = nil
  30673. m.addorganization_id = nil
  30674. delete(m.clearedFields, soptask.FieldOrganizationID)
  30675. }
  30676. // SetToken sets the "token" field.
  30677. func (m *SopTaskMutation) SetToken(s []string) {
  30678. m.token = &s
  30679. m.appendtoken = nil
  30680. }
  30681. // Token returns the value of the "token" field in the mutation.
  30682. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  30683. v := m.token
  30684. if v == nil {
  30685. return
  30686. }
  30687. return *v, true
  30688. }
  30689. // OldToken returns the old "token" field's value of the SopTask entity.
  30690. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30692. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  30693. if !m.op.Is(OpUpdateOne) {
  30694. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  30695. }
  30696. if m.id == nil || m.oldValue == nil {
  30697. return v, errors.New("OldToken requires an ID field in the mutation")
  30698. }
  30699. oldValue, err := m.oldValue(ctx)
  30700. if err != nil {
  30701. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  30702. }
  30703. return oldValue.Token, nil
  30704. }
  30705. // AppendToken adds s to the "token" field.
  30706. func (m *SopTaskMutation) AppendToken(s []string) {
  30707. m.appendtoken = append(m.appendtoken, s...)
  30708. }
  30709. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  30710. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  30711. if len(m.appendtoken) == 0 {
  30712. return nil, false
  30713. }
  30714. return m.appendtoken, true
  30715. }
  30716. // ClearToken clears the value of the "token" field.
  30717. func (m *SopTaskMutation) ClearToken() {
  30718. m.token = nil
  30719. m.appendtoken = nil
  30720. m.clearedFields[soptask.FieldToken] = struct{}{}
  30721. }
  30722. // TokenCleared returns if the "token" field was cleared in this mutation.
  30723. func (m *SopTaskMutation) TokenCleared() bool {
  30724. _, ok := m.clearedFields[soptask.FieldToken]
  30725. return ok
  30726. }
  30727. // ResetToken resets all changes to the "token" field.
  30728. func (m *SopTaskMutation) ResetToken() {
  30729. m.token = nil
  30730. m.appendtoken = nil
  30731. delete(m.clearedFields, soptask.FieldToken)
  30732. }
  30733. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  30734. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  30735. if m.task_stages == nil {
  30736. m.task_stages = make(map[uint64]struct{})
  30737. }
  30738. for i := range ids {
  30739. m.task_stages[ids[i]] = struct{}{}
  30740. }
  30741. }
  30742. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  30743. func (m *SopTaskMutation) ClearTaskStages() {
  30744. m.clearedtask_stages = true
  30745. }
  30746. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  30747. func (m *SopTaskMutation) TaskStagesCleared() bool {
  30748. return m.clearedtask_stages
  30749. }
  30750. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  30751. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  30752. if m.removedtask_stages == nil {
  30753. m.removedtask_stages = make(map[uint64]struct{})
  30754. }
  30755. for i := range ids {
  30756. delete(m.task_stages, ids[i])
  30757. m.removedtask_stages[ids[i]] = struct{}{}
  30758. }
  30759. }
  30760. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  30761. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  30762. for id := range m.removedtask_stages {
  30763. ids = append(ids, id)
  30764. }
  30765. return
  30766. }
  30767. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  30768. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  30769. for id := range m.task_stages {
  30770. ids = append(ids, id)
  30771. }
  30772. return
  30773. }
  30774. // ResetTaskStages resets all changes to the "task_stages" edge.
  30775. func (m *SopTaskMutation) ResetTaskStages() {
  30776. m.task_stages = nil
  30777. m.clearedtask_stages = false
  30778. m.removedtask_stages = nil
  30779. }
  30780. // Where appends a list predicates to the SopTaskMutation builder.
  30781. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  30782. m.predicates = append(m.predicates, ps...)
  30783. }
  30784. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  30785. // users can use type-assertion to append predicates that do not depend on any generated package.
  30786. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  30787. p := make([]predicate.SopTask, len(ps))
  30788. for i := range ps {
  30789. p[i] = ps[i]
  30790. }
  30791. m.Where(p...)
  30792. }
  30793. // Op returns the operation name.
  30794. func (m *SopTaskMutation) Op() Op {
  30795. return m.op
  30796. }
  30797. // SetOp allows setting the mutation operation.
  30798. func (m *SopTaskMutation) SetOp(op Op) {
  30799. m.op = op
  30800. }
  30801. // Type returns the node type of this mutation (SopTask).
  30802. func (m *SopTaskMutation) Type() string {
  30803. return m.typ
  30804. }
  30805. // Fields returns all fields that were changed during this mutation. Note that in
  30806. // order to get all numeric fields that were incremented/decremented, call
  30807. // AddedFields().
  30808. func (m *SopTaskMutation) Fields() []string {
  30809. fields := make([]string, 0, 12)
  30810. if m.created_at != nil {
  30811. fields = append(fields, soptask.FieldCreatedAt)
  30812. }
  30813. if m.updated_at != nil {
  30814. fields = append(fields, soptask.FieldUpdatedAt)
  30815. }
  30816. if m.status != nil {
  30817. fields = append(fields, soptask.FieldStatus)
  30818. }
  30819. if m.deleted_at != nil {
  30820. fields = append(fields, soptask.FieldDeletedAt)
  30821. }
  30822. if m.name != nil {
  30823. fields = append(fields, soptask.FieldName)
  30824. }
  30825. if m.bot_wxid_list != nil {
  30826. fields = append(fields, soptask.FieldBotWxidList)
  30827. }
  30828. if m._type != nil {
  30829. fields = append(fields, soptask.FieldType)
  30830. }
  30831. if m.plan_start_time != nil {
  30832. fields = append(fields, soptask.FieldPlanStartTime)
  30833. }
  30834. if m.plan_end_time != nil {
  30835. fields = append(fields, soptask.FieldPlanEndTime)
  30836. }
  30837. if m.creator_id != nil {
  30838. fields = append(fields, soptask.FieldCreatorID)
  30839. }
  30840. if m.organization_id != nil {
  30841. fields = append(fields, soptask.FieldOrganizationID)
  30842. }
  30843. if m.token != nil {
  30844. fields = append(fields, soptask.FieldToken)
  30845. }
  30846. return fields
  30847. }
  30848. // Field returns the value of a field with the given name. The second boolean
  30849. // return value indicates that this field was not set, or was not defined in the
  30850. // schema.
  30851. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  30852. switch name {
  30853. case soptask.FieldCreatedAt:
  30854. return m.CreatedAt()
  30855. case soptask.FieldUpdatedAt:
  30856. return m.UpdatedAt()
  30857. case soptask.FieldStatus:
  30858. return m.Status()
  30859. case soptask.FieldDeletedAt:
  30860. return m.DeletedAt()
  30861. case soptask.FieldName:
  30862. return m.Name()
  30863. case soptask.FieldBotWxidList:
  30864. return m.BotWxidList()
  30865. case soptask.FieldType:
  30866. return m.GetType()
  30867. case soptask.FieldPlanStartTime:
  30868. return m.PlanStartTime()
  30869. case soptask.FieldPlanEndTime:
  30870. return m.PlanEndTime()
  30871. case soptask.FieldCreatorID:
  30872. return m.CreatorID()
  30873. case soptask.FieldOrganizationID:
  30874. return m.OrganizationID()
  30875. case soptask.FieldToken:
  30876. return m.Token()
  30877. }
  30878. return nil, false
  30879. }
  30880. // OldField returns the old value of the field from the database. An error is
  30881. // returned if the mutation operation is not UpdateOne, or the query to the
  30882. // database failed.
  30883. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30884. switch name {
  30885. case soptask.FieldCreatedAt:
  30886. return m.OldCreatedAt(ctx)
  30887. case soptask.FieldUpdatedAt:
  30888. return m.OldUpdatedAt(ctx)
  30889. case soptask.FieldStatus:
  30890. return m.OldStatus(ctx)
  30891. case soptask.FieldDeletedAt:
  30892. return m.OldDeletedAt(ctx)
  30893. case soptask.FieldName:
  30894. return m.OldName(ctx)
  30895. case soptask.FieldBotWxidList:
  30896. return m.OldBotWxidList(ctx)
  30897. case soptask.FieldType:
  30898. return m.OldType(ctx)
  30899. case soptask.FieldPlanStartTime:
  30900. return m.OldPlanStartTime(ctx)
  30901. case soptask.FieldPlanEndTime:
  30902. return m.OldPlanEndTime(ctx)
  30903. case soptask.FieldCreatorID:
  30904. return m.OldCreatorID(ctx)
  30905. case soptask.FieldOrganizationID:
  30906. return m.OldOrganizationID(ctx)
  30907. case soptask.FieldToken:
  30908. return m.OldToken(ctx)
  30909. }
  30910. return nil, fmt.Errorf("unknown SopTask field %s", name)
  30911. }
  30912. // SetField sets the value of a field with the given name. It returns an error if
  30913. // the field is not defined in the schema, or if the type mismatched the field
  30914. // type.
  30915. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  30916. switch name {
  30917. case soptask.FieldCreatedAt:
  30918. v, ok := value.(time.Time)
  30919. if !ok {
  30920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30921. }
  30922. m.SetCreatedAt(v)
  30923. return nil
  30924. case soptask.FieldUpdatedAt:
  30925. v, ok := value.(time.Time)
  30926. if !ok {
  30927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30928. }
  30929. m.SetUpdatedAt(v)
  30930. return nil
  30931. case soptask.FieldStatus:
  30932. v, ok := value.(uint8)
  30933. if !ok {
  30934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30935. }
  30936. m.SetStatus(v)
  30937. return nil
  30938. case soptask.FieldDeletedAt:
  30939. v, ok := value.(time.Time)
  30940. if !ok {
  30941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30942. }
  30943. m.SetDeletedAt(v)
  30944. return nil
  30945. case soptask.FieldName:
  30946. v, ok := value.(string)
  30947. if !ok {
  30948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30949. }
  30950. m.SetName(v)
  30951. return nil
  30952. case soptask.FieldBotWxidList:
  30953. v, ok := value.([]string)
  30954. if !ok {
  30955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30956. }
  30957. m.SetBotWxidList(v)
  30958. return nil
  30959. case soptask.FieldType:
  30960. v, ok := value.(int)
  30961. if !ok {
  30962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30963. }
  30964. m.SetType(v)
  30965. return nil
  30966. case soptask.FieldPlanStartTime:
  30967. v, ok := value.(time.Time)
  30968. if !ok {
  30969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30970. }
  30971. m.SetPlanStartTime(v)
  30972. return nil
  30973. case soptask.FieldPlanEndTime:
  30974. v, ok := value.(time.Time)
  30975. if !ok {
  30976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30977. }
  30978. m.SetPlanEndTime(v)
  30979. return nil
  30980. case soptask.FieldCreatorID:
  30981. v, ok := value.(string)
  30982. if !ok {
  30983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30984. }
  30985. m.SetCreatorID(v)
  30986. return nil
  30987. case soptask.FieldOrganizationID:
  30988. v, ok := value.(uint64)
  30989. if !ok {
  30990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30991. }
  30992. m.SetOrganizationID(v)
  30993. return nil
  30994. case soptask.FieldToken:
  30995. v, ok := value.([]string)
  30996. if !ok {
  30997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30998. }
  30999. m.SetToken(v)
  31000. return nil
  31001. }
  31002. return fmt.Errorf("unknown SopTask field %s", name)
  31003. }
  31004. // AddedFields returns all numeric fields that were incremented/decremented during
  31005. // this mutation.
  31006. func (m *SopTaskMutation) AddedFields() []string {
  31007. var fields []string
  31008. if m.addstatus != nil {
  31009. fields = append(fields, soptask.FieldStatus)
  31010. }
  31011. if m.add_type != nil {
  31012. fields = append(fields, soptask.FieldType)
  31013. }
  31014. if m.addorganization_id != nil {
  31015. fields = append(fields, soptask.FieldOrganizationID)
  31016. }
  31017. return fields
  31018. }
  31019. // AddedField returns the numeric value that was incremented/decremented on a field
  31020. // with the given name. The second boolean return value indicates that this field
  31021. // was not set, or was not defined in the schema.
  31022. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  31023. switch name {
  31024. case soptask.FieldStatus:
  31025. return m.AddedStatus()
  31026. case soptask.FieldType:
  31027. return m.AddedType()
  31028. case soptask.FieldOrganizationID:
  31029. return m.AddedOrganizationID()
  31030. }
  31031. return nil, false
  31032. }
  31033. // AddField adds the value to the field with the given name. It returns an error if
  31034. // the field is not defined in the schema, or if the type mismatched the field
  31035. // type.
  31036. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  31037. switch name {
  31038. case soptask.FieldStatus:
  31039. v, ok := value.(int8)
  31040. if !ok {
  31041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31042. }
  31043. m.AddStatus(v)
  31044. return nil
  31045. case soptask.FieldType:
  31046. v, ok := value.(int)
  31047. if !ok {
  31048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31049. }
  31050. m.AddType(v)
  31051. return nil
  31052. case soptask.FieldOrganizationID:
  31053. v, ok := value.(int64)
  31054. if !ok {
  31055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31056. }
  31057. m.AddOrganizationID(v)
  31058. return nil
  31059. }
  31060. return fmt.Errorf("unknown SopTask numeric field %s", name)
  31061. }
  31062. // ClearedFields returns all nullable fields that were cleared during this
  31063. // mutation.
  31064. func (m *SopTaskMutation) ClearedFields() []string {
  31065. var fields []string
  31066. if m.FieldCleared(soptask.FieldStatus) {
  31067. fields = append(fields, soptask.FieldStatus)
  31068. }
  31069. if m.FieldCleared(soptask.FieldDeletedAt) {
  31070. fields = append(fields, soptask.FieldDeletedAt)
  31071. }
  31072. if m.FieldCleared(soptask.FieldBotWxidList) {
  31073. fields = append(fields, soptask.FieldBotWxidList)
  31074. }
  31075. if m.FieldCleared(soptask.FieldPlanStartTime) {
  31076. fields = append(fields, soptask.FieldPlanStartTime)
  31077. }
  31078. if m.FieldCleared(soptask.FieldPlanEndTime) {
  31079. fields = append(fields, soptask.FieldPlanEndTime)
  31080. }
  31081. if m.FieldCleared(soptask.FieldCreatorID) {
  31082. fields = append(fields, soptask.FieldCreatorID)
  31083. }
  31084. if m.FieldCleared(soptask.FieldOrganizationID) {
  31085. fields = append(fields, soptask.FieldOrganizationID)
  31086. }
  31087. if m.FieldCleared(soptask.FieldToken) {
  31088. fields = append(fields, soptask.FieldToken)
  31089. }
  31090. return fields
  31091. }
  31092. // FieldCleared returns a boolean indicating if a field with the given name was
  31093. // cleared in this mutation.
  31094. func (m *SopTaskMutation) FieldCleared(name string) bool {
  31095. _, ok := m.clearedFields[name]
  31096. return ok
  31097. }
  31098. // ClearField clears the value of the field with the given name. It returns an
  31099. // error if the field is not defined in the schema.
  31100. func (m *SopTaskMutation) ClearField(name string) error {
  31101. switch name {
  31102. case soptask.FieldStatus:
  31103. m.ClearStatus()
  31104. return nil
  31105. case soptask.FieldDeletedAt:
  31106. m.ClearDeletedAt()
  31107. return nil
  31108. case soptask.FieldBotWxidList:
  31109. m.ClearBotWxidList()
  31110. return nil
  31111. case soptask.FieldPlanStartTime:
  31112. m.ClearPlanStartTime()
  31113. return nil
  31114. case soptask.FieldPlanEndTime:
  31115. m.ClearPlanEndTime()
  31116. return nil
  31117. case soptask.FieldCreatorID:
  31118. m.ClearCreatorID()
  31119. return nil
  31120. case soptask.FieldOrganizationID:
  31121. m.ClearOrganizationID()
  31122. return nil
  31123. case soptask.FieldToken:
  31124. m.ClearToken()
  31125. return nil
  31126. }
  31127. return fmt.Errorf("unknown SopTask nullable field %s", name)
  31128. }
  31129. // ResetField resets all changes in the mutation for the field with the given name.
  31130. // It returns an error if the field is not defined in the schema.
  31131. func (m *SopTaskMutation) ResetField(name string) error {
  31132. switch name {
  31133. case soptask.FieldCreatedAt:
  31134. m.ResetCreatedAt()
  31135. return nil
  31136. case soptask.FieldUpdatedAt:
  31137. m.ResetUpdatedAt()
  31138. return nil
  31139. case soptask.FieldStatus:
  31140. m.ResetStatus()
  31141. return nil
  31142. case soptask.FieldDeletedAt:
  31143. m.ResetDeletedAt()
  31144. return nil
  31145. case soptask.FieldName:
  31146. m.ResetName()
  31147. return nil
  31148. case soptask.FieldBotWxidList:
  31149. m.ResetBotWxidList()
  31150. return nil
  31151. case soptask.FieldType:
  31152. m.ResetType()
  31153. return nil
  31154. case soptask.FieldPlanStartTime:
  31155. m.ResetPlanStartTime()
  31156. return nil
  31157. case soptask.FieldPlanEndTime:
  31158. m.ResetPlanEndTime()
  31159. return nil
  31160. case soptask.FieldCreatorID:
  31161. m.ResetCreatorID()
  31162. return nil
  31163. case soptask.FieldOrganizationID:
  31164. m.ResetOrganizationID()
  31165. return nil
  31166. case soptask.FieldToken:
  31167. m.ResetToken()
  31168. return nil
  31169. }
  31170. return fmt.Errorf("unknown SopTask field %s", name)
  31171. }
  31172. // AddedEdges returns all edge names that were set/added in this mutation.
  31173. func (m *SopTaskMutation) AddedEdges() []string {
  31174. edges := make([]string, 0, 1)
  31175. if m.task_stages != nil {
  31176. edges = append(edges, soptask.EdgeTaskStages)
  31177. }
  31178. return edges
  31179. }
  31180. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31181. // name in this mutation.
  31182. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  31183. switch name {
  31184. case soptask.EdgeTaskStages:
  31185. ids := make([]ent.Value, 0, len(m.task_stages))
  31186. for id := range m.task_stages {
  31187. ids = append(ids, id)
  31188. }
  31189. return ids
  31190. }
  31191. return nil
  31192. }
  31193. // RemovedEdges returns all edge names that were removed in this mutation.
  31194. func (m *SopTaskMutation) RemovedEdges() []string {
  31195. edges := make([]string, 0, 1)
  31196. if m.removedtask_stages != nil {
  31197. edges = append(edges, soptask.EdgeTaskStages)
  31198. }
  31199. return edges
  31200. }
  31201. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31202. // the given name in this mutation.
  31203. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  31204. switch name {
  31205. case soptask.EdgeTaskStages:
  31206. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  31207. for id := range m.removedtask_stages {
  31208. ids = append(ids, id)
  31209. }
  31210. return ids
  31211. }
  31212. return nil
  31213. }
  31214. // ClearedEdges returns all edge names that were cleared in this mutation.
  31215. func (m *SopTaskMutation) ClearedEdges() []string {
  31216. edges := make([]string, 0, 1)
  31217. if m.clearedtask_stages {
  31218. edges = append(edges, soptask.EdgeTaskStages)
  31219. }
  31220. return edges
  31221. }
  31222. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31223. // was cleared in this mutation.
  31224. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  31225. switch name {
  31226. case soptask.EdgeTaskStages:
  31227. return m.clearedtask_stages
  31228. }
  31229. return false
  31230. }
  31231. // ClearEdge clears the value of the edge with the given name. It returns an error
  31232. // if that edge is not defined in the schema.
  31233. func (m *SopTaskMutation) ClearEdge(name string) error {
  31234. switch name {
  31235. }
  31236. return fmt.Errorf("unknown SopTask unique edge %s", name)
  31237. }
  31238. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31239. // It returns an error if the edge is not defined in the schema.
  31240. func (m *SopTaskMutation) ResetEdge(name string) error {
  31241. switch name {
  31242. case soptask.EdgeTaskStages:
  31243. m.ResetTaskStages()
  31244. return nil
  31245. }
  31246. return fmt.Errorf("unknown SopTask edge %s", name)
  31247. }
  31248. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  31249. type TokenMutation struct {
  31250. config
  31251. op Op
  31252. typ string
  31253. id *uint64
  31254. created_at *time.Time
  31255. updated_at *time.Time
  31256. deleted_at *time.Time
  31257. expire_at *time.Time
  31258. token *string
  31259. mac *string
  31260. organization_id *uint64
  31261. addorganization_id *int64
  31262. custom_agent_base *string
  31263. custom_agent_key *string
  31264. openai_base *string
  31265. openai_key *string
  31266. clearedFields map[string]struct{}
  31267. agent *uint64
  31268. clearedagent bool
  31269. done bool
  31270. oldValue func(context.Context) (*Token, error)
  31271. predicates []predicate.Token
  31272. }
  31273. var _ ent.Mutation = (*TokenMutation)(nil)
  31274. // tokenOption allows management of the mutation configuration using functional options.
  31275. type tokenOption func(*TokenMutation)
  31276. // newTokenMutation creates new mutation for the Token entity.
  31277. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  31278. m := &TokenMutation{
  31279. config: c,
  31280. op: op,
  31281. typ: TypeToken,
  31282. clearedFields: make(map[string]struct{}),
  31283. }
  31284. for _, opt := range opts {
  31285. opt(m)
  31286. }
  31287. return m
  31288. }
  31289. // withTokenID sets the ID field of the mutation.
  31290. func withTokenID(id uint64) tokenOption {
  31291. return func(m *TokenMutation) {
  31292. var (
  31293. err error
  31294. once sync.Once
  31295. value *Token
  31296. )
  31297. m.oldValue = func(ctx context.Context) (*Token, error) {
  31298. once.Do(func() {
  31299. if m.done {
  31300. err = errors.New("querying old values post mutation is not allowed")
  31301. } else {
  31302. value, err = m.Client().Token.Get(ctx, id)
  31303. }
  31304. })
  31305. return value, err
  31306. }
  31307. m.id = &id
  31308. }
  31309. }
  31310. // withToken sets the old Token of the mutation.
  31311. func withToken(node *Token) tokenOption {
  31312. return func(m *TokenMutation) {
  31313. m.oldValue = func(context.Context) (*Token, error) {
  31314. return node, nil
  31315. }
  31316. m.id = &node.ID
  31317. }
  31318. }
  31319. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31320. // executed in a transaction (ent.Tx), a transactional client is returned.
  31321. func (m TokenMutation) Client() *Client {
  31322. client := &Client{config: m.config}
  31323. client.init()
  31324. return client
  31325. }
  31326. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31327. // it returns an error otherwise.
  31328. func (m TokenMutation) Tx() (*Tx, error) {
  31329. if _, ok := m.driver.(*txDriver); !ok {
  31330. return nil, errors.New("ent: mutation is not running in a transaction")
  31331. }
  31332. tx := &Tx{config: m.config}
  31333. tx.init()
  31334. return tx, nil
  31335. }
  31336. // SetID sets the value of the id field. Note that this
  31337. // operation is only accepted on creation of Token entities.
  31338. func (m *TokenMutation) SetID(id uint64) {
  31339. m.id = &id
  31340. }
  31341. // ID returns the ID value in the mutation. Note that the ID is only available
  31342. // if it was provided to the builder or after it was returned from the database.
  31343. func (m *TokenMutation) ID() (id uint64, exists bool) {
  31344. if m.id == nil {
  31345. return
  31346. }
  31347. return *m.id, true
  31348. }
  31349. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31350. // That means, if the mutation is applied within a transaction with an isolation level such
  31351. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31352. // or updated by the mutation.
  31353. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  31354. switch {
  31355. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31356. id, exists := m.ID()
  31357. if exists {
  31358. return []uint64{id}, nil
  31359. }
  31360. fallthrough
  31361. case m.op.Is(OpUpdate | OpDelete):
  31362. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  31363. default:
  31364. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31365. }
  31366. }
  31367. // SetCreatedAt sets the "created_at" field.
  31368. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  31369. m.created_at = &t
  31370. }
  31371. // CreatedAt returns the value of the "created_at" field in the mutation.
  31372. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  31373. v := m.created_at
  31374. if v == nil {
  31375. return
  31376. }
  31377. return *v, true
  31378. }
  31379. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  31380. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31382. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31383. if !m.op.Is(OpUpdateOne) {
  31384. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31385. }
  31386. if m.id == nil || m.oldValue == nil {
  31387. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31388. }
  31389. oldValue, err := m.oldValue(ctx)
  31390. if err != nil {
  31391. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31392. }
  31393. return oldValue.CreatedAt, nil
  31394. }
  31395. // ResetCreatedAt resets all changes to the "created_at" field.
  31396. func (m *TokenMutation) ResetCreatedAt() {
  31397. m.created_at = nil
  31398. }
  31399. // SetUpdatedAt sets the "updated_at" field.
  31400. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  31401. m.updated_at = &t
  31402. }
  31403. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31404. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  31405. v := m.updated_at
  31406. if v == nil {
  31407. return
  31408. }
  31409. return *v, true
  31410. }
  31411. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  31412. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31414. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31415. if !m.op.Is(OpUpdateOne) {
  31416. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31417. }
  31418. if m.id == nil || m.oldValue == nil {
  31419. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31420. }
  31421. oldValue, err := m.oldValue(ctx)
  31422. if err != nil {
  31423. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31424. }
  31425. return oldValue.UpdatedAt, nil
  31426. }
  31427. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31428. func (m *TokenMutation) ResetUpdatedAt() {
  31429. m.updated_at = nil
  31430. }
  31431. // SetDeletedAt sets the "deleted_at" field.
  31432. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  31433. m.deleted_at = &t
  31434. }
  31435. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31436. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  31437. v := m.deleted_at
  31438. if v == nil {
  31439. return
  31440. }
  31441. return *v, true
  31442. }
  31443. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  31444. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31446. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31447. if !m.op.Is(OpUpdateOne) {
  31448. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31449. }
  31450. if m.id == nil || m.oldValue == nil {
  31451. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31452. }
  31453. oldValue, err := m.oldValue(ctx)
  31454. if err != nil {
  31455. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31456. }
  31457. return oldValue.DeletedAt, nil
  31458. }
  31459. // ClearDeletedAt clears the value of the "deleted_at" field.
  31460. func (m *TokenMutation) ClearDeletedAt() {
  31461. m.deleted_at = nil
  31462. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  31463. }
  31464. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31465. func (m *TokenMutation) DeletedAtCleared() bool {
  31466. _, ok := m.clearedFields[token.FieldDeletedAt]
  31467. return ok
  31468. }
  31469. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31470. func (m *TokenMutation) ResetDeletedAt() {
  31471. m.deleted_at = nil
  31472. delete(m.clearedFields, token.FieldDeletedAt)
  31473. }
  31474. // SetExpireAt sets the "expire_at" field.
  31475. func (m *TokenMutation) SetExpireAt(t time.Time) {
  31476. m.expire_at = &t
  31477. }
  31478. // ExpireAt returns the value of the "expire_at" field in the mutation.
  31479. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  31480. v := m.expire_at
  31481. if v == nil {
  31482. return
  31483. }
  31484. return *v, true
  31485. }
  31486. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  31487. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31489. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  31490. if !m.op.Is(OpUpdateOne) {
  31491. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  31492. }
  31493. if m.id == nil || m.oldValue == nil {
  31494. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  31495. }
  31496. oldValue, err := m.oldValue(ctx)
  31497. if err != nil {
  31498. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  31499. }
  31500. return oldValue.ExpireAt, nil
  31501. }
  31502. // ClearExpireAt clears the value of the "expire_at" field.
  31503. func (m *TokenMutation) ClearExpireAt() {
  31504. m.expire_at = nil
  31505. m.clearedFields[token.FieldExpireAt] = struct{}{}
  31506. }
  31507. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  31508. func (m *TokenMutation) ExpireAtCleared() bool {
  31509. _, ok := m.clearedFields[token.FieldExpireAt]
  31510. return ok
  31511. }
  31512. // ResetExpireAt resets all changes to the "expire_at" field.
  31513. func (m *TokenMutation) ResetExpireAt() {
  31514. m.expire_at = nil
  31515. delete(m.clearedFields, token.FieldExpireAt)
  31516. }
  31517. // SetToken sets the "token" field.
  31518. func (m *TokenMutation) SetToken(s string) {
  31519. m.token = &s
  31520. }
  31521. // Token returns the value of the "token" field in the mutation.
  31522. func (m *TokenMutation) Token() (r string, exists bool) {
  31523. v := m.token
  31524. if v == nil {
  31525. return
  31526. }
  31527. return *v, true
  31528. }
  31529. // OldToken returns the old "token" field's value of the Token entity.
  31530. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31532. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  31533. if !m.op.Is(OpUpdateOne) {
  31534. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  31535. }
  31536. if m.id == nil || m.oldValue == nil {
  31537. return v, errors.New("OldToken requires an ID field in the mutation")
  31538. }
  31539. oldValue, err := m.oldValue(ctx)
  31540. if err != nil {
  31541. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  31542. }
  31543. return oldValue.Token, nil
  31544. }
  31545. // ClearToken clears the value of the "token" field.
  31546. func (m *TokenMutation) ClearToken() {
  31547. m.token = nil
  31548. m.clearedFields[token.FieldToken] = struct{}{}
  31549. }
  31550. // TokenCleared returns if the "token" field was cleared in this mutation.
  31551. func (m *TokenMutation) TokenCleared() bool {
  31552. _, ok := m.clearedFields[token.FieldToken]
  31553. return ok
  31554. }
  31555. // ResetToken resets all changes to the "token" field.
  31556. func (m *TokenMutation) ResetToken() {
  31557. m.token = nil
  31558. delete(m.clearedFields, token.FieldToken)
  31559. }
  31560. // SetMAC sets the "mac" field.
  31561. func (m *TokenMutation) SetMAC(s string) {
  31562. m.mac = &s
  31563. }
  31564. // MAC returns the value of the "mac" field in the mutation.
  31565. func (m *TokenMutation) MAC() (r string, exists bool) {
  31566. v := m.mac
  31567. if v == nil {
  31568. return
  31569. }
  31570. return *v, true
  31571. }
  31572. // OldMAC returns the old "mac" field's value of the Token entity.
  31573. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31575. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  31576. if !m.op.Is(OpUpdateOne) {
  31577. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  31578. }
  31579. if m.id == nil || m.oldValue == nil {
  31580. return v, errors.New("OldMAC requires an ID field in the mutation")
  31581. }
  31582. oldValue, err := m.oldValue(ctx)
  31583. if err != nil {
  31584. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  31585. }
  31586. return oldValue.MAC, nil
  31587. }
  31588. // ClearMAC clears the value of the "mac" field.
  31589. func (m *TokenMutation) ClearMAC() {
  31590. m.mac = nil
  31591. m.clearedFields[token.FieldMAC] = struct{}{}
  31592. }
  31593. // MACCleared returns if the "mac" field was cleared in this mutation.
  31594. func (m *TokenMutation) MACCleared() bool {
  31595. _, ok := m.clearedFields[token.FieldMAC]
  31596. return ok
  31597. }
  31598. // ResetMAC resets all changes to the "mac" field.
  31599. func (m *TokenMutation) ResetMAC() {
  31600. m.mac = nil
  31601. delete(m.clearedFields, token.FieldMAC)
  31602. }
  31603. // SetOrganizationID sets the "organization_id" field.
  31604. func (m *TokenMutation) SetOrganizationID(u uint64) {
  31605. m.organization_id = &u
  31606. m.addorganization_id = nil
  31607. }
  31608. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31609. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  31610. v := m.organization_id
  31611. if v == nil {
  31612. return
  31613. }
  31614. return *v, true
  31615. }
  31616. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  31617. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31619. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31620. if !m.op.Is(OpUpdateOne) {
  31621. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31622. }
  31623. if m.id == nil || m.oldValue == nil {
  31624. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31625. }
  31626. oldValue, err := m.oldValue(ctx)
  31627. if err != nil {
  31628. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31629. }
  31630. return oldValue.OrganizationID, nil
  31631. }
  31632. // AddOrganizationID adds u to the "organization_id" field.
  31633. func (m *TokenMutation) AddOrganizationID(u int64) {
  31634. if m.addorganization_id != nil {
  31635. *m.addorganization_id += u
  31636. } else {
  31637. m.addorganization_id = &u
  31638. }
  31639. }
  31640. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31641. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  31642. v := m.addorganization_id
  31643. if v == nil {
  31644. return
  31645. }
  31646. return *v, true
  31647. }
  31648. // ResetOrganizationID resets all changes to the "organization_id" field.
  31649. func (m *TokenMutation) ResetOrganizationID() {
  31650. m.organization_id = nil
  31651. m.addorganization_id = nil
  31652. }
  31653. // SetAgentID sets the "agent_id" field.
  31654. func (m *TokenMutation) SetAgentID(u uint64) {
  31655. m.agent = &u
  31656. }
  31657. // AgentID returns the value of the "agent_id" field in the mutation.
  31658. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  31659. v := m.agent
  31660. if v == nil {
  31661. return
  31662. }
  31663. return *v, true
  31664. }
  31665. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  31666. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31668. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  31669. if !m.op.Is(OpUpdateOne) {
  31670. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  31671. }
  31672. if m.id == nil || m.oldValue == nil {
  31673. return v, errors.New("OldAgentID requires an ID field in the mutation")
  31674. }
  31675. oldValue, err := m.oldValue(ctx)
  31676. if err != nil {
  31677. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  31678. }
  31679. return oldValue.AgentID, nil
  31680. }
  31681. // ResetAgentID resets all changes to the "agent_id" field.
  31682. func (m *TokenMutation) ResetAgentID() {
  31683. m.agent = nil
  31684. }
  31685. // SetCustomAgentBase sets the "custom_agent_base" field.
  31686. func (m *TokenMutation) SetCustomAgentBase(s string) {
  31687. m.custom_agent_base = &s
  31688. }
  31689. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  31690. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  31691. v := m.custom_agent_base
  31692. if v == nil {
  31693. return
  31694. }
  31695. return *v, true
  31696. }
  31697. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  31698. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31700. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  31701. if !m.op.Is(OpUpdateOne) {
  31702. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  31703. }
  31704. if m.id == nil || m.oldValue == nil {
  31705. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  31706. }
  31707. oldValue, err := m.oldValue(ctx)
  31708. if err != nil {
  31709. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  31710. }
  31711. return oldValue.CustomAgentBase, nil
  31712. }
  31713. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  31714. func (m *TokenMutation) ClearCustomAgentBase() {
  31715. m.custom_agent_base = nil
  31716. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  31717. }
  31718. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  31719. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  31720. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  31721. return ok
  31722. }
  31723. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  31724. func (m *TokenMutation) ResetCustomAgentBase() {
  31725. m.custom_agent_base = nil
  31726. delete(m.clearedFields, token.FieldCustomAgentBase)
  31727. }
  31728. // SetCustomAgentKey sets the "custom_agent_key" field.
  31729. func (m *TokenMutation) SetCustomAgentKey(s string) {
  31730. m.custom_agent_key = &s
  31731. }
  31732. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  31733. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  31734. v := m.custom_agent_key
  31735. if v == nil {
  31736. return
  31737. }
  31738. return *v, true
  31739. }
  31740. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  31741. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31743. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  31744. if !m.op.Is(OpUpdateOne) {
  31745. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  31746. }
  31747. if m.id == nil || m.oldValue == nil {
  31748. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  31749. }
  31750. oldValue, err := m.oldValue(ctx)
  31751. if err != nil {
  31752. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  31753. }
  31754. return oldValue.CustomAgentKey, nil
  31755. }
  31756. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  31757. func (m *TokenMutation) ClearCustomAgentKey() {
  31758. m.custom_agent_key = nil
  31759. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  31760. }
  31761. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  31762. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  31763. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  31764. return ok
  31765. }
  31766. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  31767. func (m *TokenMutation) ResetCustomAgentKey() {
  31768. m.custom_agent_key = nil
  31769. delete(m.clearedFields, token.FieldCustomAgentKey)
  31770. }
  31771. // SetOpenaiBase sets the "openai_base" field.
  31772. func (m *TokenMutation) SetOpenaiBase(s string) {
  31773. m.openai_base = &s
  31774. }
  31775. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  31776. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  31777. v := m.openai_base
  31778. if v == nil {
  31779. return
  31780. }
  31781. return *v, true
  31782. }
  31783. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  31784. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31786. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  31787. if !m.op.Is(OpUpdateOne) {
  31788. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  31789. }
  31790. if m.id == nil || m.oldValue == nil {
  31791. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  31792. }
  31793. oldValue, err := m.oldValue(ctx)
  31794. if err != nil {
  31795. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  31796. }
  31797. return oldValue.OpenaiBase, nil
  31798. }
  31799. // ClearOpenaiBase clears the value of the "openai_base" field.
  31800. func (m *TokenMutation) ClearOpenaiBase() {
  31801. m.openai_base = nil
  31802. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  31803. }
  31804. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  31805. func (m *TokenMutation) OpenaiBaseCleared() bool {
  31806. _, ok := m.clearedFields[token.FieldOpenaiBase]
  31807. return ok
  31808. }
  31809. // ResetOpenaiBase resets all changes to the "openai_base" field.
  31810. func (m *TokenMutation) ResetOpenaiBase() {
  31811. m.openai_base = nil
  31812. delete(m.clearedFields, token.FieldOpenaiBase)
  31813. }
  31814. // SetOpenaiKey sets the "openai_key" field.
  31815. func (m *TokenMutation) SetOpenaiKey(s string) {
  31816. m.openai_key = &s
  31817. }
  31818. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  31819. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  31820. v := m.openai_key
  31821. if v == nil {
  31822. return
  31823. }
  31824. return *v, true
  31825. }
  31826. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  31827. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31829. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  31830. if !m.op.Is(OpUpdateOne) {
  31831. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  31832. }
  31833. if m.id == nil || m.oldValue == nil {
  31834. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  31835. }
  31836. oldValue, err := m.oldValue(ctx)
  31837. if err != nil {
  31838. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  31839. }
  31840. return oldValue.OpenaiKey, nil
  31841. }
  31842. // ClearOpenaiKey clears the value of the "openai_key" field.
  31843. func (m *TokenMutation) ClearOpenaiKey() {
  31844. m.openai_key = nil
  31845. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  31846. }
  31847. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  31848. func (m *TokenMutation) OpenaiKeyCleared() bool {
  31849. _, ok := m.clearedFields[token.FieldOpenaiKey]
  31850. return ok
  31851. }
  31852. // ResetOpenaiKey resets all changes to the "openai_key" field.
  31853. func (m *TokenMutation) ResetOpenaiKey() {
  31854. m.openai_key = nil
  31855. delete(m.clearedFields, token.FieldOpenaiKey)
  31856. }
  31857. // ClearAgent clears the "agent" edge to the Agent entity.
  31858. func (m *TokenMutation) ClearAgent() {
  31859. m.clearedagent = true
  31860. m.clearedFields[token.FieldAgentID] = struct{}{}
  31861. }
  31862. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  31863. func (m *TokenMutation) AgentCleared() bool {
  31864. return m.clearedagent
  31865. }
  31866. // AgentIDs returns the "agent" edge IDs in the mutation.
  31867. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  31868. // AgentID instead. It exists only for internal usage by the builders.
  31869. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  31870. if id := m.agent; id != nil {
  31871. ids = append(ids, *id)
  31872. }
  31873. return
  31874. }
  31875. // ResetAgent resets all changes to the "agent" edge.
  31876. func (m *TokenMutation) ResetAgent() {
  31877. m.agent = nil
  31878. m.clearedagent = false
  31879. }
  31880. // Where appends a list predicates to the TokenMutation builder.
  31881. func (m *TokenMutation) Where(ps ...predicate.Token) {
  31882. m.predicates = append(m.predicates, ps...)
  31883. }
  31884. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  31885. // users can use type-assertion to append predicates that do not depend on any generated package.
  31886. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  31887. p := make([]predicate.Token, len(ps))
  31888. for i := range ps {
  31889. p[i] = ps[i]
  31890. }
  31891. m.Where(p...)
  31892. }
  31893. // Op returns the operation name.
  31894. func (m *TokenMutation) Op() Op {
  31895. return m.op
  31896. }
  31897. // SetOp allows setting the mutation operation.
  31898. func (m *TokenMutation) SetOp(op Op) {
  31899. m.op = op
  31900. }
  31901. // Type returns the node type of this mutation (Token).
  31902. func (m *TokenMutation) Type() string {
  31903. return m.typ
  31904. }
  31905. // Fields returns all fields that were changed during this mutation. Note that in
  31906. // order to get all numeric fields that were incremented/decremented, call
  31907. // AddedFields().
  31908. func (m *TokenMutation) Fields() []string {
  31909. fields := make([]string, 0, 12)
  31910. if m.created_at != nil {
  31911. fields = append(fields, token.FieldCreatedAt)
  31912. }
  31913. if m.updated_at != nil {
  31914. fields = append(fields, token.FieldUpdatedAt)
  31915. }
  31916. if m.deleted_at != nil {
  31917. fields = append(fields, token.FieldDeletedAt)
  31918. }
  31919. if m.expire_at != nil {
  31920. fields = append(fields, token.FieldExpireAt)
  31921. }
  31922. if m.token != nil {
  31923. fields = append(fields, token.FieldToken)
  31924. }
  31925. if m.mac != nil {
  31926. fields = append(fields, token.FieldMAC)
  31927. }
  31928. if m.organization_id != nil {
  31929. fields = append(fields, token.FieldOrganizationID)
  31930. }
  31931. if m.agent != nil {
  31932. fields = append(fields, token.FieldAgentID)
  31933. }
  31934. if m.custom_agent_base != nil {
  31935. fields = append(fields, token.FieldCustomAgentBase)
  31936. }
  31937. if m.custom_agent_key != nil {
  31938. fields = append(fields, token.FieldCustomAgentKey)
  31939. }
  31940. if m.openai_base != nil {
  31941. fields = append(fields, token.FieldOpenaiBase)
  31942. }
  31943. if m.openai_key != nil {
  31944. fields = append(fields, token.FieldOpenaiKey)
  31945. }
  31946. return fields
  31947. }
  31948. // Field returns the value of a field with the given name. The second boolean
  31949. // return value indicates that this field was not set, or was not defined in the
  31950. // schema.
  31951. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  31952. switch name {
  31953. case token.FieldCreatedAt:
  31954. return m.CreatedAt()
  31955. case token.FieldUpdatedAt:
  31956. return m.UpdatedAt()
  31957. case token.FieldDeletedAt:
  31958. return m.DeletedAt()
  31959. case token.FieldExpireAt:
  31960. return m.ExpireAt()
  31961. case token.FieldToken:
  31962. return m.Token()
  31963. case token.FieldMAC:
  31964. return m.MAC()
  31965. case token.FieldOrganizationID:
  31966. return m.OrganizationID()
  31967. case token.FieldAgentID:
  31968. return m.AgentID()
  31969. case token.FieldCustomAgentBase:
  31970. return m.CustomAgentBase()
  31971. case token.FieldCustomAgentKey:
  31972. return m.CustomAgentKey()
  31973. case token.FieldOpenaiBase:
  31974. return m.OpenaiBase()
  31975. case token.FieldOpenaiKey:
  31976. return m.OpenaiKey()
  31977. }
  31978. return nil, false
  31979. }
  31980. // OldField returns the old value of the field from the database. An error is
  31981. // returned if the mutation operation is not UpdateOne, or the query to the
  31982. // database failed.
  31983. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31984. switch name {
  31985. case token.FieldCreatedAt:
  31986. return m.OldCreatedAt(ctx)
  31987. case token.FieldUpdatedAt:
  31988. return m.OldUpdatedAt(ctx)
  31989. case token.FieldDeletedAt:
  31990. return m.OldDeletedAt(ctx)
  31991. case token.FieldExpireAt:
  31992. return m.OldExpireAt(ctx)
  31993. case token.FieldToken:
  31994. return m.OldToken(ctx)
  31995. case token.FieldMAC:
  31996. return m.OldMAC(ctx)
  31997. case token.FieldOrganizationID:
  31998. return m.OldOrganizationID(ctx)
  31999. case token.FieldAgentID:
  32000. return m.OldAgentID(ctx)
  32001. case token.FieldCustomAgentBase:
  32002. return m.OldCustomAgentBase(ctx)
  32003. case token.FieldCustomAgentKey:
  32004. return m.OldCustomAgentKey(ctx)
  32005. case token.FieldOpenaiBase:
  32006. return m.OldOpenaiBase(ctx)
  32007. case token.FieldOpenaiKey:
  32008. return m.OldOpenaiKey(ctx)
  32009. }
  32010. return nil, fmt.Errorf("unknown Token field %s", name)
  32011. }
  32012. // SetField sets the value of a field with the given name. It returns an error if
  32013. // the field is not defined in the schema, or if the type mismatched the field
  32014. // type.
  32015. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  32016. switch name {
  32017. case token.FieldCreatedAt:
  32018. v, ok := value.(time.Time)
  32019. if !ok {
  32020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32021. }
  32022. m.SetCreatedAt(v)
  32023. return nil
  32024. case token.FieldUpdatedAt:
  32025. v, ok := value.(time.Time)
  32026. if !ok {
  32027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32028. }
  32029. m.SetUpdatedAt(v)
  32030. return nil
  32031. case token.FieldDeletedAt:
  32032. v, ok := value.(time.Time)
  32033. if !ok {
  32034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32035. }
  32036. m.SetDeletedAt(v)
  32037. return nil
  32038. case token.FieldExpireAt:
  32039. v, ok := value.(time.Time)
  32040. if !ok {
  32041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32042. }
  32043. m.SetExpireAt(v)
  32044. return nil
  32045. case token.FieldToken:
  32046. v, ok := value.(string)
  32047. if !ok {
  32048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32049. }
  32050. m.SetToken(v)
  32051. return nil
  32052. case token.FieldMAC:
  32053. v, ok := value.(string)
  32054. if !ok {
  32055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32056. }
  32057. m.SetMAC(v)
  32058. return nil
  32059. case token.FieldOrganizationID:
  32060. v, ok := value.(uint64)
  32061. if !ok {
  32062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32063. }
  32064. m.SetOrganizationID(v)
  32065. return nil
  32066. case token.FieldAgentID:
  32067. v, ok := value.(uint64)
  32068. if !ok {
  32069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32070. }
  32071. m.SetAgentID(v)
  32072. return nil
  32073. case token.FieldCustomAgentBase:
  32074. v, ok := value.(string)
  32075. if !ok {
  32076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32077. }
  32078. m.SetCustomAgentBase(v)
  32079. return nil
  32080. case token.FieldCustomAgentKey:
  32081. v, ok := value.(string)
  32082. if !ok {
  32083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32084. }
  32085. m.SetCustomAgentKey(v)
  32086. return nil
  32087. case token.FieldOpenaiBase:
  32088. v, ok := value.(string)
  32089. if !ok {
  32090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32091. }
  32092. m.SetOpenaiBase(v)
  32093. return nil
  32094. case token.FieldOpenaiKey:
  32095. v, ok := value.(string)
  32096. if !ok {
  32097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32098. }
  32099. m.SetOpenaiKey(v)
  32100. return nil
  32101. }
  32102. return fmt.Errorf("unknown Token field %s", name)
  32103. }
  32104. // AddedFields returns all numeric fields that were incremented/decremented during
  32105. // this mutation.
  32106. func (m *TokenMutation) AddedFields() []string {
  32107. var fields []string
  32108. if m.addorganization_id != nil {
  32109. fields = append(fields, token.FieldOrganizationID)
  32110. }
  32111. return fields
  32112. }
  32113. // AddedField returns the numeric value that was incremented/decremented on a field
  32114. // with the given name. The second boolean return value indicates that this field
  32115. // was not set, or was not defined in the schema.
  32116. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  32117. switch name {
  32118. case token.FieldOrganizationID:
  32119. return m.AddedOrganizationID()
  32120. }
  32121. return nil, false
  32122. }
  32123. // AddField adds the value to the field with the given name. It returns an error if
  32124. // the field is not defined in the schema, or if the type mismatched the field
  32125. // type.
  32126. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  32127. switch name {
  32128. case token.FieldOrganizationID:
  32129. v, ok := value.(int64)
  32130. if !ok {
  32131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32132. }
  32133. m.AddOrganizationID(v)
  32134. return nil
  32135. }
  32136. return fmt.Errorf("unknown Token numeric field %s", name)
  32137. }
  32138. // ClearedFields returns all nullable fields that were cleared during this
  32139. // mutation.
  32140. func (m *TokenMutation) ClearedFields() []string {
  32141. var fields []string
  32142. if m.FieldCleared(token.FieldDeletedAt) {
  32143. fields = append(fields, token.FieldDeletedAt)
  32144. }
  32145. if m.FieldCleared(token.FieldExpireAt) {
  32146. fields = append(fields, token.FieldExpireAt)
  32147. }
  32148. if m.FieldCleared(token.FieldToken) {
  32149. fields = append(fields, token.FieldToken)
  32150. }
  32151. if m.FieldCleared(token.FieldMAC) {
  32152. fields = append(fields, token.FieldMAC)
  32153. }
  32154. if m.FieldCleared(token.FieldCustomAgentBase) {
  32155. fields = append(fields, token.FieldCustomAgentBase)
  32156. }
  32157. if m.FieldCleared(token.FieldCustomAgentKey) {
  32158. fields = append(fields, token.FieldCustomAgentKey)
  32159. }
  32160. if m.FieldCleared(token.FieldOpenaiBase) {
  32161. fields = append(fields, token.FieldOpenaiBase)
  32162. }
  32163. if m.FieldCleared(token.FieldOpenaiKey) {
  32164. fields = append(fields, token.FieldOpenaiKey)
  32165. }
  32166. return fields
  32167. }
  32168. // FieldCleared returns a boolean indicating if a field with the given name was
  32169. // cleared in this mutation.
  32170. func (m *TokenMutation) FieldCleared(name string) bool {
  32171. _, ok := m.clearedFields[name]
  32172. return ok
  32173. }
  32174. // ClearField clears the value of the field with the given name. It returns an
  32175. // error if the field is not defined in the schema.
  32176. func (m *TokenMutation) ClearField(name string) error {
  32177. switch name {
  32178. case token.FieldDeletedAt:
  32179. m.ClearDeletedAt()
  32180. return nil
  32181. case token.FieldExpireAt:
  32182. m.ClearExpireAt()
  32183. return nil
  32184. case token.FieldToken:
  32185. m.ClearToken()
  32186. return nil
  32187. case token.FieldMAC:
  32188. m.ClearMAC()
  32189. return nil
  32190. case token.FieldCustomAgentBase:
  32191. m.ClearCustomAgentBase()
  32192. return nil
  32193. case token.FieldCustomAgentKey:
  32194. m.ClearCustomAgentKey()
  32195. return nil
  32196. case token.FieldOpenaiBase:
  32197. m.ClearOpenaiBase()
  32198. return nil
  32199. case token.FieldOpenaiKey:
  32200. m.ClearOpenaiKey()
  32201. return nil
  32202. }
  32203. return fmt.Errorf("unknown Token nullable field %s", name)
  32204. }
  32205. // ResetField resets all changes in the mutation for the field with the given name.
  32206. // It returns an error if the field is not defined in the schema.
  32207. func (m *TokenMutation) ResetField(name string) error {
  32208. switch name {
  32209. case token.FieldCreatedAt:
  32210. m.ResetCreatedAt()
  32211. return nil
  32212. case token.FieldUpdatedAt:
  32213. m.ResetUpdatedAt()
  32214. return nil
  32215. case token.FieldDeletedAt:
  32216. m.ResetDeletedAt()
  32217. return nil
  32218. case token.FieldExpireAt:
  32219. m.ResetExpireAt()
  32220. return nil
  32221. case token.FieldToken:
  32222. m.ResetToken()
  32223. return nil
  32224. case token.FieldMAC:
  32225. m.ResetMAC()
  32226. return nil
  32227. case token.FieldOrganizationID:
  32228. m.ResetOrganizationID()
  32229. return nil
  32230. case token.FieldAgentID:
  32231. m.ResetAgentID()
  32232. return nil
  32233. case token.FieldCustomAgentBase:
  32234. m.ResetCustomAgentBase()
  32235. return nil
  32236. case token.FieldCustomAgentKey:
  32237. m.ResetCustomAgentKey()
  32238. return nil
  32239. case token.FieldOpenaiBase:
  32240. m.ResetOpenaiBase()
  32241. return nil
  32242. case token.FieldOpenaiKey:
  32243. m.ResetOpenaiKey()
  32244. return nil
  32245. }
  32246. return fmt.Errorf("unknown Token field %s", name)
  32247. }
  32248. // AddedEdges returns all edge names that were set/added in this mutation.
  32249. func (m *TokenMutation) AddedEdges() []string {
  32250. edges := make([]string, 0, 1)
  32251. if m.agent != nil {
  32252. edges = append(edges, token.EdgeAgent)
  32253. }
  32254. return edges
  32255. }
  32256. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32257. // name in this mutation.
  32258. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  32259. switch name {
  32260. case token.EdgeAgent:
  32261. if id := m.agent; id != nil {
  32262. return []ent.Value{*id}
  32263. }
  32264. }
  32265. return nil
  32266. }
  32267. // RemovedEdges returns all edge names that were removed in this mutation.
  32268. func (m *TokenMutation) RemovedEdges() []string {
  32269. edges := make([]string, 0, 1)
  32270. return edges
  32271. }
  32272. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32273. // the given name in this mutation.
  32274. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  32275. return nil
  32276. }
  32277. // ClearedEdges returns all edge names that were cleared in this mutation.
  32278. func (m *TokenMutation) ClearedEdges() []string {
  32279. edges := make([]string, 0, 1)
  32280. if m.clearedagent {
  32281. edges = append(edges, token.EdgeAgent)
  32282. }
  32283. return edges
  32284. }
  32285. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32286. // was cleared in this mutation.
  32287. func (m *TokenMutation) EdgeCleared(name string) bool {
  32288. switch name {
  32289. case token.EdgeAgent:
  32290. return m.clearedagent
  32291. }
  32292. return false
  32293. }
  32294. // ClearEdge clears the value of the edge with the given name. It returns an error
  32295. // if that edge is not defined in the schema.
  32296. func (m *TokenMutation) ClearEdge(name string) error {
  32297. switch name {
  32298. case token.EdgeAgent:
  32299. m.ClearAgent()
  32300. return nil
  32301. }
  32302. return fmt.Errorf("unknown Token unique edge %s", name)
  32303. }
  32304. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32305. // It returns an error if the edge is not defined in the schema.
  32306. func (m *TokenMutation) ResetEdge(name string) error {
  32307. switch name {
  32308. case token.EdgeAgent:
  32309. m.ResetAgent()
  32310. return nil
  32311. }
  32312. return fmt.Errorf("unknown Token edge %s", name)
  32313. }
  32314. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  32315. type TutorialMutation struct {
  32316. config
  32317. op Op
  32318. typ string
  32319. id *uint64
  32320. created_at *time.Time
  32321. updated_at *time.Time
  32322. deleted_at *time.Time
  32323. index *int
  32324. addindex *int
  32325. title *string
  32326. content *string
  32327. organization_id *uint64
  32328. addorganization_id *int64
  32329. clearedFields map[string]struct{}
  32330. employee *uint64
  32331. clearedemployee bool
  32332. done bool
  32333. oldValue func(context.Context) (*Tutorial, error)
  32334. predicates []predicate.Tutorial
  32335. }
  32336. var _ ent.Mutation = (*TutorialMutation)(nil)
  32337. // tutorialOption allows management of the mutation configuration using functional options.
  32338. type tutorialOption func(*TutorialMutation)
  32339. // newTutorialMutation creates new mutation for the Tutorial entity.
  32340. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  32341. m := &TutorialMutation{
  32342. config: c,
  32343. op: op,
  32344. typ: TypeTutorial,
  32345. clearedFields: make(map[string]struct{}),
  32346. }
  32347. for _, opt := range opts {
  32348. opt(m)
  32349. }
  32350. return m
  32351. }
  32352. // withTutorialID sets the ID field of the mutation.
  32353. func withTutorialID(id uint64) tutorialOption {
  32354. return func(m *TutorialMutation) {
  32355. var (
  32356. err error
  32357. once sync.Once
  32358. value *Tutorial
  32359. )
  32360. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  32361. once.Do(func() {
  32362. if m.done {
  32363. err = errors.New("querying old values post mutation is not allowed")
  32364. } else {
  32365. value, err = m.Client().Tutorial.Get(ctx, id)
  32366. }
  32367. })
  32368. return value, err
  32369. }
  32370. m.id = &id
  32371. }
  32372. }
  32373. // withTutorial sets the old Tutorial of the mutation.
  32374. func withTutorial(node *Tutorial) tutorialOption {
  32375. return func(m *TutorialMutation) {
  32376. m.oldValue = func(context.Context) (*Tutorial, error) {
  32377. return node, nil
  32378. }
  32379. m.id = &node.ID
  32380. }
  32381. }
  32382. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32383. // executed in a transaction (ent.Tx), a transactional client is returned.
  32384. func (m TutorialMutation) Client() *Client {
  32385. client := &Client{config: m.config}
  32386. client.init()
  32387. return client
  32388. }
  32389. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32390. // it returns an error otherwise.
  32391. func (m TutorialMutation) Tx() (*Tx, error) {
  32392. if _, ok := m.driver.(*txDriver); !ok {
  32393. return nil, errors.New("ent: mutation is not running in a transaction")
  32394. }
  32395. tx := &Tx{config: m.config}
  32396. tx.init()
  32397. return tx, nil
  32398. }
  32399. // SetID sets the value of the id field. Note that this
  32400. // operation is only accepted on creation of Tutorial entities.
  32401. func (m *TutorialMutation) SetID(id uint64) {
  32402. m.id = &id
  32403. }
  32404. // ID returns the ID value in the mutation. Note that the ID is only available
  32405. // if it was provided to the builder or after it was returned from the database.
  32406. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  32407. if m.id == nil {
  32408. return
  32409. }
  32410. return *m.id, true
  32411. }
  32412. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32413. // That means, if the mutation is applied within a transaction with an isolation level such
  32414. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32415. // or updated by the mutation.
  32416. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  32417. switch {
  32418. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32419. id, exists := m.ID()
  32420. if exists {
  32421. return []uint64{id}, nil
  32422. }
  32423. fallthrough
  32424. case m.op.Is(OpUpdate | OpDelete):
  32425. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  32426. default:
  32427. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32428. }
  32429. }
  32430. // SetCreatedAt sets the "created_at" field.
  32431. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  32432. m.created_at = &t
  32433. }
  32434. // CreatedAt returns the value of the "created_at" field in the mutation.
  32435. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  32436. v := m.created_at
  32437. if v == nil {
  32438. return
  32439. }
  32440. return *v, true
  32441. }
  32442. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  32443. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32445. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32446. if !m.op.Is(OpUpdateOne) {
  32447. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32448. }
  32449. if m.id == nil || m.oldValue == nil {
  32450. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32451. }
  32452. oldValue, err := m.oldValue(ctx)
  32453. if err != nil {
  32454. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32455. }
  32456. return oldValue.CreatedAt, nil
  32457. }
  32458. // ResetCreatedAt resets all changes to the "created_at" field.
  32459. func (m *TutorialMutation) ResetCreatedAt() {
  32460. m.created_at = nil
  32461. }
  32462. // SetUpdatedAt sets the "updated_at" field.
  32463. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  32464. m.updated_at = &t
  32465. }
  32466. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32467. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  32468. v := m.updated_at
  32469. if v == nil {
  32470. return
  32471. }
  32472. return *v, true
  32473. }
  32474. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  32475. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32477. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32478. if !m.op.Is(OpUpdateOne) {
  32479. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32480. }
  32481. if m.id == nil || m.oldValue == nil {
  32482. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32483. }
  32484. oldValue, err := m.oldValue(ctx)
  32485. if err != nil {
  32486. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32487. }
  32488. return oldValue.UpdatedAt, nil
  32489. }
  32490. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32491. func (m *TutorialMutation) ResetUpdatedAt() {
  32492. m.updated_at = nil
  32493. }
  32494. // SetDeletedAt sets the "deleted_at" field.
  32495. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  32496. m.deleted_at = &t
  32497. }
  32498. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32499. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  32500. v := m.deleted_at
  32501. if v == nil {
  32502. return
  32503. }
  32504. return *v, true
  32505. }
  32506. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  32507. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32509. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32510. if !m.op.Is(OpUpdateOne) {
  32511. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32512. }
  32513. if m.id == nil || m.oldValue == nil {
  32514. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32515. }
  32516. oldValue, err := m.oldValue(ctx)
  32517. if err != nil {
  32518. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32519. }
  32520. return oldValue.DeletedAt, nil
  32521. }
  32522. // ClearDeletedAt clears the value of the "deleted_at" field.
  32523. func (m *TutorialMutation) ClearDeletedAt() {
  32524. m.deleted_at = nil
  32525. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  32526. }
  32527. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32528. func (m *TutorialMutation) DeletedAtCleared() bool {
  32529. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  32530. return ok
  32531. }
  32532. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32533. func (m *TutorialMutation) ResetDeletedAt() {
  32534. m.deleted_at = nil
  32535. delete(m.clearedFields, tutorial.FieldDeletedAt)
  32536. }
  32537. // SetEmployeeID sets the "employee_id" field.
  32538. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  32539. m.employee = &u
  32540. }
  32541. // EmployeeID returns the value of the "employee_id" field in the mutation.
  32542. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  32543. v := m.employee
  32544. if v == nil {
  32545. return
  32546. }
  32547. return *v, true
  32548. }
  32549. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  32550. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32552. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  32553. if !m.op.Is(OpUpdateOne) {
  32554. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  32555. }
  32556. if m.id == nil || m.oldValue == nil {
  32557. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  32558. }
  32559. oldValue, err := m.oldValue(ctx)
  32560. if err != nil {
  32561. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  32562. }
  32563. return oldValue.EmployeeID, nil
  32564. }
  32565. // ResetEmployeeID resets all changes to the "employee_id" field.
  32566. func (m *TutorialMutation) ResetEmployeeID() {
  32567. m.employee = nil
  32568. }
  32569. // SetIndex sets the "index" field.
  32570. func (m *TutorialMutation) SetIndex(i int) {
  32571. m.index = &i
  32572. m.addindex = nil
  32573. }
  32574. // Index returns the value of the "index" field in the mutation.
  32575. func (m *TutorialMutation) Index() (r int, exists bool) {
  32576. v := m.index
  32577. if v == nil {
  32578. return
  32579. }
  32580. return *v, true
  32581. }
  32582. // OldIndex returns the old "index" field's value of the Tutorial entity.
  32583. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32585. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  32586. if !m.op.Is(OpUpdateOne) {
  32587. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  32588. }
  32589. if m.id == nil || m.oldValue == nil {
  32590. return v, errors.New("OldIndex requires an ID field in the mutation")
  32591. }
  32592. oldValue, err := m.oldValue(ctx)
  32593. if err != nil {
  32594. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  32595. }
  32596. return oldValue.Index, nil
  32597. }
  32598. // AddIndex adds i to the "index" field.
  32599. func (m *TutorialMutation) AddIndex(i int) {
  32600. if m.addindex != nil {
  32601. *m.addindex += i
  32602. } else {
  32603. m.addindex = &i
  32604. }
  32605. }
  32606. // AddedIndex returns the value that was added to the "index" field in this mutation.
  32607. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  32608. v := m.addindex
  32609. if v == nil {
  32610. return
  32611. }
  32612. return *v, true
  32613. }
  32614. // ResetIndex resets all changes to the "index" field.
  32615. func (m *TutorialMutation) ResetIndex() {
  32616. m.index = nil
  32617. m.addindex = nil
  32618. }
  32619. // SetTitle sets the "title" field.
  32620. func (m *TutorialMutation) SetTitle(s string) {
  32621. m.title = &s
  32622. }
  32623. // Title returns the value of the "title" field in the mutation.
  32624. func (m *TutorialMutation) Title() (r string, exists bool) {
  32625. v := m.title
  32626. if v == nil {
  32627. return
  32628. }
  32629. return *v, true
  32630. }
  32631. // OldTitle returns the old "title" field's value of the Tutorial entity.
  32632. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32634. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  32635. if !m.op.Is(OpUpdateOne) {
  32636. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  32637. }
  32638. if m.id == nil || m.oldValue == nil {
  32639. return v, errors.New("OldTitle requires an ID field in the mutation")
  32640. }
  32641. oldValue, err := m.oldValue(ctx)
  32642. if err != nil {
  32643. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  32644. }
  32645. return oldValue.Title, nil
  32646. }
  32647. // ResetTitle resets all changes to the "title" field.
  32648. func (m *TutorialMutation) ResetTitle() {
  32649. m.title = nil
  32650. }
  32651. // SetContent sets the "content" field.
  32652. func (m *TutorialMutation) SetContent(s string) {
  32653. m.content = &s
  32654. }
  32655. // Content returns the value of the "content" field in the mutation.
  32656. func (m *TutorialMutation) Content() (r string, exists bool) {
  32657. v := m.content
  32658. if v == nil {
  32659. return
  32660. }
  32661. return *v, true
  32662. }
  32663. // OldContent returns the old "content" field's value of the Tutorial entity.
  32664. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32666. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  32667. if !m.op.Is(OpUpdateOne) {
  32668. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  32669. }
  32670. if m.id == nil || m.oldValue == nil {
  32671. return v, errors.New("OldContent requires an ID field in the mutation")
  32672. }
  32673. oldValue, err := m.oldValue(ctx)
  32674. if err != nil {
  32675. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  32676. }
  32677. return oldValue.Content, nil
  32678. }
  32679. // ResetContent resets all changes to the "content" field.
  32680. func (m *TutorialMutation) ResetContent() {
  32681. m.content = nil
  32682. }
  32683. // SetOrganizationID sets the "organization_id" field.
  32684. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  32685. m.organization_id = &u
  32686. m.addorganization_id = nil
  32687. }
  32688. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32689. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  32690. v := m.organization_id
  32691. if v == nil {
  32692. return
  32693. }
  32694. return *v, true
  32695. }
  32696. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  32697. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32699. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32700. if !m.op.Is(OpUpdateOne) {
  32701. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32702. }
  32703. if m.id == nil || m.oldValue == nil {
  32704. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32705. }
  32706. oldValue, err := m.oldValue(ctx)
  32707. if err != nil {
  32708. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32709. }
  32710. return oldValue.OrganizationID, nil
  32711. }
  32712. // AddOrganizationID adds u to the "organization_id" field.
  32713. func (m *TutorialMutation) AddOrganizationID(u int64) {
  32714. if m.addorganization_id != nil {
  32715. *m.addorganization_id += u
  32716. } else {
  32717. m.addorganization_id = &u
  32718. }
  32719. }
  32720. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32721. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  32722. v := m.addorganization_id
  32723. if v == nil {
  32724. return
  32725. }
  32726. return *v, true
  32727. }
  32728. // ResetOrganizationID resets all changes to the "organization_id" field.
  32729. func (m *TutorialMutation) ResetOrganizationID() {
  32730. m.organization_id = nil
  32731. m.addorganization_id = nil
  32732. }
  32733. // ClearEmployee clears the "employee" edge to the Employee entity.
  32734. func (m *TutorialMutation) ClearEmployee() {
  32735. m.clearedemployee = true
  32736. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  32737. }
  32738. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  32739. func (m *TutorialMutation) EmployeeCleared() bool {
  32740. return m.clearedemployee
  32741. }
  32742. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  32743. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  32744. // EmployeeID instead. It exists only for internal usage by the builders.
  32745. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  32746. if id := m.employee; id != nil {
  32747. ids = append(ids, *id)
  32748. }
  32749. return
  32750. }
  32751. // ResetEmployee resets all changes to the "employee" edge.
  32752. func (m *TutorialMutation) ResetEmployee() {
  32753. m.employee = nil
  32754. m.clearedemployee = false
  32755. }
  32756. // Where appends a list predicates to the TutorialMutation builder.
  32757. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  32758. m.predicates = append(m.predicates, ps...)
  32759. }
  32760. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  32761. // users can use type-assertion to append predicates that do not depend on any generated package.
  32762. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  32763. p := make([]predicate.Tutorial, len(ps))
  32764. for i := range ps {
  32765. p[i] = ps[i]
  32766. }
  32767. m.Where(p...)
  32768. }
  32769. // Op returns the operation name.
  32770. func (m *TutorialMutation) Op() Op {
  32771. return m.op
  32772. }
  32773. // SetOp allows setting the mutation operation.
  32774. func (m *TutorialMutation) SetOp(op Op) {
  32775. m.op = op
  32776. }
  32777. // Type returns the node type of this mutation (Tutorial).
  32778. func (m *TutorialMutation) Type() string {
  32779. return m.typ
  32780. }
  32781. // Fields returns all fields that were changed during this mutation. Note that in
  32782. // order to get all numeric fields that were incremented/decremented, call
  32783. // AddedFields().
  32784. func (m *TutorialMutation) Fields() []string {
  32785. fields := make([]string, 0, 8)
  32786. if m.created_at != nil {
  32787. fields = append(fields, tutorial.FieldCreatedAt)
  32788. }
  32789. if m.updated_at != nil {
  32790. fields = append(fields, tutorial.FieldUpdatedAt)
  32791. }
  32792. if m.deleted_at != nil {
  32793. fields = append(fields, tutorial.FieldDeletedAt)
  32794. }
  32795. if m.employee != nil {
  32796. fields = append(fields, tutorial.FieldEmployeeID)
  32797. }
  32798. if m.index != nil {
  32799. fields = append(fields, tutorial.FieldIndex)
  32800. }
  32801. if m.title != nil {
  32802. fields = append(fields, tutorial.FieldTitle)
  32803. }
  32804. if m.content != nil {
  32805. fields = append(fields, tutorial.FieldContent)
  32806. }
  32807. if m.organization_id != nil {
  32808. fields = append(fields, tutorial.FieldOrganizationID)
  32809. }
  32810. return fields
  32811. }
  32812. // Field returns the value of a field with the given name. The second boolean
  32813. // return value indicates that this field was not set, or was not defined in the
  32814. // schema.
  32815. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  32816. switch name {
  32817. case tutorial.FieldCreatedAt:
  32818. return m.CreatedAt()
  32819. case tutorial.FieldUpdatedAt:
  32820. return m.UpdatedAt()
  32821. case tutorial.FieldDeletedAt:
  32822. return m.DeletedAt()
  32823. case tutorial.FieldEmployeeID:
  32824. return m.EmployeeID()
  32825. case tutorial.FieldIndex:
  32826. return m.Index()
  32827. case tutorial.FieldTitle:
  32828. return m.Title()
  32829. case tutorial.FieldContent:
  32830. return m.Content()
  32831. case tutorial.FieldOrganizationID:
  32832. return m.OrganizationID()
  32833. }
  32834. return nil, false
  32835. }
  32836. // OldField returns the old value of the field from the database. An error is
  32837. // returned if the mutation operation is not UpdateOne, or the query to the
  32838. // database failed.
  32839. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32840. switch name {
  32841. case tutorial.FieldCreatedAt:
  32842. return m.OldCreatedAt(ctx)
  32843. case tutorial.FieldUpdatedAt:
  32844. return m.OldUpdatedAt(ctx)
  32845. case tutorial.FieldDeletedAt:
  32846. return m.OldDeletedAt(ctx)
  32847. case tutorial.FieldEmployeeID:
  32848. return m.OldEmployeeID(ctx)
  32849. case tutorial.FieldIndex:
  32850. return m.OldIndex(ctx)
  32851. case tutorial.FieldTitle:
  32852. return m.OldTitle(ctx)
  32853. case tutorial.FieldContent:
  32854. return m.OldContent(ctx)
  32855. case tutorial.FieldOrganizationID:
  32856. return m.OldOrganizationID(ctx)
  32857. }
  32858. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  32859. }
  32860. // SetField sets the value of a field with the given name. It returns an error if
  32861. // the field is not defined in the schema, or if the type mismatched the field
  32862. // type.
  32863. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  32864. switch name {
  32865. case tutorial.FieldCreatedAt:
  32866. v, ok := value.(time.Time)
  32867. if !ok {
  32868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32869. }
  32870. m.SetCreatedAt(v)
  32871. return nil
  32872. case tutorial.FieldUpdatedAt:
  32873. v, ok := value.(time.Time)
  32874. if !ok {
  32875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32876. }
  32877. m.SetUpdatedAt(v)
  32878. return nil
  32879. case tutorial.FieldDeletedAt:
  32880. v, ok := value.(time.Time)
  32881. if !ok {
  32882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32883. }
  32884. m.SetDeletedAt(v)
  32885. return nil
  32886. case tutorial.FieldEmployeeID:
  32887. v, ok := value.(uint64)
  32888. if !ok {
  32889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32890. }
  32891. m.SetEmployeeID(v)
  32892. return nil
  32893. case tutorial.FieldIndex:
  32894. v, ok := value.(int)
  32895. if !ok {
  32896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32897. }
  32898. m.SetIndex(v)
  32899. return nil
  32900. case tutorial.FieldTitle:
  32901. v, ok := value.(string)
  32902. if !ok {
  32903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32904. }
  32905. m.SetTitle(v)
  32906. return nil
  32907. case tutorial.FieldContent:
  32908. v, ok := value.(string)
  32909. if !ok {
  32910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32911. }
  32912. m.SetContent(v)
  32913. return nil
  32914. case tutorial.FieldOrganizationID:
  32915. v, ok := value.(uint64)
  32916. if !ok {
  32917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32918. }
  32919. m.SetOrganizationID(v)
  32920. return nil
  32921. }
  32922. return fmt.Errorf("unknown Tutorial field %s", name)
  32923. }
  32924. // AddedFields returns all numeric fields that were incremented/decremented during
  32925. // this mutation.
  32926. func (m *TutorialMutation) AddedFields() []string {
  32927. var fields []string
  32928. if m.addindex != nil {
  32929. fields = append(fields, tutorial.FieldIndex)
  32930. }
  32931. if m.addorganization_id != nil {
  32932. fields = append(fields, tutorial.FieldOrganizationID)
  32933. }
  32934. return fields
  32935. }
  32936. // AddedField returns the numeric value that was incremented/decremented on a field
  32937. // with the given name. The second boolean return value indicates that this field
  32938. // was not set, or was not defined in the schema.
  32939. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  32940. switch name {
  32941. case tutorial.FieldIndex:
  32942. return m.AddedIndex()
  32943. case tutorial.FieldOrganizationID:
  32944. return m.AddedOrganizationID()
  32945. }
  32946. return nil, false
  32947. }
  32948. // AddField adds the value to the field with the given name. It returns an error if
  32949. // the field is not defined in the schema, or if the type mismatched the field
  32950. // type.
  32951. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  32952. switch name {
  32953. case tutorial.FieldIndex:
  32954. v, ok := value.(int)
  32955. if !ok {
  32956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32957. }
  32958. m.AddIndex(v)
  32959. return nil
  32960. case tutorial.FieldOrganizationID:
  32961. v, ok := value.(int64)
  32962. if !ok {
  32963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32964. }
  32965. m.AddOrganizationID(v)
  32966. return nil
  32967. }
  32968. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  32969. }
  32970. // ClearedFields returns all nullable fields that were cleared during this
  32971. // mutation.
  32972. func (m *TutorialMutation) ClearedFields() []string {
  32973. var fields []string
  32974. if m.FieldCleared(tutorial.FieldDeletedAt) {
  32975. fields = append(fields, tutorial.FieldDeletedAt)
  32976. }
  32977. return fields
  32978. }
  32979. // FieldCleared returns a boolean indicating if a field with the given name was
  32980. // cleared in this mutation.
  32981. func (m *TutorialMutation) FieldCleared(name string) bool {
  32982. _, ok := m.clearedFields[name]
  32983. return ok
  32984. }
  32985. // ClearField clears the value of the field with the given name. It returns an
  32986. // error if the field is not defined in the schema.
  32987. func (m *TutorialMutation) ClearField(name string) error {
  32988. switch name {
  32989. case tutorial.FieldDeletedAt:
  32990. m.ClearDeletedAt()
  32991. return nil
  32992. }
  32993. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  32994. }
  32995. // ResetField resets all changes in the mutation for the field with the given name.
  32996. // It returns an error if the field is not defined in the schema.
  32997. func (m *TutorialMutation) ResetField(name string) error {
  32998. switch name {
  32999. case tutorial.FieldCreatedAt:
  33000. m.ResetCreatedAt()
  33001. return nil
  33002. case tutorial.FieldUpdatedAt:
  33003. m.ResetUpdatedAt()
  33004. return nil
  33005. case tutorial.FieldDeletedAt:
  33006. m.ResetDeletedAt()
  33007. return nil
  33008. case tutorial.FieldEmployeeID:
  33009. m.ResetEmployeeID()
  33010. return nil
  33011. case tutorial.FieldIndex:
  33012. m.ResetIndex()
  33013. return nil
  33014. case tutorial.FieldTitle:
  33015. m.ResetTitle()
  33016. return nil
  33017. case tutorial.FieldContent:
  33018. m.ResetContent()
  33019. return nil
  33020. case tutorial.FieldOrganizationID:
  33021. m.ResetOrganizationID()
  33022. return nil
  33023. }
  33024. return fmt.Errorf("unknown Tutorial field %s", name)
  33025. }
  33026. // AddedEdges returns all edge names that were set/added in this mutation.
  33027. func (m *TutorialMutation) AddedEdges() []string {
  33028. edges := make([]string, 0, 1)
  33029. if m.employee != nil {
  33030. edges = append(edges, tutorial.EdgeEmployee)
  33031. }
  33032. return edges
  33033. }
  33034. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33035. // name in this mutation.
  33036. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  33037. switch name {
  33038. case tutorial.EdgeEmployee:
  33039. if id := m.employee; id != nil {
  33040. return []ent.Value{*id}
  33041. }
  33042. }
  33043. return nil
  33044. }
  33045. // RemovedEdges returns all edge names that were removed in this mutation.
  33046. func (m *TutorialMutation) RemovedEdges() []string {
  33047. edges := make([]string, 0, 1)
  33048. return edges
  33049. }
  33050. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33051. // the given name in this mutation.
  33052. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  33053. return nil
  33054. }
  33055. // ClearedEdges returns all edge names that were cleared in this mutation.
  33056. func (m *TutorialMutation) ClearedEdges() []string {
  33057. edges := make([]string, 0, 1)
  33058. if m.clearedemployee {
  33059. edges = append(edges, tutorial.EdgeEmployee)
  33060. }
  33061. return edges
  33062. }
  33063. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33064. // was cleared in this mutation.
  33065. func (m *TutorialMutation) EdgeCleared(name string) bool {
  33066. switch name {
  33067. case tutorial.EdgeEmployee:
  33068. return m.clearedemployee
  33069. }
  33070. return false
  33071. }
  33072. // ClearEdge clears the value of the edge with the given name. It returns an error
  33073. // if that edge is not defined in the schema.
  33074. func (m *TutorialMutation) ClearEdge(name string) error {
  33075. switch name {
  33076. case tutorial.EdgeEmployee:
  33077. m.ClearEmployee()
  33078. return nil
  33079. }
  33080. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  33081. }
  33082. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33083. // It returns an error if the edge is not defined in the schema.
  33084. func (m *TutorialMutation) ResetEdge(name string) error {
  33085. switch name {
  33086. case tutorial.EdgeEmployee:
  33087. m.ResetEmployee()
  33088. return nil
  33089. }
  33090. return fmt.Errorf("unknown Tutorial edge %s", name)
  33091. }
  33092. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  33093. type UsageDetailMutation struct {
  33094. config
  33095. op Op
  33096. typ string
  33097. id *uint64
  33098. created_at *time.Time
  33099. updated_at *time.Time
  33100. status *uint8
  33101. addstatus *int8
  33102. _type *int
  33103. add_type *int
  33104. bot_id *string
  33105. receiver_id *string
  33106. app *int
  33107. addapp *int
  33108. session_id *uint64
  33109. addsession_id *int64
  33110. request *string
  33111. response *string
  33112. original_data *custom_types.OriginalData
  33113. total_tokens *uint64
  33114. addtotal_tokens *int64
  33115. prompt_tokens *uint64
  33116. addprompt_tokens *int64
  33117. completion_tokens *uint64
  33118. addcompletion_tokens *int64
  33119. organization_id *uint64
  33120. addorganization_id *int64
  33121. model *string
  33122. credits *float64
  33123. addcredits *float64
  33124. clearedFields map[string]struct{}
  33125. done bool
  33126. oldValue func(context.Context) (*UsageDetail, error)
  33127. predicates []predicate.UsageDetail
  33128. }
  33129. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  33130. // usagedetailOption allows management of the mutation configuration using functional options.
  33131. type usagedetailOption func(*UsageDetailMutation)
  33132. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  33133. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  33134. m := &UsageDetailMutation{
  33135. config: c,
  33136. op: op,
  33137. typ: TypeUsageDetail,
  33138. clearedFields: make(map[string]struct{}),
  33139. }
  33140. for _, opt := range opts {
  33141. opt(m)
  33142. }
  33143. return m
  33144. }
  33145. // withUsageDetailID sets the ID field of the mutation.
  33146. func withUsageDetailID(id uint64) usagedetailOption {
  33147. return func(m *UsageDetailMutation) {
  33148. var (
  33149. err error
  33150. once sync.Once
  33151. value *UsageDetail
  33152. )
  33153. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  33154. once.Do(func() {
  33155. if m.done {
  33156. err = errors.New("querying old values post mutation is not allowed")
  33157. } else {
  33158. value, err = m.Client().UsageDetail.Get(ctx, id)
  33159. }
  33160. })
  33161. return value, err
  33162. }
  33163. m.id = &id
  33164. }
  33165. }
  33166. // withUsageDetail sets the old UsageDetail of the mutation.
  33167. func withUsageDetail(node *UsageDetail) usagedetailOption {
  33168. return func(m *UsageDetailMutation) {
  33169. m.oldValue = func(context.Context) (*UsageDetail, error) {
  33170. return node, nil
  33171. }
  33172. m.id = &node.ID
  33173. }
  33174. }
  33175. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33176. // executed in a transaction (ent.Tx), a transactional client is returned.
  33177. func (m UsageDetailMutation) Client() *Client {
  33178. client := &Client{config: m.config}
  33179. client.init()
  33180. return client
  33181. }
  33182. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33183. // it returns an error otherwise.
  33184. func (m UsageDetailMutation) Tx() (*Tx, error) {
  33185. if _, ok := m.driver.(*txDriver); !ok {
  33186. return nil, errors.New("ent: mutation is not running in a transaction")
  33187. }
  33188. tx := &Tx{config: m.config}
  33189. tx.init()
  33190. return tx, nil
  33191. }
  33192. // SetID sets the value of the id field. Note that this
  33193. // operation is only accepted on creation of UsageDetail entities.
  33194. func (m *UsageDetailMutation) SetID(id uint64) {
  33195. m.id = &id
  33196. }
  33197. // ID returns the ID value in the mutation. Note that the ID is only available
  33198. // if it was provided to the builder or after it was returned from the database.
  33199. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  33200. if m.id == nil {
  33201. return
  33202. }
  33203. return *m.id, true
  33204. }
  33205. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33206. // That means, if the mutation is applied within a transaction with an isolation level such
  33207. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33208. // or updated by the mutation.
  33209. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  33210. switch {
  33211. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33212. id, exists := m.ID()
  33213. if exists {
  33214. return []uint64{id}, nil
  33215. }
  33216. fallthrough
  33217. case m.op.Is(OpUpdate | OpDelete):
  33218. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  33219. default:
  33220. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33221. }
  33222. }
  33223. // SetCreatedAt sets the "created_at" field.
  33224. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  33225. m.created_at = &t
  33226. }
  33227. // CreatedAt returns the value of the "created_at" field in the mutation.
  33228. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  33229. v := m.created_at
  33230. if v == nil {
  33231. return
  33232. }
  33233. return *v, true
  33234. }
  33235. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  33236. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33238. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33239. if !m.op.Is(OpUpdateOne) {
  33240. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33241. }
  33242. if m.id == nil || m.oldValue == nil {
  33243. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33244. }
  33245. oldValue, err := m.oldValue(ctx)
  33246. if err != nil {
  33247. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33248. }
  33249. return oldValue.CreatedAt, nil
  33250. }
  33251. // ResetCreatedAt resets all changes to the "created_at" field.
  33252. func (m *UsageDetailMutation) ResetCreatedAt() {
  33253. m.created_at = nil
  33254. }
  33255. // SetUpdatedAt sets the "updated_at" field.
  33256. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  33257. m.updated_at = &t
  33258. }
  33259. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33260. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  33261. v := m.updated_at
  33262. if v == nil {
  33263. return
  33264. }
  33265. return *v, true
  33266. }
  33267. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  33268. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33270. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33271. if !m.op.Is(OpUpdateOne) {
  33272. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33273. }
  33274. if m.id == nil || m.oldValue == nil {
  33275. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33276. }
  33277. oldValue, err := m.oldValue(ctx)
  33278. if err != nil {
  33279. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33280. }
  33281. return oldValue.UpdatedAt, nil
  33282. }
  33283. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33284. func (m *UsageDetailMutation) ResetUpdatedAt() {
  33285. m.updated_at = nil
  33286. }
  33287. // SetStatus sets the "status" field.
  33288. func (m *UsageDetailMutation) SetStatus(u uint8) {
  33289. m.status = &u
  33290. m.addstatus = nil
  33291. }
  33292. // Status returns the value of the "status" field in the mutation.
  33293. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  33294. v := m.status
  33295. if v == nil {
  33296. return
  33297. }
  33298. return *v, true
  33299. }
  33300. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  33301. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33303. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33304. if !m.op.Is(OpUpdateOne) {
  33305. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33306. }
  33307. if m.id == nil || m.oldValue == nil {
  33308. return v, errors.New("OldStatus requires an ID field in the mutation")
  33309. }
  33310. oldValue, err := m.oldValue(ctx)
  33311. if err != nil {
  33312. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33313. }
  33314. return oldValue.Status, nil
  33315. }
  33316. // AddStatus adds u to the "status" field.
  33317. func (m *UsageDetailMutation) AddStatus(u int8) {
  33318. if m.addstatus != nil {
  33319. *m.addstatus += u
  33320. } else {
  33321. m.addstatus = &u
  33322. }
  33323. }
  33324. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33325. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  33326. v := m.addstatus
  33327. if v == nil {
  33328. return
  33329. }
  33330. return *v, true
  33331. }
  33332. // ClearStatus clears the value of the "status" field.
  33333. func (m *UsageDetailMutation) ClearStatus() {
  33334. m.status = nil
  33335. m.addstatus = nil
  33336. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  33337. }
  33338. // StatusCleared returns if the "status" field was cleared in this mutation.
  33339. func (m *UsageDetailMutation) StatusCleared() bool {
  33340. _, ok := m.clearedFields[usagedetail.FieldStatus]
  33341. return ok
  33342. }
  33343. // ResetStatus resets all changes to the "status" field.
  33344. func (m *UsageDetailMutation) ResetStatus() {
  33345. m.status = nil
  33346. m.addstatus = nil
  33347. delete(m.clearedFields, usagedetail.FieldStatus)
  33348. }
  33349. // SetType sets the "type" field.
  33350. func (m *UsageDetailMutation) SetType(i int) {
  33351. m._type = &i
  33352. m.add_type = nil
  33353. }
  33354. // GetType returns the value of the "type" field in the mutation.
  33355. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  33356. v := m._type
  33357. if v == nil {
  33358. return
  33359. }
  33360. return *v, true
  33361. }
  33362. // OldType returns the old "type" field's value of the UsageDetail entity.
  33363. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33365. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  33366. if !m.op.Is(OpUpdateOne) {
  33367. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33368. }
  33369. if m.id == nil || m.oldValue == nil {
  33370. return v, errors.New("OldType requires an ID field in the mutation")
  33371. }
  33372. oldValue, err := m.oldValue(ctx)
  33373. if err != nil {
  33374. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33375. }
  33376. return oldValue.Type, nil
  33377. }
  33378. // AddType adds i to the "type" field.
  33379. func (m *UsageDetailMutation) AddType(i int) {
  33380. if m.add_type != nil {
  33381. *m.add_type += i
  33382. } else {
  33383. m.add_type = &i
  33384. }
  33385. }
  33386. // AddedType returns the value that was added to the "type" field in this mutation.
  33387. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  33388. v := m.add_type
  33389. if v == nil {
  33390. return
  33391. }
  33392. return *v, true
  33393. }
  33394. // ClearType clears the value of the "type" field.
  33395. func (m *UsageDetailMutation) ClearType() {
  33396. m._type = nil
  33397. m.add_type = nil
  33398. m.clearedFields[usagedetail.FieldType] = struct{}{}
  33399. }
  33400. // TypeCleared returns if the "type" field was cleared in this mutation.
  33401. func (m *UsageDetailMutation) TypeCleared() bool {
  33402. _, ok := m.clearedFields[usagedetail.FieldType]
  33403. return ok
  33404. }
  33405. // ResetType resets all changes to the "type" field.
  33406. func (m *UsageDetailMutation) ResetType() {
  33407. m._type = nil
  33408. m.add_type = nil
  33409. delete(m.clearedFields, usagedetail.FieldType)
  33410. }
  33411. // SetBotID sets the "bot_id" field.
  33412. func (m *UsageDetailMutation) SetBotID(s string) {
  33413. m.bot_id = &s
  33414. }
  33415. // BotID returns the value of the "bot_id" field in the mutation.
  33416. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  33417. v := m.bot_id
  33418. if v == nil {
  33419. return
  33420. }
  33421. return *v, true
  33422. }
  33423. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  33424. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33426. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  33427. if !m.op.Is(OpUpdateOne) {
  33428. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33429. }
  33430. if m.id == nil || m.oldValue == nil {
  33431. return v, errors.New("OldBotID requires an ID field in the mutation")
  33432. }
  33433. oldValue, err := m.oldValue(ctx)
  33434. if err != nil {
  33435. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33436. }
  33437. return oldValue.BotID, nil
  33438. }
  33439. // ResetBotID resets all changes to the "bot_id" field.
  33440. func (m *UsageDetailMutation) ResetBotID() {
  33441. m.bot_id = nil
  33442. }
  33443. // SetReceiverID sets the "receiver_id" field.
  33444. func (m *UsageDetailMutation) SetReceiverID(s string) {
  33445. m.receiver_id = &s
  33446. }
  33447. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  33448. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  33449. v := m.receiver_id
  33450. if v == nil {
  33451. return
  33452. }
  33453. return *v, true
  33454. }
  33455. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  33456. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33458. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  33459. if !m.op.Is(OpUpdateOne) {
  33460. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  33461. }
  33462. if m.id == nil || m.oldValue == nil {
  33463. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  33464. }
  33465. oldValue, err := m.oldValue(ctx)
  33466. if err != nil {
  33467. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  33468. }
  33469. return oldValue.ReceiverID, nil
  33470. }
  33471. // ResetReceiverID resets all changes to the "receiver_id" field.
  33472. func (m *UsageDetailMutation) ResetReceiverID() {
  33473. m.receiver_id = nil
  33474. }
  33475. // SetApp sets the "app" field.
  33476. func (m *UsageDetailMutation) SetApp(i int) {
  33477. m.app = &i
  33478. m.addapp = nil
  33479. }
  33480. // App returns the value of the "app" field in the mutation.
  33481. func (m *UsageDetailMutation) App() (r int, exists bool) {
  33482. v := m.app
  33483. if v == nil {
  33484. return
  33485. }
  33486. return *v, true
  33487. }
  33488. // OldApp returns the old "app" field's value of the UsageDetail entity.
  33489. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33491. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  33492. if !m.op.Is(OpUpdateOne) {
  33493. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  33494. }
  33495. if m.id == nil || m.oldValue == nil {
  33496. return v, errors.New("OldApp requires an ID field in the mutation")
  33497. }
  33498. oldValue, err := m.oldValue(ctx)
  33499. if err != nil {
  33500. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  33501. }
  33502. return oldValue.App, nil
  33503. }
  33504. // AddApp adds i to the "app" field.
  33505. func (m *UsageDetailMutation) AddApp(i int) {
  33506. if m.addapp != nil {
  33507. *m.addapp += i
  33508. } else {
  33509. m.addapp = &i
  33510. }
  33511. }
  33512. // AddedApp returns the value that was added to the "app" field in this mutation.
  33513. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  33514. v := m.addapp
  33515. if v == nil {
  33516. return
  33517. }
  33518. return *v, true
  33519. }
  33520. // ClearApp clears the value of the "app" field.
  33521. func (m *UsageDetailMutation) ClearApp() {
  33522. m.app = nil
  33523. m.addapp = nil
  33524. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  33525. }
  33526. // AppCleared returns if the "app" field was cleared in this mutation.
  33527. func (m *UsageDetailMutation) AppCleared() bool {
  33528. _, ok := m.clearedFields[usagedetail.FieldApp]
  33529. return ok
  33530. }
  33531. // ResetApp resets all changes to the "app" field.
  33532. func (m *UsageDetailMutation) ResetApp() {
  33533. m.app = nil
  33534. m.addapp = nil
  33535. delete(m.clearedFields, usagedetail.FieldApp)
  33536. }
  33537. // SetSessionID sets the "session_id" field.
  33538. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  33539. m.session_id = &u
  33540. m.addsession_id = nil
  33541. }
  33542. // SessionID returns the value of the "session_id" field in the mutation.
  33543. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  33544. v := m.session_id
  33545. if v == nil {
  33546. return
  33547. }
  33548. return *v, true
  33549. }
  33550. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  33551. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33553. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  33554. if !m.op.Is(OpUpdateOne) {
  33555. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  33556. }
  33557. if m.id == nil || m.oldValue == nil {
  33558. return v, errors.New("OldSessionID requires an ID field in the mutation")
  33559. }
  33560. oldValue, err := m.oldValue(ctx)
  33561. if err != nil {
  33562. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  33563. }
  33564. return oldValue.SessionID, nil
  33565. }
  33566. // AddSessionID adds u to the "session_id" field.
  33567. func (m *UsageDetailMutation) AddSessionID(u int64) {
  33568. if m.addsession_id != nil {
  33569. *m.addsession_id += u
  33570. } else {
  33571. m.addsession_id = &u
  33572. }
  33573. }
  33574. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  33575. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  33576. v := m.addsession_id
  33577. if v == nil {
  33578. return
  33579. }
  33580. return *v, true
  33581. }
  33582. // ClearSessionID clears the value of the "session_id" field.
  33583. func (m *UsageDetailMutation) ClearSessionID() {
  33584. m.session_id = nil
  33585. m.addsession_id = nil
  33586. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  33587. }
  33588. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  33589. func (m *UsageDetailMutation) SessionIDCleared() bool {
  33590. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  33591. return ok
  33592. }
  33593. // ResetSessionID resets all changes to the "session_id" field.
  33594. func (m *UsageDetailMutation) ResetSessionID() {
  33595. m.session_id = nil
  33596. m.addsession_id = nil
  33597. delete(m.clearedFields, usagedetail.FieldSessionID)
  33598. }
  33599. // SetRequest sets the "request" field.
  33600. func (m *UsageDetailMutation) SetRequest(s string) {
  33601. m.request = &s
  33602. }
  33603. // Request returns the value of the "request" field in the mutation.
  33604. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  33605. v := m.request
  33606. if v == nil {
  33607. return
  33608. }
  33609. return *v, true
  33610. }
  33611. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  33612. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33614. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  33615. if !m.op.Is(OpUpdateOne) {
  33616. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  33617. }
  33618. if m.id == nil || m.oldValue == nil {
  33619. return v, errors.New("OldRequest requires an ID field in the mutation")
  33620. }
  33621. oldValue, err := m.oldValue(ctx)
  33622. if err != nil {
  33623. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  33624. }
  33625. return oldValue.Request, nil
  33626. }
  33627. // ResetRequest resets all changes to the "request" field.
  33628. func (m *UsageDetailMutation) ResetRequest() {
  33629. m.request = nil
  33630. }
  33631. // SetResponse sets the "response" field.
  33632. func (m *UsageDetailMutation) SetResponse(s string) {
  33633. m.response = &s
  33634. }
  33635. // Response returns the value of the "response" field in the mutation.
  33636. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  33637. v := m.response
  33638. if v == nil {
  33639. return
  33640. }
  33641. return *v, true
  33642. }
  33643. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  33644. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33646. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  33647. if !m.op.Is(OpUpdateOne) {
  33648. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  33649. }
  33650. if m.id == nil || m.oldValue == nil {
  33651. return v, errors.New("OldResponse requires an ID field in the mutation")
  33652. }
  33653. oldValue, err := m.oldValue(ctx)
  33654. if err != nil {
  33655. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  33656. }
  33657. return oldValue.Response, nil
  33658. }
  33659. // ResetResponse resets all changes to the "response" field.
  33660. func (m *UsageDetailMutation) ResetResponse() {
  33661. m.response = nil
  33662. }
  33663. // SetOriginalData sets the "original_data" field.
  33664. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  33665. m.original_data = &ctd
  33666. }
  33667. // OriginalData returns the value of the "original_data" field in the mutation.
  33668. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  33669. v := m.original_data
  33670. if v == nil {
  33671. return
  33672. }
  33673. return *v, true
  33674. }
  33675. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  33676. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33678. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  33679. if !m.op.Is(OpUpdateOne) {
  33680. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  33681. }
  33682. if m.id == nil || m.oldValue == nil {
  33683. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  33684. }
  33685. oldValue, err := m.oldValue(ctx)
  33686. if err != nil {
  33687. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  33688. }
  33689. return oldValue.OriginalData, nil
  33690. }
  33691. // ResetOriginalData resets all changes to the "original_data" field.
  33692. func (m *UsageDetailMutation) ResetOriginalData() {
  33693. m.original_data = nil
  33694. }
  33695. // SetTotalTokens sets the "total_tokens" field.
  33696. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  33697. m.total_tokens = &u
  33698. m.addtotal_tokens = nil
  33699. }
  33700. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  33701. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  33702. v := m.total_tokens
  33703. if v == nil {
  33704. return
  33705. }
  33706. return *v, true
  33707. }
  33708. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  33709. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33711. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  33712. if !m.op.Is(OpUpdateOne) {
  33713. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  33714. }
  33715. if m.id == nil || m.oldValue == nil {
  33716. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  33717. }
  33718. oldValue, err := m.oldValue(ctx)
  33719. if err != nil {
  33720. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  33721. }
  33722. return oldValue.TotalTokens, nil
  33723. }
  33724. // AddTotalTokens adds u to the "total_tokens" field.
  33725. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  33726. if m.addtotal_tokens != nil {
  33727. *m.addtotal_tokens += u
  33728. } else {
  33729. m.addtotal_tokens = &u
  33730. }
  33731. }
  33732. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  33733. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  33734. v := m.addtotal_tokens
  33735. if v == nil {
  33736. return
  33737. }
  33738. return *v, true
  33739. }
  33740. // ClearTotalTokens clears the value of the "total_tokens" field.
  33741. func (m *UsageDetailMutation) ClearTotalTokens() {
  33742. m.total_tokens = nil
  33743. m.addtotal_tokens = nil
  33744. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  33745. }
  33746. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33747. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  33748. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  33749. return ok
  33750. }
  33751. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33752. func (m *UsageDetailMutation) ResetTotalTokens() {
  33753. m.total_tokens = nil
  33754. m.addtotal_tokens = nil
  33755. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  33756. }
  33757. // SetPromptTokens sets the "prompt_tokens" field.
  33758. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  33759. m.prompt_tokens = &u
  33760. m.addprompt_tokens = nil
  33761. }
  33762. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  33763. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  33764. v := m.prompt_tokens
  33765. if v == nil {
  33766. return
  33767. }
  33768. return *v, true
  33769. }
  33770. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  33771. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33773. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  33774. if !m.op.Is(OpUpdateOne) {
  33775. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  33776. }
  33777. if m.id == nil || m.oldValue == nil {
  33778. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  33779. }
  33780. oldValue, err := m.oldValue(ctx)
  33781. if err != nil {
  33782. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  33783. }
  33784. return oldValue.PromptTokens, nil
  33785. }
  33786. // AddPromptTokens adds u to the "prompt_tokens" field.
  33787. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  33788. if m.addprompt_tokens != nil {
  33789. *m.addprompt_tokens += u
  33790. } else {
  33791. m.addprompt_tokens = &u
  33792. }
  33793. }
  33794. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  33795. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  33796. v := m.addprompt_tokens
  33797. if v == nil {
  33798. return
  33799. }
  33800. return *v, true
  33801. }
  33802. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  33803. func (m *UsageDetailMutation) ClearPromptTokens() {
  33804. m.prompt_tokens = nil
  33805. m.addprompt_tokens = nil
  33806. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  33807. }
  33808. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  33809. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  33810. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  33811. return ok
  33812. }
  33813. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  33814. func (m *UsageDetailMutation) ResetPromptTokens() {
  33815. m.prompt_tokens = nil
  33816. m.addprompt_tokens = nil
  33817. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  33818. }
  33819. // SetCompletionTokens sets the "completion_tokens" field.
  33820. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  33821. m.completion_tokens = &u
  33822. m.addcompletion_tokens = nil
  33823. }
  33824. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  33825. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  33826. v := m.completion_tokens
  33827. if v == nil {
  33828. return
  33829. }
  33830. return *v, true
  33831. }
  33832. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  33833. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33835. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  33836. if !m.op.Is(OpUpdateOne) {
  33837. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  33838. }
  33839. if m.id == nil || m.oldValue == nil {
  33840. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  33841. }
  33842. oldValue, err := m.oldValue(ctx)
  33843. if err != nil {
  33844. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  33845. }
  33846. return oldValue.CompletionTokens, nil
  33847. }
  33848. // AddCompletionTokens adds u to the "completion_tokens" field.
  33849. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  33850. if m.addcompletion_tokens != nil {
  33851. *m.addcompletion_tokens += u
  33852. } else {
  33853. m.addcompletion_tokens = &u
  33854. }
  33855. }
  33856. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  33857. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  33858. v := m.addcompletion_tokens
  33859. if v == nil {
  33860. return
  33861. }
  33862. return *v, true
  33863. }
  33864. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  33865. func (m *UsageDetailMutation) ClearCompletionTokens() {
  33866. m.completion_tokens = nil
  33867. m.addcompletion_tokens = nil
  33868. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  33869. }
  33870. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  33871. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  33872. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  33873. return ok
  33874. }
  33875. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  33876. func (m *UsageDetailMutation) ResetCompletionTokens() {
  33877. m.completion_tokens = nil
  33878. m.addcompletion_tokens = nil
  33879. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  33880. }
  33881. // SetOrganizationID sets the "organization_id" field.
  33882. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  33883. m.organization_id = &u
  33884. m.addorganization_id = nil
  33885. }
  33886. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33887. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  33888. v := m.organization_id
  33889. if v == nil {
  33890. return
  33891. }
  33892. return *v, true
  33893. }
  33894. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  33895. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33897. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33898. if !m.op.Is(OpUpdateOne) {
  33899. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33900. }
  33901. if m.id == nil || m.oldValue == nil {
  33902. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33903. }
  33904. oldValue, err := m.oldValue(ctx)
  33905. if err != nil {
  33906. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33907. }
  33908. return oldValue.OrganizationID, nil
  33909. }
  33910. // AddOrganizationID adds u to the "organization_id" field.
  33911. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  33912. if m.addorganization_id != nil {
  33913. *m.addorganization_id += u
  33914. } else {
  33915. m.addorganization_id = &u
  33916. }
  33917. }
  33918. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33919. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  33920. v := m.addorganization_id
  33921. if v == nil {
  33922. return
  33923. }
  33924. return *v, true
  33925. }
  33926. // ClearOrganizationID clears the value of the "organization_id" field.
  33927. func (m *UsageDetailMutation) ClearOrganizationID() {
  33928. m.organization_id = nil
  33929. m.addorganization_id = nil
  33930. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  33931. }
  33932. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33933. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  33934. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  33935. return ok
  33936. }
  33937. // ResetOrganizationID resets all changes to the "organization_id" field.
  33938. func (m *UsageDetailMutation) ResetOrganizationID() {
  33939. m.organization_id = nil
  33940. m.addorganization_id = nil
  33941. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  33942. }
  33943. // SetModel sets the "model" field.
  33944. func (m *UsageDetailMutation) SetModel(s string) {
  33945. m.model = &s
  33946. }
  33947. // Model returns the value of the "model" field in the mutation.
  33948. func (m *UsageDetailMutation) Model() (r string, exists bool) {
  33949. v := m.model
  33950. if v == nil {
  33951. return
  33952. }
  33953. return *v, true
  33954. }
  33955. // OldModel returns the old "model" field's value of the UsageDetail entity.
  33956. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33958. func (m *UsageDetailMutation) OldModel(ctx context.Context) (v string, err error) {
  33959. if !m.op.Is(OpUpdateOne) {
  33960. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  33961. }
  33962. if m.id == nil || m.oldValue == nil {
  33963. return v, errors.New("OldModel requires an ID field in the mutation")
  33964. }
  33965. oldValue, err := m.oldValue(ctx)
  33966. if err != nil {
  33967. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  33968. }
  33969. return oldValue.Model, nil
  33970. }
  33971. // ClearModel clears the value of the "model" field.
  33972. func (m *UsageDetailMutation) ClearModel() {
  33973. m.model = nil
  33974. m.clearedFields[usagedetail.FieldModel] = struct{}{}
  33975. }
  33976. // ModelCleared returns if the "model" field was cleared in this mutation.
  33977. func (m *UsageDetailMutation) ModelCleared() bool {
  33978. _, ok := m.clearedFields[usagedetail.FieldModel]
  33979. return ok
  33980. }
  33981. // ResetModel resets all changes to the "model" field.
  33982. func (m *UsageDetailMutation) ResetModel() {
  33983. m.model = nil
  33984. delete(m.clearedFields, usagedetail.FieldModel)
  33985. }
  33986. // SetCredits sets the "credits" field.
  33987. func (m *UsageDetailMutation) SetCredits(f float64) {
  33988. m.credits = &f
  33989. m.addcredits = nil
  33990. }
  33991. // Credits returns the value of the "credits" field in the mutation.
  33992. func (m *UsageDetailMutation) Credits() (r float64, exists bool) {
  33993. v := m.credits
  33994. if v == nil {
  33995. return
  33996. }
  33997. return *v, true
  33998. }
  33999. // OldCredits returns the old "credits" field's value of the UsageDetail entity.
  34000. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34002. func (m *UsageDetailMutation) OldCredits(ctx context.Context) (v float64, err error) {
  34003. if !m.op.Is(OpUpdateOne) {
  34004. return v, errors.New("OldCredits is only allowed on UpdateOne operations")
  34005. }
  34006. if m.id == nil || m.oldValue == nil {
  34007. return v, errors.New("OldCredits requires an ID field in the mutation")
  34008. }
  34009. oldValue, err := m.oldValue(ctx)
  34010. if err != nil {
  34011. return v, fmt.Errorf("querying old value for OldCredits: %w", err)
  34012. }
  34013. return oldValue.Credits, nil
  34014. }
  34015. // AddCredits adds f to the "credits" field.
  34016. func (m *UsageDetailMutation) AddCredits(f float64) {
  34017. if m.addcredits != nil {
  34018. *m.addcredits += f
  34019. } else {
  34020. m.addcredits = &f
  34021. }
  34022. }
  34023. // AddedCredits returns the value that was added to the "credits" field in this mutation.
  34024. func (m *UsageDetailMutation) AddedCredits() (r float64, exists bool) {
  34025. v := m.addcredits
  34026. if v == nil {
  34027. return
  34028. }
  34029. return *v, true
  34030. }
  34031. // ClearCredits clears the value of the "credits" field.
  34032. func (m *UsageDetailMutation) ClearCredits() {
  34033. m.credits = nil
  34034. m.addcredits = nil
  34035. m.clearedFields[usagedetail.FieldCredits] = struct{}{}
  34036. }
  34037. // CreditsCleared returns if the "credits" field was cleared in this mutation.
  34038. func (m *UsageDetailMutation) CreditsCleared() bool {
  34039. _, ok := m.clearedFields[usagedetail.FieldCredits]
  34040. return ok
  34041. }
  34042. // ResetCredits resets all changes to the "credits" field.
  34043. func (m *UsageDetailMutation) ResetCredits() {
  34044. m.credits = nil
  34045. m.addcredits = nil
  34046. delete(m.clearedFields, usagedetail.FieldCredits)
  34047. }
  34048. // Where appends a list predicates to the UsageDetailMutation builder.
  34049. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  34050. m.predicates = append(m.predicates, ps...)
  34051. }
  34052. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  34053. // users can use type-assertion to append predicates that do not depend on any generated package.
  34054. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  34055. p := make([]predicate.UsageDetail, len(ps))
  34056. for i := range ps {
  34057. p[i] = ps[i]
  34058. }
  34059. m.Where(p...)
  34060. }
  34061. // Op returns the operation name.
  34062. func (m *UsageDetailMutation) Op() Op {
  34063. return m.op
  34064. }
  34065. // SetOp allows setting the mutation operation.
  34066. func (m *UsageDetailMutation) SetOp(op Op) {
  34067. m.op = op
  34068. }
  34069. // Type returns the node type of this mutation (UsageDetail).
  34070. func (m *UsageDetailMutation) Type() string {
  34071. return m.typ
  34072. }
  34073. // Fields returns all fields that were changed during this mutation. Note that in
  34074. // order to get all numeric fields that were incremented/decremented, call
  34075. // AddedFields().
  34076. func (m *UsageDetailMutation) Fields() []string {
  34077. fields := make([]string, 0, 17)
  34078. if m.created_at != nil {
  34079. fields = append(fields, usagedetail.FieldCreatedAt)
  34080. }
  34081. if m.updated_at != nil {
  34082. fields = append(fields, usagedetail.FieldUpdatedAt)
  34083. }
  34084. if m.status != nil {
  34085. fields = append(fields, usagedetail.FieldStatus)
  34086. }
  34087. if m._type != nil {
  34088. fields = append(fields, usagedetail.FieldType)
  34089. }
  34090. if m.bot_id != nil {
  34091. fields = append(fields, usagedetail.FieldBotID)
  34092. }
  34093. if m.receiver_id != nil {
  34094. fields = append(fields, usagedetail.FieldReceiverID)
  34095. }
  34096. if m.app != nil {
  34097. fields = append(fields, usagedetail.FieldApp)
  34098. }
  34099. if m.session_id != nil {
  34100. fields = append(fields, usagedetail.FieldSessionID)
  34101. }
  34102. if m.request != nil {
  34103. fields = append(fields, usagedetail.FieldRequest)
  34104. }
  34105. if m.response != nil {
  34106. fields = append(fields, usagedetail.FieldResponse)
  34107. }
  34108. if m.original_data != nil {
  34109. fields = append(fields, usagedetail.FieldOriginalData)
  34110. }
  34111. if m.total_tokens != nil {
  34112. fields = append(fields, usagedetail.FieldTotalTokens)
  34113. }
  34114. if m.prompt_tokens != nil {
  34115. fields = append(fields, usagedetail.FieldPromptTokens)
  34116. }
  34117. if m.completion_tokens != nil {
  34118. fields = append(fields, usagedetail.FieldCompletionTokens)
  34119. }
  34120. if m.organization_id != nil {
  34121. fields = append(fields, usagedetail.FieldOrganizationID)
  34122. }
  34123. if m.model != nil {
  34124. fields = append(fields, usagedetail.FieldModel)
  34125. }
  34126. if m.credits != nil {
  34127. fields = append(fields, usagedetail.FieldCredits)
  34128. }
  34129. return fields
  34130. }
  34131. // Field returns the value of a field with the given name. The second boolean
  34132. // return value indicates that this field was not set, or was not defined in the
  34133. // schema.
  34134. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  34135. switch name {
  34136. case usagedetail.FieldCreatedAt:
  34137. return m.CreatedAt()
  34138. case usagedetail.FieldUpdatedAt:
  34139. return m.UpdatedAt()
  34140. case usagedetail.FieldStatus:
  34141. return m.Status()
  34142. case usagedetail.FieldType:
  34143. return m.GetType()
  34144. case usagedetail.FieldBotID:
  34145. return m.BotID()
  34146. case usagedetail.FieldReceiverID:
  34147. return m.ReceiverID()
  34148. case usagedetail.FieldApp:
  34149. return m.App()
  34150. case usagedetail.FieldSessionID:
  34151. return m.SessionID()
  34152. case usagedetail.FieldRequest:
  34153. return m.Request()
  34154. case usagedetail.FieldResponse:
  34155. return m.Response()
  34156. case usagedetail.FieldOriginalData:
  34157. return m.OriginalData()
  34158. case usagedetail.FieldTotalTokens:
  34159. return m.TotalTokens()
  34160. case usagedetail.FieldPromptTokens:
  34161. return m.PromptTokens()
  34162. case usagedetail.FieldCompletionTokens:
  34163. return m.CompletionTokens()
  34164. case usagedetail.FieldOrganizationID:
  34165. return m.OrganizationID()
  34166. case usagedetail.FieldModel:
  34167. return m.Model()
  34168. case usagedetail.FieldCredits:
  34169. return m.Credits()
  34170. }
  34171. return nil, false
  34172. }
  34173. // OldField returns the old value of the field from the database. An error is
  34174. // returned if the mutation operation is not UpdateOne, or the query to the
  34175. // database failed.
  34176. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34177. switch name {
  34178. case usagedetail.FieldCreatedAt:
  34179. return m.OldCreatedAt(ctx)
  34180. case usagedetail.FieldUpdatedAt:
  34181. return m.OldUpdatedAt(ctx)
  34182. case usagedetail.FieldStatus:
  34183. return m.OldStatus(ctx)
  34184. case usagedetail.FieldType:
  34185. return m.OldType(ctx)
  34186. case usagedetail.FieldBotID:
  34187. return m.OldBotID(ctx)
  34188. case usagedetail.FieldReceiverID:
  34189. return m.OldReceiverID(ctx)
  34190. case usagedetail.FieldApp:
  34191. return m.OldApp(ctx)
  34192. case usagedetail.FieldSessionID:
  34193. return m.OldSessionID(ctx)
  34194. case usagedetail.FieldRequest:
  34195. return m.OldRequest(ctx)
  34196. case usagedetail.FieldResponse:
  34197. return m.OldResponse(ctx)
  34198. case usagedetail.FieldOriginalData:
  34199. return m.OldOriginalData(ctx)
  34200. case usagedetail.FieldTotalTokens:
  34201. return m.OldTotalTokens(ctx)
  34202. case usagedetail.FieldPromptTokens:
  34203. return m.OldPromptTokens(ctx)
  34204. case usagedetail.FieldCompletionTokens:
  34205. return m.OldCompletionTokens(ctx)
  34206. case usagedetail.FieldOrganizationID:
  34207. return m.OldOrganizationID(ctx)
  34208. case usagedetail.FieldModel:
  34209. return m.OldModel(ctx)
  34210. case usagedetail.FieldCredits:
  34211. return m.OldCredits(ctx)
  34212. }
  34213. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  34214. }
  34215. // SetField sets the value of a field with the given name. It returns an error if
  34216. // the field is not defined in the schema, or if the type mismatched the field
  34217. // type.
  34218. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  34219. switch name {
  34220. case usagedetail.FieldCreatedAt:
  34221. v, ok := value.(time.Time)
  34222. if !ok {
  34223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34224. }
  34225. m.SetCreatedAt(v)
  34226. return nil
  34227. case usagedetail.FieldUpdatedAt:
  34228. v, ok := value.(time.Time)
  34229. if !ok {
  34230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34231. }
  34232. m.SetUpdatedAt(v)
  34233. return nil
  34234. case usagedetail.FieldStatus:
  34235. v, ok := value.(uint8)
  34236. if !ok {
  34237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34238. }
  34239. m.SetStatus(v)
  34240. return nil
  34241. case usagedetail.FieldType:
  34242. v, ok := value.(int)
  34243. if !ok {
  34244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34245. }
  34246. m.SetType(v)
  34247. return nil
  34248. case usagedetail.FieldBotID:
  34249. v, ok := value.(string)
  34250. if !ok {
  34251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34252. }
  34253. m.SetBotID(v)
  34254. return nil
  34255. case usagedetail.FieldReceiverID:
  34256. v, ok := value.(string)
  34257. if !ok {
  34258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34259. }
  34260. m.SetReceiverID(v)
  34261. return nil
  34262. case usagedetail.FieldApp:
  34263. v, ok := value.(int)
  34264. if !ok {
  34265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34266. }
  34267. m.SetApp(v)
  34268. return nil
  34269. case usagedetail.FieldSessionID:
  34270. v, ok := value.(uint64)
  34271. if !ok {
  34272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34273. }
  34274. m.SetSessionID(v)
  34275. return nil
  34276. case usagedetail.FieldRequest:
  34277. v, ok := value.(string)
  34278. if !ok {
  34279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34280. }
  34281. m.SetRequest(v)
  34282. return nil
  34283. case usagedetail.FieldResponse:
  34284. v, ok := value.(string)
  34285. if !ok {
  34286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34287. }
  34288. m.SetResponse(v)
  34289. return nil
  34290. case usagedetail.FieldOriginalData:
  34291. v, ok := value.(custom_types.OriginalData)
  34292. if !ok {
  34293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34294. }
  34295. m.SetOriginalData(v)
  34296. return nil
  34297. case usagedetail.FieldTotalTokens:
  34298. v, ok := value.(uint64)
  34299. if !ok {
  34300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34301. }
  34302. m.SetTotalTokens(v)
  34303. return nil
  34304. case usagedetail.FieldPromptTokens:
  34305. v, ok := value.(uint64)
  34306. if !ok {
  34307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34308. }
  34309. m.SetPromptTokens(v)
  34310. return nil
  34311. case usagedetail.FieldCompletionTokens:
  34312. v, ok := value.(uint64)
  34313. if !ok {
  34314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34315. }
  34316. m.SetCompletionTokens(v)
  34317. return nil
  34318. case usagedetail.FieldOrganizationID:
  34319. v, ok := value.(uint64)
  34320. if !ok {
  34321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34322. }
  34323. m.SetOrganizationID(v)
  34324. return nil
  34325. case usagedetail.FieldModel:
  34326. v, ok := value.(string)
  34327. if !ok {
  34328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34329. }
  34330. m.SetModel(v)
  34331. return nil
  34332. case usagedetail.FieldCredits:
  34333. v, ok := value.(float64)
  34334. if !ok {
  34335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34336. }
  34337. m.SetCredits(v)
  34338. return nil
  34339. }
  34340. return fmt.Errorf("unknown UsageDetail field %s", name)
  34341. }
  34342. // AddedFields returns all numeric fields that were incremented/decremented during
  34343. // this mutation.
  34344. func (m *UsageDetailMutation) AddedFields() []string {
  34345. var fields []string
  34346. if m.addstatus != nil {
  34347. fields = append(fields, usagedetail.FieldStatus)
  34348. }
  34349. if m.add_type != nil {
  34350. fields = append(fields, usagedetail.FieldType)
  34351. }
  34352. if m.addapp != nil {
  34353. fields = append(fields, usagedetail.FieldApp)
  34354. }
  34355. if m.addsession_id != nil {
  34356. fields = append(fields, usagedetail.FieldSessionID)
  34357. }
  34358. if m.addtotal_tokens != nil {
  34359. fields = append(fields, usagedetail.FieldTotalTokens)
  34360. }
  34361. if m.addprompt_tokens != nil {
  34362. fields = append(fields, usagedetail.FieldPromptTokens)
  34363. }
  34364. if m.addcompletion_tokens != nil {
  34365. fields = append(fields, usagedetail.FieldCompletionTokens)
  34366. }
  34367. if m.addorganization_id != nil {
  34368. fields = append(fields, usagedetail.FieldOrganizationID)
  34369. }
  34370. if m.addcredits != nil {
  34371. fields = append(fields, usagedetail.FieldCredits)
  34372. }
  34373. return fields
  34374. }
  34375. // AddedField returns the numeric value that was incremented/decremented on a field
  34376. // with the given name. The second boolean return value indicates that this field
  34377. // was not set, or was not defined in the schema.
  34378. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  34379. switch name {
  34380. case usagedetail.FieldStatus:
  34381. return m.AddedStatus()
  34382. case usagedetail.FieldType:
  34383. return m.AddedType()
  34384. case usagedetail.FieldApp:
  34385. return m.AddedApp()
  34386. case usagedetail.FieldSessionID:
  34387. return m.AddedSessionID()
  34388. case usagedetail.FieldTotalTokens:
  34389. return m.AddedTotalTokens()
  34390. case usagedetail.FieldPromptTokens:
  34391. return m.AddedPromptTokens()
  34392. case usagedetail.FieldCompletionTokens:
  34393. return m.AddedCompletionTokens()
  34394. case usagedetail.FieldOrganizationID:
  34395. return m.AddedOrganizationID()
  34396. case usagedetail.FieldCredits:
  34397. return m.AddedCredits()
  34398. }
  34399. return nil, false
  34400. }
  34401. // AddField adds the value to the field with the given name. It returns an error if
  34402. // the field is not defined in the schema, or if the type mismatched the field
  34403. // type.
  34404. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  34405. switch name {
  34406. case usagedetail.FieldStatus:
  34407. v, ok := value.(int8)
  34408. if !ok {
  34409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34410. }
  34411. m.AddStatus(v)
  34412. return nil
  34413. case usagedetail.FieldType:
  34414. v, ok := value.(int)
  34415. if !ok {
  34416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34417. }
  34418. m.AddType(v)
  34419. return nil
  34420. case usagedetail.FieldApp:
  34421. v, ok := value.(int)
  34422. if !ok {
  34423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34424. }
  34425. m.AddApp(v)
  34426. return nil
  34427. case usagedetail.FieldSessionID:
  34428. v, ok := value.(int64)
  34429. if !ok {
  34430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34431. }
  34432. m.AddSessionID(v)
  34433. return nil
  34434. case usagedetail.FieldTotalTokens:
  34435. v, ok := value.(int64)
  34436. if !ok {
  34437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34438. }
  34439. m.AddTotalTokens(v)
  34440. return nil
  34441. case usagedetail.FieldPromptTokens:
  34442. v, ok := value.(int64)
  34443. if !ok {
  34444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34445. }
  34446. m.AddPromptTokens(v)
  34447. return nil
  34448. case usagedetail.FieldCompletionTokens:
  34449. v, ok := value.(int64)
  34450. if !ok {
  34451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34452. }
  34453. m.AddCompletionTokens(v)
  34454. return nil
  34455. case usagedetail.FieldOrganizationID:
  34456. v, ok := value.(int64)
  34457. if !ok {
  34458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34459. }
  34460. m.AddOrganizationID(v)
  34461. return nil
  34462. case usagedetail.FieldCredits:
  34463. v, ok := value.(float64)
  34464. if !ok {
  34465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34466. }
  34467. m.AddCredits(v)
  34468. return nil
  34469. }
  34470. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  34471. }
  34472. // ClearedFields returns all nullable fields that were cleared during this
  34473. // mutation.
  34474. func (m *UsageDetailMutation) ClearedFields() []string {
  34475. var fields []string
  34476. if m.FieldCleared(usagedetail.FieldStatus) {
  34477. fields = append(fields, usagedetail.FieldStatus)
  34478. }
  34479. if m.FieldCleared(usagedetail.FieldType) {
  34480. fields = append(fields, usagedetail.FieldType)
  34481. }
  34482. if m.FieldCleared(usagedetail.FieldApp) {
  34483. fields = append(fields, usagedetail.FieldApp)
  34484. }
  34485. if m.FieldCleared(usagedetail.FieldSessionID) {
  34486. fields = append(fields, usagedetail.FieldSessionID)
  34487. }
  34488. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  34489. fields = append(fields, usagedetail.FieldTotalTokens)
  34490. }
  34491. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  34492. fields = append(fields, usagedetail.FieldPromptTokens)
  34493. }
  34494. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  34495. fields = append(fields, usagedetail.FieldCompletionTokens)
  34496. }
  34497. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  34498. fields = append(fields, usagedetail.FieldOrganizationID)
  34499. }
  34500. if m.FieldCleared(usagedetail.FieldModel) {
  34501. fields = append(fields, usagedetail.FieldModel)
  34502. }
  34503. if m.FieldCleared(usagedetail.FieldCredits) {
  34504. fields = append(fields, usagedetail.FieldCredits)
  34505. }
  34506. return fields
  34507. }
  34508. // FieldCleared returns a boolean indicating if a field with the given name was
  34509. // cleared in this mutation.
  34510. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  34511. _, ok := m.clearedFields[name]
  34512. return ok
  34513. }
  34514. // ClearField clears the value of the field with the given name. It returns an
  34515. // error if the field is not defined in the schema.
  34516. func (m *UsageDetailMutation) ClearField(name string) error {
  34517. switch name {
  34518. case usagedetail.FieldStatus:
  34519. m.ClearStatus()
  34520. return nil
  34521. case usagedetail.FieldType:
  34522. m.ClearType()
  34523. return nil
  34524. case usagedetail.FieldApp:
  34525. m.ClearApp()
  34526. return nil
  34527. case usagedetail.FieldSessionID:
  34528. m.ClearSessionID()
  34529. return nil
  34530. case usagedetail.FieldTotalTokens:
  34531. m.ClearTotalTokens()
  34532. return nil
  34533. case usagedetail.FieldPromptTokens:
  34534. m.ClearPromptTokens()
  34535. return nil
  34536. case usagedetail.FieldCompletionTokens:
  34537. m.ClearCompletionTokens()
  34538. return nil
  34539. case usagedetail.FieldOrganizationID:
  34540. m.ClearOrganizationID()
  34541. return nil
  34542. case usagedetail.FieldModel:
  34543. m.ClearModel()
  34544. return nil
  34545. case usagedetail.FieldCredits:
  34546. m.ClearCredits()
  34547. return nil
  34548. }
  34549. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  34550. }
  34551. // ResetField resets all changes in the mutation for the field with the given name.
  34552. // It returns an error if the field is not defined in the schema.
  34553. func (m *UsageDetailMutation) ResetField(name string) error {
  34554. switch name {
  34555. case usagedetail.FieldCreatedAt:
  34556. m.ResetCreatedAt()
  34557. return nil
  34558. case usagedetail.FieldUpdatedAt:
  34559. m.ResetUpdatedAt()
  34560. return nil
  34561. case usagedetail.FieldStatus:
  34562. m.ResetStatus()
  34563. return nil
  34564. case usagedetail.FieldType:
  34565. m.ResetType()
  34566. return nil
  34567. case usagedetail.FieldBotID:
  34568. m.ResetBotID()
  34569. return nil
  34570. case usagedetail.FieldReceiverID:
  34571. m.ResetReceiverID()
  34572. return nil
  34573. case usagedetail.FieldApp:
  34574. m.ResetApp()
  34575. return nil
  34576. case usagedetail.FieldSessionID:
  34577. m.ResetSessionID()
  34578. return nil
  34579. case usagedetail.FieldRequest:
  34580. m.ResetRequest()
  34581. return nil
  34582. case usagedetail.FieldResponse:
  34583. m.ResetResponse()
  34584. return nil
  34585. case usagedetail.FieldOriginalData:
  34586. m.ResetOriginalData()
  34587. return nil
  34588. case usagedetail.FieldTotalTokens:
  34589. m.ResetTotalTokens()
  34590. return nil
  34591. case usagedetail.FieldPromptTokens:
  34592. m.ResetPromptTokens()
  34593. return nil
  34594. case usagedetail.FieldCompletionTokens:
  34595. m.ResetCompletionTokens()
  34596. return nil
  34597. case usagedetail.FieldOrganizationID:
  34598. m.ResetOrganizationID()
  34599. return nil
  34600. case usagedetail.FieldModel:
  34601. m.ResetModel()
  34602. return nil
  34603. case usagedetail.FieldCredits:
  34604. m.ResetCredits()
  34605. return nil
  34606. }
  34607. return fmt.Errorf("unknown UsageDetail field %s", name)
  34608. }
  34609. // AddedEdges returns all edge names that were set/added in this mutation.
  34610. func (m *UsageDetailMutation) AddedEdges() []string {
  34611. edges := make([]string, 0, 0)
  34612. return edges
  34613. }
  34614. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34615. // name in this mutation.
  34616. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  34617. return nil
  34618. }
  34619. // RemovedEdges returns all edge names that were removed in this mutation.
  34620. func (m *UsageDetailMutation) RemovedEdges() []string {
  34621. edges := make([]string, 0, 0)
  34622. return edges
  34623. }
  34624. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34625. // the given name in this mutation.
  34626. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  34627. return nil
  34628. }
  34629. // ClearedEdges returns all edge names that were cleared in this mutation.
  34630. func (m *UsageDetailMutation) ClearedEdges() []string {
  34631. edges := make([]string, 0, 0)
  34632. return edges
  34633. }
  34634. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34635. // was cleared in this mutation.
  34636. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  34637. return false
  34638. }
  34639. // ClearEdge clears the value of the edge with the given name. It returns an error
  34640. // if that edge is not defined in the schema.
  34641. func (m *UsageDetailMutation) ClearEdge(name string) error {
  34642. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  34643. }
  34644. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34645. // It returns an error if the edge is not defined in the schema.
  34646. func (m *UsageDetailMutation) ResetEdge(name string) error {
  34647. return fmt.Errorf("unknown UsageDetail edge %s", name)
  34648. }
  34649. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  34650. type UsageStatisticDayMutation struct {
  34651. config
  34652. op Op
  34653. typ string
  34654. id *uint64
  34655. created_at *time.Time
  34656. updated_at *time.Time
  34657. status *uint8
  34658. addstatus *int8
  34659. deleted_at *time.Time
  34660. addtime *uint64
  34661. addaddtime *int64
  34662. _type *int
  34663. add_type *int
  34664. bot_id *string
  34665. organization_id *uint64
  34666. addorganization_id *int64
  34667. ai_response *uint64
  34668. addai_response *int64
  34669. sop_run *uint64
  34670. addsop_run *int64
  34671. total_friend *uint64
  34672. addtotal_friend *int64
  34673. total_group *uint64
  34674. addtotal_group *int64
  34675. account_balance *uint64
  34676. addaccount_balance *int64
  34677. consume_token *uint64
  34678. addconsume_token *int64
  34679. active_user *uint64
  34680. addactive_user *int64
  34681. new_user *int64
  34682. addnew_user *int64
  34683. label_dist *[]custom_types.LabelDist
  34684. appendlabel_dist []custom_types.LabelDist
  34685. consume_coin *float64
  34686. addconsume_coin *float64
  34687. clearedFields map[string]struct{}
  34688. done bool
  34689. oldValue func(context.Context) (*UsageStatisticDay, error)
  34690. predicates []predicate.UsageStatisticDay
  34691. }
  34692. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  34693. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  34694. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  34695. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  34696. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  34697. m := &UsageStatisticDayMutation{
  34698. config: c,
  34699. op: op,
  34700. typ: TypeUsageStatisticDay,
  34701. clearedFields: make(map[string]struct{}),
  34702. }
  34703. for _, opt := range opts {
  34704. opt(m)
  34705. }
  34706. return m
  34707. }
  34708. // withUsageStatisticDayID sets the ID field of the mutation.
  34709. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  34710. return func(m *UsageStatisticDayMutation) {
  34711. var (
  34712. err error
  34713. once sync.Once
  34714. value *UsageStatisticDay
  34715. )
  34716. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  34717. once.Do(func() {
  34718. if m.done {
  34719. err = errors.New("querying old values post mutation is not allowed")
  34720. } else {
  34721. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  34722. }
  34723. })
  34724. return value, err
  34725. }
  34726. m.id = &id
  34727. }
  34728. }
  34729. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  34730. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  34731. return func(m *UsageStatisticDayMutation) {
  34732. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  34733. return node, nil
  34734. }
  34735. m.id = &node.ID
  34736. }
  34737. }
  34738. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34739. // executed in a transaction (ent.Tx), a transactional client is returned.
  34740. func (m UsageStatisticDayMutation) Client() *Client {
  34741. client := &Client{config: m.config}
  34742. client.init()
  34743. return client
  34744. }
  34745. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34746. // it returns an error otherwise.
  34747. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  34748. if _, ok := m.driver.(*txDriver); !ok {
  34749. return nil, errors.New("ent: mutation is not running in a transaction")
  34750. }
  34751. tx := &Tx{config: m.config}
  34752. tx.init()
  34753. return tx, nil
  34754. }
  34755. // SetID sets the value of the id field. Note that this
  34756. // operation is only accepted on creation of UsageStatisticDay entities.
  34757. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  34758. m.id = &id
  34759. }
  34760. // ID returns the ID value in the mutation. Note that the ID is only available
  34761. // if it was provided to the builder or after it was returned from the database.
  34762. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  34763. if m.id == nil {
  34764. return
  34765. }
  34766. return *m.id, true
  34767. }
  34768. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34769. // That means, if the mutation is applied within a transaction with an isolation level such
  34770. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34771. // or updated by the mutation.
  34772. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  34773. switch {
  34774. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34775. id, exists := m.ID()
  34776. if exists {
  34777. return []uint64{id}, nil
  34778. }
  34779. fallthrough
  34780. case m.op.Is(OpUpdate | OpDelete):
  34781. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  34782. default:
  34783. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34784. }
  34785. }
  34786. // SetCreatedAt sets the "created_at" field.
  34787. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  34788. m.created_at = &t
  34789. }
  34790. // CreatedAt returns the value of the "created_at" field in the mutation.
  34791. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  34792. v := m.created_at
  34793. if v == nil {
  34794. return
  34795. }
  34796. return *v, true
  34797. }
  34798. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  34799. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34801. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34802. if !m.op.Is(OpUpdateOne) {
  34803. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34804. }
  34805. if m.id == nil || m.oldValue == nil {
  34806. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34807. }
  34808. oldValue, err := m.oldValue(ctx)
  34809. if err != nil {
  34810. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34811. }
  34812. return oldValue.CreatedAt, nil
  34813. }
  34814. // ResetCreatedAt resets all changes to the "created_at" field.
  34815. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  34816. m.created_at = nil
  34817. }
  34818. // SetUpdatedAt sets the "updated_at" field.
  34819. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  34820. m.updated_at = &t
  34821. }
  34822. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34823. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  34824. v := m.updated_at
  34825. if v == nil {
  34826. return
  34827. }
  34828. return *v, true
  34829. }
  34830. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  34831. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34833. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34834. if !m.op.Is(OpUpdateOne) {
  34835. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34836. }
  34837. if m.id == nil || m.oldValue == nil {
  34838. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34839. }
  34840. oldValue, err := m.oldValue(ctx)
  34841. if err != nil {
  34842. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34843. }
  34844. return oldValue.UpdatedAt, nil
  34845. }
  34846. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34847. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  34848. m.updated_at = nil
  34849. }
  34850. // SetStatus sets the "status" field.
  34851. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  34852. m.status = &u
  34853. m.addstatus = nil
  34854. }
  34855. // Status returns the value of the "status" field in the mutation.
  34856. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  34857. v := m.status
  34858. if v == nil {
  34859. return
  34860. }
  34861. return *v, true
  34862. }
  34863. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  34864. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34866. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34867. if !m.op.Is(OpUpdateOne) {
  34868. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34869. }
  34870. if m.id == nil || m.oldValue == nil {
  34871. return v, errors.New("OldStatus requires an ID field in the mutation")
  34872. }
  34873. oldValue, err := m.oldValue(ctx)
  34874. if err != nil {
  34875. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34876. }
  34877. return oldValue.Status, nil
  34878. }
  34879. // AddStatus adds u to the "status" field.
  34880. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  34881. if m.addstatus != nil {
  34882. *m.addstatus += u
  34883. } else {
  34884. m.addstatus = &u
  34885. }
  34886. }
  34887. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34888. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  34889. v := m.addstatus
  34890. if v == nil {
  34891. return
  34892. }
  34893. return *v, true
  34894. }
  34895. // ClearStatus clears the value of the "status" field.
  34896. func (m *UsageStatisticDayMutation) ClearStatus() {
  34897. m.status = nil
  34898. m.addstatus = nil
  34899. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  34900. }
  34901. // StatusCleared returns if the "status" field was cleared in this mutation.
  34902. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  34903. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  34904. return ok
  34905. }
  34906. // ResetStatus resets all changes to the "status" field.
  34907. func (m *UsageStatisticDayMutation) ResetStatus() {
  34908. m.status = nil
  34909. m.addstatus = nil
  34910. delete(m.clearedFields, usagestatisticday.FieldStatus)
  34911. }
  34912. // SetDeletedAt sets the "deleted_at" field.
  34913. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  34914. m.deleted_at = &t
  34915. }
  34916. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34917. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  34918. v := m.deleted_at
  34919. if v == nil {
  34920. return
  34921. }
  34922. return *v, true
  34923. }
  34924. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  34925. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34927. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34928. if !m.op.Is(OpUpdateOne) {
  34929. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34930. }
  34931. if m.id == nil || m.oldValue == nil {
  34932. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34933. }
  34934. oldValue, err := m.oldValue(ctx)
  34935. if err != nil {
  34936. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34937. }
  34938. return oldValue.DeletedAt, nil
  34939. }
  34940. // ClearDeletedAt clears the value of the "deleted_at" field.
  34941. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  34942. m.deleted_at = nil
  34943. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  34944. }
  34945. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34946. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  34947. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  34948. return ok
  34949. }
  34950. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34951. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  34952. m.deleted_at = nil
  34953. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  34954. }
  34955. // SetAddtime sets the "addtime" field.
  34956. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  34957. m.addtime = &u
  34958. m.addaddtime = nil
  34959. }
  34960. // Addtime returns the value of the "addtime" field in the mutation.
  34961. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  34962. v := m.addtime
  34963. if v == nil {
  34964. return
  34965. }
  34966. return *v, true
  34967. }
  34968. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  34969. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34971. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  34972. if !m.op.Is(OpUpdateOne) {
  34973. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  34974. }
  34975. if m.id == nil || m.oldValue == nil {
  34976. return v, errors.New("OldAddtime requires an ID field in the mutation")
  34977. }
  34978. oldValue, err := m.oldValue(ctx)
  34979. if err != nil {
  34980. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  34981. }
  34982. return oldValue.Addtime, nil
  34983. }
  34984. // AddAddtime adds u to the "addtime" field.
  34985. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  34986. if m.addaddtime != nil {
  34987. *m.addaddtime += u
  34988. } else {
  34989. m.addaddtime = &u
  34990. }
  34991. }
  34992. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  34993. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  34994. v := m.addaddtime
  34995. if v == nil {
  34996. return
  34997. }
  34998. return *v, true
  34999. }
  35000. // ResetAddtime resets all changes to the "addtime" field.
  35001. func (m *UsageStatisticDayMutation) ResetAddtime() {
  35002. m.addtime = nil
  35003. m.addaddtime = nil
  35004. }
  35005. // SetType sets the "type" field.
  35006. func (m *UsageStatisticDayMutation) SetType(i int) {
  35007. m._type = &i
  35008. m.add_type = nil
  35009. }
  35010. // GetType returns the value of the "type" field in the mutation.
  35011. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  35012. v := m._type
  35013. if v == nil {
  35014. return
  35015. }
  35016. return *v, true
  35017. }
  35018. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  35019. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35021. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  35022. if !m.op.Is(OpUpdateOne) {
  35023. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35024. }
  35025. if m.id == nil || m.oldValue == nil {
  35026. return v, errors.New("OldType requires an ID field in the mutation")
  35027. }
  35028. oldValue, err := m.oldValue(ctx)
  35029. if err != nil {
  35030. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35031. }
  35032. return oldValue.Type, nil
  35033. }
  35034. // AddType adds i to the "type" field.
  35035. func (m *UsageStatisticDayMutation) AddType(i int) {
  35036. if m.add_type != nil {
  35037. *m.add_type += i
  35038. } else {
  35039. m.add_type = &i
  35040. }
  35041. }
  35042. // AddedType returns the value that was added to the "type" field in this mutation.
  35043. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  35044. v := m.add_type
  35045. if v == nil {
  35046. return
  35047. }
  35048. return *v, true
  35049. }
  35050. // ResetType resets all changes to the "type" field.
  35051. func (m *UsageStatisticDayMutation) ResetType() {
  35052. m._type = nil
  35053. m.add_type = nil
  35054. }
  35055. // SetBotID sets the "bot_id" field.
  35056. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  35057. m.bot_id = &s
  35058. }
  35059. // BotID returns the value of the "bot_id" field in the mutation.
  35060. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  35061. v := m.bot_id
  35062. if v == nil {
  35063. return
  35064. }
  35065. return *v, true
  35066. }
  35067. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  35068. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35070. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  35071. if !m.op.Is(OpUpdateOne) {
  35072. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35073. }
  35074. if m.id == nil || m.oldValue == nil {
  35075. return v, errors.New("OldBotID requires an ID field in the mutation")
  35076. }
  35077. oldValue, err := m.oldValue(ctx)
  35078. if err != nil {
  35079. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35080. }
  35081. return oldValue.BotID, nil
  35082. }
  35083. // ClearBotID clears the value of the "bot_id" field.
  35084. func (m *UsageStatisticDayMutation) ClearBotID() {
  35085. m.bot_id = nil
  35086. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  35087. }
  35088. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  35089. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  35090. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  35091. return ok
  35092. }
  35093. // ResetBotID resets all changes to the "bot_id" field.
  35094. func (m *UsageStatisticDayMutation) ResetBotID() {
  35095. m.bot_id = nil
  35096. delete(m.clearedFields, usagestatisticday.FieldBotID)
  35097. }
  35098. // SetOrganizationID sets the "organization_id" field.
  35099. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  35100. m.organization_id = &u
  35101. m.addorganization_id = nil
  35102. }
  35103. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35104. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  35105. v := m.organization_id
  35106. if v == nil {
  35107. return
  35108. }
  35109. return *v, true
  35110. }
  35111. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  35112. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35114. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35115. if !m.op.Is(OpUpdateOne) {
  35116. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35117. }
  35118. if m.id == nil || m.oldValue == nil {
  35119. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35120. }
  35121. oldValue, err := m.oldValue(ctx)
  35122. if err != nil {
  35123. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35124. }
  35125. return oldValue.OrganizationID, nil
  35126. }
  35127. // AddOrganizationID adds u to the "organization_id" field.
  35128. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  35129. if m.addorganization_id != nil {
  35130. *m.addorganization_id += u
  35131. } else {
  35132. m.addorganization_id = &u
  35133. }
  35134. }
  35135. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35136. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  35137. v := m.addorganization_id
  35138. if v == nil {
  35139. return
  35140. }
  35141. return *v, true
  35142. }
  35143. // ClearOrganizationID clears the value of the "organization_id" field.
  35144. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  35145. m.organization_id = nil
  35146. m.addorganization_id = nil
  35147. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  35148. }
  35149. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35150. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  35151. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  35152. return ok
  35153. }
  35154. // ResetOrganizationID resets all changes to the "organization_id" field.
  35155. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  35156. m.organization_id = nil
  35157. m.addorganization_id = nil
  35158. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  35159. }
  35160. // SetAiResponse sets the "ai_response" field.
  35161. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  35162. m.ai_response = &u
  35163. m.addai_response = nil
  35164. }
  35165. // AiResponse returns the value of the "ai_response" field in the mutation.
  35166. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  35167. v := m.ai_response
  35168. if v == nil {
  35169. return
  35170. }
  35171. return *v, true
  35172. }
  35173. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  35174. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35176. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  35177. if !m.op.Is(OpUpdateOne) {
  35178. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  35179. }
  35180. if m.id == nil || m.oldValue == nil {
  35181. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  35182. }
  35183. oldValue, err := m.oldValue(ctx)
  35184. if err != nil {
  35185. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  35186. }
  35187. return oldValue.AiResponse, nil
  35188. }
  35189. // AddAiResponse adds u to the "ai_response" field.
  35190. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  35191. if m.addai_response != nil {
  35192. *m.addai_response += u
  35193. } else {
  35194. m.addai_response = &u
  35195. }
  35196. }
  35197. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  35198. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  35199. v := m.addai_response
  35200. if v == nil {
  35201. return
  35202. }
  35203. return *v, true
  35204. }
  35205. // ResetAiResponse resets all changes to the "ai_response" field.
  35206. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  35207. m.ai_response = nil
  35208. m.addai_response = nil
  35209. }
  35210. // SetSopRun sets the "sop_run" field.
  35211. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  35212. m.sop_run = &u
  35213. m.addsop_run = nil
  35214. }
  35215. // SopRun returns the value of the "sop_run" field in the mutation.
  35216. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  35217. v := m.sop_run
  35218. if v == nil {
  35219. return
  35220. }
  35221. return *v, true
  35222. }
  35223. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  35224. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35226. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  35227. if !m.op.Is(OpUpdateOne) {
  35228. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  35229. }
  35230. if m.id == nil || m.oldValue == nil {
  35231. return v, errors.New("OldSopRun requires an ID field in the mutation")
  35232. }
  35233. oldValue, err := m.oldValue(ctx)
  35234. if err != nil {
  35235. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  35236. }
  35237. return oldValue.SopRun, nil
  35238. }
  35239. // AddSopRun adds u to the "sop_run" field.
  35240. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  35241. if m.addsop_run != nil {
  35242. *m.addsop_run += u
  35243. } else {
  35244. m.addsop_run = &u
  35245. }
  35246. }
  35247. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  35248. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  35249. v := m.addsop_run
  35250. if v == nil {
  35251. return
  35252. }
  35253. return *v, true
  35254. }
  35255. // ResetSopRun resets all changes to the "sop_run" field.
  35256. func (m *UsageStatisticDayMutation) ResetSopRun() {
  35257. m.sop_run = nil
  35258. m.addsop_run = nil
  35259. }
  35260. // SetTotalFriend sets the "total_friend" field.
  35261. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  35262. m.total_friend = &u
  35263. m.addtotal_friend = nil
  35264. }
  35265. // TotalFriend returns the value of the "total_friend" field in the mutation.
  35266. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  35267. v := m.total_friend
  35268. if v == nil {
  35269. return
  35270. }
  35271. return *v, true
  35272. }
  35273. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  35274. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35276. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  35277. if !m.op.Is(OpUpdateOne) {
  35278. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  35279. }
  35280. if m.id == nil || m.oldValue == nil {
  35281. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  35282. }
  35283. oldValue, err := m.oldValue(ctx)
  35284. if err != nil {
  35285. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  35286. }
  35287. return oldValue.TotalFriend, nil
  35288. }
  35289. // AddTotalFriend adds u to the "total_friend" field.
  35290. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  35291. if m.addtotal_friend != nil {
  35292. *m.addtotal_friend += u
  35293. } else {
  35294. m.addtotal_friend = &u
  35295. }
  35296. }
  35297. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  35298. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  35299. v := m.addtotal_friend
  35300. if v == nil {
  35301. return
  35302. }
  35303. return *v, true
  35304. }
  35305. // ResetTotalFriend resets all changes to the "total_friend" field.
  35306. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  35307. m.total_friend = nil
  35308. m.addtotal_friend = nil
  35309. }
  35310. // SetTotalGroup sets the "total_group" field.
  35311. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  35312. m.total_group = &u
  35313. m.addtotal_group = nil
  35314. }
  35315. // TotalGroup returns the value of the "total_group" field in the mutation.
  35316. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  35317. v := m.total_group
  35318. if v == nil {
  35319. return
  35320. }
  35321. return *v, true
  35322. }
  35323. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  35324. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35326. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  35327. if !m.op.Is(OpUpdateOne) {
  35328. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  35329. }
  35330. if m.id == nil || m.oldValue == nil {
  35331. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  35332. }
  35333. oldValue, err := m.oldValue(ctx)
  35334. if err != nil {
  35335. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  35336. }
  35337. return oldValue.TotalGroup, nil
  35338. }
  35339. // AddTotalGroup adds u to the "total_group" field.
  35340. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  35341. if m.addtotal_group != nil {
  35342. *m.addtotal_group += u
  35343. } else {
  35344. m.addtotal_group = &u
  35345. }
  35346. }
  35347. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  35348. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  35349. v := m.addtotal_group
  35350. if v == nil {
  35351. return
  35352. }
  35353. return *v, true
  35354. }
  35355. // ResetTotalGroup resets all changes to the "total_group" field.
  35356. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  35357. m.total_group = nil
  35358. m.addtotal_group = nil
  35359. }
  35360. // SetAccountBalance sets the "account_balance" field.
  35361. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  35362. m.account_balance = &u
  35363. m.addaccount_balance = nil
  35364. }
  35365. // AccountBalance returns the value of the "account_balance" field in the mutation.
  35366. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  35367. v := m.account_balance
  35368. if v == nil {
  35369. return
  35370. }
  35371. return *v, true
  35372. }
  35373. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  35374. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35376. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  35377. if !m.op.Is(OpUpdateOne) {
  35378. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  35379. }
  35380. if m.id == nil || m.oldValue == nil {
  35381. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  35382. }
  35383. oldValue, err := m.oldValue(ctx)
  35384. if err != nil {
  35385. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  35386. }
  35387. return oldValue.AccountBalance, nil
  35388. }
  35389. // AddAccountBalance adds u to the "account_balance" field.
  35390. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  35391. if m.addaccount_balance != nil {
  35392. *m.addaccount_balance += u
  35393. } else {
  35394. m.addaccount_balance = &u
  35395. }
  35396. }
  35397. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  35398. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  35399. v := m.addaccount_balance
  35400. if v == nil {
  35401. return
  35402. }
  35403. return *v, true
  35404. }
  35405. // ResetAccountBalance resets all changes to the "account_balance" field.
  35406. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  35407. m.account_balance = nil
  35408. m.addaccount_balance = nil
  35409. }
  35410. // SetConsumeToken sets the "consume_token" field.
  35411. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  35412. m.consume_token = &u
  35413. m.addconsume_token = nil
  35414. }
  35415. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  35416. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  35417. v := m.consume_token
  35418. if v == nil {
  35419. return
  35420. }
  35421. return *v, true
  35422. }
  35423. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  35424. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35426. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  35427. if !m.op.Is(OpUpdateOne) {
  35428. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  35429. }
  35430. if m.id == nil || m.oldValue == nil {
  35431. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  35432. }
  35433. oldValue, err := m.oldValue(ctx)
  35434. if err != nil {
  35435. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  35436. }
  35437. return oldValue.ConsumeToken, nil
  35438. }
  35439. // AddConsumeToken adds u to the "consume_token" field.
  35440. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  35441. if m.addconsume_token != nil {
  35442. *m.addconsume_token += u
  35443. } else {
  35444. m.addconsume_token = &u
  35445. }
  35446. }
  35447. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  35448. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  35449. v := m.addconsume_token
  35450. if v == nil {
  35451. return
  35452. }
  35453. return *v, true
  35454. }
  35455. // ResetConsumeToken resets all changes to the "consume_token" field.
  35456. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  35457. m.consume_token = nil
  35458. m.addconsume_token = nil
  35459. }
  35460. // SetActiveUser sets the "active_user" field.
  35461. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  35462. m.active_user = &u
  35463. m.addactive_user = nil
  35464. }
  35465. // ActiveUser returns the value of the "active_user" field in the mutation.
  35466. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  35467. v := m.active_user
  35468. if v == nil {
  35469. return
  35470. }
  35471. return *v, true
  35472. }
  35473. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  35474. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35476. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  35477. if !m.op.Is(OpUpdateOne) {
  35478. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  35479. }
  35480. if m.id == nil || m.oldValue == nil {
  35481. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  35482. }
  35483. oldValue, err := m.oldValue(ctx)
  35484. if err != nil {
  35485. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  35486. }
  35487. return oldValue.ActiveUser, nil
  35488. }
  35489. // AddActiveUser adds u to the "active_user" field.
  35490. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  35491. if m.addactive_user != nil {
  35492. *m.addactive_user += u
  35493. } else {
  35494. m.addactive_user = &u
  35495. }
  35496. }
  35497. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  35498. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  35499. v := m.addactive_user
  35500. if v == nil {
  35501. return
  35502. }
  35503. return *v, true
  35504. }
  35505. // ResetActiveUser resets all changes to the "active_user" field.
  35506. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  35507. m.active_user = nil
  35508. m.addactive_user = nil
  35509. }
  35510. // SetNewUser sets the "new_user" field.
  35511. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  35512. m.new_user = &i
  35513. m.addnew_user = nil
  35514. }
  35515. // NewUser returns the value of the "new_user" field in the mutation.
  35516. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  35517. v := m.new_user
  35518. if v == nil {
  35519. return
  35520. }
  35521. return *v, true
  35522. }
  35523. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  35524. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35526. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  35527. if !m.op.Is(OpUpdateOne) {
  35528. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  35529. }
  35530. if m.id == nil || m.oldValue == nil {
  35531. return v, errors.New("OldNewUser requires an ID field in the mutation")
  35532. }
  35533. oldValue, err := m.oldValue(ctx)
  35534. if err != nil {
  35535. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  35536. }
  35537. return oldValue.NewUser, nil
  35538. }
  35539. // AddNewUser adds i to the "new_user" field.
  35540. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  35541. if m.addnew_user != nil {
  35542. *m.addnew_user += i
  35543. } else {
  35544. m.addnew_user = &i
  35545. }
  35546. }
  35547. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  35548. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  35549. v := m.addnew_user
  35550. if v == nil {
  35551. return
  35552. }
  35553. return *v, true
  35554. }
  35555. // ResetNewUser resets all changes to the "new_user" field.
  35556. func (m *UsageStatisticDayMutation) ResetNewUser() {
  35557. m.new_user = nil
  35558. m.addnew_user = nil
  35559. }
  35560. // SetLabelDist sets the "label_dist" field.
  35561. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  35562. m.label_dist = &ctd
  35563. m.appendlabel_dist = nil
  35564. }
  35565. // LabelDist returns the value of the "label_dist" field in the mutation.
  35566. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  35567. v := m.label_dist
  35568. if v == nil {
  35569. return
  35570. }
  35571. return *v, true
  35572. }
  35573. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  35574. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35576. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  35577. if !m.op.Is(OpUpdateOne) {
  35578. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  35579. }
  35580. if m.id == nil || m.oldValue == nil {
  35581. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  35582. }
  35583. oldValue, err := m.oldValue(ctx)
  35584. if err != nil {
  35585. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  35586. }
  35587. return oldValue.LabelDist, nil
  35588. }
  35589. // AppendLabelDist adds ctd to the "label_dist" field.
  35590. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  35591. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  35592. }
  35593. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  35594. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  35595. if len(m.appendlabel_dist) == 0 {
  35596. return nil, false
  35597. }
  35598. return m.appendlabel_dist, true
  35599. }
  35600. // ResetLabelDist resets all changes to the "label_dist" field.
  35601. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  35602. m.label_dist = nil
  35603. m.appendlabel_dist = nil
  35604. }
  35605. // SetConsumeCoin sets the "consume_coin" field.
  35606. func (m *UsageStatisticDayMutation) SetConsumeCoin(f float64) {
  35607. m.consume_coin = &f
  35608. m.addconsume_coin = nil
  35609. }
  35610. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  35611. func (m *UsageStatisticDayMutation) ConsumeCoin() (r float64, exists bool) {
  35612. v := m.consume_coin
  35613. if v == nil {
  35614. return
  35615. }
  35616. return *v, true
  35617. }
  35618. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticDay entity.
  35619. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35621. func (m *UsageStatisticDayMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  35622. if !m.op.Is(OpUpdateOne) {
  35623. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  35624. }
  35625. if m.id == nil || m.oldValue == nil {
  35626. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  35627. }
  35628. oldValue, err := m.oldValue(ctx)
  35629. if err != nil {
  35630. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  35631. }
  35632. return oldValue.ConsumeCoin, nil
  35633. }
  35634. // AddConsumeCoin adds f to the "consume_coin" field.
  35635. func (m *UsageStatisticDayMutation) AddConsumeCoin(f float64) {
  35636. if m.addconsume_coin != nil {
  35637. *m.addconsume_coin += f
  35638. } else {
  35639. m.addconsume_coin = &f
  35640. }
  35641. }
  35642. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  35643. func (m *UsageStatisticDayMutation) AddedConsumeCoin() (r float64, exists bool) {
  35644. v := m.addconsume_coin
  35645. if v == nil {
  35646. return
  35647. }
  35648. return *v, true
  35649. }
  35650. // ClearConsumeCoin clears the value of the "consume_coin" field.
  35651. func (m *UsageStatisticDayMutation) ClearConsumeCoin() {
  35652. m.consume_coin = nil
  35653. m.addconsume_coin = nil
  35654. m.clearedFields[usagestatisticday.FieldConsumeCoin] = struct{}{}
  35655. }
  35656. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  35657. func (m *UsageStatisticDayMutation) ConsumeCoinCleared() bool {
  35658. _, ok := m.clearedFields[usagestatisticday.FieldConsumeCoin]
  35659. return ok
  35660. }
  35661. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  35662. func (m *UsageStatisticDayMutation) ResetConsumeCoin() {
  35663. m.consume_coin = nil
  35664. m.addconsume_coin = nil
  35665. delete(m.clearedFields, usagestatisticday.FieldConsumeCoin)
  35666. }
  35667. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  35668. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  35669. m.predicates = append(m.predicates, ps...)
  35670. }
  35671. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  35672. // users can use type-assertion to append predicates that do not depend on any generated package.
  35673. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  35674. p := make([]predicate.UsageStatisticDay, len(ps))
  35675. for i := range ps {
  35676. p[i] = ps[i]
  35677. }
  35678. m.Where(p...)
  35679. }
  35680. // Op returns the operation name.
  35681. func (m *UsageStatisticDayMutation) Op() Op {
  35682. return m.op
  35683. }
  35684. // SetOp allows setting the mutation operation.
  35685. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  35686. m.op = op
  35687. }
  35688. // Type returns the node type of this mutation (UsageStatisticDay).
  35689. func (m *UsageStatisticDayMutation) Type() string {
  35690. return m.typ
  35691. }
  35692. // Fields returns all fields that were changed during this mutation. Note that in
  35693. // order to get all numeric fields that were incremented/decremented, call
  35694. // AddedFields().
  35695. func (m *UsageStatisticDayMutation) Fields() []string {
  35696. fields := make([]string, 0, 18)
  35697. if m.created_at != nil {
  35698. fields = append(fields, usagestatisticday.FieldCreatedAt)
  35699. }
  35700. if m.updated_at != nil {
  35701. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  35702. }
  35703. if m.status != nil {
  35704. fields = append(fields, usagestatisticday.FieldStatus)
  35705. }
  35706. if m.deleted_at != nil {
  35707. fields = append(fields, usagestatisticday.FieldDeletedAt)
  35708. }
  35709. if m.addtime != nil {
  35710. fields = append(fields, usagestatisticday.FieldAddtime)
  35711. }
  35712. if m._type != nil {
  35713. fields = append(fields, usagestatisticday.FieldType)
  35714. }
  35715. if m.bot_id != nil {
  35716. fields = append(fields, usagestatisticday.FieldBotID)
  35717. }
  35718. if m.organization_id != nil {
  35719. fields = append(fields, usagestatisticday.FieldOrganizationID)
  35720. }
  35721. if m.ai_response != nil {
  35722. fields = append(fields, usagestatisticday.FieldAiResponse)
  35723. }
  35724. if m.sop_run != nil {
  35725. fields = append(fields, usagestatisticday.FieldSopRun)
  35726. }
  35727. if m.total_friend != nil {
  35728. fields = append(fields, usagestatisticday.FieldTotalFriend)
  35729. }
  35730. if m.total_group != nil {
  35731. fields = append(fields, usagestatisticday.FieldTotalGroup)
  35732. }
  35733. if m.account_balance != nil {
  35734. fields = append(fields, usagestatisticday.FieldAccountBalance)
  35735. }
  35736. if m.consume_token != nil {
  35737. fields = append(fields, usagestatisticday.FieldConsumeToken)
  35738. }
  35739. if m.active_user != nil {
  35740. fields = append(fields, usagestatisticday.FieldActiveUser)
  35741. }
  35742. if m.new_user != nil {
  35743. fields = append(fields, usagestatisticday.FieldNewUser)
  35744. }
  35745. if m.label_dist != nil {
  35746. fields = append(fields, usagestatisticday.FieldLabelDist)
  35747. }
  35748. if m.consume_coin != nil {
  35749. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  35750. }
  35751. return fields
  35752. }
  35753. // Field returns the value of a field with the given name. The second boolean
  35754. // return value indicates that this field was not set, or was not defined in the
  35755. // schema.
  35756. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  35757. switch name {
  35758. case usagestatisticday.FieldCreatedAt:
  35759. return m.CreatedAt()
  35760. case usagestatisticday.FieldUpdatedAt:
  35761. return m.UpdatedAt()
  35762. case usagestatisticday.FieldStatus:
  35763. return m.Status()
  35764. case usagestatisticday.FieldDeletedAt:
  35765. return m.DeletedAt()
  35766. case usagestatisticday.FieldAddtime:
  35767. return m.Addtime()
  35768. case usagestatisticday.FieldType:
  35769. return m.GetType()
  35770. case usagestatisticday.FieldBotID:
  35771. return m.BotID()
  35772. case usagestatisticday.FieldOrganizationID:
  35773. return m.OrganizationID()
  35774. case usagestatisticday.FieldAiResponse:
  35775. return m.AiResponse()
  35776. case usagestatisticday.FieldSopRun:
  35777. return m.SopRun()
  35778. case usagestatisticday.FieldTotalFriend:
  35779. return m.TotalFriend()
  35780. case usagestatisticday.FieldTotalGroup:
  35781. return m.TotalGroup()
  35782. case usagestatisticday.FieldAccountBalance:
  35783. return m.AccountBalance()
  35784. case usagestatisticday.FieldConsumeToken:
  35785. return m.ConsumeToken()
  35786. case usagestatisticday.FieldActiveUser:
  35787. return m.ActiveUser()
  35788. case usagestatisticday.FieldNewUser:
  35789. return m.NewUser()
  35790. case usagestatisticday.FieldLabelDist:
  35791. return m.LabelDist()
  35792. case usagestatisticday.FieldConsumeCoin:
  35793. return m.ConsumeCoin()
  35794. }
  35795. return nil, false
  35796. }
  35797. // OldField returns the old value of the field from the database. An error is
  35798. // returned if the mutation operation is not UpdateOne, or the query to the
  35799. // database failed.
  35800. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35801. switch name {
  35802. case usagestatisticday.FieldCreatedAt:
  35803. return m.OldCreatedAt(ctx)
  35804. case usagestatisticday.FieldUpdatedAt:
  35805. return m.OldUpdatedAt(ctx)
  35806. case usagestatisticday.FieldStatus:
  35807. return m.OldStatus(ctx)
  35808. case usagestatisticday.FieldDeletedAt:
  35809. return m.OldDeletedAt(ctx)
  35810. case usagestatisticday.FieldAddtime:
  35811. return m.OldAddtime(ctx)
  35812. case usagestatisticday.FieldType:
  35813. return m.OldType(ctx)
  35814. case usagestatisticday.FieldBotID:
  35815. return m.OldBotID(ctx)
  35816. case usagestatisticday.FieldOrganizationID:
  35817. return m.OldOrganizationID(ctx)
  35818. case usagestatisticday.FieldAiResponse:
  35819. return m.OldAiResponse(ctx)
  35820. case usagestatisticday.FieldSopRun:
  35821. return m.OldSopRun(ctx)
  35822. case usagestatisticday.FieldTotalFriend:
  35823. return m.OldTotalFriend(ctx)
  35824. case usagestatisticday.FieldTotalGroup:
  35825. return m.OldTotalGroup(ctx)
  35826. case usagestatisticday.FieldAccountBalance:
  35827. return m.OldAccountBalance(ctx)
  35828. case usagestatisticday.FieldConsumeToken:
  35829. return m.OldConsumeToken(ctx)
  35830. case usagestatisticday.FieldActiveUser:
  35831. return m.OldActiveUser(ctx)
  35832. case usagestatisticday.FieldNewUser:
  35833. return m.OldNewUser(ctx)
  35834. case usagestatisticday.FieldLabelDist:
  35835. return m.OldLabelDist(ctx)
  35836. case usagestatisticday.FieldConsumeCoin:
  35837. return m.OldConsumeCoin(ctx)
  35838. }
  35839. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  35840. }
  35841. // SetField sets the value of a field with the given name. It returns an error if
  35842. // the field is not defined in the schema, or if the type mismatched the field
  35843. // type.
  35844. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  35845. switch name {
  35846. case usagestatisticday.FieldCreatedAt:
  35847. v, ok := value.(time.Time)
  35848. if !ok {
  35849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35850. }
  35851. m.SetCreatedAt(v)
  35852. return nil
  35853. case usagestatisticday.FieldUpdatedAt:
  35854. v, ok := value.(time.Time)
  35855. if !ok {
  35856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35857. }
  35858. m.SetUpdatedAt(v)
  35859. return nil
  35860. case usagestatisticday.FieldStatus:
  35861. v, ok := value.(uint8)
  35862. if !ok {
  35863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35864. }
  35865. m.SetStatus(v)
  35866. return nil
  35867. case usagestatisticday.FieldDeletedAt:
  35868. v, ok := value.(time.Time)
  35869. if !ok {
  35870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35871. }
  35872. m.SetDeletedAt(v)
  35873. return nil
  35874. case usagestatisticday.FieldAddtime:
  35875. v, ok := value.(uint64)
  35876. if !ok {
  35877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35878. }
  35879. m.SetAddtime(v)
  35880. return nil
  35881. case usagestatisticday.FieldType:
  35882. v, ok := value.(int)
  35883. if !ok {
  35884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35885. }
  35886. m.SetType(v)
  35887. return nil
  35888. case usagestatisticday.FieldBotID:
  35889. v, ok := value.(string)
  35890. if !ok {
  35891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35892. }
  35893. m.SetBotID(v)
  35894. return nil
  35895. case usagestatisticday.FieldOrganizationID:
  35896. v, ok := value.(uint64)
  35897. if !ok {
  35898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35899. }
  35900. m.SetOrganizationID(v)
  35901. return nil
  35902. case usagestatisticday.FieldAiResponse:
  35903. v, ok := value.(uint64)
  35904. if !ok {
  35905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35906. }
  35907. m.SetAiResponse(v)
  35908. return nil
  35909. case usagestatisticday.FieldSopRun:
  35910. v, ok := value.(uint64)
  35911. if !ok {
  35912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35913. }
  35914. m.SetSopRun(v)
  35915. return nil
  35916. case usagestatisticday.FieldTotalFriend:
  35917. v, ok := value.(uint64)
  35918. if !ok {
  35919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35920. }
  35921. m.SetTotalFriend(v)
  35922. return nil
  35923. case usagestatisticday.FieldTotalGroup:
  35924. v, ok := value.(uint64)
  35925. if !ok {
  35926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35927. }
  35928. m.SetTotalGroup(v)
  35929. return nil
  35930. case usagestatisticday.FieldAccountBalance:
  35931. v, ok := value.(uint64)
  35932. if !ok {
  35933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35934. }
  35935. m.SetAccountBalance(v)
  35936. return nil
  35937. case usagestatisticday.FieldConsumeToken:
  35938. v, ok := value.(uint64)
  35939. if !ok {
  35940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35941. }
  35942. m.SetConsumeToken(v)
  35943. return nil
  35944. case usagestatisticday.FieldActiveUser:
  35945. v, ok := value.(uint64)
  35946. if !ok {
  35947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35948. }
  35949. m.SetActiveUser(v)
  35950. return nil
  35951. case usagestatisticday.FieldNewUser:
  35952. v, ok := value.(int64)
  35953. if !ok {
  35954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35955. }
  35956. m.SetNewUser(v)
  35957. return nil
  35958. case usagestatisticday.FieldLabelDist:
  35959. v, ok := value.([]custom_types.LabelDist)
  35960. if !ok {
  35961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35962. }
  35963. m.SetLabelDist(v)
  35964. return nil
  35965. case usagestatisticday.FieldConsumeCoin:
  35966. v, ok := value.(float64)
  35967. if !ok {
  35968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35969. }
  35970. m.SetConsumeCoin(v)
  35971. return nil
  35972. }
  35973. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  35974. }
  35975. // AddedFields returns all numeric fields that were incremented/decremented during
  35976. // this mutation.
  35977. func (m *UsageStatisticDayMutation) AddedFields() []string {
  35978. var fields []string
  35979. if m.addstatus != nil {
  35980. fields = append(fields, usagestatisticday.FieldStatus)
  35981. }
  35982. if m.addaddtime != nil {
  35983. fields = append(fields, usagestatisticday.FieldAddtime)
  35984. }
  35985. if m.add_type != nil {
  35986. fields = append(fields, usagestatisticday.FieldType)
  35987. }
  35988. if m.addorganization_id != nil {
  35989. fields = append(fields, usagestatisticday.FieldOrganizationID)
  35990. }
  35991. if m.addai_response != nil {
  35992. fields = append(fields, usagestatisticday.FieldAiResponse)
  35993. }
  35994. if m.addsop_run != nil {
  35995. fields = append(fields, usagestatisticday.FieldSopRun)
  35996. }
  35997. if m.addtotal_friend != nil {
  35998. fields = append(fields, usagestatisticday.FieldTotalFriend)
  35999. }
  36000. if m.addtotal_group != nil {
  36001. fields = append(fields, usagestatisticday.FieldTotalGroup)
  36002. }
  36003. if m.addaccount_balance != nil {
  36004. fields = append(fields, usagestatisticday.FieldAccountBalance)
  36005. }
  36006. if m.addconsume_token != nil {
  36007. fields = append(fields, usagestatisticday.FieldConsumeToken)
  36008. }
  36009. if m.addactive_user != nil {
  36010. fields = append(fields, usagestatisticday.FieldActiveUser)
  36011. }
  36012. if m.addnew_user != nil {
  36013. fields = append(fields, usagestatisticday.FieldNewUser)
  36014. }
  36015. if m.addconsume_coin != nil {
  36016. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  36017. }
  36018. return fields
  36019. }
  36020. // AddedField returns the numeric value that was incremented/decremented on a field
  36021. // with the given name. The second boolean return value indicates that this field
  36022. // was not set, or was not defined in the schema.
  36023. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  36024. switch name {
  36025. case usagestatisticday.FieldStatus:
  36026. return m.AddedStatus()
  36027. case usagestatisticday.FieldAddtime:
  36028. return m.AddedAddtime()
  36029. case usagestatisticday.FieldType:
  36030. return m.AddedType()
  36031. case usagestatisticday.FieldOrganizationID:
  36032. return m.AddedOrganizationID()
  36033. case usagestatisticday.FieldAiResponse:
  36034. return m.AddedAiResponse()
  36035. case usagestatisticday.FieldSopRun:
  36036. return m.AddedSopRun()
  36037. case usagestatisticday.FieldTotalFriend:
  36038. return m.AddedTotalFriend()
  36039. case usagestatisticday.FieldTotalGroup:
  36040. return m.AddedTotalGroup()
  36041. case usagestatisticday.FieldAccountBalance:
  36042. return m.AddedAccountBalance()
  36043. case usagestatisticday.FieldConsumeToken:
  36044. return m.AddedConsumeToken()
  36045. case usagestatisticday.FieldActiveUser:
  36046. return m.AddedActiveUser()
  36047. case usagestatisticday.FieldNewUser:
  36048. return m.AddedNewUser()
  36049. case usagestatisticday.FieldConsumeCoin:
  36050. return m.AddedConsumeCoin()
  36051. }
  36052. return nil, false
  36053. }
  36054. // AddField adds the value to the field with the given name. It returns an error if
  36055. // the field is not defined in the schema, or if the type mismatched the field
  36056. // type.
  36057. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  36058. switch name {
  36059. case usagestatisticday.FieldStatus:
  36060. v, ok := value.(int8)
  36061. if !ok {
  36062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36063. }
  36064. m.AddStatus(v)
  36065. return nil
  36066. case usagestatisticday.FieldAddtime:
  36067. v, ok := value.(int64)
  36068. if !ok {
  36069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36070. }
  36071. m.AddAddtime(v)
  36072. return nil
  36073. case usagestatisticday.FieldType:
  36074. v, ok := value.(int)
  36075. if !ok {
  36076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36077. }
  36078. m.AddType(v)
  36079. return nil
  36080. case usagestatisticday.FieldOrganizationID:
  36081. v, ok := value.(int64)
  36082. if !ok {
  36083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36084. }
  36085. m.AddOrganizationID(v)
  36086. return nil
  36087. case usagestatisticday.FieldAiResponse:
  36088. v, ok := value.(int64)
  36089. if !ok {
  36090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36091. }
  36092. m.AddAiResponse(v)
  36093. return nil
  36094. case usagestatisticday.FieldSopRun:
  36095. v, ok := value.(int64)
  36096. if !ok {
  36097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36098. }
  36099. m.AddSopRun(v)
  36100. return nil
  36101. case usagestatisticday.FieldTotalFriend:
  36102. v, ok := value.(int64)
  36103. if !ok {
  36104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36105. }
  36106. m.AddTotalFriend(v)
  36107. return nil
  36108. case usagestatisticday.FieldTotalGroup:
  36109. v, ok := value.(int64)
  36110. if !ok {
  36111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36112. }
  36113. m.AddTotalGroup(v)
  36114. return nil
  36115. case usagestatisticday.FieldAccountBalance:
  36116. v, ok := value.(int64)
  36117. if !ok {
  36118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36119. }
  36120. m.AddAccountBalance(v)
  36121. return nil
  36122. case usagestatisticday.FieldConsumeToken:
  36123. v, ok := value.(int64)
  36124. if !ok {
  36125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36126. }
  36127. m.AddConsumeToken(v)
  36128. return nil
  36129. case usagestatisticday.FieldActiveUser:
  36130. v, ok := value.(int64)
  36131. if !ok {
  36132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36133. }
  36134. m.AddActiveUser(v)
  36135. return nil
  36136. case usagestatisticday.FieldNewUser:
  36137. v, ok := value.(int64)
  36138. if !ok {
  36139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36140. }
  36141. m.AddNewUser(v)
  36142. return nil
  36143. case usagestatisticday.FieldConsumeCoin:
  36144. v, ok := value.(float64)
  36145. if !ok {
  36146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36147. }
  36148. m.AddConsumeCoin(v)
  36149. return nil
  36150. }
  36151. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  36152. }
  36153. // ClearedFields returns all nullable fields that were cleared during this
  36154. // mutation.
  36155. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  36156. var fields []string
  36157. if m.FieldCleared(usagestatisticday.FieldStatus) {
  36158. fields = append(fields, usagestatisticday.FieldStatus)
  36159. }
  36160. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  36161. fields = append(fields, usagestatisticday.FieldDeletedAt)
  36162. }
  36163. if m.FieldCleared(usagestatisticday.FieldBotID) {
  36164. fields = append(fields, usagestatisticday.FieldBotID)
  36165. }
  36166. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  36167. fields = append(fields, usagestatisticday.FieldOrganizationID)
  36168. }
  36169. if m.FieldCleared(usagestatisticday.FieldConsumeCoin) {
  36170. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  36171. }
  36172. return fields
  36173. }
  36174. // FieldCleared returns a boolean indicating if a field with the given name was
  36175. // cleared in this mutation.
  36176. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  36177. _, ok := m.clearedFields[name]
  36178. return ok
  36179. }
  36180. // ClearField clears the value of the field with the given name. It returns an
  36181. // error if the field is not defined in the schema.
  36182. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  36183. switch name {
  36184. case usagestatisticday.FieldStatus:
  36185. m.ClearStatus()
  36186. return nil
  36187. case usagestatisticday.FieldDeletedAt:
  36188. m.ClearDeletedAt()
  36189. return nil
  36190. case usagestatisticday.FieldBotID:
  36191. m.ClearBotID()
  36192. return nil
  36193. case usagestatisticday.FieldOrganizationID:
  36194. m.ClearOrganizationID()
  36195. return nil
  36196. case usagestatisticday.FieldConsumeCoin:
  36197. m.ClearConsumeCoin()
  36198. return nil
  36199. }
  36200. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  36201. }
  36202. // ResetField resets all changes in the mutation for the field with the given name.
  36203. // It returns an error if the field is not defined in the schema.
  36204. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  36205. switch name {
  36206. case usagestatisticday.FieldCreatedAt:
  36207. m.ResetCreatedAt()
  36208. return nil
  36209. case usagestatisticday.FieldUpdatedAt:
  36210. m.ResetUpdatedAt()
  36211. return nil
  36212. case usagestatisticday.FieldStatus:
  36213. m.ResetStatus()
  36214. return nil
  36215. case usagestatisticday.FieldDeletedAt:
  36216. m.ResetDeletedAt()
  36217. return nil
  36218. case usagestatisticday.FieldAddtime:
  36219. m.ResetAddtime()
  36220. return nil
  36221. case usagestatisticday.FieldType:
  36222. m.ResetType()
  36223. return nil
  36224. case usagestatisticday.FieldBotID:
  36225. m.ResetBotID()
  36226. return nil
  36227. case usagestatisticday.FieldOrganizationID:
  36228. m.ResetOrganizationID()
  36229. return nil
  36230. case usagestatisticday.FieldAiResponse:
  36231. m.ResetAiResponse()
  36232. return nil
  36233. case usagestatisticday.FieldSopRun:
  36234. m.ResetSopRun()
  36235. return nil
  36236. case usagestatisticday.FieldTotalFriend:
  36237. m.ResetTotalFriend()
  36238. return nil
  36239. case usagestatisticday.FieldTotalGroup:
  36240. m.ResetTotalGroup()
  36241. return nil
  36242. case usagestatisticday.FieldAccountBalance:
  36243. m.ResetAccountBalance()
  36244. return nil
  36245. case usagestatisticday.FieldConsumeToken:
  36246. m.ResetConsumeToken()
  36247. return nil
  36248. case usagestatisticday.FieldActiveUser:
  36249. m.ResetActiveUser()
  36250. return nil
  36251. case usagestatisticday.FieldNewUser:
  36252. m.ResetNewUser()
  36253. return nil
  36254. case usagestatisticday.FieldLabelDist:
  36255. m.ResetLabelDist()
  36256. return nil
  36257. case usagestatisticday.FieldConsumeCoin:
  36258. m.ResetConsumeCoin()
  36259. return nil
  36260. }
  36261. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  36262. }
  36263. // AddedEdges returns all edge names that were set/added in this mutation.
  36264. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  36265. edges := make([]string, 0, 0)
  36266. return edges
  36267. }
  36268. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36269. // name in this mutation.
  36270. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  36271. return nil
  36272. }
  36273. // RemovedEdges returns all edge names that were removed in this mutation.
  36274. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  36275. edges := make([]string, 0, 0)
  36276. return edges
  36277. }
  36278. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36279. // the given name in this mutation.
  36280. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  36281. return nil
  36282. }
  36283. // ClearedEdges returns all edge names that were cleared in this mutation.
  36284. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  36285. edges := make([]string, 0, 0)
  36286. return edges
  36287. }
  36288. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36289. // was cleared in this mutation.
  36290. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  36291. return false
  36292. }
  36293. // ClearEdge clears the value of the edge with the given name. It returns an error
  36294. // if that edge is not defined in the schema.
  36295. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  36296. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  36297. }
  36298. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36299. // It returns an error if the edge is not defined in the schema.
  36300. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  36301. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  36302. }
  36303. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  36304. type UsageStatisticHourMutation struct {
  36305. config
  36306. op Op
  36307. typ string
  36308. id *uint64
  36309. created_at *time.Time
  36310. updated_at *time.Time
  36311. status *uint8
  36312. addstatus *int8
  36313. deleted_at *time.Time
  36314. addtime *uint64
  36315. addaddtime *int64
  36316. _type *int
  36317. add_type *int
  36318. bot_id *string
  36319. organization_id *uint64
  36320. addorganization_id *int64
  36321. ai_response *uint64
  36322. addai_response *int64
  36323. sop_run *uint64
  36324. addsop_run *int64
  36325. total_friend *uint64
  36326. addtotal_friend *int64
  36327. total_group *uint64
  36328. addtotal_group *int64
  36329. account_balance *uint64
  36330. addaccount_balance *int64
  36331. consume_token *uint64
  36332. addconsume_token *int64
  36333. active_user *uint64
  36334. addactive_user *int64
  36335. new_user *int64
  36336. addnew_user *int64
  36337. label_dist *[]custom_types.LabelDist
  36338. appendlabel_dist []custom_types.LabelDist
  36339. consume_coin *float64
  36340. addconsume_coin *float64
  36341. clearedFields map[string]struct{}
  36342. done bool
  36343. oldValue func(context.Context) (*UsageStatisticHour, error)
  36344. predicates []predicate.UsageStatisticHour
  36345. }
  36346. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  36347. // usagestatistichourOption allows management of the mutation configuration using functional options.
  36348. type usagestatistichourOption func(*UsageStatisticHourMutation)
  36349. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  36350. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  36351. m := &UsageStatisticHourMutation{
  36352. config: c,
  36353. op: op,
  36354. typ: TypeUsageStatisticHour,
  36355. clearedFields: make(map[string]struct{}),
  36356. }
  36357. for _, opt := range opts {
  36358. opt(m)
  36359. }
  36360. return m
  36361. }
  36362. // withUsageStatisticHourID sets the ID field of the mutation.
  36363. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  36364. return func(m *UsageStatisticHourMutation) {
  36365. var (
  36366. err error
  36367. once sync.Once
  36368. value *UsageStatisticHour
  36369. )
  36370. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  36371. once.Do(func() {
  36372. if m.done {
  36373. err = errors.New("querying old values post mutation is not allowed")
  36374. } else {
  36375. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  36376. }
  36377. })
  36378. return value, err
  36379. }
  36380. m.id = &id
  36381. }
  36382. }
  36383. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  36384. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  36385. return func(m *UsageStatisticHourMutation) {
  36386. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  36387. return node, nil
  36388. }
  36389. m.id = &node.ID
  36390. }
  36391. }
  36392. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36393. // executed in a transaction (ent.Tx), a transactional client is returned.
  36394. func (m UsageStatisticHourMutation) Client() *Client {
  36395. client := &Client{config: m.config}
  36396. client.init()
  36397. return client
  36398. }
  36399. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36400. // it returns an error otherwise.
  36401. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  36402. if _, ok := m.driver.(*txDriver); !ok {
  36403. return nil, errors.New("ent: mutation is not running in a transaction")
  36404. }
  36405. tx := &Tx{config: m.config}
  36406. tx.init()
  36407. return tx, nil
  36408. }
  36409. // SetID sets the value of the id field. Note that this
  36410. // operation is only accepted on creation of UsageStatisticHour entities.
  36411. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  36412. m.id = &id
  36413. }
  36414. // ID returns the ID value in the mutation. Note that the ID is only available
  36415. // if it was provided to the builder or after it was returned from the database.
  36416. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  36417. if m.id == nil {
  36418. return
  36419. }
  36420. return *m.id, true
  36421. }
  36422. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36423. // That means, if the mutation is applied within a transaction with an isolation level such
  36424. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36425. // or updated by the mutation.
  36426. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  36427. switch {
  36428. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36429. id, exists := m.ID()
  36430. if exists {
  36431. return []uint64{id}, nil
  36432. }
  36433. fallthrough
  36434. case m.op.Is(OpUpdate | OpDelete):
  36435. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  36436. default:
  36437. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36438. }
  36439. }
  36440. // SetCreatedAt sets the "created_at" field.
  36441. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  36442. m.created_at = &t
  36443. }
  36444. // CreatedAt returns the value of the "created_at" field in the mutation.
  36445. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  36446. v := m.created_at
  36447. if v == nil {
  36448. return
  36449. }
  36450. return *v, true
  36451. }
  36452. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  36453. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36455. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36456. if !m.op.Is(OpUpdateOne) {
  36457. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36458. }
  36459. if m.id == nil || m.oldValue == nil {
  36460. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36461. }
  36462. oldValue, err := m.oldValue(ctx)
  36463. if err != nil {
  36464. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36465. }
  36466. return oldValue.CreatedAt, nil
  36467. }
  36468. // ResetCreatedAt resets all changes to the "created_at" field.
  36469. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  36470. m.created_at = nil
  36471. }
  36472. // SetUpdatedAt sets the "updated_at" field.
  36473. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  36474. m.updated_at = &t
  36475. }
  36476. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36477. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  36478. v := m.updated_at
  36479. if v == nil {
  36480. return
  36481. }
  36482. return *v, true
  36483. }
  36484. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  36485. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36487. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36488. if !m.op.Is(OpUpdateOne) {
  36489. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36490. }
  36491. if m.id == nil || m.oldValue == nil {
  36492. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36493. }
  36494. oldValue, err := m.oldValue(ctx)
  36495. if err != nil {
  36496. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36497. }
  36498. return oldValue.UpdatedAt, nil
  36499. }
  36500. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36501. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  36502. m.updated_at = nil
  36503. }
  36504. // SetStatus sets the "status" field.
  36505. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  36506. m.status = &u
  36507. m.addstatus = nil
  36508. }
  36509. // Status returns the value of the "status" field in the mutation.
  36510. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  36511. v := m.status
  36512. if v == nil {
  36513. return
  36514. }
  36515. return *v, true
  36516. }
  36517. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  36518. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36520. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36521. if !m.op.Is(OpUpdateOne) {
  36522. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36523. }
  36524. if m.id == nil || m.oldValue == nil {
  36525. return v, errors.New("OldStatus requires an ID field in the mutation")
  36526. }
  36527. oldValue, err := m.oldValue(ctx)
  36528. if err != nil {
  36529. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36530. }
  36531. return oldValue.Status, nil
  36532. }
  36533. // AddStatus adds u to the "status" field.
  36534. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  36535. if m.addstatus != nil {
  36536. *m.addstatus += u
  36537. } else {
  36538. m.addstatus = &u
  36539. }
  36540. }
  36541. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36542. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  36543. v := m.addstatus
  36544. if v == nil {
  36545. return
  36546. }
  36547. return *v, true
  36548. }
  36549. // ClearStatus clears the value of the "status" field.
  36550. func (m *UsageStatisticHourMutation) ClearStatus() {
  36551. m.status = nil
  36552. m.addstatus = nil
  36553. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  36554. }
  36555. // StatusCleared returns if the "status" field was cleared in this mutation.
  36556. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  36557. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  36558. return ok
  36559. }
  36560. // ResetStatus resets all changes to the "status" field.
  36561. func (m *UsageStatisticHourMutation) ResetStatus() {
  36562. m.status = nil
  36563. m.addstatus = nil
  36564. delete(m.clearedFields, usagestatistichour.FieldStatus)
  36565. }
  36566. // SetDeletedAt sets the "deleted_at" field.
  36567. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  36568. m.deleted_at = &t
  36569. }
  36570. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36571. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  36572. v := m.deleted_at
  36573. if v == nil {
  36574. return
  36575. }
  36576. return *v, true
  36577. }
  36578. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  36579. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36581. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36582. if !m.op.Is(OpUpdateOne) {
  36583. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36584. }
  36585. if m.id == nil || m.oldValue == nil {
  36586. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36587. }
  36588. oldValue, err := m.oldValue(ctx)
  36589. if err != nil {
  36590. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36591. }
  36592. return oldValue.DeletedAt, nil
  36593. }
  36594. // ClearDeletedAt clears the value of the "deleted_at" field.
  36595. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  36596. m.deleted_at = nil
  36597. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  36598. }
  36599. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36600. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  36601. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  36602. return ok
  36603. }
  36604. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36605. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  36606. m.deleted_at = nil
  36607. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  36608. }
  36609. // SetAddtime sets the "addtime" field.
  36610. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  36611. m.addtime = &u
  36612. m.addaddtime = nil
  36613. }
  36614. // Addtime returns the value of the "addtime" field in the mutation.
  36615. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  36616. v := m.addtime
  36617. if v == nil {
  36618. return
  36619. }
  36620. return *v, true
  36621. }
  36622. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  36623. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36625. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  36626. if !m.op.Is(OpUpdateOne) {
  36627. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  36628. }
  36629. if m.id == nil || m.oldValue == nil {
  36630. return v, errors.New("OldAddtime requires an ID field in the mutation")
  36631. }
  36632. oldValue, err := m.oldValue(ctx)
  36633. if err != nil {
  36634. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  36635. }
  36636. return oldValue.Addtime, nil
  36637. }
  36638. // AddAddtime adds u to the "addtime" field.
  36639. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  36640. if m.addaddtime != nil {
  36641. *m.addaddtime += u
  36642. } else {
  36643. m.addaddtime = &u
  36644. }
  36645. }
  36646. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  36647. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  36648. v := m.addaddtime
  36649. if v == nil {
  36650. return
  36651. }
  36652. return *v, true
  36653. }
  36654. // ResetAddtime resets all changes to the "addtime" field.
  36655. func (m *UsageStatisticHourMutation) ResetAddtime() {
  36656. m.addtime = nil
  36657. m.addaddtime = nil
  36658. }
  36659. // SetType sets the "type" field.
  36660. func (m *UsageStatisticHourMutation) SetType(i int) {
  36661. m._type = &i
  36662. m.add_type = nil
  36663. }
  36664. // GetType returns the value of the "type" field in the mutation.
  36665. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  36666. v := m._type
  36667. if v == nil {
  36668. return
  36669. }
  36670. return *v, true
  36671. }
  36672. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  36673. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36675. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  36676. if !m.op.Is(OpUpdateOne) {
  36677. return v, errors.New("OldType is only allowed on UpdateOne operations")
  36678. }
  36679. if m.id == nil || m.oldValue == nil {
  36680. return v, errors.New("OldType requires an ID field in the mutation")
  36681. }
  36682. oldValue, err := m.oldValue(ctx)
  36683. if err != nil {
  36684. return v, fmt.Errorf("querying old value for OldType: %w", err)
  36685. }
  36686. return oldValue.Type, nil
  36687. }
  36688. // AddType adds i to the "type" field.
  36689. func (m *UsageStatisticHourMutation) AddType(i int) {
  36690. if m.add_type != nil {
  36691. *m.add_type += i
  36692. } else {
  36693. m.add_type = &i
  36694. }
  36695. }
  36696. // AddedType returns the value that was added to the "type" field in this mutation.
  36697. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  36698. v := m.add_type
  36699. if v == nil {
  36700. return
  36701. }
  36702. return *v, true
  36703. }
  36704. // ResetType resets all changes to the "type" field.
  36705. func (m *UsageStatisticHourMutation) ResetType() {
  36706. m._type = nil
  36707. m.add_type = nil
  36708. }
  36709. // SetBotID sets the "bot_id" field.
  36710. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  36711. m.bot_id = &s
  36712. }
  36713. // BotID returns the value of the "bot_id" field in the mutation.
  36714. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  36715. v := m.bot_id
  36716. if v == nil {
  36717. return
  36718. }
  36719. return *v, true
  36720. }
  36721. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  36722. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36724. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  36725. if !m.op.Is(OpUpdateOne) {
  36726. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36727. }
  36728. if m.id == nil || m.oldValue == nil {
  36729. return v, errors.New("OldBotID requires an ID field in the mutation")
  36730. }
  36731. oldValue, err := m.oldValue(ctx)
  36732. if err != nil {
  36733. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36734. }
  36735. return oldValue.BotID, nil
  36736. }
  36737. // ClearBotID clears the value of the "bot_id" field.
  36738. func (m *UsageStatisticHourMutation) ClearBotID() {
  36739. m.bot_id = nil
  36740. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  36741. }
  36742. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  36743. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  36744. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  36745. return ok
  36746. }
  36747. // ResetBotID resets all changes to the "bot_id" field.
  36748. func (m *UsageStatisticHourMutation) ResetBotID() {
  36749. m.bot_id = nil
  36750. delete(m.clearedFields, usagestatistichour.FieldBotID)
  36751. }
  36752. // SetOrganizationID sets the "organization_id" field.
  36753. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  36754. m.organization_id = &u
  36755. m.addorganization_id = nil
  36756. }
  36757. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36758. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  36759. v := m.organization_id
  36760. if v == nil {
  36761. return
  36762. }
  36763. return *v, true
  36764. }
  36765. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  36766. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36768. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36769. if !m.op.Is(OpUpdateOne) {
  36770. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36771. }
  36772. if m.id == nil || m.oldValue == nil {
  36773. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36774. }
  36775. oldValue, err := m.oldValue(ctx)
  36776. if err != nil {
  36777. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36778. }
  36779. return oldValue.OrganizationID, nil
  36780. }
  36781. // AddOrganizationID adds u to the "organization_id" field.
  36782. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  36783. if m.addorganization_id != nil {
  36784. *m.addorganization_id += u
  36785. } else {
  36786. m.addorganization_id = &u
  36787. }
  36788. }
  36789. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36790. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  36791. v := m.addorganization_id
  36792. if v == nil {
  36793. return
  36794. }
  36795. return *v, true
  36796. }
  36797. // ClearOrganizationID clears the value of the "organization_id" field.
  36798. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  36799. m.organization_id = nil
  36800. m.addorganization_id = nil
  36801. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  36802. }
  36803. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36804. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  36805. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  36806. return ok
  36807. }
  36808. // ResetOrganizationID resets all changes to the "organization_id" field.
  36809. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  36810. m.organization_id = nil
  36811. m.addorganization_id = nil
  36812. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  36813. }
  36814. // SetAiResponse sets the "ai_response" field.
  36815. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  36816. m.ai_response = &u
  36817. m.addai_response = nil
  36818. }
  36819. // AiResponse returns the value of the "ai_response" field in the mutation.
  36820. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  36821. v := m.ai_response
  36822. if v == nil {
  36823. return
  36824. }
  36825. return *v, true
  36826. }
  36827. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  36828. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36830. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  36831. if !m.op.Is(OpUpdateOne) {
  36832. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  36833. }
  36834. if m.id == nil || m.oldValue == nil {
  36835. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  36836. }
  36837. oldValue, err := m.oldValue(ctx)
  36838. if err != nil {
  36839. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  36840. }
  36841. return oldValue.AiResponse, nil
  36842. }
  36843. // AddAiResponse adds u to the "ai_response" field.
  36844. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  36845. if m.addai_response != nil {
  36846. *m.addai_response += u
  36847. } else {
  36848. m.addai_response = &u
  36849. }
  36850. }
  36851. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  36852. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  36853. v := m.addai_response
  36854. if v == nil {
  36855. return
  36856. }
  36857. return *v, true
  36858. }
  36859. // ResetAiResponse resets all changes to the "ai_response" field.
  36860. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  36861. m.ai_response = nil
  36862. m.addai_response = nil
  36863. }
  36864. // SetSopRun sets the "sop_run" field.
  36865. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  36866. m.sop_run = &u
  36867. m.addsop_run = nil
  36868. }
  36869. // SopRun returns the value of the "sop_run" field in the mutation.
  36870. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  36871. v := m.sop_run
  36872. if v == nil {
  36873. return
  36874. }
  36875. return *v, true
  36876. }
  36877. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  36878. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36880. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  36881. if !m.op.Is(OpUpdateOne) {
  36882. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  36883. }
  36884. if m.id == nil || m.oldValue == nil {
  36885. return v, errors.New("OldSopRun requires an ID field in the mutation")
  36886. }
  36887. oldValue, err := m.oldValue(ctx)
  36888. if err != nil {
  36889. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  36890. }
  36891. return oldValue.SopRun, nil
  36892. }
  36893. // AddSopRun adds u to the "sop_run" field.
  36894. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  36895. if m.addsop_run != nil {
  36896. *m.addsop_run += u
  36897. } else {
  36898. m.addsop_run = &u
  36899. }
  36900. }
  36901. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  36902. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  36903. v := m.addsop_run
  36904. if v == nil {
  36905. return
  36906. }
  36907. return *v, true
  36908. }
  36909. // ResetSopRun resets all changes to the "sop_run" field.
  36910. func (m *UsageStatisticHourMutation) ResetSopRun() {
  36911. m.sop_run = nil
  36912. m.addsop_run = nil
  36913. }
  36914. // SetTotalFriend sets the "total_friend" field.
  36915. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  36916. m.total_friend = &u
  36917. m.addtotal_friend = nil
  36918. }
  36919. // TotalFriend returns the value of the "total_friend" field in the mutation.
  36920. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  36921. v := m.total_friend
  36922. if v == nil {
  36923. return
  36924. }
  36925. return *v, true
  36926. }
  36927. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  36928. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36930. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  36931. if !m.op.Is(OpUpdateOne) {
  36932. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  36933. }
  36934. if m.id == nil || m.oldValue == nil {
  36935. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  36936. }
  36937. oldValue, err := m.oldValue(ctx)
  36938. if err != nil {
  36939. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  36940. }
  36941. return oldValue.TotalFriend, nil
  36942. }
  36943. // AddTotalFriend adds u to the "total_friend" field.
  36944. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  36945. if m.addtotal_friend != nil {
  36946. *m.addtotal_friend += u
  36947. } else {
  36948. m.addtotal_friend = &u
  36949. }
  36950. }
  36951. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  36952. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  36953. v := m.addtotal_friend
  36954. if v == nil {
  36955. return
  36956. }
  36957. return *v, true
  36958. }
  36959. // ResetTotalFriend resets all changes to the "total_friend" field.
  36960. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  36961. m.total_friend = nil
  36962. m.addtotal_friend = nil
  36963. }
  36964. // SetTotalGroup sets the "total_group" field.
  36965. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  36966. m.total_group = &u
  36967. m.addtotal_group = nil
  36968. }
  36969. // TotalGroup returns the value of the "total_group" field in the mutation.
  36970. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  36971. v := m.total_group
  36972. if v == nil {
  36973. return
  36974. }
  36975. return *v, true
  36976. }
  36977. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  36978. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36980. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  36981. if !m.op.Is(OpUpdateOne) {
  36982. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  36983. }
  36984. if m.id == nil || m.oldValue == nil {
  36985. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  36986. }
  36987. oldValue, err := m.oldValue(ctx)
  36988. if err != nil {
  36989. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  36990. }
  36991. return oldValue.TotalGroup, nil
  36992. }
  36993. // AddTotalGroup adds u to the "total_group" field.
  36994. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  36995. if m.addtotal_group != nil {
  36996. *m.addtotal_group += u
  36997. } else {
  36998. m.addtotal_group = &u
  36999. }
  37000. }
  37001. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  37002. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  37003. v := m.addtotal_group
  37004. if v == nil {
  37005. return
  37006. }
  37007. return *v, true
  37008. }
  37009. // ResetTotalGroup resets all changes to the "total_group" field.
  37010. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  37011. m.total_group = nil
  37012. m.addtotal_group = nil
  37013. }
  37014. // SetAccountBalance sets the "account_balance" field.
  37015. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  37016. m.account_balance = &u
  37017. m.addaccount_balance = nil
  37018. }
  37019. // AccountBalance returns the value of the "account_balance" field in the mutation.
  37020. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  37021. v := m.account_balance
  37022. if v == nil {
  37023. return
  37024. }
  37025. return *v, true
  37026. }
  37027. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  37028. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37030. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  37031. if !m.op.Is(OpUpdateOne) {
  37032. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  37033. }
  37034. if m.id == nil || m.oldValue == nil {
  37035. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  37036. }
  37037. oldValue, err := m.oldValue(ctx)
  37038. if err != nil {
  37039. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  37040. }
  37041. return oldValue.AccountBalance, nil
  37042. }
  37043. // AddAccountBalance adds u to the "account_balance" field.
  37044. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  37045. if m.addaccount_balance != nil {
  37046. *m.addaccount_balance += u
  37047. } else {
  37048. m.addaccount_balance = &u
  37049. }
  37050. }
  37051. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  37052. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  37053. v := m.addaccount_balance
  37054. if v == nil {
  37055. return
  37056. }
  37057. return *v, true
  37058. }
  37059. // ResetAccountBalance resets all changes to the "account_balance" field.
  37060. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  37061. m.account_balance = nil
  37062. m.addaccount_balance = nil
  37063. }
  37064. // SetConsumeToken sets the "consume_token" field.
  37065. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  37066. m.consume_token = &u
  37067. m.addconsume_token = nil
  37068. }
  37069. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  37070. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  37071. v := m.consume_token
  37072. if v == nil {
  37073. return
  37074. }
  37075. return *v, true
  37076. }
  37077. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  37078. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37080. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  37081. if !m.op.Is(OpUpdateOne) {
  37082. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  37083. }
  37084. if m.id == nil || m.oldValue == nil {
  37085. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  37086. }
  37087. oldValue, err := m.oldValue(ctx)
  37088. if err != nil {
  37089. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  37090. }
  37091. return oldValue.ConsumeToken, nil
  37092. }
  37093. // AddConsumeToken adds u to the "consume_token" field.
  37094. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  37095. if m.addconsume_token != nil {
  37096. *m.addconsume_token += u
  37097. } else {
  37098. m.addconsume_token = &u
  37099. }
  37100. }
  37101. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  37102. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  37103. v := m.addconsume_token
  37104. if v == nil {
  37105. return
  37106. }
  37107. return *v, true
  37108. }
  37109. // ResetConsumeToken resets all changes to the "consume_token" field.
  37110. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  37111. m.consume_token = nil
  37112. m.addconsume_token = nil
  37113. }
  37114. // SetActiveUser sets the "active_user" field.
  37115. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  37116. m.active_user = &u
  37117. m.addactive_user = nil
  37118. }
  37119. // ActiveUser returns the value of the "active_user" field in the mutation.
  37120. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  37121. v := m.active_user
  37122. if v == nil {
  37123. return
  37124. }
  37125. return *v, true
  37126. }
  37127. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  37128. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37130. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  37131. if !m.op.Is(OpUpdateOne) {
  37132. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  37133. }
  37134. if m.id == nil || m.oldValue == nil {
  37135. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  37136. }
  37137. oldValue, err := m.oldValue(ctx)
  37138. if err != nil {
  37139. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  37140. }
  37141. return oldValue.ActiveUser, nil
  37142. }
  37143. // AddActiveUser adds u to the "active_user" field.
  37144. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  37145. if m.addactive_user != nil {
  37146. *m.addactive_user += u
  37147. } else {
  37148. m.addactive_user = &u
  37149. }
  37150. }
  37151. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  37152. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  37153. v := m.addactive_user
  37154. if v == nil {
  37155. return
  37156. }
  37157. return *v, true
  37158. }
  37159. // ResetActiveUser resets all changes to the "active_user" field.
  37160. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  37161. m.active_user = nil
  37162. m.addactive_user = nil
  37163. }
  37164. // SetNewUser sets the "new_user" field.
  37165. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  37166. m.new_user = &i
  37167. m.addnew_user = nil
  37168. }
  37169. // NewUser returns the value of the "new_user" field in the mutation.
  37170. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  37171. v := m.new_user
  37172. if v == nil {
  37173. return
  37174. }
  37175. return *v, true
  37176. }
  37177. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  37178. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37180. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  37181. if !m.op.Is(OpUpdateOne) {
  37182. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  37183. }
  37184. if m.id == nil || m.oldValue == nil {
  37185. return v, errors.New("OldNewUser requires an ID field in the mutation")
  37186. }
  37187. oldValue, err := m.oldValue(ctx)
  37188. if err != nil {
  37189. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  37190. }
  37191. return oldValue.NewUser, nil
  37192. }
  37193. // AddNewUser adds i to the "new_user" field.
  37194. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  37195. if m.addnew_user != nil {
  37196. *m.addnew_user += i
  37197. } else {
  37198. m.addnew_user = &i
  37199. }
  37200. }
  37201. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  37202. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  37203. v := m.addnew_user
  37204. if v == nil {
  37205. return
  37206. }
  37207. return *v, true
  37208. }
  37209. // ResetNewUser resets all changes to the "new_user" field.
  37210. func (m *UsageStatisticHourMutation) ResetNewUser() {
  37211. m.new_user = nil
  37212. m.addnew_user = nil
  37213. }
  37214. // SetLabelDist sets the "label_dist" field.
  37215. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  37216. m.label_dist = &ctd
  37217. m.appendlabel_dist = nil
  37218. }
  37219. // LabelDist returns the value of the "label_dist" field in the mutation.
  37220. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  37221. v := m.label_dist
  37222. if v == nil {
  37223. return
  37224. }
  37225. return *v, true
  37226. }
  37227. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  37228. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37230. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  37231. if !m.op.Is(OpUpdateOne) {
  37232. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  37233. }
  37234. if m.id == nil || m.oldValue == nil {
  37235. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  37236. }
  37237. oldValue, err := m.oldValue(ctx)
  37238. if err != nil {
  37239. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  37240. }
  37241. return oldValue.LabelDist, nil
  37242. }
  37243. // AppendLabelDist adds ctd to the "label_dist" field.
  37244. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  37245. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  37246. }
  37247. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  37248. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  37249. if len(m.appendlabel_dist) == 0 {
  37250. return nil, false
  37251. }
  37252. return m.appendlabel_dist, true
  37253. }
  37254. // ResetLabelDist resets all changes to the "label_dist" field.
  37255. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  37256. m.label_dist = nil
  37257. m.appendlabel_dist = nil
  37258. }
  37259. // SetConsumeCoin sets the "consume_coin" field.
  37260. func (m *UsageStatisticHourMutation) SetConsumeCoin(f float64) {
  37261. m.consume_coin = &f
  37262. m.addconsume_coin = nil
  37263. }
  37264. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  37265. func (m *UsageStatisticHourMutation) ConsumeCoin() (r float64, exists bool) {
  37266. v := m.consume_coin
  37267. if v == nil {
  37268. return
  37269. }
  37270. return *v, true
  37271. }
  37272. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticHour entity.
  37273. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37275. func (m *UsageStatisticHourMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  37276. if !m.op.Is(OpUpdateOne) {
  37277. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  37278. }
  37279. if m.id == nil || m.oldValue == nil {
  37280. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  37281. }
  37282. oldValue, err := m.oldValue(ctx)
  37283. if err != nil {
  37284. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  37285. }
  37286. return oldValue.ConsumeCoin, nil
  37287. }
  37288. // AddConsumeCoin adds f to the "consume_coin" field.
  37289. func (m *UsageStatisticHourMutation) AddConsumeCoin(f float64) {
  37290. if m.addconsume_coin != nil {
  37291. *m.addconsume_coin += f
  37292. } else {
  37293. m.addconsume_coin = &f
  37294. }
  37295. }
  37296. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  37297. func (m *UsageStatisticHourMutation) AddedConsumeCoin() (r float64, exists bool) {
  37298. v := m.addconsume_coin
  37299. if v == nil {
  37300. return
  37301. }
  37302. return *v, true
  37303. }
  37304. // ClearConsumeCoin clears the value of the "consume_coin" field.
  37305. func (m *UsageStatisticHourMutation) ClearConsumeCoin() {
  37306. m.consume_coin = nil
  37307. m.addconsume_coin = nil
  37308. m.clearedFields[usagestatistichour.FieldConsumeCoin] = struct{}{}
  37309. }
  37310. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  37311. func (m *UsageStatisticHourMutation) ConsumeCoinCleared() bool {
  37312. _, ok := m.clearedFields[usagestatistichour.FieldConsumeCoin]
  37313. return ok
  37314. }
  37315. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  37316. func (m *UsageStatisticHourMutation) ResetConsumeCoin() {
  37317. m.consume_coin = nil
  37318. m.addconsume_coin = nil
  37319. delete(m.clearedFields, usagestatistichour.FieldConsumeCoin)
  37320. }
  37321. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  37322. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  37323. m.predicates = append(m.predicates, ps...)
  37324. }
  37325. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  37326. // users can use type-assertion to append predicates that do not depend on any generated package.
  37327. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  37328. p := make([]predicate.UsageStatisticHour, len(ps))
  37329. for i := range ps {
  37330. p[i] = ps[i]
  37331. }
  37332. m.Where(p...)
  37333. }
  37334. // Op returns the operation name.
  37335. func (m *UsageStatisticHourMutation) Op() Op {
  37336. return m.op
  37337. }
  37338. // SetOp allows setting the mutation operation.
  37339. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  37340. m.op = op
  37341. }
  37342. // Type returns the node type of this mutation (UsageStatisticHour).
  37343. func (m *UsageStatisticHourMutation) Type() string {
  37344. return m.typ
  37345. }
  37346. // Fields returns all fields that were changed during this mutation. Note that in
  37347. // order to get all numeric fields that were incremented/decremented, call
  37348. // AddedFields().
  37349. func (m *UsageStatisticHourMutation) Fields() []string {
  37350. fields := make([]string, 0, 18)
  37351. if m.created_at != nil {
  37352. fields = append(fields, usagestatistichour.FieldCreatedAt)
  37353. }
  37354. if m.updated_at != nil {
  37355. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  37356. }
  37357. if m.status != nil {
  37358. fields = append(fields, usagestatistichour.FieldStatus)
  37359. }
  37360. if m.deleted_at != nil {
  37361. fields = append(fields, usagestatistichour.FieldDeletedAt)
  37362. }
  37363. if m.addtime != nil {
  37364. fields = append(fields, usagestatistichour.FieldAddtime)
  37365. }
  37366. if m._type != nil {
  37367. fields = append(fields, usagestatistichour.FieldType)
  37368. }
  37369. if m.bot_id != nil {
  37370. fields = append(fields, usagestatistichour.FieldBotID)
  37371. }
  37372. if m.organization_id != nil {
  37373. fields = append(fields, usagestatistichour.FieldOrganizationID)
  37374. }
  37375. if m.ai_response != nil {
  37376. fields = append(fields, usagestatistichour.FieldAiResponse)
  37377. }
  37378. if m.sop_run != nil {
  37379. fields = append(fields, usagestatistichour.FieldSopRun)
  37380. }
  37381. if m.total_friend != nil {
  37382. fields = append(fields, usagestatistichour.FieldTotalFriend)
  37383. }
  37384. if m.total_group != nil {
  37385. fields = append(fields, usagestatistichour.FieldTotalGroup)
  37386. }
  37387. if m.account_balance != nil {
  37388. fields = append(fields, usagestatistichour.FieldAccountBalance)
  37389. }
  37390. if m.consume_token != nil {
  37391. fields = append(fields, usagestatistichour.FieldConsumeToken)
  37392. }
  37393. if m.active_user != nil {
  37394. fields = append(fields, usagestatistichour.FieldActiveUser)
  37395. }
  37396. if m.new_user != nil {
  37397. fields = append(fields, usagestatistichour.FieldNewUser)
  37398. }
  37399. if m.label_dist != nil {
  37400. fields = append(fields, usagestatistichour.FieldLabelDist)
  37401. }
  37402. if m.consume_coin != nil {
  37403. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  37404. }
  37405. return fields
  37406. }
  37407. // Field returns the value of a field with the given name. The second boolean
  37408. // return value indicates that this field was not set, or was not defined in the
  37409. // schema.
  37410. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  37411. switch name {
  37412. case usagestatistichour.FieldCreatedAt:
  37413. return m.CreatedAt()
  37414. case usagestatistichour.FieldUpdatedAt:
  37415. return m.UpdatedAt()
  37416. case usagestatistichour.FieldStatus:
  37417. return m.Status()
  37418. case usagestatistichour.FieldDeletedAt:
  37419. return m.DeletedAt()
  37420. case usagestatistichour.FieldAddtime:
  37421. return m.Addtime()
  37422. case usagestatistichour.FieldType:
  37423. return m.GetType()
  37424. case usagestatistichour.FieldBotID:
  37425. return m.BotID()
  37426. case usagestatistichour.FieldOrganizationID:
  37427. return m.OrganizationID()
  37428. case usagestatistichour.FieldAiResponse:
  37429. return m.AiResponse()
  37430. case usagestatistichour.FieldSopRun:
  37431. return m.SopRun()
  37432. case usagestatistichour.FieldTotalFriend:
  37433. return m.TotalFriend()
  37434. case usagestatistichour.FieldTotalGroup:
  37435. return m.TotalGroup()
  37436. case usagestatistichour.FieldAccountBalance:
  37437. return m.AccountBalance()
  37438. case usagestatistichour.FieldConsumeToken:
  37439. return m.ConsumeToken()
  37440. case usagestatistichour.FieldActiveUser:
  37441. return m.ActiveUser()
  37442. case usagestatistichour.FieldNewUser:
  37443. return m.NewUser()
  37444. case usagestatistichour.FieldLabelDist:
  37445. return m.LabelDist()
  37446. case usagestatistichour.FieldConsumeCoin:
  37447. return m.ConsumeCoin()
  37448. }
  37449. return nil, false
  37450. }
  37451. // OldField returns the old value of the field from the database. An error is
  37452. // returned if the mutation operation is not UpdateOne, or the query to the
  37453. // database failed.
  37454. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37455. switch name {
  37456. case usagestatistichour.FieldCreatedAt:
  37457. return m.OldCreatedAt(ctx)
  37458. case usagestatistichour.FieldUpdatedAt:
  37459. return m.OldUpdatedAt(ctx)
  37460. case usagestatistichour.FieldStatus:
  37461. return m.OldStatus(ctx)
  37462. case usagestatistichour.FieldDeletedAt:
  37463. return m.OldDeletedAt(ctx)
  37464. case usagestatistichour.FieldAddtime:
  37465. return m.OldAddtime(ctx)
  37466. case usagestatistichour.FieldType:
  37467. return m.OldType(ctx)
  37468. case usagestatistichour.FieldBotID:
  37469. return m.OldBotID(ctx)
  37470. case usagestatistichour.FieldOrganizationID:
  37471. return m.OldOrganizationID(ctx)
  37472. case usagestatistichour.FieldAiResponse:
  37473. return m.OldAiResponse(ctx)
  37474. case usagestatistichour.FieldSopRun:
  37475. return m.OldSopRun(ctx)
  37476. case usagestatistichour.FieldTotalFriend:
  37477. return m.OldTotalFriend(ctx)
  37478. case usagestatistichour.FieldTotalGroup:
  37479. return m.OldTotalGroup(ctx)
  37480. case usagestatistichour.FieldAccountBalance:
  37481. return m.OldAccountBalance(ctx)
  37482. case usagestatistichour.FieldConsumeToken:
  37483. return m.OldConsumeToken(ctx)
  37484. case usagestatistichour.FieldActiveUser:
  37485. return m.OldActiveUser(ctx)
  37486. case usagestatistichour.FieldNewUser:
  37487. return m.OldNewUser(ctx)
  37488. case usagestatistichour.FieldLabelDist:
  37489. return m.OldLabelDist(ctx)
  37490. case usagestatistichour.FieldConsumeCoin:
  37491. return m.OldConsumeCoin(ctx)
  37492. }
  37493. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  37494. }
  37495. // SetField sets the value of a field with the given name. It returns an error if
  37496. // the field is not defined in the schema, or if the type mismatched the field
  37497. // type.
  37498. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  37499. switch name {
  37500. case usagestatistichour.FieldCreatedAt:
  37501. v, ok := value.(time.Time)
  37502. if !ok {
  37503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37504. }
  37505. m.SetCreatedAt(v)
  37506. return nil
  37507. case usagestatistichour.FieldUpdatedAt:
  37508. v, ok := value.(time.Time)
  37509. if !ok {
  37510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37511. }
  37512. m.SetUpdatedAt(v)
  37513. return nil
  37514. case usagestatistichour.FieldStatus:
  37515. v, ok := value.(uint8)
  37516. if !ok {
  37517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37518. }
  37519. m.SetStatus(v)
  37520. return nil
  37521. case usagestatistichour.FieldDeletedAt:
  37522. v, ok := value.(time.Time)
  37523. if !ok {
  37524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37525. }
  37526. m.SetDeletedAt(v)
  37527. return nil
  37528. case usagestatistichour.FieldAddtime:
  37529. v, ok := value.(uint64)
  37530. if !ok {
  37531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37532. }
  37533. m.SetAddtime(v)
  37534. return nil
  37535. case usagestatistichour.FieldType:
  37536. v, ok := value.(int)
  37537. if !ok {
  37538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37539. }
  37540. m.SetType(v)
  37541. return nil
  37542. case usagestatistichour.FieldBotID:
  37543. v, ok := value.(string)
  37544. if !ok {
  37545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37546. }
  37547. m.SetBotID(v)
  37548. return nil
  37549. case usagestatistichour.FieldOrganizationID:
  37550. v, ok := value.(uint64)
  37551. if !ok {
  37552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37553. }
  37554. m.SetOrganizationID(v)
  37555. return nil
  37556. case usagestatistichour.FieldAiResponse:
  37557. v, ok := value.(uint64)
  37558. if !ok {
  37559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37560. }
  37561. m.SetAiResponse(v)
  37562. return nil
  37563. case usagestatistichour.FieldSopRun:
  37564. v, ok := value.(uint64)
  37565. if !ok {
  37566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37567. }
  37568. m.SetSopRun(v)
  37569. return nil
  37570. case usagestatistichour.FieldTotalFriend:
  37571. v, ok := value.(uint64)
  37572. if !ok {
  37573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37574. }
  37575. m.SetTotalFriend(v)
  37576. return nil
  37577. case usagestatistichour.FieldTotalGroup:
  37578. v, ok := value.(uint64)
  37579. if !ok {
  37580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37581. }
  37582. m.SetTotalGroup(v)
  37583. return nil
  37584. case usagestatistichour.FieldAccountBalance:
  37585. v, ok := value.(uint64)
  37586. if !ok {
  37587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37588. }
  37589. m.SetAccountBalance(v)
  37590. return nil
  37591. case usagestatistichour.FieldConsumeToken:
  37592. v, ok := value.(uint64)
  37593. if !ok {
  37594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37595. }
  37596. m.SetConsumeToken(v)
  37597. return nil
  37598. case usagestatistichour.FieldActiveUser:
  37599. v, ok := value.(uint64)
  37600. if !ok {
  37601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37602. }
  37603. m.SetActiveUser(v)
  37604. return nil
  37605. case usagestatistichour.FieldNewUser:
  37606. v, ok := value.(int64)
  37607. if !ok {
  37608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37609. }
  37610. m.SetNewUser(v)
  37611. return nil
  37612. case usagestatistichour.FieldLabelDist:
  37613. v, ok := value.([]custom_types.LabelDist)
  37614. if !ok {
  37615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37616. }
  37617. m.SetLabelDist(v)
  37618. return nil
  37619. case usagestatistichour.FieldConsumeCoin:
  37620. v, ok := value.(float64)
  37621. if !ok {
  37622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37623. }
  37624. m.SetConsumeCoin(v)
  37625. return nil
  37626. }
  37627. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  37628. }
  37629. // AddedFields returns all numeric fields that were incremented/decremented during
  37630. // this mutation.
  37631. func (m *UsageStatisticHourMutation) AddedFields() []string {
  37632. var fields []string
  37633. if m.addstatus != nil {
  37634. fields = append(fields, usagestatistichour.FieldStatus)
  37635. }
  37636. if m.addaddtime != nil {
  37637. fields = append(fields, usagestatistichour.FieldAddtime)
  37638. }
  37639. if m.add_type != nil {
  37640. fields = append(fields, usagestatistichour.FieldType)
  37641. }
  37642. if m.addorganization_id != nil {
  37643. fields = append(fields, usagestatistichour.FieldOrganizationID)
  37644. }
  37645. if m.addai_response != nil {
  37646. fields = append(fields, usagestatistichour.FieldAiResponse)
  37647. }
  37648. if m.addsop_run != nil {
  37649. fields = append(fields, usagestatistichour.FieldSopRun)
  37650. }
  37651. if m.addtotal_friend != nil {
  37652. fields = append(fields, usagestatistichour.FieldTotalFriend)
  37653. }
  37654. if m.addtotal_group != nil {
  37655. fields = append(fields, usagestatistichour.FieldTotalGroup)
  37656. }
  37657. if m.addaccount_balance != nil {
  37658. fields = append(fields, usagestatistichour.FieldAccountBalance)
  37659. }
  37660. if m.addconsume_token != nil {
  37661. fields = append(fields, usagestatistichour.FieldConsumeToken)
  37662. }
  37663. if m.addactive_user != nil {
  37664. fields = append(fields, usagestatistichour.FieldActiveUser)
  37665. }
  37666. if m.addnew_user != nil {
  37667. fields = append(fields, usagestatistichour.FieldNewUser)
  37668. }
  37669. if m.addconsume_coin != nil {
  37670. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  37671. }
  37672. return fields
  37673. }
  37674. // AddedField returns the numeric value that was incremented/decremented on a field
  37675. // with the given name. The second boolean return value indicates that this field
  37676. // was not set, or was not defined in the schema.
  37677. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  37678. switch name {
  37679. case usagestatistichour.FieldStatus:
  37680. return m.AddedStatus()
  37681. case usagestatistichour.FieldAddtime:
  37682. return m.AddedAddtime()
  37683. case usagestatistichour.FieldType:
  37684. return m.AddedType()
  37685. case usagestatistichour.FieldOrganizationID:
  37686. return m.AddedOrganizationID()
  37687. case usagestatistichour.FieldAiResponse:
  37688. return m.AddedAiResponse()
  37689. case usagestatistichour.FieldSopRun:
  37690. return m.AddedSopRun()
  37691. case usagestatistichour.FieldTotalFriend:
  37692. return m.AddedTotalFriend()
  37693. case usagestatistichour.FieldTotalGroup:
  37694. return m.AddedTotalGroup()
  37695. case usagestatistichour.FieldAccountBalance:
  37696. return m.AddedAccountBalance()
  37697. case usagestatistichour.FieldConsumeToken:
  37698. return m.AddedConsumeToken()
  37699. case usagestatistichour.FieldActiveUser:
  37700. return m.AddedActiveUser()
  37701. case usagestatistichour.FieldNewUser:
  37702. return m.AddedNewUser()
  37703. case usagestatistichour.FieldConsumeCoin:
  37704. return m.AddedConsumeCoin()
  37705. }
  37706. return nil, false
  37707. }
  37708. // AddField adds the value to the field with the given name. It returns an error if
  37709. // the field is not defined in the schema, or if the type mismatched the field
  37710. // type.
  37711. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  37712. switch name {
  37713. case usagestatistichour.FieldStatus:
  37714. v, ok := value.(int8)
  37715. if !ok {
  37716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37717. }
  37718. m.AddStatus(v)
  37719. return nil
  37720. case usagestatistichour.FieldAddtime:
  37721. v, ok := value.(int64)
  37722. if !ok {
  37723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37724. }
  37725. m.AddAddtime(v)
  37726. return nil
  37727. case usagestatistichour.FieldType:
  37728. v, ok := value.(int)
  37729. if !ok {
  37730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37731. }
  37732. m.AddType(v)
  37733. return nil
  37734. case usagestatistichour.FieldOrganizationID:
  37735. v, ok := value.(int64)
  37736. if !ok {
  37737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37738. }
  37739. m.AddOrganizationID(v)
  37740. return nil
  37741. case usagestatistichour.FieldAiResponse:
  37742. v, ok := value.(int64)
  37743. if !ok {
  37744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37745. }
  37746. m.AddAiResponse(v)
  37747. return nil
  37748. case usagestatistichour.FieldSopRun:
  37749. v, ok := value.(int64)
  37750. if !ok {
  37751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37752. }
  37753. m.AddSopRun(v)
  37754. return nil
  37755. case usagestatistichour.FieldTotalFriend:
  37756. v, ok := value.(int64)
  37757. if !ok {
  37758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37759. }
  37760. m.AddTotalFriend(v)
  37761. return nil
  37762. case usagestatistichour.FieldTotalGroup:
  37763. v, ok := value.(int64)
  37764. if !ok {
  37765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37766. }
  37767. m.AddTotalGroup(v)
  37768. return nil
  37769. case usagestatistichour.FieldAccountBalance:
  37770. v, ok := value.(int64)
  37771. if !ok {
  37772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37773. }
  37774. m.AddAccountBalance(v)
  37775. return nil
  37776. case usagestatistichour.FieldConsumeToken:
  37777. v, ok := value.(int64)
  37778. if !ok {
  37779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37780. }
  37781. m.AddConsumeToken(v)
  37782. return nil
  37783. case usagestatistichour.FieldActiveUser:
  37784. v, ok := value.(int64)
  37785. if !ok {
  37786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37787. }
  37788. m.AddActiveUser(v)
  37789. return nil
  37790. case usagestatistichour.FieldNewUser:
  37791. v, ok := value.(int64)
  37792. if !ok {
  37793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37794. }
  37795. m.AddNewUser(v)
  37796. return nil
  37797. case usagestatistichour.FieldConsumeCoin:
  37798. v, ok := value.(float64)
  37799. if !ok {
  37800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37801. }
  37802. m.AddConsumeCoin(v)
  37803. return nil
  37804. }
  37805. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  37806. }
  37807. // ClearedFields returns all nullable fields that were cleared during this
  37808. // mutation.
  37809. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  37810. var fields []string
  37811. if m.FieldCleared(usagestatistichour.FieldStatus) {
  37812. fields = append(fields, usagestatistichour.FieldStatus)
  37813. }
  37814. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  37815. fields = append(fields, usagestatistichour.FieldDeletedAt)
  37816. }
  37817. if m.FieldCleared(usagestatistichour.FieldBotID) {
  37818. fields = append(fields, usagestatistichour.FieldBotID)
  37819. }
  37820. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  37821. fields = append(fields, usagestatistichour.FieldOrganizationID)
  37822. }
  37823. if m.FieldCleared(usagestatistichour.FieldConsumeCoin) {
  37824. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  37825. }
  37826. return fields
  37827. }
  37828. // FieldCleared returns a boolean indicating if a field with the given name was
  37829. // cleared in this mutation.
  37830. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  37831. _, ok := m.clearedFields[name]
  37832. return ok
  37833. }
  37834. // ClearField clears the value of the field with the given name. It returns an
  37835. // error if the field is not defined in the schema.
  37836. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  37837. switch name {
  37838. case usagestatistichour.FieldStatus:
  37839. m.ClearStatus()
  37840. return nil
  37841. case usagestatistichour.FieldDeletedAt:
  37842. m.ClearDeletedAt()
  37843. return nil
  37844. case usagestatistichour.FieldBotID:
  37845. m.ClearBotID()
  37846. return nil
  37847. case usagestatistichour.FieldOrganizationID:
  37848. m.ClearOrganizationID()
  37849. return nil
  37850. case usagestatistichour.FieldConsumeCoin:
  37851. m.ClearConsumeCoin()
  37852. return nil
  37853. }
  37854. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  37855. }
  37856. // ResetField resets all changes in the mutation for the field with the given name.
  37857. // It returns an error if the field is not defined in the schema.
  37858. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  37859. switch name {
  37860. case usagestatistichour.FieldCreatedAt:
  37861. m.ResetCreatedAt()
  37862. return nil
  37863. case usagestatistichour.FieldUpdatedAt:
  37864. m.ResetUpdatedAt()
  37865. return nil
  37866. case usagestatistichour.FieldStatus:
  37867. m.ResetStatus()
  37868. return nil
  37869. case usagestatistichour.FieldDeletedAt:
  37870. m.ResetDeletedAt()
  37871. return nil
  37872. case usagestatistichour.FieldAddtime:
  37873. m.ResetAddtime()
  37874. return nil
  37875. case usagestatistichour.FieldType:
  37876. m.ResetType()
  37877. return nil
  37878. case usagestatistichour.FieldBotID:
  37879. m.ResetBotID()
  37880. return nil
  37881. case usagestatistichour.FieldOrganizationID:
  37882. m.ResetOrganizationID()
  37883. return nil
  37884. case usagestatistichour.FieldAiResponse:
  37885. m.ResetAiResponse()
  37886. return nil
  37887. case usagestatistichour.FieldSopRun:
  37888. m.ResetSopRun()
  37889. return nil
  37890. case usagestatistichour.FieldTotalFriend:
  37891. m.ResetTotalFriend()
  37892. return nil
  37893. case usagestatistichour.FieldTotalGroup:
  37894. m.ResetTotalGroup()
  37895. return nil
  37896. case usagestatistichour.FieldAccountBalance:
  37897. m.ResetAccountBalance()
  37898. return nil
  37899. case usagestatistichour.FieldConsumeToken:
  37900. m.ResetConsumeToken()
  37901. return nil
  37902. case usagestatistichour.FieldActiveUser:
  37903. m.ResetActiveUser()
  37904. return nil
  37905. case usagestatistichour.FieldNewUser:
  37906. m.ResetNewUser()
  37907. return nil
  37908. case usagestatistichour.FieldLabelDist:
  37909. m.ResetLabelDist()
  37910. return nil
  37911. case usagestatistichour.FieldConsumeCoin:
  37912. m.ResetConsumeCoin()
  37913. return nil
  37914. }
  37915. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  37916. }
  37917. // AddedEdges returns all edge names that were set/added in this mutation.
  37918. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  37919. edges := make([]string, 0, 0)
  37920. return edges
  37921. }
  37922. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37923. // name in this mutation.
  37924. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  37925. return nil
  37926. }
  37927. // RemovedEdges returns all edge names that were removed in this mutation.
  37928. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  37929. edges := make([]string, 0, 0)
  37930. return edges
  37931. }
  37932. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37933. // the given name in this mutation.
  37934. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  37935. return nil
  37936. }
  37937. // ClearedEdges returns all edge names that were cleared in this mutation.
  37938. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  37939. edges := make([]string, 0, 0)
  37940. return edges
  37941. }
  37942. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37943. // was cleared in this mutation.
  37944. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  37945. return false
  37946. }
  37947. // ClearEdge clears the value of the edge with the given name. It returns an error
  37948. // if that edge is not defined in the schema.
  37949. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  37950. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  37951. }
  37952. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37953. // It returns an error if the edge is not defined in the schema.
  37954. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  37955. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  37956. }
  37957. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  37958. type UsageStatisticMonthMutation struct {
  37959. config
  37960. op Op
  37961. typ string
  37962. id *uint64
  37963. created_at *time.Time
  37964. updated_at *time.Time
  37965. status *uint8
  37966. addstatus *int8
  37967. deleted_at *time.Time
  37968. addtime *uint64
  37969. addaddtime *int64
  37970. _type *int
  37971. add_type *int
  37972. bot_id *string
  37973. organization_id *uint64
  37974. addorganization_id *int64
  37975. ai_response *uint64
  37976. addai_response *int64
  37977. sop_run *uint64
  37978. addsop_run *int64
  37979. total_friend *uint64
  37980. addtotal_friend *int64
  37981. total_group *uint64
  37982. addtotal_group *int64
  37983. account_balance *uint64
  37984. addaccount_balance *int64
  37985. consume_token *uint64
  37986. addconsume_token *int64
  37987. active_user *uint64
  37988. addactive_user *int64
  37989. new_user *int64
  37990. addnew_user *int64
  37991. label_dist *[]custom_types.LabelDist
  37992. appendlabel_dist []custom_types.LabelDist
  37993. consume_coin *float64
  37994. addconsume_coin *float64
  37995. clearedFields map[string]struct{}
  37996. done bool
  37997. oldValue func(context.Context) (*UsageStatisticMonth, error)
  37998. predicates []predicate.UsageStatisticMonth
  37999. }
  38000. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  38001. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  38002. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  38003. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  38004. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  38005. m := &UsageStatisticMonthMutation{
  38006. config: c,
  38007. op: op,
  38008. typ: TypeUsageStatisticMonth,
  38009. clearedFields: make(map[string]struct{}),
  38010. }
  38011. for _, opt := range opts {
  38012. opt(m)
  38013. }
  38014. return m
  38015. }
  38016. // withUsageStatisticMonthID sets the ID field of the mutation.
  38017. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  38018. return func(m *UsageStatisticMonthMutation) {
  38019. var (
  38020. err error
  38021. once sync.Once
  38022. value *UsageStatisticMonth
  38023. )
  38024. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  38025. once.Do(func() {
  38026. if m.done {
  38027. err = errors.New("querying old values post mutation is not allowed")
  38028. } else {
  38029. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  38030. }
  38031. })
  38032. return value, err
  38033. }
  38034. m.id = &id
  38035. }
  38036. }
  38037. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  38038. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  38039. return func(m *UsageStatisticMonthMutation) {
  38040. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  38041. return node, nil
  38042. }
  38043. m.id = &node.ID
  38044. }
  38045. }
  38046. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38047. // executed in a transaction (ent.Tx), a transactional client is returned.
  38048. func (m UsageStatisticMonthMutation) Client() *Client {
  38049. client := &Client{config: m.config}
  38050. client.init()
  38051. return client
  38052. }
  38053. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38054. // it returns an error otherwise.
  38055. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  38056. if _, ok := m.driver.(*txDriver); !ok {
  38057. return nil, errors.New("ent: mutation is not running in a transaction")
  38058. }
  38059. tx := &Tx{config: m.config}
  38060. tx.init()
  38061. return tx, nil
  38062. }
  38063. // SetID sets the value of the id field. Note that this
  38064. // operation is only accepted on creation of UsageStatisticMonth entities.
  38065. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  38066. m.id = &id
  38067. }
  38068. // ID returns the ID value in the mutation. Note that the ID is only available
  38069. // if it was provided to the builder or after it was returned from the database.
  38070. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  38071. if m.id == nil {
  38072. return
  38073. }
  38074. return *m.id, true
  38075. }
  38076. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38077. // That means, if the mutation is applied within a transaction with an isolation level such
  38078. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38079. // or updated by the mutation.
  38080. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  38081. switch {
  38082. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38083. id, exists := m.ID()
  38084. if exists {
  38085. return []uint64{id}, nil
  38086. }
  38087. fallthrough
  38088. case m.op.Is(OpUpdate | OpDelete):
  38089. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  38090. default:
  38091. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38092. }
  38093. }
  38094. // SetCreatedAt sets the "created_at" field.
  38095. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  38096. m.created_at = &t
  38097. }
  38098. // CreatedAt returns the value of the "created_at" field in the mutation.
  38099. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  38100. v := m.created_at
  38101. if v == nil {
  38102. return
  38103. }
  38104. return *v, true
  38105. }
  38106. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  38107. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38109. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38110. if !m.op.Is(OpUpdateOne) {
  38111. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38112. }
  38113. if m.id == nil || m.oldValue == nil {
  38114. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38115. }
  38116. oldValue, err := m.oldValue(ctx)
  38117. if err != nil {
  38118. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38119. }
  38120. return oldValue.CreatedAt, nil
  38121. }
  38122. // ResetCreatedAt resets all changes to the "created_at" field.
  38123. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  38124. m.created_at = nil
  38125. }
  38126. // SetUpdatedAt sets the "updated_at" field.
  38127. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  38128. m.updated_at = &t
  38129. }
  38130. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38131. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  38132. v := m.updated_at
  38133. if v == nil {
  38134. return
  38135. }
  38136. return *v, true
  38137. }
  38138. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  38139. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38141. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38142. if !m.op.Is(OpUpdateOne) {
  38143. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38144. }
  38145. if m.id == nil || m.oldValue == nil {
  38146. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38147. }
  38148. oldValue, err := m.oldValue(ctx)
  38149. if err != nil {
  38150. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38151. }
  38152. return oldValue.UpdatedAt, nil
  38153. }
  38154. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38155. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  38156. m.updated_at = nil
  38157. }
  38158. // SetStatus sets the "status" field.
  38159. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  38160. m.status = &u
  38161. m.addstatus = nil
  38162. }
  38163. // Status returns the value of the "status" field in the mutation.
  38164. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  38165. v := m.status
  38166. if v == nil {
  38167. return
  38168. }
  38169. return *v, true
  38170. }
  38171. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  38172. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38174. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38175. if !m.op.Is(OpUpdateOne) {
  38176. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38177. }
  38178. if m.id == nil || m.oldValue == nil {
  38179. return v, errors.New("OldStatus requires an ID field in the mutation")
  38180. }
  38181. oldValue, err := m.oldValue(ctx)
  38182. if err != nil {
  38183. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38184. }
  38185. return oldValue.Status, nil
  38186. }
  38187. // AddStatus adds u to the "status" field.
  38188. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  38189. if m.addstatus != nil {
  38190. *m.addstatus += u
  38191. } else {
  38192. m.addstatus = &u
  38193. }
  38194. }
  38195. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38196. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  38197. v := m.addstatus
  38198. if v == nil {
  38199. return
  38200. }
  38201. return *v, true
  38202. }
  38203. // ClearStatus clears the value of the "status" field.
  38204. func (m *UsageStatisticMonthMutation) ClearStatus() {
  38205. m.status = nil
  38206. m.addstatus = nil
  38207. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  38208. }
  38209. // StatusCleared returns if the "status" field was cleared in this mutation.
  38210. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  38211. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  38212. return ok
  38213. }
  38214. // ResetStatus resets all changes to the "status" field.
  38215. func (m *UsageStatisticMonthMutation) ResetStatus() {
  38216. m.status = nil
  38217. m.addstatus = nil
  38218. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  38219. }
  38220. // SetDeletedAt sets the "deleted_at" field.
  38221. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  38222. m.deleted_at = &t
  38223. }
  38224. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38225. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  38226. v := m.deleted_at
  38227. if v == nil {
  38228. return
  38229. }
  38230. return *v, true
  38231. }
  38232. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  38233. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38235. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38236. if !m.op.Is(OpUpdateOne) {
  38237. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38238. }
  38239. if m.id == nil || m.oldValue == nil {
  38240. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38241. }
  38242. oldValue, err := m.oldValue(ctx)
  38243. if err != nil {
  38244. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38245. }
  38246. return oldValue.DeletedAt, nil
  38247. }
  38248. // ClearDeletedAt clears the value of the "deleted_at" field.
  38249. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  38250. m.deleted_at = nil
  38251. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  38252. }
  38253. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38254. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  38255. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  38256. return ok
  38257. }
  38258. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38259. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  38260. m.deleted_at = nil
  38261. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  38262. }
  38263. // SetAddtime sets the "addtime" field.
  38264. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  38265. m.addtime = &u
  38266. m.addaddtime = nil
  38267. }
  38268. // Addtime returns the value of the "addtime" field in the mutation.
  38269. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  38270. v := m.addtime
  38271. if v == nil {
  38272. return
  38273. }
  38274. return *v, true
  38275. }
  38276. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  38277. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38279. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  38280. if !m.op.Is(OpUpdateOne) {
  38281. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  38282. }
  38283. if m.id == nil || m.oldValue == nil {
  38284. return v, errors.New("OldAddtime requires an ID field in the mutation")
  38285. }
  38286. oldValue, err := m.oldValue(ctx)
  38287. if err != nil {
  38288. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  38289. }
  38290. return oldValue.Addtime, nil
  38291. }
  38292. // AddAddtime adds u to the "addtime" field.
  38293. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  38294. if m.addaddtime != nil {
  38295. *m.addaddtime += u
  38296. } else {
  38297. m.addaddtime = &u
  38298. }
  38299. }
  38300. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  38301. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  38302. v := m.addaddtime
  38303. if v == nil {
  38304. return
  38305. }
  38306. return *v, true
  38307. }
  38308. // ResetAddtime resets all changes to the "addtime" field.
  38309. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  38310. m.addtime = nil
  38311. m.addaddtime = nil
  38312. }
  38313. // SetType sets the "type" field.
  38314. func (m *UsageStatisticMonthMutation) SetType(i int) {
  38315. m._type = &i
  38316. m.add_type = nil
  38317. }
  38318. // GetType returns the value of the "type" field in the mutation.
  38319. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  38320. v := m._type
  38321. if v == nil {
  38322. return
  38323. }
  38324. return *v, true
  38325. }
  38326. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  38327. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38329. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  38330. if !m.op.Is(OpUpdateOne) {
  38331. return v, errors.New("OldType is only allowed on UpdateOne operations")
  38332. }
  38333. if m.id == nil || m.oldValue == nil {
  38334. return v, errors.New("OldType requires an ID field in the mutation")
  38335. }
  38336. oldValue, err := m.oldValue(ctx)
  38337. if err != nil {
  38338. return v, fmt.Errorf("querying old value for OldType: %w", err)
  38339. }
  38340. return oldValue.Type, nil
  38341. }
  38342. // AddType adds i to the "type" field.
  38343. func (m *UsageStatisticMonthMutation) AddType(i int) {
  38344. if m.add_type != nil {
  38345. *m.add_type += i
  38346. } else {
  38347. m.add_type = &i
  38348. }
  38349. }
  38350. // AddedType returns the value that was added to the "type" field in this mutation.
  38351. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  38352. v := m.add_type
  38353. if v == nil {
  38354. return
  38355. }
  38356. return *v, true
  38357. }
  38358. // ResetType resets all changes to the "type" field.
  38359. func (m *UsageStatisticMonthMutation) ResetType() {
  38360. m._type = nil
  38361. m.add_type = nil
  38362. }
  38363. // SetBotID sets the "bot_id" field.
  38364. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  38365. m.bot_id = &s
  38366. }
  38367. // BotID returns the value of the "bot_id" field in the mutation.
  38368. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  38369. v := m.bot_id
  38370. if v == nil {
  38371. return
  38372. }
  38373. return *v, true
  38374. }
  38375. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  38376. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38378. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  38379. if !m.op.Is(OpUpdateOne) {
  38380. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  38381. }
  38382. if m.id == nil || m.oldValue == nil {
  38383. return v, errors.New("OldBotID requires an ID field in the mutation")
  38384. }
  38385. oldValue, err := m.oldValue(ctx)
  38386. if err != nil {
  38387. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  38388. }
  38389. return oldValue.BotID, nil
  38390. }
  38391. // ClearBotID clears the value of the "bot_id" field.
  38392. func (m *UsageStatisticMonthMutation) ClearBotID() {
  38393. m.bot_id = nil
  38394. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  38395. }
  38396. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  38397. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  38398. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  38399. return ok
  38400. }
  38401. // ResetBotID resets all changes to the "bot_id" field.
  38402. func (m *UsageStatisticMonthMutation) ResetBotID() {
  38403. m.bot_id = nil
  38404. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  38405. }
  38406. // SetOrganizationID sets the "organization_id" field.
  38407. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  38408. m.organization_id = &u
  38409. m.addorganization_id = nil
  38410. }
  38411. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38412. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  38413. v := m.organization_id
  38414. if v == nil {
  38415. return
  38416. }
  38417. return *v, true
  38418. }
  38419. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  38420. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38422. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38423. if !m.op.Is(OpUpdateOne) {
  38424. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38425. }
  38426. if m.id == nil || m.oldValue == nil {
  38427. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38428. }
  38429. oldValue, err := m.oldValue(ctx)
  38430. if err != nil {
  38431. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38432. }
  38433. return oldValue.OrganizationID, nil
  38434. }
  38435. // AddOrganizationID adds u to the "organization_id" field.
  38436. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  38437. if m.addorganization_id != nil {
  38438. *m.addorganization_id += u
  38439. } else {
  38440. m.addorganization_id = &u
  38441. }
  38442. }
  38443. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38444. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  38445. v := m.addorganization_id
  38446. if v == nil {
  38447. return
  38448. }
  38449. return *v, true
  38450. }
  38451. // ClearOrganizationID clears the value of the "organization_id" field.
  38452. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  38453. m.organization_id = nil
  38454. m.addorganization_id = nil
  38455. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  38456. }
  38457. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38458. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  38459. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  38460. return ok
  38461. }
  38462. // ResetOrganizationID resets all changes to the "organization_id" field.
  38463. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  38464. m.organization_id = nil
  38465. m.addorganization_id = nil
  38466. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  38467. }
  38468. // SetAiResponse sets the "ai_response" field.
  38469. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  38470. m.ai_response = &u
  38471. m.addai_response = nil
  38472. }
  38473. // AiResponse returns the value of the "ai_response" field in the mutation.
  38474. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  38475. v := m.ai_response
  38476. if v == nil {
  38477. return
  38478. }
  38479. return *v, true
  38480. }
  38481. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  38482. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38484. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  38485. if !m.op.Is(OpUpdateOne) {
  38486. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  38487. }
  38488. if m.id == nil || m.oldValue == nil {
  38489. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  38490. }
  38491. oldValue, err := m.oldValue(ctx)
  38492. if err != nil {
  38493. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  38494. }
  38495. return oldValue.AiResponse, nil
  38496. }
  38497. // AddAiResponse adds u to the "ai_response" field.
  38498. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  38499. if m.addai_response != nil {
  38500. *m.addai_response += u
  38501. } else {
  38502. m.addai_response = &u
  38503. }
  38504. }
  38505. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  38506. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  38507. v := m.addai_response
  38508. if v == nil {
  38509. return
  38510. }
  38511. return *v, true
  38512. }
  38513. // ResetAiResponse resets all changes to the "ai_response" field.
  38514. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  38515. m.ai_response = nil
  38516. m.addai_response = nil
  38517. }
  38518. // SetSopRun sets the "sop_run" field.
  38519. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  38520. m.sop_run = &u
  38521. m.addsop_run = nil
  38522. }
  38523. // SopRun returns the value of the "sop_run" field in the mutation.
  38524. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  38525. v := m.sop_run
  38526. if v == nil {
  38527. return
  38528. }
  38529. return *v, true
  38530. }
  38531. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  38532. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38534. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  38535. if !m.op.Is(OpUpdateOne) {
  38536. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  38537. }
  38538. if m.id == nil || m.oldValue == nil {
  38539. return v, errors.New("OldSopRun requires an ID field in the mutation")
  38540. }
  38541. oldValue, err := m.oldValue(ctx)
  38542. if err != nil {
  38543. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  38544. }
  38545. return oldValue.SopRun, nil
  38546. }
  38547. // AddSopRun adds u to the "sop_run" field.
  38548. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  38549. if m.addsop_run != nil {
  38550. *m.addsop_run += u
  38551. } else {
  38552. m.addsop_run = &u
  38553. }
  38554. }
  38555. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  38556. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  38557. v := m.addsop_run
  38558. if v == nil {
  38559. return
  38560. }
  38561. return *v, true
  38562. }
  38563. // ResetSopRun resets all changes to the "sop_run" field.
  38564. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  38565. m.sop_run = nil
  38566. m.addsop_run = nil
  38567. }
  38568. // SetTotalFriend sets the "total_friend" field.
  38569. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  38570. m.total_friend = &u
  38571. m.addtotal_friend = nil
  38572. }
  38573. // TotalFriend returns the value of the "total_friend" field in the mutation.
  38574. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  38575. v := m.total_friend
  38576. if v == nil {
  38577. return
  38578. }
  38579. return *v, true
  38580. }
  38581. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  38582. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38584. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  38585. if !m.op.Is(OpUpdateOne) {
  38586. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  38587. }
  38588. if m.id == nil || m.oldValue == nil {
  38589. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  38590. }
  38591. oldValue, err := m.oldValue(ctx)
  38592. if err != nil {
  38593. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  38594. }
  38595. return oldValue.TotalFriend, nil
  38596. }
  38597. // AddTotalFriend adds u to the "total_friend" field.
  38598. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  38599. if m.addtotal_friend != nil {
  38600. *m.addtotal_friend += u
  38601. } else {
  38602. m.addtotal_friend = &u
  38603. }
  38604. }
  38605. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  38606. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  38607. v := m.addtotal_friend
  38608. if v == nil {
  38609. return
  38610. }
  38611. return *v, true
  38612. }
  38613. // ResetTotalFriend resets all changes to the "total_friend" field.
  38614. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  38615. m.total_friend = nil
  38616. m.addtotal_friend = nil
  38617. }
  38618. // SetTotalGroup sets the "total_group" field.
  38619. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  38620. m.total_group = &u
  38621. m.addtotal_group = nil
  38622. }
  38623. // TotalGroup returns the value of the "total_group" field in the mutation.
  38624. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  38625. v := m.total_group
  38626. if v == nil {
  38627. return
  38628. }
  38629. return *v, true
  38630. }
  38631. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  38632. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38634. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  38635. if !m.op.Is(OpUpdateOne) {
  38636. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  38637. }
  38638. if m.id == nil || m.oldValue == nil {
  38639. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  38640. }
  38641. oldValue, err := m.oldValue(ctx)
  38642. if err != nil {
  38643. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  38644. }
  38645. return oldValue.TotalGroup, nil
  38646. }
  38647. // AddTotalGroup adds u to the "total_group" field.
  38648. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  38649. if m.addtotal_group != nil {
  38650. *m.addtotal_group += u
  38651. } else {
  38652. m.addtotal_group = &u
  38653. }
  38654. }
  38655. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  38656. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  38657. v := m.addtotal_group
  38658. if v == nil {
  38659. return
  38660. }
  38661. return *v, true
  38662. }
  38663. // ResetTotalGroup resets all changes to the "total_group" field.
  38664. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  38665. m.total_group = nil
  38666. m.addtotal_group = nil
  38667. }
  38668. // SetAccountBalance sets the "account_balance" field.
  38669. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  38670. m.account_balance = &u
  38671. m.addaccount_balance = nil
  38672. }
  38673. // AccountBalance returns the value of the "account_balance" field in the mutation.
  38674. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  38675. v := m.account_balance
  38676. if v == nil {
  38677. return
  38678. }
  38679. return *v, true
  38680. }
  38681. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  38682. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38684. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  38685. if !m.op.Is(OpUpdateOne) {
  38686. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  38687. }
  38688. if m.id == nil || m.oldValue == nil {
  38689. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  38690. }
  38691. oldValue, err := m.oldValue(ctx)
  38692. if err != nil {
  38693. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  38694. }
  38695. return oldValue.AccountBalance, nil
  38696. }
  38697. // AddAccountBalance adds u to the "account_balance" field.
  38698. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  38699. if m.addaccount_balance != nil {
  38700. *m.addaccount_balance += u
  38701. } else {
  38702. m.addaccount_balance = &u
  38703. }
  38704. }
  38705. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  38706. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  38707. v := m.addaccount_balance
  38708. if v == nil {
  38709. return
  38710. }
  38711. return *v, true
  38712. }
  38713. // ResetAccountBalance resets all changes to the "account_balance" field.
  38714. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  38715. m.account_balance = nil
  38716. m.addaccount_balance = nil
  38717. }
  38718. // SetConsumeToken sets the "consume_token" field.
  38719. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  38720. m.consume_token = &u
  38721. m.addconsume_token = nil
  38722. }
  38723. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  38724. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  38725. v := m.consume_token
  38726. if v == nil {
  38727. return
  38728. }
  38729. return *v, true
  38730. }
  38731. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  38732. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38734. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  38735. if !m.op.Is(OpUpdateOne) {
  38736. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  38737. }
  38738. if m.id == nil || m.oldValue == nil {
  38739. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  38740. }
  38741. oldValue, err := m.oldValue(ctx)
  38742. if err != nil {
  38743. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  38744. }
  38745. return oldValue.ConsumeToken, nil
  38746. }
  38747. // AddConsumeToken adds u to the "consume_token" field.
  38748. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  38749. if m.addconsume_token != nil {
  38750. *m.addconsume_token += u
  38751. } else {
  38752. m.addconsume_token = &u
  38753. }
  38754. }
  38755. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  38756. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  38757. v := m.addconsume_token
  38758. if v == nil {
  38759. return
  38760. }
  38761. return *v, true
  38762. }
  38763. // ResetConsumeToken resets all changes to the "consume_token" field.
  38764. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  38765. m.consume_token = nil
  38766. m.addconsume_token = nil
  38767. }
  38768. // SetActiveUser sets the "active_user" field.
  38769. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  38770. m.active_user = &u
  38771. m.addactive_user = nil
  38772. }
  38773. // ActiveUser returns the value of the "active_user" field in the mutation.
  38774. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  38775. v := m.active_user
  38776. if v == nil {
  38777. return
  38778. }
  38779. return *v, true
  38780. }
  38781. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  38782. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38784. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  38785. if !m.op.Is(OpUpdateOne) {
  38786. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  38787. }
  38788. if m.id == nil || m.oldValue == nil {
  38789. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  38790. }
  38791. oldValue, err := m.oldValue(ctx)
  38792. if err != nil {
  38793. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  38794. }
  38795. return oldValue.ActiveUser, nil
  38796. }
  38797. // AddActiveUser adds u to the "active_user" field.
  38798. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  38799. if m.addactive_user != nil {
  38800. *m.addactive_user += u
  38801. } else {
  38802. m.addactive_user = &u
  38803. }
  38804. }
  38805. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  38806. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  38807. v := m.addactive_user
  38808. if v == nil {
  38809. return
  38810. }
  38811. return *v, true
  38812. }
  38813. // ResetActiveUser resets all changes to the "active_user" field.
  38814. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  38815. m.active_user = nil
  38816. m.addactive_user = nil
  38817. }
  38818. // SetNewUser sets the "new_user" field.
  38819. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  38820. m.new_user = &i
  38821. m.addnew_user = nil
  38822. }
  38823. // NewUser returns the value of the "new_user" field in the mutation.
  38824. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  38825. v := m.new_user
  38826. if v == nil {
  38827. return
  38828. }
  38829. return *v, true
  38830. }
  38831. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  38832. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38834. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  38835. if !m.op.Is(OpUpdateOne) {
  38836. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  38837. }
  38838. if m.id == nil || m.oldValue == nil {
  38839. return v, errors.New("OldNewUser requires an ID field in the mutation")
  38840. }
  38841. oldValue, err := m.oldValue(ctx)
  38842. if err != nil {
  38843. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  38844. }
  38845. return oldValue.NewUser, nil
  38846. }
  38847. // AddNewUser adds i to the "new_user" field.
  38848. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  38849. if m.addnew_user != nil {
  38850. *m.addnew_user += i
  38851. } else {
  38852. m.addnew_user = &i
  38853. }
  38854. }
  38855. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  38856. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  38857. v := m.addnew_user
  38858. if v == nil {
  38859. return
  38860. }
  38861. return *v, true
  38862. }
  38863. // ResetNewUser resets all changes to the "new_user" field.
  38864. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  38865. m.new_user = nil
  38866. m.addnew_user = nil
  38867. }
  38868. // SetLabelDist sets the "label_dist" field.
  38869. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  38870. m.label_dist = &ctd
  38871. m.appendlabel_dist = nil
  38872. }
  38873. // LabelDist returns the value of the "label_dist" field in the mutation.
  38874. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  38875. v := m.label_dist
  38876. if v == nil {
  38877. return
  38878. }
  38879. return *v, true
  38880. }
  38881. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  38882. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38884. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  38885. if !m.op.Is(OpUpdateOne) {
  38886. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  38887. }
  38888. if m.id == nil || m.oldValue == nil {
  38889. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  38890. }
  38891. oldValue, err := m.oldValue(ctx)
  38892. if err != nil {
  38893. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  38894. }
  38895. return oldValue.LabelDist, nil
  38896. }
  38897. // AppendLabelDist adds ctd to the "label_dist" field.
  38898. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  38899. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  38900. }
  38901. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  38902. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  38903. if len(m.appendlabel_dist) == 0 {
  38904. return nil, false
  38905. }
  38906. return m.appendlabel_dist, true
  38907. }
  38908. // ResetLabelDist resets all changes to the "label_dist" field.
  38909. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  38910. m.label_dist = nil
  38911. m.appendlabel_dist = nil
  38912. }
  38913. // SetConsumeCoin sets the "consume_coin" field.
  38914. func (m *UsageStatisticMonthMutation) SetConsumeCoin(f float64) {
  38915. m.consume_coin = &f
  38916. m.addconsume_coin = nil
  38917. }
  38918. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  38919. func (m *UsageStatisticMonthMutation) ConsumeCoin() (r float64, exists bool) {
  38920. v := m.consume_coin
  38921. if v == nil {
  38922. return
  38923. }
  38924. return *v, true
  38925. }
  38926. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticMonth entity.
  38927. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38929. func (m *UsageStatisticMonthMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  38930. if !m.op.Is(OpUpdateOne) {
  38931. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  38932. }
  38933. if m.id == nil || m.oldValue == nil {
  38934. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  38935. }
  38936. oldValue, err := m.oldValue(ctx)
  38937. if err != nil {
  38938. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  38939. }
  38940. return oldValue.ConsumeCoin, nil
  38941. }
  38942. // AddConsumeCoin adds f to the "consume_coin" field.
  38943. func (m *UsageStatisticMonthMutation) AddConsumeCoin(f float64) {
  38944. if m.addconsume_coin != nil {
  38945. *m.addconsume_coin += f
  38946. } else {
  38947. m.addconsume_coin = &f
  38948. }
  38949. }
  38950. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  38951. func (m *UsageStatisticMonthMutation) AddedConsumeCoin() (r float64, exists bool) {
  38952. v := m.addconsume_coin
  38953. if v == nil {
  38954. return
  38955. }
  38956. return *v, true
  38957. }
  38958. // ClearConsumeCoin clears the value of the "consume_coin" field.
  38959. func (m *UsageStatisticMonthMutation) ClearConsumeCoin() {
  38960. m.consume_coin = nil
  38961. m.addconsume_coin = nil
  38962. m.clearedFields[usagestatisticmonth.FieldConsumeCoin] = struct{}{}
  38963. }
  38964. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  38965. func (m *UsageStatisticMonthMutation) ConsumeCoinCleared() bool {
  38966. _, ok := m.clearedFields[usagestatisticmonth.FieldConsumeCoin]
  38967. return ok
  38968. }
  38969. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  38970. func (m *UsageStatisticMonthMutation) ResetConsumeCoin() {
  38971. m.consume_coin = nil
  38972. m.addconsume_coin = nil
  38973. delete(m.clearedFields, usagestatisticmonth.FieldConsumeCoin)
  38974. }
  38975. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  38976. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  38977. m.predicates = append(m.predicates, ps...)
  38978. }
  38979. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  38980. // users can use type-assertion to append predicates that do not depend on any generated package.
  38981. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  38982. p := make([]predicate.UsageStatisticMonth, len(ps))
  38983. for i := range ps {
  38984. p[i] = ps[i]
  38985. }
  38986. m.Where(p...)
  38987. }
  38988. // Op returns the operation name.
  38989. func (m *UsageStatisticMonthMutation) Op() Op {
  38990. return m.op
  38991. }
  38992. // SetOp allows setting the mutation operation.
  38993. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  38994. m.op = op
  38995. }
  38996. // Type returns the node type of this mutation (UsageStatisticMonth).
  38997. func (m *UsageStatisticMonthMutation) Type() string {
  38998. return m.typ
  38999. }
  39000. // Fields returns all fields that were changed during this mutation. Note that in
  39001. // order to get all numeric fields that were incremented/decremented, call
  39002. // AddedFields().
  39003. func (m *UsageStatisticMonthMutation) Fields() []string {
  39004. fields := make([]string, 0, 18)
  39005. if m.created_at != nil {
  39006. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  39007. }
  39008. if m.updated_at != nil {
  39009. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  39010. }
  39011. if m.status != nil {
  39012. fields = append(fields, usagestatisticmonth.FieldStatus)
  39013. }
  39014. if m.deleted_at != nil {
  39015. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  39016. }
  39017. if m.addtime != nil {
  39018. fields = append(fields, usagestatisticmonth.FieldAddtime)
  39019. }
  39020. if m._type != nil {
  39021. fields = append(fields, usagestatisticmonth.FieldType)
  39022. }
  39023. if m.bot_id != nil {
  39024. fields = append(fields, usagestatisticmonth.FieldBotID)
  39025. }
  39026. if m.organization_id != nil {
  39027. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  39028. }
  39029. if m.ai_response != nil {
  39030. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  39031. }
  39032. if m.sop_run != nil {
  39033. fields = append(fields, usagestatisticmonth.FieldSopRun)
  39034. }
  39035. if m.total_friend != nil {
  39036. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  39037. }
  39038. if m.total_group != nil {
  39039. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  39040. }
  39041. if m.account_balance != nil {
  39042. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  39043. }
  39044. if m.consume_token != nil {
  39045. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  39046. }
  39047. if m.active_user != nil {
  39048. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  39049. }
  39050. if m.new_user != nil {
  39051. fields = append(fields, usagestatisticmonth.FieldNewUser)
  39052. }
  39053. if m.label_dist != nil {
  39054. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  39055. }
  39056. if m.consume_coin != nil {
  39057. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  39058. }
  39059. return fields
  39060. }
  39061. // Field returns the value of a field with the given name. The second boolean
  39062. // return value indicates that this field was not set, or was not defined in the
  39063. // schema.
  39064. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  39065. switch name {
  39066. case usagestatisticmonth.FieldCreatedAt:
  39067. return m.CreatedAt()
  39068. case usagestatisticmonth.FieldUpdatedAt:
  39069. return m.UpdatedAt()
  39070. case usagestatisticmonth.FieldStatus:
  39071. return m.Status()
  39072. case usagestatisticmonth.FieldDeletedAt:
  39073. return m.DeletedAt()
  39074. case usagestatisticmonth.FieldAddtime:
  39075. return m.Addtime()
  39076. case usagestatisticmonth.FieldType:
  39077. return m.GetType()
  39078. case usagestatisticmonth.FieldBotID:
  39079. return m.BotID()
  39080. case usagestatisticmonth.FieldOrganizationID:
  39081. return m.OrganizationID()
  39082. case usagestatisticmonth.FieldAiResponse:
  39083. return m.AiResponse()
  39084. case usagestatisticmonth.FieldSopRun:
  39085. return m.SopRun()
  39086. case usagestatisticmonth.FieldTotalFriend:
  39087. return m.TotalFriend()
  39088. case usagestatisticmonth.FieldTotalGroup:
  39089. return m.TotalGroup()
  39090. case usagestatisticmonth.FieldAccountBalance:
  39091. return m.AccountBalance()
  39092. case usagestatisticmonth.FieldConsumeToken:
  39093. return m.ConsumeToken()
  39094. case usagestatisticmonth.FieldActiveUser:
  39095. return m.ActiveUser()
  39096. case usagestatisticmonth.FieldNewUser:
  39097. return m.NewUser()
  39098. case usagestatisticmonth.FieldLabelDist:
  39099. return m.LabelDist()
  39100. case usagestatisticmonth.FieldConsumeCoin:
  39101. return m.ConsumeCoin()
  39102. }
  39103. return nil, false
  39104. }
  39105. // OldField returns the old value of the field from the database. An error is
  39106. // returned if the mutation operation is not UpdateOne, or the query to the
  39107. // database failed.
  39108. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39109. switch name {
  39110. case usagestatisticmonth.FieldCreatedAt:
  39111. return m.OldCreatedAt(ctx)
  39112. case usagestatisticmonth.FieldUpdatedAt:
  39113. return m.OldUpdatedAt(ctx)
  39114. case usagestatisticmonth.FieldStatus:
  39115. return m.OldStatus(ctx)
  39116. case usagestatisticmonth.FieldDeletedAt:
  39117. return m.OldDeletedAt(ctx)
  39118. case usagestatisticmonth.FieldAddtime:
  39119. return m.OldAddtime(ctx)
  39120. case usagestatisticmonth.FieldType:
  39121. return m.OldType(ctx)
  39122. case usagestatisticmonth.FieldBotID:
  39123. return m.OldBotID(ctx)
  39124. case usagestatisticmonth.FieldOrganizationID:
  39125. return m.OldOrganizationID(ctx)
  39126. case usagestatisticmonth.FieldAiResponse:
  39127. return m.OldAiResponse(ctx)
  39128. case usagestatisticmonth.FieldSopRun:
  39129. return m.OldSopRun(ctx)
  39130. case usagestatisticmonth.FieldTotalFriend:
  39131. return m.OldTotalFriend(ctx)
  39132. case usagestatisticmonth.FieldTotalGroup:
  39133. return m.OldTotalGroup(ctx)
  39134. case usagestatisticmonth.FieldAccountBalance:
  39135. return m.OldAccountBalance(ctx)
  39136. case usagestatisticmonth.FieldConsumeToken:
  39137. return m.OldConsumeToken(ctx)
  39138. case usagestatisticmonth.FieldActiveUser:
  39139. return m.OldActiveUser(ctx)
  39140. case usagestatisticmonth.FieldNewUser:
  39141. return m.OldNewUser(ctx)
  39142. case usagestatisticmonth.FieldLabelDist:
  39143. return m.OldLabelDist(ctx)
  39144. case usagestatisticmonth.FieldConsumeCoin:
  39145. return m.OldConsumeCoin(ctx)
  39146. }
  39147. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  39148. }
  39149. // SetField sets the value of a field with the given name. It returns an error if
  39150. // the field is not defined in the schema, or if the type mismatched the field
  39151. // type.
  39152. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  39153. switch name {
  39154. case usagestatisticmonth.FieldCreatedAt:
  39155. v, ok := value.(time.Time)
  39156. if !ok {
  39157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39158. }
  39159. m.SetCreatedAt(v)
  39160. return nil
  39161. case usagestatisticmonth.FieldUpdatedAt:
  39162. v, ok := value.(time.Time)
  39163. if !ok {
  39164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39165. }
  39166. m.SetUpdatedAt(v)
  39167. return nil
  39168. case usagestatisticmonth.FieldStatus:
  39169. v, ok := value.(uint8)
  39170. if !ok {
  39171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39172. }
  39173. m.SetStatus(v)
  39174. return nil
  39175. case usagestatisticmonth.FieldDeletedAt:
  39176. v, ok := value.(time.Time)
  39177. if !ok {
  39178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39179. }
  39180. m.SetDeletedAt(v)
  39181. return nil
  39182. case usagestatisticmonth.FieldAddtime:
  39183. v, ok := value.(uint64)
  39184. if !ok {
  39185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39186. }
  39187. m.SetAddtime(v)
  39188. return nil
  39189. case usagestatisticmonth.FieldType:
  39190. v, ok := value.(int)
  39191. if !ok {
  39192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39193. }
  39194. m.SetType(v)
  39195. return nil
  39196. case usagestatisticmonth.FieldBotID:
  39197. v, ok := value.(string)
  39198. if !ok {
  39199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39200. }
  39201. m.SetBotID(v)
  39202. return nil
  39203. case usagestatisticmonth.FieldOrganizationID:
  39204. v, ok := value.(uint64)
  39205. if !ok {
  39206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39207. }
  39208. m.SetOrganizationID(v)
  39209. return nil
  39210. case usagestatisticmonth.FieldAiResponse:
  39211. v, ok := value.(uint64)
  39212. if !ok {
  39213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39214. }
  39215. m.SetAiResponse(v)
  39216. return nil
  39217. case usagestatisticmonth.FieldSopRun:
  39218. v, ok := value.(uint64)
  39219. if !ok {
  39220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39221. }
  39222. m.SetSopRun(v)
  39223. return nil
  39224. case usagestatisticmonth.FieldTotalFriend:
  39225. v, ok := value.(uint64)
  39226. if !ok {
  39227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39228. }
  39229. m.SetTotalFriend(v)
  39230. return nil
  39231. case usagestatisticmonth.FieldTotalGroup:
  39232. v, ok := value.(uint64)
  39233. if !ok {
  39234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39235. }
  39236. m.SetTotalGroup(v)
  39237. return nil
  39238. case usagestatisticmonth.FieldAccountBalance:
  39239. v, ok := value.(uint64)
  39240. if !ok {
  39241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39242. }
  39243. m.SetAccountBalance(v)
  39244. return nil
  39245. case usagestatisticmonth.FieldConsumeToken:
  39246. v, ok := value.(uint64)
  39247. if !ok {
  39248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39249. }
  39250. m.SetConsumeToken(v)
  39251. return nil
  39252. case usagestatisticmonth.FieldActiveUser:
  39253. v, ok := value.(uint64)
  39254. if !ok {
  39255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39256. }
  39257. m.SetActiveUser(v)
  39258. return nil
  39259. case usagestatisticmonth.FieldNewUser:
  39260. v, ok := value.(int64)
  39261. if !ok {
  39262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39263. }
  39264. m.SetNewUser(v)
  39265. return nil
  39266. case usagestatisticmonth.FieldLabelDist:
  39267. v, ok := value.([]custom_types.LabelDist)
  39268. if !ok {
  39269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39270. }
  39271. m.SetLabelDist(v)
  39272. return nil
  39273. case usagestatisticmonth.FieldConsumeCoin:
  39274. v, ok := value.(float64)
  39275. if !ok {
  39276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39277. }
  39278. m.SetConsumeCoin(v)
  39279. return nil
  39280. }
  39281. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  39282. }
  39283. // AddedFields returns all numeric fields that were incremented/decremented during
  39284. // this mutation.
  39285. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  39286. var fields []string
  39287. if m.addstatus != nil {
  39288. fields = append(fields, usagestatisticmonth.FieldStatus)
  39289. }
  39290. if m.addaddtime != nil {
  39291. fields = append(fields, usagestatisticmonth.FieldAddtime)
  39292. }
  39293. if m.add_type != nil {
  39294. fields = append(fields, usagestatisticmonth.FieldType)
  39295. }
  39296. if m.addorganization_id != nil {
  39297. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  39298. }
  39299. if m.addai_response != nil {
  39300. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  39301. }
  39302. if m.addsop_run != nil {
  39303. fields = append(fields, usagestatisticmonth.FieldSopRun)
  39304. }
  39305. if m.addtotal_friend != nil {
  39306. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  39307. }
  39308. if m.addtotal_group != nil {
  39309. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  39310. }
  39311. if m.addaccount_balance != nil {
  39312. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  39313. }
  39314. if m.addconsume_token != nil {
  39315. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  39316. }
  39317. if m.addactive_user != nil {
  39318. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  39319. }
  39320. if m.addnew_user != nil {
  39321. fields = append(fields, usagestatisticmonth.FieldNewUser)
  39322. }
  39323. if m.addconsume_coin != nil {
  39324. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  39325. }
  39326. return fields
  39327. }
  39328. // AddedField returns the numeric value that was incremented/decremented on a field
  39329. // with the given name. The second boolean return value indicates that this field
  39330. // was not set, or was not defined in the schema.
  39331. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  39332. switch name {
  39333. case usagestatisticmonth.FieldStatus:
  39334. return m.AddedStatus()
  39335. case usagestatisticmonth.FieldAddtime:
  39336. return m.AddedAddtime()
  39337. case usagestatisticmonth.FieldType:
  39338. return m.AddedType()
  39339. case usagestatisticmonth.FieldOrganizationID:
  39340. return m.AddedOrganizationID()
  39341. case usagestatisticmonth.FieldAiResponse:
  39342. return m.AddedAiResponse()
  39343. case usagestatisticmonth.FieldSopRun:
  39344. return m.AddedSopRun()
  39345. case usagestatisticmonth.FieldTotalFriend:
  39346. return m.AddedTotalFriend()
  39347. case usagestatisticmonth.FieldTotalGroup:
  39348. return m.AddedTotalGroup()
  39349. case usagestatisticmonth.FieldAccountBalance:
  39350. return m.AddedAccountBalance()
  39351. case usagestatisticmonth.FieldConsumeToken:
  39352. return m.AddedConsumeToken()
  39353. case usagestatisticmonth.FieldActiveUser:
  39354. return m.AddedActiveUser()
  39355. case usagestatisticmonth.FieldNewUser:
  39356. return m.AddedNewUser()
  39357. case usagestatisticmonth.FieldConsumeCoin:
  39358. return m.AddedConsumeCoin()
  39359. }
  39360. return nil, false
  39361. }
  39362. // AddField adds the value to the field with the given name. It returns an error if
  39363. // the field is not defined in the schema, or if the type mismatched the field
  39364. // type.
  39365. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  39366. switch name {
  39367. case usagestatisticmonth.FieldStatus:
  39368. v, ok := value.(int8)
  39369. if !ok {
  39370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39371. }
  39372. m.AddStatus(v)
  39373. return nil
  39374. case usagestatisticmonth.FieldAddtime:
  39375. v, ok := value.(int64)
  39376. if !ok {
  39377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39378. }
  39379. m.AddAddtime(v)
  39380. return nil
  39381. case usagestatisticmonth.FieldType:
  39382. v, ok := value.(int)
  39383. if !ok {
  39384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39385. }
  39386. m.AddType(v)
  39387. return nil
  39388. case usagestatisticmonth.FieldOrganizationID:
  39389. v, ok := value.(int64)
  39390. if !ok {
  39391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39392. }
  39393. m.AddOrganizationID(v)
  39394. return nil
  39395. case usagestatisticmonth.FieldAiResponse:
  39396. v, ok := value.(int64)
  39397. if !ok {
  39398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39399. }
  39400. m.AddAiResponse(v)
  39401. return nil
  39402. case usagestatisticmonth.FieldSopRun:
  39403. v, ok := value.(int64)
  39404. if !ok {
  39405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39406. }
  39407. m.AddSopRun(v)
  39408. return nil
  39409. case usagestatisticmonth.FieldTotalFriend:
  39410. v, ok := value.(int64)
  39411. if !ok {
  39412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39413. }
  39414. m.AddTotalFriend(v)
  39415. return nil
  39416. case usagestatisticmonth.FieldTotalGroup:
  39417. v, ok := value.(int64)
  39418. if !ok {
  39419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39420. }
  39421. m.AddTotalGroup(v)
  39422. return nil
  39423. case usagestatisticmonth.FieldAccountBalance:
  39424. v, ok := value.(int64)
  39425. if !ok {
  39426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39427. }
  39428. m.AddAccountBalance(v)
  39429. return nil
  39430. case usagestatisticmonth.FieldConsumeToken:
  39431. v, ok := value.(int64)
  39432. if !ok {
  39433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39434. }
  39435. m.AddConsumeToken(v)
  39436. return nil
  39437. case usagestatisticmonth.FieldActiveUser:
  39438. v, ok := value.(int64)
  39439. if !ok {
  39440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39441. }
  39442. m.AddActiveUser(v)
  39443. return nil
  39444. case usagestatisticmonth.FieldNewUser:
  39445. v, ok := value.(int64)
  39446. if !ok {
  39447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39448. }
  39449. m.AddNewUser(v)
  39450. return nil
  39451. case usagestatisticmonth.FieldConsumeCoin:
  39452. v, ok := value.(float64)
  39453. if !ok {
  39454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39455. }
  39456. m.AddConsumeCoin(v)
  39457. return nil
  39458. }
  39459. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  39460. }
  39461. // ClearedFields returns all nullable fields that were cleared during this
  39462. // mutation.
  39463. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  39464. var fields []string
  39465. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  39466. fields = append(fields, usagestatisticmonth.FieldStatus)
  39467. }
  39468. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  39469. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  39470. }
  39471. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  39472. fields = append(fields, usagestatisticmonth.FieldBotID)
  39473. }
  39474. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  39475. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  39476. }
  39477. if m.FieldCleared(usagestatisticmonth.FieldConsumeCoin) {
  39478. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  39479. }
  39480. return fields
  39481. }
  39482. // FieldCleared returns a boolean indicating if a field with the given name was
  39483. // cleared in this mutation.
  39484. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  39485. _, ok := m.clearedFields[name]
  39486. return ok
  39487. }
  39488. // ClearField clears the value of the field with the given name. It returns an
  39489. // error if the field is not defined in the schema.
  39490. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  39491. switch name {
  39492. case usagestatisticmonth.FieldStatus:
  39493. m.ClearStatus()
  39494. return nil
  39495. case usagestatisticmonth.FieldDeletedAt:
  39496. m.ClearDeletedAt()
  39497. return nil
  39498. case usagestatisticmonth.FieldBotID:
  39499. m.ClearBotID()
  39500. return nil
  39501. case usagestatisticmonth.FieldOrganizationID:
  39502. m.ClearOrganizationID()
  39503. return nil
  39504. case usagestatisticmonth.FieldConsumeCoin:
  39505. m.ClearConsumeCoin()
  39506. return nil
  39507. }
  39508. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  39509. }
  39510. // ResetField resets all changes in the mutation for the field with the given name.
  39511. // It returns an error if the field is not defined in the schema.
  39512. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  39513. switch name {
  39514. case usagestatisticmonth.FieldCreatedAt:
  39515. m.ResetCreatedAt()
  39516. return nil
  39517. case usagestatisticmonth.FieldUpdatedAt:
  39518. m.ResetUpdatedAt()
  39519. return nil
  39520. case usagestatisticmonth.FieldStatus:
  39521. m.ResetStatus()
  39522. return nil
  39523. case usagestatisticmonth.FieldDeletedAt:
  39524. m.ResetDeletedAt()
  39525. return nil
  39526. case usagestatisticmonth.FieldAddtime:
  39527. m.ResetAddtime()
  39528. return nil
  39529. case usagestatisticmonth.FieldType:
  39530. m.ResetType()
  39531. return nil
  39532. case usagestatisticmonth.FieldBotID:
  39533. m.ResetBotID()
  39534. return nil
  39535. case usagestatisticmonth.FieldOrganizationID:
  39536. m.ResetOrganizationID()
  39537. return nil
  39538. case usagestatisticmonth.FieldAiResponse:
  39539. m.ResetAiResponse()
  39540. return nil
  39541. case usagestatisticmonth.FieldSopRun:
  39542. m.ResetSopRun()
  39543. return nil
  39544. case usagestatisticmonth.FieldTotalFriend:
  39545. m.ResetTotalFriend()
  39546. return nil
  39547. case usagestatisticmonth.FieldTotalGroup:
  39548. m.ResetTotalGroup()
  39549. return nil
  39550. case usagestatisticmonth.FieldAccountBalance:
  39551. m.ResetAccountBalance()
  39552. return nil
  39553. case usagestatisticmonth.FieldConsumeToken:
  39554. m.ResetConsumeToken()
  39555. return nil
  39556. case usagestatisticmonth.FieldActiveUser:
  39557. m.ResetActiveUser()
  39558. return nil
  39559. case usagestatisticmonth.FieldNewUser:
  39560. m.ResetNewUser()
  39561. return nil
  39562. case usagestatisticmonth.FieldLabelDist:
  39563. m.ResetLabelDist()
  39564. return nil
  39565. case usagestatisticmonth.FieldConsumeCoin:
  39566. m.ResetConsumeCoin()
  39567. return nil
  39568. }
  39569. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  39570. }
  39571. // AddedEdges returns all edge names that were set/added in this mutation.
  39572. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  39573. edges := make([]string, 0, 0)
  39574. return edges
  39575. }
  39576. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39577. // name in this mutation.
  39578. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  39579. return nil
  39580. }
  39581. // RemovedEdges returns all edge names that were removed in this mutation.
  39582. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  39583. edges := make([]string, 0, 0)
  39584. return edges
  39585. }
  39586. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39587. // the given name in this mutation.
  39588. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  39589. return nil
  39590. }
  39591. // ClearedEdges returns all edge names that were cleared in this mutation.
  39592. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  39593. edges := make([]string, 0, 0)
  39594. return edges
  39595. }
  39596. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39597. // was cleared in this mutation.
  39598. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  39599. return false
  39600. }
  39601. // ClearEdge clears the value of the edge with the given name. It returns an error
  39602. // if that edge is not defined in the schema.
  39603. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  39604. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  39605. }
  39606. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39607. // It returns an error if the edge is not defined in the schema.
  39608. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  39609. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  39610. }
  39611. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  39612. type UsageTotalMutation struct {
  39613. config
  39614. op Op
  39615. typ string
  39616. id *uint64
  39617. created_at *time.Time
  39618. updated_at *time.Time
  39619. status *uint8
  39620. addstatus *int8
  39621. _type *int
  39622. add_type *int
  39623. bot_id *string
  39624. total_tokens *uint64
  39625. addtotal_tokens *int64
  39626. start_index *uint64
  39627. addstart_index *int64
  39628. end_index *uint64
  39629. addend_index *int64
  39630. organization_id *uint64
  39631. addorganization_id *int64
  39632. clearedFields map[string]struct{}
  39633. done bool
  39634. oldValue func(context.Context) (*UsageTotal, error)
  39635. predicates []predicate.UsageTotal
  39636. }
  39637. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  39638. // usagetotalOption allows management of the mutation configuration using functional options.
  39639. type usagetotalOption func(*UsageTotalMutation)
  39640. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  39641. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  39642. m := &UsageTotalMutation{
  39643. config: c,
  39644. op: op,
  39645. typ: TypeUsageTotal,
  39646. clearedFields: make(map[string]struct{}),
  39647. }
  39648. for _, opt := range opts {
  39649. opt(m)
  39650. }
  39651. return m
  39652. }
  39653. // withUsageTotalID sets the ID field of the mutation.
  39654. func withUsageTotalID(id uint64) usagetotalOption {
  39655. return func(m *UsageTotalMutation) {
  39656. var (
  39657. err error
  39658. once sync.Once
  39659. value *UsageTotal
  39660. )
  39661. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  39662. once.Do(func() {
  39663. if m.done {
  39664. err = errors.New("querying old values post mutation is not allowed")
  39665. } else {
  39666. value, err = m.Client().UsageTotal.Get(ctx, id)
  39667. }
  39668. })
  39669. return value, err
  39670. }
  39671. m.id = &id
  39672. }
  39673. }
  39674. // withUsageTotal sets the old UsageTotal of the mutation.
  39675. func withUsageTotal(node *UsageTotal) usagetotalOption {
  39676. return func(m *UsageTotalMutation) {
  39677. m.oldValue = func(context.Context) (*UsageTotal, error) {
  39678. return node, nil
  39679. }
  39680. m.id = &node.ID
  39681. }
  39682. }
  39683. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39684. // executed in a transaction (ent.Tx), a transactional client is returned.
  39685. func (m UsageTotalMutation) Client() *Client {
  39686. client := &Client{config: m.config}
  39687. client.init()
  39688. return client
  39689. }
  39690. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39691. // it returns an error otherwise.
  39692. func (m UsageTotalMutation) Tx() (*Tx, error) {
  39693. if _, ok := m.driver.(*txDriver); !ok {
  39694. return nil, errors.New("ent: mutation is not running in a transaction")
  39695. }
  39696. tx := &Tx{config: m.config}
  39697. tx.init()
  39698. return tx, nil
  39699. }
  39700. // SetID sets the value of the id field. Note that this
  39701. // operation is only accepted on creation of UsageTotal entities.
  39702. func (m *UsageTotalMutation) SetID(id uint64) {
  39703. m.id = &id
  39704. }
  39705. // ID returns the ID value in the mutation. Note that the ID is only available
  39706. // if it was provided to the builder or after it was returned from the database.
  39707. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  39708. if m.id == nil {
  39709. return
  39710. }
  39711. return *m.id, true
  39712. }
  39713. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39714. // That means, if the mutation is applied within a transaction with an isolation level such
  39715. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39716. // or updated by the mutation.
  39717. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  39718. switch {
  39719. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39720. id, exists := m.ID()
  39721. if exists {
  39722. return []uint64{id}, nil
  39723. }
  39724. fallthrough
  39725. case m.op.Is(OpUpdate | OpDelete):
  39726. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  39727. default:
  39728. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39729. }
  39730. }
  39731. // SetCreatedAt sets the "created_at" field.
  39732. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  39733. m.created_at = &t
  39734. }
  39735. // CreatedAt returns the value of the "created_at" field in the mutation.
  39736. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  39737. v := m.created_at
  39738. if v == nil {
  39739. return
  39740. }
  39741. return *v, true
  39742. }
  39743. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  39744. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39746. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39747. if !m.op.Is(OpUpdateOne) {
  39748. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39749. }
  39750. if m.id == nil || m.oldValue == nil {
  39751. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39752. }
  39753. oldValue, err := m.oldValue(ctx)
  39754. if err != nil {
  39755. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39756. }
  39757. return oldValue.CreatedAt, nil
  39758. }
  39759. // ResetCreatedAt resets all changes to the "created_at" field.
  39760. func (m *UsageTotalMutation) ResetCreatedAt() {
  39761. m.created_at = nil
  39762. }
  39763. // SetUpdatedAt sets the "updated_at" field.
  39764. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  39765. m.updated_at = &t
  39766. }
  39767. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39768. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  39769. v := m.updated_at
  39770. if v == nil {
  39771. return
  39772. }
  39773. return *v, true
  39774. }
  39775. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  39776. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39778. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39779. if !m.op.Is(OpUpdateOne) {
  39780. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39781. }
  39782. if m.id == nil || m.oldValue == nil {
  39783. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39784. }
  39785. oldValue, err := m.oldValue(ctx)
  39786. if err != nil {
  39787. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39788. }
  39789. return oldValue.UpdatedAt, nil
  39790. }
  39791. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39792. func (m *UsageTotalMutation) ResetUpdatedAt() {
  39793. m.updated_at = nil
  39794. }
  39795. // SetStatus sets the "status" field.
  39796. func (m *UsageTotalMutation) SetStatus(u uint8) {
  39797. m.status = &u
  39798. m.addstatus = nil
  39799. }
  39800. // Status returns the value of the "status" field in the mutation.
  39801. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  39802. v := m.status
  39803. if v == nil {
  39804. return
  39805. }
  39806. return *v, true
  39807. }
  39808. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  39809. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39811. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39812. if !m.op.Is(OpUpdateOne) {
  39813. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39814. }
  39815. if m.id == nil || m.oldValue == nil {
  39816. return v, errors.New("OldStatus requires an ID field in the mutation")
  39817. }
  39818. oldValue, err := m.oldValue(ctx)
  39819. if err != nil {
  39820. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39821. }
  39822. return oldValue.Status, nil
  39823. }
  39824. // AddStatus adds u to the "status" field.
  39825. func (m *UsageTotalMutation) AddStatus(u int8) {
  39826. if m.addstatus != nil {
  39827. *m.addstatus += u
  39828. } else {
  39829. m.addstatus = &u
  39830. }
  39831. }
  39832. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39833. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  39834. v := m.addstatus
  39835. if v == nil {
  39836. return
  39837. }
  39838. return *v, true
  39839. }
  39840. // ClearStatus clears the value of the "status" field.
  39841. func (m *UsageTotalMutation) ClearStatus() {
  39842. m.status = nil
  39843. m.addstatus = nil
  39844. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  39845. }
  39846. // StatusCleared returns if the "status" field was cleared in this mutation.
  39847. func (m *UsageTotalMutation) StatusCleared() bool {
  39848. _, ok := m.clearedFields[usagetotal.FieldStatus]
  39849. return ok
  39850. }
  39851. // ResetStatus resets all changes to the "status" field.
  39852. func (m *UsageTotalMutation) ResetStatus() {
  39853. m.status = nil
  39854. m.addstatus = nil
  39855. delete(m.clearedFields, usagetotal.FieldStatus)
  39856. }
  39857. // SetType sets the "type" field.
  39858. func (m *UsageTotalMutation) SetType(i int) {
  39859. m._type = &i
  39860. m.add_type = nil
  39861. }
  39862. // GetType returns the value of the "type" field in the mutation.
  39863. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  39864. v := m._type
  39865. if v == nil {
  39866. return
  39867. }
  39868. return *v, true
  39869. }
  39870. // OldType returns the old "type" field's value of the UsageTotal entity.
  39871. // If the UsageTotal 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 *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  39874. if !m.op.Is(OpUpdateOne) {
  39875. return v, errors.New("OldType is only allowed on UpdateOne operations")
  39876. }
  39877. if m.id == nil || m.oldValue == nil {
  39878. return v, errors.New("OldType 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 OldType: %w", err)
  39883. }
  39884. return oldValue.Type, nil
  39885. }
  39886. // AddType adds i to the "type" field.
  39887. func (m *UsageTotalMutation) AddType(i int) {
  39888. if m.add_type != nil {
  39889. *m.add_type += i
  39890. } else {
  39891. m.add_type = &i
  39892. }
  39893. }
  39894. // AddedType returns the value that was added to the "type" field in this mutation.
  39895. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  39896. v := m.add_type
  39897. if v == nil {
  39898. return
  39899. }
  39900. return *v, true
  39901. }
  39902. // ClearType clears the value of the "type" field.
  39903. func (m *UsageTotalMutation) ClearType() {
  39904. m._type = nil
  39905. m.add_type = nil
  39906. m.clearedFields[usagetotal.FieldType] = struct{}{}
  39907. }
  39908. // TypeCleared returns if the "type" field was cleared in this mutation.
  39909. func (m *UsageTotalMutation) TypeCleared() bool {
  39910. _, ok := m.clearedFields[usagetotal.FieldType]
  39911. return ok
  39912. }
  39913. // ResetType resets all changes to the "type" field.
  39914. func (m *UsageTotalMutation) ResetType() {
  39915. m._type = nil
  39916. m.add_type = nil
  39917. delete(m.clearedFields, usagetotal.FieldType)
  39918. }
  39919. // SetBotID sets the "bot_id" field.
  39920. func (m *UsageTotalMutation) SetBotID(s string) {
  39921. m.bot_id = &s
  39922. }
  39923. // BotID returns the value of the "bot_id" field in the mutation.
  39924. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  39925. v := m.bot_id
  39926. if v == nil {
  39927. return
  39928. }
  39929. return *v, true
  39930. }
  39931. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  39932. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39934. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  39935. if !m.op.Is(OpUpdateOne) {
  39936. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  39937. }
  39938. if m.id == nil || m.oldValue == nil {
  39939. return v, errors.New("OldBotID requires an ID field in the mutation")
  39940. }
  39941. oldValue, err := m.oldValue(ctx)
  39942. if err != nil {
  39943. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  39944. }
  39945. return oldValue.BotID, nil
  39946. }
  39947. // ResetBotID resets all changes to the "bot_id" field.
  39948. func (m *UsageTotalMutation) ResetBotID() {
  39949. m.bot_id = nil
  39950. }
  39951. // SetTotalTokens sets the "total_tokens" field.
  39952. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  39953. m.total_tokens = &u
  39954. m.addtotal_tokens = nil
  39955. }
  39956. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  39957. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  39958. v := m.total_tokens
  39959. if v == nil {
  39960. return
  39961. }
  39962. return *v, true
  39963. }
  39964. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  39965. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39967. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  39968. if !m.op.Is(OpUpdateOne) {
  39969. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  39970. }
  39971. if m.id == nil || m.oldValue == nil {
  39972. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  39973. }
  39974. oldValue, err := m.oldValue(ctx)
  39975. if err != nil {
  39976. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  39977. }
  39978. return oldValue.TotalTokens, nil
  39979. }
  39980. // AddTotalTokens adds u to the "total_tokens" field.
  39981. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  39982. if m.addtotal_tokens != nil {
  39983. *m.addtotal_tokens += u
  39984. } else {
  39985. m.addtotal_tokens = &u
  39986. }
  39987. }
  39988. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  39989. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  39990. v := m.addtotal_tokens
  39991. if v == nil {
  39992. return
  39993. }
  39994. return *v, true
  39995. }
  39996. // ClearTotalTokens clears the value of the "total_tokens" field.
  39997. func (m *UsageTotalMutation) ClearTotalTokens() {
  39998. m.total_tokens = nil
  39999. m.addtotal_tokens = nil
  40000. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  40001. }
  40002. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  40003. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  40004. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  40005. return ok
  40006. }
  40007. // ResetTotalTokens resets all changes to the "total_tokens" field.
  40008. func (m *UsageTotalMutation) ResetTotalTokens() {
  40009. m.total_tokens = nil
  40010. m.addtotal_tokens = nil
  40011. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  40012. }
  40013. // SetStartIndex sets the "start_index" field.
  40014. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  40015. m.start_index = &u
  40016. m.addstart_index = nil
  40017. }
  40018. // StartIndex returns the value of the "start_index" field in the mutation.
  40019. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  40020. v := m.start_index
  40021. if v == nil {
  40022. return
  40023. }
  40024. return *v, true
  40025. }
  40026. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  40027. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40029. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  40030. if !m.op.Is(OpUpdateOne) {
  40031. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  40032. }
  40033. if m.id == nil || m.oldValue == nil {
  40034. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  40035. }
  40036. oldValue, err := m.oldValue(ctx)
  40037. if err != nil {
  40038. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  40039. }
  40040. return oldValue.StartIndex, nil
  40041. }
  40042. // AddStartIndex adds u to the "start_index" field.
  40043. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  40044. if m.addstart_index != nil {
  40045. *m.addstart_index += u
  40046. } else {
  40047. m.addstart_index = &u
  40048. }
  40049. }
  40050. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  40051. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  40052. v := m.addstart_index
  40053. if v == nil {
  40054. return
  40055. }
  40056. return *v, true
  40057. }
  40058. // ClearStartIndex clears the value of the "start_index" field.
  40059. func (m *UsageTotalMutation) ClearStartIndex() {
  40060. m.start_index = nil
  40061. m.addstart_index = nil
  40062. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  40063. }
  40064. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  40065. func (m *UsageTotalMutation) StartIndexCleared() bool {
  40066. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  40067. return ok
  40068. }
  40069. // ResetStartIndex resets all changes to the "start_index" field.
  40070. func (m *UsageTotalMutation) ResetStartIndex() {
  40071. m.start_index = nil
  40072. m.addstart_index = nil
  40073. delete(m.clearedFields, usagetotal.FieldStartIndex)
  40074. }
  40075. // SetEndIndex sets the "end_index" field.
  40076. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  40077. m.end_index = &u
  40078. m.addend_index = nil
  40079. }
  40080. // EndIndex returns the value of the "end_index" field in the mutation.
  40081. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  40082. v := m.end_index
  40083. if v == nil {
  40084. return
  40085. }
  40086. return *v, true
  40087. }
  40088. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  40089. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40091. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  40092. if !m.op.Is(OpUpdateOne) {
  40093. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  40094. }
  40095. if m.id == nil || m.oldValue == nil {
  40096. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  40097. }
  40098. oldValue, err := m.oldValue(ctx)
  40099. if err != nil {
  40100. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  40101. }
  40102. return oldValue.EndIndex, nil
  40103. }
  40104. // AddEndIndex adds u to the "end_index" field.
  40105. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  40106. if m.addend_index != nil {
  40107. *m.addend_index += u
  40108. } else {
  40109. m.addend_index = &u
  40110. }
  40111. }
  40112. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  40113. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  40114. v := m.addend_index
  40115. if v == nil {
  40116. return
  40117. }
  40118. return *v, true
  40119. }
  40120. // ClearEndIndex clears the value of the "end_index" field.
  40121. func (m *UsageTotalMutation) ClearEndIndex() {
  40122. m.end_index = nil
  40123. m.addend_index = nil
  40124. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  40125. }
  40126. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  40127. func (m *UsageTotalMutation) EndIndexCleared() bool {
  40128. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  40129. return ok
  40130. }
  40131. // ResetEndIndex resets all changes to the "end_index" field.
  40132. func (m *UsageTotalMutation) ResetEndIndex() {
  40133. m.end_index = nil
  40134. m.addend_index = nil
  40135. delete(m.clearedFields, usagetotal.FieldEndIndex)
  40136. }
  40137. // SetOrganizationID sets the "organization_id" field.
  40138. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  40139. m.organization_id = &u
  40140. m.addorganization_id = nil
  40141. }
  40142. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40143. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  40144. v := m.organization_id
  40145. if v == nil {
  40146. return
  40147. }
  40148. return *v, true
  40149. }
  40150. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  40151. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40153. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40154. if !m.op.Is(OpUpdateOne) {
  40155. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40156. }
  40157. if m.id == nil || m.oldValue == nil {
  40158. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40159. }
  40160. oldValue, err := m.oldValue(ctx)
  40161. if err != nil {
  40162. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40163. }
  40164. return oldValue.OrganizationID, nil
  40165. }
  40166. // AddOrganizationID adds u to the "organization_id" field.
  40167. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  40168. if m.addorganization_id != nil {
  40169. *m.addorganization_id += u
  40170. } else {
  40171. m.addorganization_id = &u
  40172. }
  40173. }
  40174. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40175. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  40176. v := m.addorganization_id
  40177. if v == nil {
  40178. return
  40179. }
  40180. return *v, true
  40181. }
  40182. // ClearOrganizationID clears the value of the "organization_id" field.
  40183. func (m *UsageTotalMutation) ClearOrganizationID() {
  40184. m.organization_id = nil
  40185. m.addorganization_id = nil
  40186. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  40187. }
  40188. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40189. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  40190. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  40191. return ok
  40192. }
  40193. // ResetOrganizationID resets all changes to the "organization_id" field.
  40194. func (m *UsageTotalMutation) ResetOrganizationID() {
  40195. m.organization_id = nil
  40196. m.addorganization_id = nil
  40197. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  40198. }
  40199. // Where appends a list predicates to the UsageTotalMutation builder.
  40200. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  40201. m.predicates = append(m.predicates, ps...)
  40202. }
  40203. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  40204. // users can use type-assertion to append predicates that do not depend on any generated package.
  40205. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  40206. p := make([]predicate.UsageTotal, len(ps))
  40207. for i := range ps {
  40208. p[i] = ps[i]
  40209. }
  40210. m.Where(p...)
  40211. }
  40212. // Op returns the operation name.
  40213. func (m *UsageTotalMutation) Op() Op {
  40214. return m.op
  40215. }
  40216. // SetOp allows setting the mutation operation.
  40217. func (m *UsageTotalMutation) SetOp(op Op) {
  40218. m.op = op
  40219. }
  40220. // Type returns the node type of this mutation (UsageTotal).
  40221. func (m *UsageTotalMutation) Type() string {
  40222. return m.typ
  40223. }
  40224. // Fields returns all fields that were changed during this mutation. Note that in
  40225. // order to get all numeric fields that were incremented/decremented, call
  40226. // AddedFields().
  40227. func (m *UsageTotalMutation) Fields() []string {
  40228. fields := make([]string, 0, 9)
  40229. if m.created_at != nil {
  40230. fields = append(fields, usagetotal.FieldCreatedAt)
  40231. }
  40232. if m.updated_at != nil {
  40233. fields = append(fields, usagetotal.FieldUpdatedAt)
  40234. }
  40235. if m.status != nil {
  40236. fields = append(fields, usagetotal.FieldStatus)
  40237. }
  40238. if m._type != nil {
  40239. fields = append(fields, usagetotal.FieldType)
  40240. }
  40241. if m.bot_id != nil {
  40242. fields = append(fields, usagetotal.FieldBotID)
  40243. }
  40244. if m.total_tokens != nil {
  40245. fields = append(fields, usagetotal.FieldTotalTokens)
  40246. }
  40247. if m.start_index != nil {
  40248. fields = append(fields, usagetotal.FieldStartIndex)
  40249. }
  40250. if m.end_index != nil {
  40251. fields = append(fields, usagetotal.FieldEndIndex)
  40252. }
  40253. if m.organization_id != nil {
  40254. fields = append(fields, usagetotal.FieldOrganizationID)
  40255. }
  40256. return fields
  40257. }
  40258. // Field returns the value of a field with the given name. The second boolean
  40259. // return value indicates that this field was not set, or was not defined in the
  40260. // schema.
  40261. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  40262. switch name {
  40263. case usagetotal.FieldCreatedAt:
  40264. return m.CreatedAt()
  40265. case usagetotal.FieldUpdatedAt:
  40266. return m.UpdatedAt()
  40267. case usagetotal.FieldStatus:
  40268. return m.Status()
  40269. case usagetotal.FieldType:
  40270. return m.GetType()
  40271. case usagetotal.FieldBotID:
  40272. return m.BotID()
  40273. case usagetotal.FieldTotalTokens:
  40274. return m.TotalTokens()
  40275. case usagetotal.FieldStartIndex:
  40276. return m.StartIndex()
  40277. case usagetotal.FieldEndIndex:
  40278. return m.EndIndex()
  40279. case usagetotal.FieldOrganizationID:
  40280. return m.OrganizationID()
  40281. }
  40282. return nil, false
  40283. }
  40284. // OldField returns the old value of the field from the database. An error is
  40285. // returned if the mutation operation is not UpdateOne, or the query to the
  40286. // database failed.
  40287. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40288. switch name {
  40289. case usagetotal.FieldCreatedAt:
  40290. return m.OldCreatedAt(ctx)
  40291. case usagetotal.FieldUpdatedAt:
  40292. return m.OldUpdatedAt(ctx)
  40293. case usagetotal.FieldStatus:
  40294. return m.OldStatus(ctx)
  40295. case usagetotal.FieldType:
  40296. return m.OldType(ctx)
  40297. case usagetotal.FieldBotID:
  40298. return m.OldBotID(ctx)
  40299. case usagetotal.FieldTotalTokens:
  40300. return m.OldTotalTokens(ctx)
  40301. case usagetotal.FieldStartIndex:
  40302. return m.OldStartIndex(ctx)
  40303. case usagetotal.FieldEndIndex:
  40304. return m.OldEndIndex(ctx)
  40305. case usagetotal.FieldOrganizationID:
  40306. return m.OldOrganizationID(ctx)
  40307. }
  40308. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  40309. }
  40310. // SetField sets the value of a field with the given name. It returns an error if
  40311. // the field is not defined in the schema, or if the type mismatched the field
  40312. // type.
  40313. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  40314. switch name {
  40315. case usagetotal.FieldCreatedAt:
  40316. v, ok := value.(time.Time)
  40317. if !ok {
  40318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40319. }
  40320. m.SetCreatedAt(v)
  40321. return nil
  40322. case usagetotal.FieldUpdatedAt:
  40323. v, ok := value.(time.Time)
  40324. if !ok {
  40325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40326. }
  40327. m.SetUpdatedAt(v)
  40328. return nil
  40329. case usagetotal.FieldStatus:
  40330. v, ok := value.(uint8)
  40331. if !ok {
  40332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40333. }
  40334. m.SetStatus(v)
  40335. return nil
  40336. case usagetotal.FieldType:
  40337. v, ok := value.(int)
  40338. if !ok {
  40339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40340. }
  40341. m.SetType(v)
  40342. return nil
  40343. case usagetotal.FieldBotID:
  40344. v, ok := value.(string)
  40345. if !ok {
  40346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40347. }
  40348. m.SetBotID(v)
  40349. return nil
  40350. case usagetotal.FieldTotalTokens:
  40351. v, ok := value.(uint64)
  40352. if !ok {
  40353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40354. }
  40355. m.SetTotalTokens(v)
  40356. return nil
  40357. case usagetotal.FieldStartIndex:
  40358. v, ok := value.(uint64)
  40359. if !ok {
  40360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40361. }
  40362. m.SetStartIndex(v)
  40363. return nil
  40364. case usagetotal.FieldEndIndex:
  40365. v, ok := value.(uint64)
  40366. if !ok {
  40367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40368. }
  40369. m.SetEndIndex(v)
  40370. return nil
  40371. case usagetotal.FieldOrganizationID:
  40372. v, ok := value.(uint64)
  40373. if !ok {
  40374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40375. }
  40376. m.SetOrganizationID(v)
  40377. return nil
  40378. }
  40379. return fmt.Errorf("unknown UsageTotal field %s", name)
  40380. }
  40381. // AddedFields returns all numeric fields that were incremented/decremented during
  40382. // this mutation.
  40383. func (m *UsageTotalMutation) AddedFields() []string {
  40384. var fields []string
  40385. if m.addstatus != nil {
  40386. fields = append(fields, usagetotal.FieldStatus)
  40387. }
  40388. if m.add_type != nil {
  40389. fields = append(fields, usagetotal.FieldType)
  40390. }
  40391. if m.addtotal_tokens != nil {
  40392. fields = append(fields, usagetotal.FieldTotalTokens)
  40393. }
  40394. if m.addstart_index != nil {
  40395. fields = append(fields, usagetotal.FieldStartIndex)
  40396. }
  40397. if m.addend_index != nil {
  40398. fields = append(fields, usagetotal.FieldEndIndex)
  40399. }
  40400. if m.addorganization_id != nil {
  40401. fields = append(fields, usagetotal.FieldOrganizationID)
  40402. }
  40403. return fields
  40404. }
  40405. // AddedField returns the numeric value that was incremented/decremented on a field
  40406. // with the given name. The second boolean return value indicates that this field
  40407. // was not set, or was not defined in the schema.
  40408. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  40409. switch name {
  40410. case usagetotal.FieldStatus:
  40411. return m.AddedStatus()
  40412. case usagetotal.FieldType:
  40413. return m.AddedType()
  40414. case usagetotal.FieldTotalTokens:
  40415. return m.AddedTotalTokens()
  40416. case usagetotal.FieldStartIndex:
  40417. return m.AddedStartIndex()
  40418. case usagetotal.FieldEndIndex:
  40419. return m.AddedEndIndex()
  40420. case usagetotal.FieldOrganizationID:
  40421. return m.AddedOrganizationID()
  40422. }
  40423. return nil, false
  40424. }
  40425. // AddField adds the value to the field with the given name. It returns an error if
  40426. // the field is not defined in the schema, or if the type mismatched the field
  40427. // type.
  40428. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  40429. switch name {
  40430. case usagetotal.FieldStatus:
  40431. v, ok := value.(int8)
  40432. if !ok {
  40433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40434. }
  40435. m.AddStatus(v)
  40436. return nil
  40437. case usagetotal.FieldType:
  40438. v, ok := value.(int)
  40439. if !ok {
  40440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40441. }
  40442. m.AddType(v)
  40443. return nil
  40444. case usagetotal.FieldTotalTokens:
  40445. v, ok := value.(int64)
  40446. if !ok {
  40447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40448. }
  40449. m.AddTotalTokens(v)
  40450. return nil
  40451. case usagetotal.FieldStartIndex:
  40452. v, ok := value.(int64)
  40453. if !ok {
  40454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40455. }
  40456. m.AddStartIndex(v)
  40457. return nil
  40458. case usagetotal.FieldEndIndex:
  40459. v, ok := value.(int64)
  40460. if !ok {
  40461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40462. }
  40463. m.AddEndIndex(v)
  40464. return nil
  40465. case usagetotal.FieldOrganizationID:
  40466. v, ok := value.(int64)
  40467. if !ok {
  40468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40469. }
  40470. m.AddOrganizationID(v)
  40471. return nil
  40472. }
  40473. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  40474. }
  40475. // ClearedFields returns all nullable fields that were cleared during this
  40476. // mutation.
  40477. func (m *UsageTotalMutation) ClearedFields() []string {
  40478. var fields []string
  40479. if m.FieldCleared(usagetotal.FieldStatus) {
  40480. fields = append(fields, usagetotal.FieldStatus)
  40481. }
  40482. if m.FieldCleared(usagetotal.FieldType) {
  40483. fields = append(fields, usagetotal.FieldType)
  40484. }
  40485. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  40486. fields = append(fields, usagetotal.FieldTotalTokens)
  40487. }
  40488. if m.FieldCleared(usagetotal.FieldStartIndex) {
  40489. fields = append(fields, usagetotal.FieldStartIndex)
  40490. }
  40491. if m.FieldCleared(usagetotal.FieldEndIndex) {
  40492. fields = append(fields, usagetotal.FieldEndIndex)
  40493. }
  40494. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  40495. fields = append(fields, usagetotal.FieldOrganizationID)
  40496. }
  40497. return fields
  40498. }
  40499. // FieldCleared returns a boolean indicating if a field with the given name was
  40500. // cleared in this mutation.
  40501. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  40502. _, ok := m.clearedFields[name]
  40503. return ok
  40504. }
  40505. // ClearField clears the value of the field with the given name. It returns an
  40506. // error if the field is not defined in the schema.
  40507. func (m *UsageTotalMutation) ClearField(name string) error {
  40508. switch name {
  40509. case usagetotal.FieldStatus:
  40510. m.ClearStatus()
  40511. return nil
  40512. case usagetotal.FieldType:
  40513. m.ClearType()
  40514. return nil
  40515. case usagetotal.FieldTotalTokens:
  40516. m.ClearTotalTokens()
  40517. return nil
  40518. case usagetotal.FieldStartIndex:
  40519. m.ClearStartIndex()
  40520. return nil
  40521. case usagetotal.FieldEndIndex:
  40522. m.ClearEndIndex()
  40523. return nil
  40524. case usagetotal.FieldOrganizationID:
  40525. m.ClearOrganizationID()
  40526. return nil
  40527. }
  40528. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  40529. }
  40530. // ResetField resets all changes in the mutation for the field with the given name.
  40531. // It returns an error if the field is not defined in the schema.
  40532. func (m *UsageTotalMutation) ResetField(name string) error {
  40533. switch name {
  40534. case usagetotal.FieldCreatedAt:
  40535. m.ResetCreatedAt()
  40536. return nil
  40537. case usagetotal.FieldUpdatedAt:
  40538. m.ResetUpdatedAt()
  40539. return nil
  40540. case usagetotal.FieldStatus:
  40541. m.ResetStatus()
  40542. return nil
  40543. case usagetotal.FieldType:
  40544. m.ResetType()
  40545. return nil
  40546. case usagetotal.FieldBotID:
  40547. m.ResetBotID()
  40548. return nil
  40549. case usagetotal.FieldTotalTokens:
  40550. m.ResetTotalTokens()
  40551. return nil
  40552. case usagetotal.FieldStartIndex:
  40553. m.ResetStartIndex()
  40554. return nil
  40555. case usagetotal.FieldEndIndex:
  40556. m.ResetEndIndex()
  40557. return nil
  40558. case usagetotal.FieldOrganizationID:
  40559. m.ResetOrganizationID()
  40560. return nil
  40561. }
  40562. return fmt.Errorf("unknown UsageTotal field %s", name)
  40563. }
  40564. // AddedEdges returns all edge names that were set/added in this mutation.
  40565. func (m *UsageTotalMutation) AddedEdges() []string {
  40566. edges := make([]string, 0, 0)
  40567. return edges
  40568. }
  40569. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40570. // name in this mutation.
  40571. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  40572. return nil
  40573. }
  40574. // RemovedEdges returns all edge names that were removed in this mutation.
  40575. func (m *UsageTotalMutation) RemovedEdges() []string {
  40576. edges := make([]string, 0, 0)
  40577. return edges
  40578. }
  40579. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40580. // the given name in this mutation.
  40581. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  40582. return nil
  40583. }
  40584. // ClearedEdges returns all edge names that were cleared in this mutation.
  40585. func (m *UsageTotalMutation) ClearedEdges() []string {
  40586. edges := make([]string, 0, 0)
  40587. return edges
  40588. }
  40589. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40590. // was cleared in this mutation.
  40591. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  40592. return false
  40593. }
  40594. // ClearEdge clears the value of the edge with the given name. It returns an error
  40595. // if that edge is not defined in the schema.
  40596. func (m *UsageTotalMutation) ClearEdge(name string) error {
  40597. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  40598. }
  40599. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40600. // It returns an error if the edge is not defined in the schema.
  40601. func (m *UsageTotalMutation) ResetEdge(name string) error {
  40602. return fmt.Errorf("unknown UsageTotal edge %s", name)
  40603. }
  40604. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  40605. type WhatsappMutation struct {
  40606. config
  40607. op Op
  40608. typ string
  40609. id *uint64
  40610. created_at *time.Time
  40611. updated_at *time.Time
  40612. status *uint8
  40613. addstatus *int8
  40614. deleted_at *time.Time
  40615. wa_id *string
  40616. wa_name *string
  40617. callback *string
  40618. account *string
  40619. cc *string
  40620. phone *string
  40621. cc_phone *string
  40622. phone_name *string
  40623. phone_status *int8
  40624. addphone_status *int8
  40625. organization_id *uint64
  40626. addorganization_id *int64
  40627. api_base *string
  40628. api_key *string
  40629. allow_list *[]string
  40630. appendallow_list []string
  40631. group_allow_list *[]string
  40632. appendgroup_allow_list []string
  40633. block_list *[]string
  40634. appendblock_list []string
  40635. group_block_list *[]string
  40636. appendgroup_block_list []string
  40637. clearedFields map[string]struct{}
  40638. agent *uint64
  40639. clearedagent bool
  40640. done bool
  40641. oldValue func(context.Context) (*Whatsapp, error)
  40642. predicates []predicate.Whatsapp
  40643. }
  40644. var _ ent.Mutation = (*WhatsappMutation)(nil)
  40645. // whatsappOption allows management of the mutation configuration using functional options.
  40646. type whatsappOption func(*WhatsappMutation)
  40647. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  40648. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  40649. m := &WhatsappMutation{
  40650. config: c,
  40651. op: op,
  40652. typ: TypeWhatsapp,
  40653. clearedFields: make(map[string]struct{}),
  40654. }
  40655. for _, opt := range opts {
  40656. opt(m)
  40657. }
  40658. return m
  40659. }
  40660. // withWhatsappID sets the ID field of the mutation.
  40661. func withWhatsappID(id uint64) whatsappOption {
  40662. return func(m *WhatsappMutation) {
  40663. var (
  40664. err error
  40665. once sync.Once
  40666. value *Whatsapp
  40667. )
  40668. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  40669. once.Do(func() {
  40670. if m.done {
  40671. err = errors.New("querying old values post mutation is not allowed")
  40672. } else {
  40673. value, err = m.Client().Whatsapp.Get(ctx, id)
  40674. }
  40675. })
  40676. return value, err
  40677. }
  40678. m.id = &id
  40679. }
  40680. }
  40681. // withWhatsapp sets the old Whatsapp of the mutation.
  40682. func withWhatsapp(node *Whatsapp) whatsappOption {
  40683. return func(m *WhatsappMutation) {
  40684. m.oldValue = func(context.Context) (*Whatsapp, error) {
  40685. return node, nil
  40686. }
  40687. m.id = &node.ID
  40688. }
  40689. }
  40690. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40691. // executed in a transaction (ent.Tx), a transactional client is returned.
  40692. func (m WhatsappMutation) Client() *Client {
  40693. client := &Client{config: m.config}
  40694. client.init()
  40695. return client
  40696. }
  40697. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40698. // it returns an error otherwise.
  40699. func (m WhatsappMutation) Tx() (*Tx, error) {
  40700. if _, ok := m.driver.(*txDriver); !ok {
  40701. return nil, errors.New("ent: mutation is not running in a transaction")
  40702. }
  40703. tx := &Tx{config: m.config}
  40704. tx.init()
  40705. return tx, nil
  40706. }
  40707. // SetID sets the value of the id field. Note that this
  40708. // operation is only accepted on creation of Whatsapp entities.
  40709. func (m *WhatsappMutation) SetID(id uint64) {
  40710. m.id = &id
  40711. }
  40712. // ID returns the ID value in the mutation. Note that the ID is only available
  40713. // if it was provided to the builder or after it was returned from the database.
  40714. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  40715. if m.id == nil {
  40716. return
  40717. }
  40718. return *m.id, true
  40719. }
  40720. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40721. // That means, if the mutation is applied within a transaction with an isolation level such
  40722. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40723. // or updated by the mutation.
  40724. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  40725. switch {
  40726. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40727. id, exists := m.ID()
  40728. if exists {
  40729. return []uint64{id}, nil
  40730. }
  40731. fallthrough
  40732. case m.op.Is(OpUpdate | OpDelete):
  40733. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  40734. default:
  40735. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40736. }
  40737. }
  40738. // SetCreatedAt sets the "created_at" field.
  40739. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  40740. m.created_at = &t
  40741. }
  40742. // CreatedAt returns the value of the "created_at" field in the mutation.
  40743. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  40744. v := m.created_at
  40745. if v == nil {
  40746. return
  40747. }
  40748. return *v, true
  40749. }
  40750. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  40751. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40753. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40754. if !m.op.Is(OpUpdateOne) {
  40755. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40756. }
  40757. if m.id == nil || m.oldValue == nil {
  40758. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40759. }
  40760. oldValue, err := m.oldValue(ctx)
  40761. if err != nil {
  40762. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40763. }
  40764. return oldValue.CreatedAt, nil
  40765. }
  40766. // ResetCreatedAt resets all changes to the "created_at" field.
  40767. func (m *WhatsappMutation) ResetCreatedAt() {
  40768. m.created_at = nil
  40769. }
  40770. // SetUpdatedAt sets the "updated_at" field.
  40771. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  40772. m.updated_at = &t
  40773. }
  40774. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40775. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  40776. v := m.updated_at
  40777. if v == nil {
  40778. return
  40779. }
  40780. return *v, true
  40781. }
  40782. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  40783. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40785. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40786. if !m.op.Is(OpUpdateOne) {
  40787. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40788. }
  40789. if m.id == nil || m.oldValue == nil {
  40790. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40791. }
  40792. oldValue, err := m.oldValue(ctx)
  40793. if err != nil {
  40794. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40795. }
  40796. return oldValue.UpdatedAt, nil
  40797. }
  40798. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40799. func (m *WhatsappMutation) ResetUpdatedAt() {
  40800. m.updated_at = nil
  40801. }
  40802. // SetStatus sets the "status" field.
  40803. func (m *WhatsappMutation) SetStatus(u uint8) {
  40804. m.status = &u
  40805. m.addstatus = nil
  40806. }
  40807. // Status returns the value of the "status" field in the mutation.
  40808. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  40809. v := m.status
  40810. if v == nil {
  40811. return
  40812. }
  40813. return *v, true
  40814. }
  40815. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  40816. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40818. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40819. if !m.op.Is(OpUpdateOne) {
  40820. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40821. }
  40822. if m.id == nil || m.oldValue == nil {
  40823. return v, errors.New("OldStatus requires an ID field in the mutation")
  40824. }
  40825. oldValue, err := m.oldValue(ctx)
  40826. if err != nil {
  40827. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40828. }
  40829. return oldValue.Status, nil
  40830. }
  40831. // AddStatus adds u to the "status" field.
  40832. func (m *WhatsappMutation) AddStatus(u int8) {
  40833. if m.addstatus != nil {
  40834. *m.addstatus += u
  40835. } else {
  40836. m.addstatus = &u
  40837. }
  40838. }
  40839. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40840. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  40841. v := m.addstatus
  40842. if v == nil {
  40843. return
  40844. }
  40845. return *v, true
  40846. }
  40847. // ClearStatus clears the value of the "status" field.
  40848. func (m *WhatsappMutation) ClearStatus() {
  40849. m.status = nil
  40850. m.addstatus = nil
  40851. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  40852. }
  40853. // StatusCleared returns if the "status" field was cleared in this mutation.
  40854. func (m *WhatsappMutation) StatusCleared() bool {
  40855. _, ok := m.clearedFields[whatsapp.FieldStatus]
  40856. return ok
  40857. }
  40858. // ResetStatus resets all changes to the "status" field.
  40859. func (m *WhatsappMutation) ResetStatus() {
  40860. m.status = nil
  40861. m.addstatus = nil
  40862. delete(m.clearedFields, whatsapp.FieldStatus)
  40863. }
  40864. // SetDeletedAt sets the "deleted_at" field.
  40865. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  40866. m.deleted_at = &t
  40867. }
  40868. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40869. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  40870. v := m.deleted_at
  40871. if v == nil {
  40872. return
  40873. }
  40874. return *v, true
  40875. }
  40876. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  40877. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40879. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40880. if !m.op.Is(OpUpdateOne) {
  40881. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40882. }
  40883. if m.id == nil || m.oldValue == nil {
  40884. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40885. }
  40886. oldValue, err := m.oldValue(ctx)
  40887. if err != nil {
  40888. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40889. }
  40890. return oldValue.DeletedAt, nil
  40891. }
  40892. // ClearDeletedAt clears the value of the "deleted_at" field.
  40893. func (m *WhatsappMutation) ClearDeletedAt() {
  40894. m.deleted_at = nil
  40895. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  40896. }
  40897. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40898. func (m *WhatsappMutation) DeletedAtCleared() bool {
  40899. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  40900. return ok
  40901. }
  40902. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40903. func (m *WhatsappMutation) ResetDeletedAt() {
  40904. m.deleted_at = nil
  40905. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  40906. }
  40907. // SetWaID sets the "wa_id" field.
  40908. func (m *WhatsappMutation) SetWaID(s string) {
  40909. m.wa_id = &s
  40910. }
  40911. // WaID returns the value of the "wa_id" field in the mutation.
  40912. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  40913. v := m.wa_id
  40914. if v == nil {
  40915. return
  40916. }
  40917. return *v, true
  40918. }
  40919. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  40920. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40922. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  40923. if !m.op.Is(OpUpdateOne) {
  40924. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  40925. }
  40926. if m.id == nil || m.oldValue == nil {
  40927. return v, errors.New("OldWaID requires an ID field in the mutation")
  40928. }
  40929. oldValue, err := m.oldValue(ctx)
  40930. if err != nil {
  40931. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  40932. }
  40933. return oldValue.WaID, nil
  40934. }
  40935. // ClearWaID clears the value of the "wa_id" field.
  40936. func (m *WhatsappMutation) ClearWaID() {
  40937. m.wa_id = nil
  40938. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  40939. }
  40940. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  40941. func (m *WhatsappMutation) WaIDCleared() bool {
  40942. _, ok := m.clearedFields[whatsapp.FieldWaID]
  40943. return ok
  40944. }
  40945. // ResetWaID resets all changes to the "wa_id" field.
  40946. func (m *WhatsappMutation) ResetWaID() {
  40947. m.wa_id = nil
  40948. delete(m.clearedFields, whatsapp.FieldWaID)
  40949. }
  40950. // SetWaName sets the "wa_name" field.
  40951. func (m *WhatsappMutation) SetWaName(s string) {
  40952. m.wa_name = &s
  40953. }
  40954. // WaName returns the value of the "wa_name" field in the mutation.
  40955. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  40956. v := m.wa_name
  40957. if v == nil {
  40958. return
  40959. }
  40960. return *v, true
  40961. }
  40962. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  40963. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40965. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  40966. if !m.op.Is(OpUpdateOne) {
  40967. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  40968. }
  40969. if m.id == nil || m.oldValue == nil {
  40970. return v, errors.New("OldWaName requires an ID field in the mutation")
  40971. }
  40972. oldValue, err := m.oldValue(ctx)
  40973. if err != nil {
  40974. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  40975. }
  40976. return oldValue.WaName, nil
  40977. }
  40978. // ClearWaName clears the value of the "wa_name" field.
  40979. func (m *WhatsappMutation) ClearWaName() {
  40980. m.wa_name = nil
  40981. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  40982. }
  40983. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  40984. func (m *WhatsappMutation) WaNameCleared() bool {
  40985. _, ok := m.clearedFields[whatsapp.FieldWaName]
  40986. return ok
  40987. }
  40988. // ResetWaName resets all changes to the "wa_name" field.
  40989. func (m *WhatsappMutation) ResetWaName() {
  40990. m.wa_name = nil
  40991. delete(m.clearedFields, whatsapp.FieldWaName)
  40992. }
  40993. // SetCallback sets the "callback" field.
  40994. func (m *WhatsappMutation) SetCallback(s string) {
  40995. m.callback = &s
  40996. }
  40997. // Callback returns the value of the "callback" field in the mutation.
  40998. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  40999. v := m.callback
  41000. if v == nil {
  41001. return
  41002. }
  41003. return *v, true
  41004. }
  41005. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  41006. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41008. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  41009. if !m.op.Is(OpUpdateOne) {
  41010. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  41011. }
  41012. if m.id == nil || m.oldValue == nil {
  41013. return v, errors.New("OldCallback requires an ID field in the mutation")
  41014. }
  41015. oldValue, err := m.oldValue(ctx)
  41016. if err != nil {
  41017. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  41018. }
  41019. return oldValue.Callback, nil
  41020. }
  41021. // ClearCallback clears the value of the "callback" field.
  41022. func (m *WhatsappMutation) ClearCallback() {
  41023. m.callback = nil
  41024. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  41025. }
  41026. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  41027. func (m *WhatsappMutation) CallbackCleared() bool {
  41028. _, ok := m.clearedFields[whatsapp.FieldCallback]
  41029. return ok
  41030. }
  41031. // ResetCallback resets all changes to the "callback" field.
  41032. func (m *WhatsappMutation) ResetCallback() {
  41033. m.callback = nil
  41034. delete(m.clearedFields, whatsapp.FieldCallback)
  41035. }
  41036. // SetAgentID sets the "agent_id" field.
  41037. func (m *WhatsappMutation) SetAgentID(u uint64) {
  41038. m.agent = &u
  41039. }
  41040. // AgentID returns the value of the "agent_id" field in the mutation.
  41041. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  41042. v := m.agent
  41043. if v == nil {
  41044. return
  41045. }
  41046. return *v, true
  41047. }
  41048. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  41049. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41051. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  41052. if !m.op.Is(OpUpdateOne) {
  41053. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  41054. }
  41055. if m.id == nil || m.oldValue == nil {
  41056. return v, errors.New("OldAgentID requires an ID field in the mutation")
  41057. }
  41058. oldValue, err := m.oldValue(ctx)
  41059. if err != nil {
  41060. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  41061. }
  41062. return oldValue.AgentID, nil
  41063. }
  41064. // ResetAgentID resets all changes to the "agent_id" field.
  41065. func (m *WhatsappMutation) ResetAgentID() {
  41066. m.agent = nil
  41067. }
  41068. // SetAccount sets the "account" field.
  41069. func (m *WhatsappMutation) SetAccount(s string) {
  41070. m.account = &s
  41071. }
  41072. // Account returns the value of the "account" field in the mutation.
  41073. func (m *WhatsappMutation) Account() (r string, exists bool) {
  41074. v := m.account
  41075. if v == nil {
  41076. return
  41077. }
  41078. return *v, true
  41079. }
  41080. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  41081. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41083. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  41084. if !m.op.Is(OpUpdateOne) {
  41085. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41086. }
  41087. if m.id == nil || m.oldValue == nil {
  41088. return v, errors.New("OldAccount requires an ID field in the mutation")
  41089. }
  41090. oldValue, err := m.oldValue(ctx)
  41091. if err != nil {
  41092. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  41093. }
  41094. return oldValue.Account, nil
  41095. }
  41096. // ClearAccount clears the value of the "account" field.
  41097. func (m *WhatsappMutation) ClearAccount() {
  41098. m.account = nil
  41099. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  41100. }
  41101. // AccountCleared returns if the "account" field was cleared in this mutation.
  41102. func (m *WhatsappMutation) AccountCleared() bool {
  41103. _, ok := m.clearedFields[whatsapp.FieldAccount]
  41104. return ok
  41105. }
  41106. // ResetAccount resets all changes to the "account" field.
  41107. func (m *WhatsappMutation) ResetAccount() {
  41108. m.account = nil
  41109. delete(m.clearedFields, whatsapp.FieldAccount)
  41110. }
  41111. // SetCc sets the "cc" field.
  41112. func (m *WhatsappMutation) SetCc(s string) {
  41113. m.cc = &s
  41114. }
  41115. // Cc returns the value of the "cc" field in the mutation.
  41116. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  41117. v := m.cc
  41118. if v == nil {
  41119. return
  41120. }
  41121. return *v, true
  41122. }
  41123. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  41124. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41126. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  41127. if !m.op.Is(OpUpdateOne) {
  41128. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  41129. }
  41130. if m.id == nil || m.oldValue == nil {
  41131. return v, errors.New("OldCc requires an ID field in the mutation")
  41132. }
  41133. oldValue, err := m.oldValue(ctx)
  41134. if err != nil {
  41135. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  41136. }
  41137. return oldValue.Cc, nil
  41138. }
  41139. // ResetCc resets all changes to the "cc" field.
  41140. func (m *WhatsappMutation) ResetCc() {
  41141. m.cc = nil
  41142. }
  41143. // SetPhone sets the "phone" field.
  41144. func (m *WhatsappMutation) SetPhone(s string) {
  41145. m.phone = &s
  41146. }
  41147. // Phone returns the value of the "phone" field in the mutation.
  41148. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  41149. v := m.phone
  41150. if v == nil {
  41151. return
  41152. }
  41153. return *v, true
  41154. }
  41155. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  41156. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41158. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  41159. if !m.op.Is(OpUpdateOne) {
  41160. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  41161. }
  41162. if m.id == nil || m.oldValue == nil {
  41163. return v, errors.New("OldPhone requires an ID field in the mutation")
  41164. }
  41165. oldValue, err := m.oldValue(ctx)
  41166. if err != nil {
  41167. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  41168. }
  41169. return oldValue.Phone, nil
  41170. }
  41171. // ResetPhone resets all changes to the "phone" field.
  41172. func (m *WhatsappMutation) ResetPhone() {
  41173. m.phone = nil
  41174. }
  41175. // SetCcPhone sets the "cc_phone" field.
  41176. func (m *WhatsappMutation) SetCcPhone(s string) {
  41177. m.cc_phone = &s
  41178. }
  41179. // CcPhone returns the value of the "cc_phone" field in the mutation.
  41180. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  41181. v := m.cc_phone
  41182. if v == nil {
  41183. return
  41184. }
  41185. return *v, true
  41186. }
  41187. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  41188. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41190. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  41191. if !m.op.Is(OpUpdateOne) {
  41192. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  41193. }
  41194. if m.id == nil || m.oldValue == nil {
  41195. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  41196. }
  41197. oldValue, err := m.oldValue(ctx)
  41198. if err != nil {
  41199. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  41200. }
  41201. return oldValue.CcPhone, nil
  41202. }
  41203. // ResetCcPhone resets all changes to the "cc_phone" field.
  41204. func (m *WhatsappMutation) ResetCcPhone() {
  41205. m.cc_phone = nil
  41206. }
  41207. // SetPhoneName sets the "phone_name" field.
  41208. func (m *WhatsappMutation) SetPhoneName(s string) {
  41209. m.phone_name = &s
  41210. }
  41211. // PhoneName returns the value of the "phone_name" field in the mutation.
  41212. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  41213. v := m.phone_name
  41214. if v == nil {
  41215. return
  41216. }
  41217. return *v, true
  41218. }
  41219. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  41220. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41222. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  41223. if !m.op.Is(OpUpdateOne) {
  41224. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  41225. }
  41226. if m.id == nil || m.oldValue == nil {
  41227. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  41228. }
  41229. oldValue, err := m.oldValue(ctx)
  41230. if err != nil {
  41231. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  41232. }
  41233. return oldValue.PhoneName, nil
  41234. }
  41235. // ResetPhoneName resets all changes to the "phone_name" field.
  41236. func (m *WhatsappMutation) ResetPhoneName() {
  41237. m.phone_name = nil
  41238. }
  41239. // SetPhoneStatus sets the "phone_status" field.
  41240. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  41241. m.phone_status = &i
  41242. m.addphone_status = nil
  41243. }
  41244. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  41245. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  41246. v := m.phone_status
  41247. if v == nil {
  41248. return
  41249. }
  41250. return *v, true
  41251. }
  41252. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  41253. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41255. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  41256. if !m.op.Is(OpUpdateOne) {
  41257. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  41258. }
  41259. if m.id == nil || m.oldValue == nil {
  41260. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  41261. }
  41262. oldValue, err := m.oldValue(ctx)
  41263. if err != nil {
  41264. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  41265. }
  41266. return oldValue.PhoneStatus, nil
  41267. }
  41268. // AddPhoneStatus adds i to the "phone_status" field.
  41269. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  41270. if m.addphone_status != nil {
  41271. *m.addphone_status += i
  41272. } else {
  41273. m.addphone_status = &i
  41274. }
  41275. }
  41276. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  41277. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  41278. v := m.addphone_status
  41279. if v == nil {
  41280. return
  41281. }
  41282. return *v, true
  41283. }
  41284. // ResetPhoneStatus resets all changes to the "phone_status" field.
  41285. func (m *WhatsappMutation) ResetPhoneStatus() {
  41286. m.phone_status = nil
  41287. m.addphone_status = nil
  41288. }
  41289. // SetOrganizationID sets the "organization_id" field.
  41290. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  41291. m.organization_id = &u
  41292. m.addorganization_id = nil
  41293. }
  41294. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41295. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  41296. v := m.organization_id
  41297. if v == nil {
  41298. return
  41299. }
  41300. return *v, true
  41301. }
  41302. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  41303. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41305. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41306. if !m.op.Is(OpUpdateOne) {
  41307. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41308. }
  41309. if m.id == nil || m.oldValue == nil {
  41310. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41311. }
  41312. oldValue, err := m.oldValue(ctx)
  41313. if err != nil {
  41314. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41315. }
  41316. return oldValue.OrganizationID, nil
  41317. }
  41318. // AddOrganizationID adds u to the "organization_id" field.
  41319. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  41320. if m.addorganization_id != nil {
  41321. *m.addorganization_id += u
  41322. } else {
  41323. m.addorganization_id = &u
  41324. }
  41325. }
  41326. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41327. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  41328. v := m.addorganization_id
  41329. if v == nil {
  41330. return
  41331. }
  41332. return *v, true
  41333. }
  41334. // ClearOrganizationID clears the value of the "organization_id" field.
  41335. func (m *WhatsappMutation) ClearOrganizationID() {
  41336. m.organization_id = nil
  41337. m.addorganization_id = nil
  41338. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  41339. }
  41340. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41341. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  41342. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  41343. return ok
  41344. }
  41345. // ResetOrganizationID resets all changes to the "organization_id" field.
  41346. func (m *WhatsappMutation) ResetOrganizationID() {
  41347. m.organization_id = nil
  41348. m.addorganization_id = nil
  41349. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  41350. }
  41351. // SetAPIBase sets the "api_base" field.
  41352. func (m *WhatsappMutation) SetAPIBase(s string) {
  41353. m.api_base = &s
  41354. }
  41355. // APIBase returns the value of the "api_base" field in the mutation.
  41356. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  41357. v := m.api_base
  41358. if v == nil {
  41359. return
  41360. }
  41361. return *v, true
  41362. }
  41363. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  41364. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41366. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  41367. if !m.op.Is(OpUpdateOne) {
  41368. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  41369. }
  41370. if m.id == nil || m.oldValue == nil {
  41371. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  41372. }
  41373. oldValue, err := m.oldValue(ctx)
  41374. if err != nil {
  41375. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  41376. }
  41377. return oldValue.APIBase, nil
  41378. }
  41379. // ClearAPIBase clears the value of the "api_base" field.
  41380. func (m *WhatsappMutation) ClearAPIBase() {
  41381. m.api_base = nil
  41382. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  41383. }
  41384. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  41385. func (m *WhatsappMutation) APIBaseCleared() bool {
  41386. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  41387. return ok
  41388. }
  41389. // ResetAPIBase resets all changes to the "api_base" field.
  41390. func (m *WhatsappMutation) ResetAPIBase() {
  41391. m.api_base = nil
  41392. delete(m.clearedFields, whatsapp.FieldAPIBase)
  41393. }
  41394. // SetAPIKey sets the "api_key" field.
  41395. func (m *WhatsappMutation) SetAPIKey(s string) {
  41396. m.api_key = &s
  41397. }
  41398. // APIKey returns the value of the "api_key" field in the mutation.
  41399. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  41400. v := m.api_key
  41401. if v == nil {
  41402. return
  41403. }
  41404. return *v, true
  41405. }
  41406. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  41407. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41409. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  41410. if !m.op.Is(OpUpdateOne) {
  41411. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  41412. }
  41413. if m.id == nil || m.oldValue == nil {
  41414. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  41415. }
  41416. oldValue, err := m.oldValue(ctx)
  41417. if err != nil {
  41418. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  41419. }
  41420. return oldValue.APIKey, nil
  41421. }
  41422. // ClearAPIKey clears the value of the "api_key" field.
  41423. func (m *WhatsappMutation) ClearAPIKey() {
  41424. m.api_key = nil
  41425. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  41426. }
  41427. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  41428. func (m *WhatsappMutation) APIKeyCleared() bool {
  41429. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  41430. return ok
  41431. }
  41432. // ResetAPIKey resets all changes to the "api_key" field.
  41433. func (m *WhatsappMutation) ResetAPIKey() {
  41434. m.api_key = nil
  41435. delete(m.clearedFields, whatsapp.FieldAPIKey)
  41436. }
  41437. // SetAllowList sets the "allow_list" field.
  41438. func (m *WhatsappMutation) SetAllowList(s []string) {
  41439. m.allow_list = &s
  41440. m.appendallow_list = nil
  41441. }
  41442. // AllowList returns the value of the "allow_list" field in the mutation.
  41443. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  41444. v := m.allow_list
  41445. if v == nil {
  41446. return
  41447. }
  41448. return *v, true
  41449. }
  41450. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  41451. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41453. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  41454. if !m.op.Is(OpUpdateOne) {
  41455. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  41456. }
  41457. if m.id == nil || m.oldValue == nil {
  41458. return v, errors.New("OldAllowList requires an ID field in the mutation")
  41459. }
  41460. oldValue, err := m.oldValue(ctx)
  41461. if err != nil {
  41462. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  41463. }
  41464. return oldValue.AllowList, nil
  41465. }
  41466. // AppendAllowList adds s to the "allow_list" field.
  41467. func (m *WhatsappMutation) AppendAllowList(s []string) {
  41468. m.appendallow_list = append(m.appendallow_list, s...)
  41469. }
  41470. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  41471. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  41472. if len(m.appendallow_list) == 0 {
  41473. return nil, false
  41474. }
  41475. return m.appendallow_list, true
  41476. }
  41477. // ClearAllowList clears the value of the "allow_list" field.
  41478. func (m *WhatsappMutation) ClearAllowList() {
  41479. m.allow_list = nil
  41480. m.appendallow_list = nil
  41481. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  41482. }
  41483. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  41484. func (m *WhatsappMutation) AllowListCleared() bool {
  41485. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  41486. return ok
  41487. }
  41488. // ResetAllowList resets all changes to the "allow_list" field.
  41489. func (m *WhatsappMutation) ResetAllowList() {
  41490. m.allow_list = nil
  41491. m.appendallow_list = nil
  41492. delete(m.clearedFields, whatsapp.FieldAllowList)
  41493. }
  41494. // SetGroupAllowList sets the "group_allow_list" field.
  41495. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  41496. m.group_allow_list = &s
  41497. m.appendgroup_allow_list = nil
  41498. }
  41499. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  41500. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  41501. v := m.group_allow_list
  41502. if v == nil {
  41503. return
  41504. }
  41505. return *v, true
  41506. }
  41507. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  41508. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41510. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  41511. if !m.op.Is(OpUpdateOne) {
  41512. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  41513. }
  41514. if m.id == nil || m.oldValue == nil {
  41515. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  41516. }
  41517. oldValue, err := m.oldValue(ctx)
  41518. if err != nil {
  41519. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  41520. }
  41521. return oldValue.GroupAllowList, nil
  41522. }
  41523. // AppendGroupAllowList adds s to the "group_allow_list" field.
  41524. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  41525. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  41526. }
  41527. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  41528. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  41529. if len(m.appendgroup_allow_list) == 0 {
  41530. return nil, false
  41531. }
  41532. return m.appendgroup_allow_list, true
  41533. }
  41534. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  41535. func (m *WhatsappMutation) ClearGroupAllowList() {
  41536. m.group_allow_list = nil
  41537. m.appendgroup_allow_list = nil
  41538. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  41539. }
  41540. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  41541. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  41542. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  41543. return ok
  41544. }
  41545. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  41546. func (m *WhatsappMutation) ResetGroupAllowList() {
  41547. m.group_allow_list = nil
  41548. m.appendgroup_allow_list = nil
  41549. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  41550. }
  41551. // SetBlockList sets the "block_list" field.
  41552. func (m *WhatsappMutation) SetBlockList(s []string) {
  41553. m.block_list = &s
  41554. m.appendblock_list = nil
  41555. }
  41556. // BlockList returns the value of the "block_list" field in the mutation.
  41557. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  41558. v := m.block_list
  41559. if v == nil {
  41560. return
  41561. }
  41562. return *v, true
  41563. }
  41564. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  41565. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41567. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  41568. if !m.op.Is(OpUpdateOne) {
  41569. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  41570. }
  41571. if m.id == nil || m.oldValue == nil {
  41572. return v, errors.New("OldBlockList requires an ID field in the mutation")
  41573. }
  41574. oldValue, err := m.oldValue(ctx)
  41575. if err != nil {
  41576. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  41577. }
  41578. return oldValue.BlockList, nil
  41579. }
  41580. // AppendBlockList adds s to the "block_list" field.
  41581. func (m *WhatsappMutation) AppendBlockList(s []string) {
  41582. m.appendblock_list = append(m.appendblock_list, s...)
  41583. }
  41584. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  41585. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  41586. if len(m.appendblock_list) == 0 {
  41587. return nil, false
  41588. }
  41589. return m.appendblock_list, true
  41590. }
  41591. // ClearBlockList clears the value of the "block_list" field.
  41592. func (m *WhatsappMutation) ClearBlockList() {
  41593. m.block_list = nil
  41594. m.appendblock_list = nil
  41595. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  41596. }
  41597. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  41598. func (m *WhatsappMutation) BlockListCleared() bool {
  41599. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  41600. return ok
  41601. }
  41602. // ResetBlockList resets all changes to the "block_list" field.
  41603. func (m *WhatsappMutation) ResetBlockList() {
  41604. m.block_list = nil
  41605. m.appendblock_list = nil
  41606. delete(m.clearedFields, whatsapp.FieldBlockList)
  41607. }
  41608. // SetGroupBlockList sets the "group_block_list" field.
  41609. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  41610. m.group_block_list = &s
  41611. m.appendgroup_block_list = nil
  41612. }
  41613. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  41614. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  41615. v := m.group_block_list
  41616. if v == nil {
  41617. return
  41618. }
  41619. return *v, true
  41620. }
  41621. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  41622. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41624. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  41625. if !m.op.Is(OpUpdateOne) {
  41626. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  41627. }
  41628. if m.id == nil || m.oldValue == nil {
  41629. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  41630. }
  41631. oldValue, err := m.oldValue(ctx)
  41632. if err != nil {
  41633. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  41634. }
  41635. return oldValue.GroupBlockList, nil
  41636. }
  41637. // AppendGroupBlockList adds s to the "group_block_list" field.
  41638. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  41639. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  41640. }
  41641. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  41642. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  41643. if len(m.appendgroup_block_list) == 0 {
  41644. return nil, false
  41645. }
  41646. return m.appendgroup_block_list, true
  41647. }
  41648. // ClearGroupBlockList clears the value of the "group_block_list" field.
  41649. func (m *WhatsappMutation) ClearGroupBlockList() {
  41650. m.group_block_list = nil
  41651. m.appendgroup_block_list = nil
  41652. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  41653. }
  41654. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  41655. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  41656. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  41657. return ok
  41658. }
  41659. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  41660. func (m *WhatsappMutation) ResetGroupBlockList() {
  41661. m.group_block_list = nil
  41662. m.appendgroup_block_list = nil
  41663. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  41664. }
  41665. // ClearAgent clears the "agent" edge to the Agent entity.
  41666. func (m *WhatsappMutation) ClearAgent() {
  41667. m.clearedagent = true
  41668. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  41669. }
  41670. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  41671. func (m *WhatsappMutation) AgentCleared() bool {
  41672. return m.clearedagent
  41673. }
  41674. // AgentIDs returns the "agent" edge IDs in the mutation.
  41675. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  41676. // AgentID instead. It exists only for internal usage by the builders.
  41677. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  41678. if id := m.agent; id != nil {
  41679. ids = append(ids, *id)
  41680. }
  41681. return
  41682. }
  41683. // ResetAgent resets all changes to the "agent" edge.
  41684. func (m *WhatsappMutation) ResetAgent() {
  41685. m.agent = nil
  41686. m.clearedagent = false
  41687. }
  41688. // Where appends a list predicates to the WhatsappMutation builder.
  41689. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  41690. m.predicates = append(m.predicates, ps...)
  41691. }
  41692. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  41693. // users can use type-assertion to append predicates that do not depend on any generated package.
  41694. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  41695. p := make([]predicate.Whatsapp, len(ps))
  41696. for i := range ps {
  41697. p[i] = ps[i]
  41698. }
  41699. m.Where(p...)
  41700. }
  41701. // Op returns the operation name.
  41702. func (m *WhatsappMutation) Op() Op {
  41703. return m.op
  41704. }
  41705. // SetOp allows setting the mutation operation.
  41706. func (m *WhatsappMutation) SetOp(op Op) {
  41707. m.op = op
  41708. }
  41709. // Type returns the node type of this mutation (Whatsapp).
  41710. func (m *WhatsappMutation) Type() string {
  41711. return m.typ
  41712. }
  41713. // Fields returns all fields that were changed during this mutation. Note that in
  41714. // order to get all numeric fields that were incremented/decremented, call
  41715. // AddedFields().
  41716. func (m *WhatsappMutation) Fields() []string {
  41717. fields := make([]string, 0, 21)
  41718. if m.created_at != nil {
  41719. fields = append(fields, whatsapp.FieldCreatedAt)
  41720. }
  41721. if m.updated_at != nil {
  41722. fields = append(fields, whatsapp.FieldUpdatedAt)
  41723. }
  41724. if m.status != nil {
  41725. fields = append(fields, whatsapp.FieldStatus)
  41726. }
  41727. if m.deleted_at != nil {
  41728. fields = append(fields, whatsapp.FieldDeletedAt)
  41729. }
  41730. if m.wa_id != nil {
  41731. fields = append(fields, whatsapp.FieldWaID)
  41732. }
  41733. if m.wa_name != nil {
  41734. fields = append(fields, whatsapp.FieldWaName)
  41735. }
  41736. if m.callback != nil {
  41737. fields = append(fields, whatsapp.FieldCallback)
  41738. }
  41739. if m.agent != nil {
  41740. fields = append(fields, whatsapp.FieldAgentID)
  41741. }
  41742. if m.account != nil {
  41743. fields = append(fields, whatsapp.FieldAccount)
  41744. }
  41745. if m.cc != nil {
  41746. fields = append(fields, whatsapp.FieldCc)
  41747. }
  41748. if m.phone != nil {
  41749. fields = append(fields, whatsapp.FieldPhone)
  41750. }
  41751. if m.cc_phone != nil {
  41752. fields = append(fields, whatsapp.FieldCcPhone)
  41753. }
  41754. if m.phone_name != nil {
  41755. fields = append(fields, whatsapp.FieldPhoneName)
  41756. }
  41757. if m.phone_status != nil {
  41758. fields = append(fields, whatsapp.FieldPhoneStatus)
  41759. }
  41760. if m.organization_id != nil {
  41761. fields = append(fields, whatsapp.FieldOrganizationID)
  41762. }
  41763. if m.api_base != nil {
  41764. fields = append(fields, whatsapp.FieldAPIBase)
  41765. }
  41766. if m.api_key != nil {
  41767. fields = append(fields, whatsapp.FieldAPIKey)
  41768. }
  41769. if m.allow_list != nil {
  41770. fields = append(fields, whatsapp.FieldAllowList)
  41771. }
  41772. if m.group_allow_list != nil {
  41773. fields = append(fields, whatsapp.FieldGroupAllowList)
  41774. }
  41775. if m.block_list != nil {
  41776. fields = append(fields, whatsapp.FieldBlockList)
  41777. }
  41778. if m.group_block_list != nil {
  41779. fields = append(fields, whatsapp.FieldGroupBlockList)
  41780. }
  41781. return fields
  41782. }
  41783. // Field returns the value of a field with the given name. The second boolean
  41784. // return value indicates that this field was not set, or was not defined in the
  41785. // schema.
  41786. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  41787. switch name {
  41788. case whatsapp.FieldCreatedAt:
  41789. return m.CreatedAt()
  41790. case whatsapp.FieldUpdatedAt:
  41791. return m.UpdatedAt()
  41792. case whatsapp.FieldStatus:
  41793. return m.Status()
  41794. case whatsapp.FieldDeletedAt:
  41795. return m.DeletedAt()
  41796. case whatsapp.FieldWaID:
  41797. return m.WaID()
  41798. case whatsapp.FieldWaName:
  41799. return m.WaName()
  41800. case whatsapp.FieldCallback:
  41801. return m.Callback()
  41802. case whatsapp.FieldAgentID:
  41803. return m.AgentID()
  41804. case whatsapp.FieldAccount:
  41805. return m.Account()
  41806. case whatsapp.FieldCc:
  41807. return m.Cc()
  41808. case whatsapp.FieldPhone:
  41809. return m.Phone()
  41810. case whatsapp.FieldCcPhone:
  41811. return m.CcPhone()
  41812. case whatsapp.FieldPhoneName:
  41813. return m.PhoneName()
  41814. case whatsapp.FieldPhoneStatus:
  41815. return m.PhoneStatus()
  41816. case whatsapp.FieldOrganizationID:
  41817. return m.OrganizationID()
  41818. case whatsapp.FieldAPIBase:
  41819. return m.APIBase()
  41820. case whatsapp.FieldAPIKey:
  41821. return m.APIKey()
  41822. case whatsapp.FieldAllowList:
  41823. return m.AllowList()
  41824. case whatsapp.FieldGroupAllowList:
  41825. return m.GroupAllowList()
  41826. case whatsapp.FieldBlockList:
  41827. return m.BlockList()
  41828. case whatsapp.FieldGroupBlockList:
  41829. return m.GroupBlockList()
  41830. }
  41831. return nil, false
  41832. }
  41833. // OldField returns the old value of the field from the database. An error is
  41834. // returned if the mutation operation is not UpdateOne, or the query to the
  41835. // database failed.
  41836. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41837. switch name {
  41838. case whatsapp.FieldCreatedAt:
  41839. return m.OldCreatedAt(ctx)
  41840. case whatsapp.FieldUpdatedAt:
  41841. return m.OldUpdatedAt(ctx)
  41842. case whatsapp.FieldStatus:
  41843. return m.OldStatus(ctx)
  41844. case whatsapp.FieldDeletedAt:
  41845. return m.OldDeletedAt(ctx)
  41846. case whatsapp.FieldWaID:
  41847. return m.OldWaID(ctx)
  41848. case whatsapp.FieldWaName:
  41849. return m.OldWaName(ctx)
  41850. case whatsapp.FieldCallback:
  41851. return m.OldCallback(ctx)
  41852. case whatsapp.FieldAgentID:
  41853. return m.OldAgentID(ctx)
  41854. case whatsapp.FieldAccount:
  41855. return m.OldAccount(ctx)
  41856. case whatsapp.FieldCc:
  41857. return m.OldCc(ctx)
  41858. case whatsapp.FieldPhone:
  41859. return m.OldPhone(ctx)
  41860. case whatsapp.FieldCcPhone:
  41861. return m.OldCcPhone(ctx)
  41862. case whatsapp.FieldPhoneName:
  41863. return m.OldPhoneName(ctx)
  41864. case whatsapp.FieldPhoneStatus:
  41865. return m.OldPhoneStatus(ctx)
  41866. case whatsapp.FieldOrganizationID:
  41867. return m.OldOrganizationID(ctx)
  41868. case whatsapp.FieldAPIBase:
  41869. return m.OldAPIBase(ctx)
  41870. case whatsapp.FieldAPIKey:
  41871. return m.OldAPIKey(ctx)
  41872. case whatsapp.FieldAllowList:
  41873. return m.OldAllowList(ctx)
  41874. case whatsapp.FieldGroupAllowList:
  41875. return m.OldGroupAllowList(ctx)
  41876. case whatsapp.FieldBlockList:
  41877. return m.OldBlockList(ctx)
  41878. case whatsapp.FieldGroupBlockList:
  41879. return m.OldGroupBlockList(ctx)
  41880. }
  41881. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  41882. }
  41883. // SetField sets the value of a field with the given name. It returns an error if
  41884. // the field is not defined in the schema, or if the type mismatched the field
  41885. // type.
  41886. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  41887. switch name {
  41888. case whatsapp.FieldCreatedAt:
  41889. v, ok := value.(time.Time)
  41890. if !ok {
  41891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41892. }
  41893. m.SetCreatedAt(v)
  41894. return nil
  41895. case whatsapp.FieldUpdatedAt:
  41896. v, ok := value.(time.Time)
  41897. if !ok {
  41898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41899. }
  41900. m.SetUpdatedAt(v)
  41901. return nil
  41902. case whatsapp.FieldStatus:
  41903. v, ok := value.(uint8)
  41904. if !ok {
  41905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41906. }
  41907. m.SetStatus(v)
  41908. return nil
  41909. case whatsapp.FieldDeletedAt:
  41910. v, ok := value.(time.Time)
  41911. if !ok {
  41912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41913. }
  41914. m.SetDeletedAt(v)
  41915. return nil
  41916. case whatsapp.FieldWaID:
  41917. v, ok := value.(string)
  41918. if !ok {
  41919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41920. }
  41921. m.SetWaID(v)
  41922. return nil
  41923. case whatsapp.FieldWaName:
  41924. v, ok := value.(string)
  41925. if !ok {
  41926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41927. }
  41928. m.SetWaName(v)
  41929. return nil
  41930. case whatsapp.FieldCallback:
  41931. v, ok := value.(string)
  41932. if !ok {
  41933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41934. }
  41935. m.SetCallback(v)
  41936. return nil
  41937. case whatsapp.FieldAgentID:
  41938. v, ok := value.(uint64)
  41939. if !ok {
  41940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41941. }
  41942. m.SetAgentID(v)
  41943. return nil
  41944. case whatsapp.FieldAccount:
  41945. v, ok := value.(string)
  41946. if !ok {
  41947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41948. }
  41949. m.SetAccount(v)
  41950. return nil
  41951. case whatsapp.FieldCc:
  41952. v, ok := value.(string)
  41953. if !ok {
  41954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41955. }
  41956. m.SetCc(v)
  41957. return nil
  41958. case whatsapp.FieldPhone:
  41959. v, ok := value.(string)
  41960. if !ok {
  41961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41962. }
  41963. m.SetPhone(v)
  41964. return nil
  41965. case whatsapp.FieldCcPhone:
  41966. v, ok := value.(string)
  41967. if !ok {
  41968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41969. }
  41970. m.SetCcPhone(v)
  41971. return nil
  41972. case whatsapp.FieldPhoneName:
  41973. v, ok := value.(string)
  41974. if !ok {
  41975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41976. }
  41977. m.SetPhoneName(v)
  41978. return nil
  41979. case whatsapp.FieldPhoneStatus:
  41980. v, ok := value.(int8)
  41981. if !ok {
  41982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41983. }
  41984. m.SetPhoneStatus(v)
  41985. return nil
  41986. case whatsapp.FieldOrganizationID:
  41987. v, ok := value.(uint64)
  41988. if !ok {
  41989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41990. }
  41991. m.SetOrganizationID(v)
  41992. return nil
  41993. case whatsapp.FieldAPIBase:
  41994. v, ok := value.(string)
  41995. if !ok {
  41996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41997. }
  41998. m.SetAPIBase(v)
  41999. return nil
  42000. case whatsapp.FieldAPIKey:
  42001. v, ok := value.(string)
  42002. if !ok {
  42003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42004. }
  42005. m.SetAPIKey(v)
  42006. return nil
  42007. case whatsapp.FieldAllowList:
  42008. v, ok := value.([]string)
  42009. if !ok {
  42010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42011. }
  42012. m.SetAllowList(v)
  42013. return nil
  42014. case whatsapp.FieldGroupAllowList:
  42015. v, ok := value.([]string)
  42016. if !ok {
  42017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42018. }
  42019. m.SetGroupAllowList(v)
  42020. return nil
  42021. case whatsapp.FieldBlockList:
  42022. v, ok := value.([]string)
  42023. if !ok {
  42024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42025. }
  42026. m.SetBlockList(v)
  42027. return nil
  42028. case whatsapp.FieldGroupBlockList:
  42029. v, ok := value.([]string)
  42030. if !ok {
  42031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42032. }
  42033. m.SetGroupBlockList(v)
  42034. return nil
  42035. }
  42036. return fmt.Errorf("unknown Whatsapp field %s", name)
  42037. }
  42038. // AddedFields returns all numeric fields that were incremented/decremented during
  42039. // this mutation.
  42040. func (m *WhatsappMutation) AddedFields() []string {
  42041. var fields []string
  42042. if m.addstatus != nil {
  42043. fields = append(fields, whatsapp.FieldStatus)
  42044. }
  42045. if m.addphone_status != nil {
  42046. fields = append(fields, whatsapp.FieldPhoneStatus)
  42047. }
  42048. if m.addorganization_id != nil {
  42049. fields = append(fields, whatsapp.FieldOrganizationID)
  42050. }
  42051. return fields
  42052. }
  42053. // AddedField returns the numeric value that was incremented/decremented on a field
  42054. // with the given name. The second boolean return value indicates that this field
  42055. // was not set, or was not defined in the schema.
  42056. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  42057. switch name {
  42058. case whatsapp.FieldStatus:
  42059. return m.AddedStatus()
  42060. case whatsapp.FieldPhoneStatus:
  42061. return m.AddedPhoneStatus()
  42062. case whatsapp.FieldOrganizationID:
  42063. return m.AddedOrganizationID()
  42064. }
  42065. return nil, false
  42066. }
  42067. // AddField adds the value to the field with the given name. It returns an error if
  42068. // the field is not defined in the schema, or if the type mismatched the field
  42069. // type.
  42070. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  42071. switch name {
  42072. case whatsapp.FieldStatus:
  42073. v, ok := value.(int8)
  42074. if !ok {
  42075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42076. }
  42077. m.AddStatus(v)
  42078. return nil
  42079. case whatsapp.FieldPhoneStatus:
  42080. v, ok := value.(int8)
  42081. if !ok {
  42082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42083. }
  42084. m.AddPhoneStatus(v)
  42085. return nil
  42086. case whatsapp.FieldOrganizationID:
  42087. v, ok := value.(int64)
  42088. if !ok {
  42089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42090. }
  42091. m.AddOrganizationID(v)
  42092. return nil
  42093. }
  42094. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  42095. }
  42096. // ClearedFields returns all nullable fields that were cleared during this
  42097. // mutation.
  42098. func (m *WhatsappMutation) ClearedFields() []string {
  42099. var fields []string
  42100. if m.FieldCleared(whatsapp.FieldStatus) {
  42101. fields = append(fields, whatsapp.FieldStatus)
  42102. }
  42103. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  42104. fields = append(fields, whatsapp.FieldDeletedAt)
  42105. }
  42106. if m.FieldCleared(whatsapp.FieldWaID) {
  42107. fields = append(fields, whatsapp.FieldWaID)
  42108. }
  42109. if m.FieldCleared(whatsapp.FieldWaName) {
  42110. fields = append(fields, whatsapp.FieldWaName)
  42111. }
  42112. if m.FieldCleared(whatsapp.FieldCallback) {
  42113. fields = append(fields, whatsapp.FieldCallback)
  42114. }
  42115. if m.FieldCleared(whatsapp.FieldAccount) {
  42116. fields = append(fields, whatsapp.FieldAccount)
  42117. }
  42118. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  42119. fields = append(fields, whatsapp.FieldOrganizationID)
  42120. }
  42121. if m.FieldCleared(whatsapp.FieldAPIBase) {
  42122. fields = append(fields, whatsapp.FieldAPIBase)
  42123. }
  42124. if m.FieldCleared(whatsapp.FieldAPIKey) {
  42125. fields = append(fields, whatsapp.FieldAPIKey)
  42126. }
  42127. if m.FieldCleared(whatsapp.FieldAllowList) {
  42128. fields = append(fields, whatsapp.FieldAllowList)
  42129. }
  42130. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  42131. fields = append(fields, whatsapp.FieldGroupAllowList)
  42132. }
  42133. if m.FieldCleared(whatsapp.FieldBlockList) {
  42134. fields = append(fields, whatsapp.FieldBlockList)
  42135. }
  42136. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  42137. fields = append(fields, whatsapp.FieldGroupBlockList)
  42138. }
  42139. return fields
  42140. }
  42141. // FieldCleared returns a boolean indicating if a field with the given name was
  42142. // cleared in this mutation.
  42143. func (m *WhatsappMutation) FieldCleared(name string) bool {
  42144. _, ok := m.clearedFields[name]
  42145. return ok
  42146. }
  42147. // ClearField clears the value of the field with the given name. It returns an
  42148. // error if the field is not defined in the schema.
  42149. func (m *WhatsappMutation) ClearField(name string) error {
  42150. switch name {
  42151. case whatsapp.FieldStatus:
  42152. m.ClearStatus()
  42153. return nil
  42154. case whatsapp.FieldDeletedAt:
  42155. m.ClearDeletedAt()
  42156. return nil
  42157. case whatsapp.FieldWaID:
  42158. m.ClearWaID()
  42159. return nil
  42160. case whatsapp.FieldWaName:
  42161. m.ClearWaName()
  42162. return nil
  42163. case whatsapp.FieldCallback:
  42164. m.ClearCallback()
  42165. return nil
  42166. case whatsapp.FieldAccount:
  42167. m.ClearAccount()
  42168. return nil
  42169. case whatsapp.FieldOrganizationID:
  42170. m.ClearOrganizationID()
  42171. return nil
  42172. case whatsapp.FieldAPIBase:
  42173. m.ClearAPIBase()
  42174. return nil
  42175. case whatsapp.FieldAPIKey:
  42176. m.ClearAPIKey()
  42177. return nil
  42178. case whatsapp.FieldAllowList:
  42179. m.ClearAllowList()
  42180. return nil
  42181. case whatsapp.FieldGroupAllowList:
  42182. m.ClearGroupAllowList()
  42183. return nil
  42184. case whatsapp.FieldBlockList:
  42185. m.ClearBlockList()
  42186. return nil
  42187. case whatsapp.FieldGroupBlockList:
  42188. m.ClearGroupBlockList()
  42189. return nil
  42190. }
  42191. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  42192. }
  42193. // ResetField resets all changes in the mutation for the field with the given name.
  42194. // It returns an error if the field is not defined in the schema.
  42195. func (m *WhatsappMutation) ResetField(name string) error {
  42196. switch name {
  42197. case whatsapp.FieldCreatedAt:
  42198. m.ResetCreatedAt()
  42199. return nil
  42200. case whatsapp.FieldUpdatedAt:
  42201. m.ResetUpdatedAt()
  42202. return nil
  42203. case whatsapp.FieldStatus:
  42204. m.ResetStatus()
  42205. return nil
  42206. case whatsapp.FieldDeletedAt:
  42207. m.ResetDeletedAt()
  42208. return nil
  42209. case whatsapp.FieldWaID:
  42210. m.ResetWaID()
  42211. return nil
  42212. case whatsapp.FieldWaName:
  42213. m.ResetWaName()
  42214. return nil
  42215. case whatsapp.FieldCallback:
  42216. m.ResetCallback()
  42217. return nil
  42218. case whatsapp.FieldAgentID:
  42219. m.ResetAgentID()
  42220. return nil
  42221. case whatsapp.FieldAccount:
  42222. m.ResetAccount()
  42223. return nil
  42224. case whatsapp.FieldCc:
  42225. m.ResetCc()
  42226. return nil
  42227. case whatsapp.FieldPhone:
  42228. m.ResetPhone()
  42229. return nil
  42230. case whatsapp.FieldCcPhone:
  42231. m.ResetCcPhone()
  42232. return nil
  42233. case whatsapp.FieldPhoneName:
  42234. m.ResetPhoneName()
  42235. return nil
  42236. case whatsapp.FieldPhoneStatus:
  42237. m.ResetPhoneStatus()
  42238. return nil
  42239. case whatsapp.FieldOrganizationID:
  42240. m.ResetOrganizationID()
  42241. return nil
  42242. case whatsapp.FieldAPIBase:
  42243. m.ResetAPIBase()
  42244. return nil
  42245. case whatsapp.FieldAPIKey:
  42246. m.ResetAPIKey()
  42247. return nil
  42248. case whatsapp.FieldAllowList:
  42249. m.ResetAllowList()
  42250. return nil
  42251. case whatsapp.FieldGroupAllowList:
  42252. m.ResetGroupAllowList()
  42253. return nil
  42254. case whatsapp.FieldBlockList:
  42255. m.ResetBlockList()
  42256. return nil
  42257. case whatsapp.FieldGroupBlockList:
  42258. m.ResetGroupBlockList()
  42259. return nil
  42260. }
  42261. return fmt.Errorf("unknown Whatsapp field %s", name)
  42262. }
  42263. // AddedEdges returns all edge names that were set/added in this mutation.
  42264. func (m *WhatsappMutation) AddedEdges() []string {
  42265. edges := make([]string, 0, 1)
  42266. if m.agent != nil {
  42267. edges = append(edges, whatsapp.EdgeAgent)
  42268. }
  42269. return edges
  42270. }
  42271. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42272. // name in this mutation.
  42273. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  42274. switch name {
  42275. case whatsapp.EdgeAgent:
  42276. if id := m.agent; id != nil {
  42277. return []ent.Value{*id}
  42278. }
  42279. }
  42280. return nil
  42281. }
  42282. // RemovedEdges returns all edge names that were removed in this mutation.
  42283. func (m *WhatsappMutation) RemovedEdges() []string {
  42284. edges := make([]string, 0, 1)
  42285. return edges
  42286. }
  42287. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42288. // the given name in this mutation.
  42289. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  42290. return nil
  42291. }
  42292. // ClearedEdges returns all edge names that were cleared in this mutation.
  42293. func (m *WhatsappMutation) ClearedEdges() []string {
  42294. edges := make([]string, 0, 1)
  42295. if m.clearedagent {
  42296. edges = append(edges, whatsapp.EdgeAgent)
  42297. }
  42298. return edges
  42299. }
  42300. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42301. // was cleared in this mutation.
  42302. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  42303. switch name {
  42304. case whatsapp.EdgeAgent:
  42305. return m.clearedagent
  42306. }
  42307. return false
  42308. }
  42309. // ClearEdge clears the value of the edge with the given name. It returns an error
  42310. // if that edge is not defined in the schema.
  42311. func (m *WhatsappMutation) ClearEdge(name string) error {
  42312. switch name {
  42313. case whatsapp.EdgeAgent:
  42314. m.ClearAgent()
  42315. return nil
  42316. }
  42317. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  42318. }
  42319. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42320. // It returns an error if the edge is not defined in the schema.
  42321. func (m *WhatsappMutation) ResetEdge(name string) error {
  42322. switch name {
  42323. case whatsapp.EdgeAgent:
  42324. m.ResetAgent()
  42325. return nil
  42326. }
  42327. return fmt.Errorf("unknown Whatsapp edge %s", name)
  42328. }
  42329. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  42330. type WhatsappChannelMutation struct {
  42331. config
  42332. op Op
  42333. typ string
  42334. id *uint64
  42335. created_at *time.Time
  42336. updated_at *time.Time
  42337. status *uint8
  42338. addstatus *int8
  42339. deleted_at *time.Time
  42340. ak *string
  42341. sk *string
  42342. wa_id *string
  42343. wa_name *string
  42344. waba_id *uint64
  42345. addwaba_id *int64
  42346. business_id *uint64
  42347. addbusiness_id *int64
  42348. organization_id *uint64
  42349. addorganization_id *int64
  42350. verify_account *string
  42351. clearedFields map[string]struct{}
  42352. done bool
  42353. oldValue func(context.Context) (*WhatsappChannel, error)
  42354. predicates []predicate.WhatsappChannel
  42355. }
  42356. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  42357. // whatsappchannelOption allows management of the mutation configuration using functional options.
  42358. type whatsappchannelOption func(*WhatsappChannelMutation)
  42359. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  42360. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  42361. m := &WhatsappChannelMutation{
  42362. config: c,
  42363. op: op,
  42364. typ: TypeWhatsappChannel,
  42365. clearedFields: make(map[string]struct{}),
  42366. }
  42367. for _, opt := range opts {
  42368. opt(m)
  42369. }
  42370. return m
  42371. }
  42372. // withWhatsappChannelID sets the ID field of the mutation.
  42373. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  42374. return func(m *WhatsappChannelMutation) {
  42375. var (
  42376. err error
  42377. once sync.Once
  42378. value *WhatsappChannel
  42379. )
  42380. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  42381. once.Do(func() {
  42382. if m.done {
  42383. err = errors.New("querying old values post mutation is not allowed")
  42384. } else {
  42385. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  42386. }
  42387. })
  42388. return value, err
  42389. }
  42390. m.id = &id
  42391. }
  42392. }
  42393. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  42394. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  42395. return func(m *WhatsappChannelMutation) {
  42396. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  42397. return node, nil
  42398. }
  42399. m.id = &node.ID
  42400. }
  42401. }
  42402. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42403. // executed in a transaction (ent.Tx), a transactional client is returned.
  42404. func (m WhatsappChannelMutation) Client() *Client {
  42405. client := &Client{config: m.config}
  42406. client.init()
  42407. return client
  42408. }
  42409. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42410. // it returns an error otherwise.
  42411. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  42412. if _, ok := m.driver.(*txDriver); !ok {
  42413. return nil, errors.New("ent: mutation is not running in a transaction")
  42414. }
  42415. tx := &Tx{config: m.config}
  42416. tx.init()
  42417. return tx, nil
  42418. }
  42419. // SetID sets the value of the id field. Note that this
  42420. // operation is only accepted on creation of WhatsappChannel entities.
  42421. func (m *WhatsappChannelMutation) SetID(id uint64) {
  42422. m.id = &id
  42423. }
  42424. // ID returns the ID value in the mutation. Note that the ID is only available
  42425. // if it was provided to the builder or after it was returned from the database.
  42426. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  42427. if m.id == nil {
  42428. return
  42429. }
  42430. return *m.id, true
  42431. }
  42432. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42433. // That means, if the mutation is applied within a transaction with an isolation level such
  42434. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42435. // or updated by the mutation.
  42436. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  42437. switch {
  42438. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42439. id, exists := m.ID()
  42440. if exists {
  42441. return []uint64{id}, nil
  42442. }
  42443. fallthrough
  42444. case m.op.Is(OpUpdate | OpDelete):
  42445. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  42446. default:
  42447. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42448. }
  42449. }
  42450. // SetCreatedAt sets the "created_at" field.
  42451. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  42452. m.created_at = &t
  42453. }
  42454. // CreatedAt returns the value of the "created_at" field in the mutation.
  42455. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  42456. v := m.created_at
  42457. if v == nil {
  42458. return
  42459. }
  42460. return *v, true
  42461. }
  42462. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  42463. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42465. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42466. if !m.op.Is(OpUpdateOne) {
  42467. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42468. }
  42469. if m.id == nil || m.oldValue == nil {
  42470. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42471. }
  42472. oldValue, err := m.oldValue(ctx)
  42473. if err != nil {
  42474. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42475. }
  42476. return oldValue.CreatedAt, nil
  42477. }
  42478. // ResetCreatedAt resets all changes to the "created_at" field.
  42479. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  42480. m.created_at = nil
  42481. }
  42482. // SetUpdatedAt sets the "updated_at" field.
  42483. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  42484. m.updated_at = &t
  42485. }
  42486. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42487. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  42488. v := m.updated_at
  42489. if v == nil {
  42490. return
  42491. }
  42492. return *v, true
  42493. }
  42494. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  42495. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42497. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42498. if !m.op.Is(OpUpdateOne) {
  42499. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42500. }
  42501. if m.id == nil || m.oldValue == nil {
  42502. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42503. }
  42504. oldValue, err := m.oldValue(ctx)
  42505. if err != nil {
  42506. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42507. }
  42508. return oldValue.UpdatedAt, nil
  42509. }
  42510. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42511. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  42512. m.updated_at = nil
  42513. }
  42514. // SetStatus sets the "status" field.
  42515. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  42516. m.status = &u
  42517. m.addstatus = nil
  42518. }
  42519. // Status returns the value of the "status" field in the mutation.
  42520. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  42521. v := m.status
  42522. if v == nil {
  42523. return
  42524. }
  42525. return *v, true
  42526. }
  42527. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  42528. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42530. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42531. if !m.op.Is(OpUpdateOne) {
  42532. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42533. }
  42534. if m.id == nil || m.oldValue == nil {
  42535. return v, errors.New("OldStatus requires an ID field in the mutation")
  42536. }
  42537. oldValue, err := m.oldValue(ctx)
  42538. if err != nil {
  42539. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42540. }
  42541. return oldValue.Status, nil
  42542. }
  42543. // AddStatus adds u to the "status" field.
  42544. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  42545. if m.addstatus != nil {
  42546. *m.addstatus += u
  42547. } else {
  42548. m.addstatus = &u
  42549. }
  42550. }
  42551. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42552. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  42553. v := m.addstatus
  42554. if v == nil {
  42555. return
  42556. }
  42557. return *v, true
  42558. }
  42559. // ClearStatus clears the value of the "status" field.
  42560. func (m *WhatsappChannelMutation) ClearStatus() {
  42561. m.status = nil
  42562. m.addstatus = nil
  42563. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  42564. }
  42565. // StatusCleared returns if the "status" field was cleared in this mutation.
  42566. func (m *WhatsappChannelMutation) StatusCleared() bool {
  42567. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  42568. return ok
  42569. }
  42570. // ResetStatus resets all changes to the "status" field.
  42571. func (m *WhatsappChannelMutation) ResetStatus() {
  42572. m.status = nil
  42573. m.addstatus = nil
  42574. delete(m.clearedFields, whatsappchannel.FieldStatus)
  42575. }
  42576. // SetDeletedAt sets the "deleted_at" field.
  42577. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  42578. m.deleted_at = &t
  42579. }
  42580. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42581. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  42582. v := m.deleted_at
  42583. if v == nil {
  42584. return
  42585. }
  42586. return *v, true
  42587. }
  42588. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  42589. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42591. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42592. if !m.op.Is(OpUpdateOne) {
  42593. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42594. }
  42595. if m.id == nil || m.oldValue == nil {
  42596. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42597. }
  42598. oldValue, err := m.oldValue(ctx)
  42599. if err != nil {
  42600. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42601. }
  42602. return oldValue.DeletedAt, nil
  42603. }
  42604. // ClearDeletedAt clears the value of the "deleted_at" field.
  42605. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  42606. m.deleted_at = nil
  42607. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  42608. }
  42609. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42610. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  42611. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  42612. return ok
  42613. }
  42614. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42615. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  42616. m.deleted_at = nil
  42617. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  42618. }
  42619. // SetAk sets the "ak" field.
  42620. func (m *WhatsappChannelMutation) SetAk(s string) {
  42621. m.ak = &s
  42622. }
  42623. // Ak returns the value of the "ak" field in the mutation.
  42624. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  42625. v := m.ak
  42626. if v == nil {
  42627. return
  42628. }
  42629. return *v, true
  42630. }
  42631. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  42632. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42634. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  42635. if !m.op.Is(OpUpdateOne) {
  42636. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  42637. }
  42638. if m.id == nil || m.oldValue == nil {
  42639. return v, errors.New("OldAk requires an ID field in the mutation")
  42640. }
  42641. oldValue, err := m.oldValue(ctx)
  42642. if err != nil {
  42643. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  42644. }
  42645. return oldValue.Ak, nil
  42646. }
  42647. // ClearAk clears the value of the "ak" field.
  42648. func (m *WhatsappChannelMutation) ClearAk() {
  42649. m.ak = nil
  42650. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  42651. }
  42652. // AkCleared returns if the "ak" field was cleared in this mutation.
  42653. func (m *WhatsappChannelMutation) AkCleared() bool {
  42654. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  42655. return ok
  42656. }
  42657. // ResetAk resets all changes to the "ak" field.
  42658. func (m *WhatsappChannelMutation) ResetAk() {
  42659. m.ak = nil
  42660. delete(m.clearedFields, whatsappchannel.FieldAk)
  42661. }
  42662. // SetSk sets the "sk" field.
  42663. func (m *WhatsappChannelMutation) SetSk(s string) {
  42664. m.sk = &s
  42665. }
  42666. // Sk returns the value of the "sk" field in the mutation.
  42667. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  42668. v := m.sk
  42669. if v == nil {
  42670. return
  42671. }
  42672. return *v, true
  42673. }
  42674. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  42675. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42677. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  42678. if !m.op.Is(OpUpdateOne) {
  42679. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  42680. }
  42681. if m.id == nil || m.oldValue == nil {
  42682. return v, errors.New("OldSk requires an ID field in the mutation")
  42683. }
  42684. oldValue, err := m.oldValue(ctx)
  42685. if err != nil {
  42686. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  42687. }
  42688. return oldValue.Sk, nil
  42689. }
  42690. // ResetSk resets all changes to the "sk" field.
  42691. func (m *WhatsappChannelMutation) ResetSk() {
  42692. m.sk = nil
  42693. }
  42694. // SetWaID sets the "wa_id" field.
  42695. func (m *WhatsappChannelMutation) SetWaID(s string) {
  42696. m.wa_id = &s
  42697. }
  42698. // WaID returns the value of the "wa_id" field in the mutation.
  42699. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  42700. v := m.wa_id
  42701. if v == nil {
  42702. return
  42703. }
  42704. return *v, true
  42705. }
  42706. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  42707. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42709. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  42710. if !m.op.Is(OpUpdateOne) {
  42711. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  42712. }
  42713. if m.id == nil || m.oldValue == nil {
  42714. return v, errors.New("OldWaID requires an ID field in the mutation")
  42715. }
  42716. oldValue, err := m.oldValue(ctx)
  42717. if err != nil {
  42718. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  42719. }
  42720. return oldValue.WaID, nil
  42721. }
  42722. // ClearWaID clears the value of the "wa_id" field.
  42723. func (m *WhatsappChannelMutation) ClearWaID() {
  42724. m.wa_id = nil
  42725. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  42726. }
  42727. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  42728. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  42729. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  42730. return ok
  42731. }
  42732. // ResetWaID resets all changes to the "wa_id" field.
  42733. func (m *WhatsappChannelMutation) ResetWaID() {
  42734. m.wa_id = nil
  42735. delete(m.clearedFields, whatsappchannel.FieldWaID)
  42736. }
  42737. // SetWaName sets the "wa_name" field.
  42738. func (m *WhatsappChannelMutation) SetWaName(s string) {
  42739. m.wa_name = &s
  42740. }
  42741. // WaName returns the value of the "wa_name" field in the mutation.
  42742. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  42743. v := m.wa_name
  42744. if v == nil {
  42745. return
  42746. }
  42747. return *v, true
  42748. }
  42749. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  42750. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42752. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  42753. if !m.op.Is(OpUpdateOne) {
  42754. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  42755. }
  42756. if m.id == nil || m.oldValue == nil {
  42757. return v, errors.New("OldWaName requires an ID field in the mutation")
  42758. }
  42759. oldValue, err := m.oldValue(ctx)
  42760. if err != nil {
  42761. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  42762. }
  42763. return oldValue.WaName, nil
  42764. }
  42765. // ClearWaName clears the value of the "wa_name" field.
  42766. func (m *WhatsappChannelMutation) ClearWaName() {
  42767. m.wa_name = nil
  42768. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  42769. }
  42770. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  42771. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  42772. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  42773. return ok
  42774. }
  42775. // ResetWaName resets all changes to the "wa_name" field.
  42776. func (m *WhatsappChannelMutation) ResetWaName() {
  42777. m.wa_name = nil
  42778. delete(m.clearedFields, whatsappchannel.FieldWaName)
  42779. }
  42780. // SetWabaID sets the "waba_id" field.
  42781. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  42782. m.waba_id = &u
  42783. m.addwaba_id = nil
  42784. }
  42785. // WabaID returns the value of the "waba_id" field in the mutation.
  42786. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  42787. v := m.waba_id
  42788. if v == nil {
  42789. return
  42790. }
  42791. return *v, true
  42792. }
  42793. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  42794. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42796. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  42797. if !m.op.Is(OpUpdateOne) {
  42798. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  42799. }
  42800. if m.id == nil || m.oldValue == nil {
  42801. return v, errors.New("OldWabaID requires an ID field in the mutation")
  42802. }
  42803. oldValue, err := m.oldValue(ctx)
  42804. if err != nil {
  42805. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  42806. }
  42807. return oldValue.WabaID, nil
  42808. }
  42809. // AddWabaID adds u to the "waba_id" field.
  42810. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  42811. if m.addwaba_id != nil {
  42812. *m.addwaba_id += u
  42813. } else {
  42814. m.addwaba_id = &u
  42815. }
  42816. }
  42817. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  42818. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  42819. v := m.addwaba_id
  42820. if v == nil {
  42821. return
  42822. }
  42823. return *v, true
  42824. }
  42825. // ResetWabaID resets all changes to the "waba_id" field.
  42826. func (m *WhatsappChannelMutation) ResetWabaID() {
  42827. m.waba_id = nil
  42828. m.addwaba_id = nil
  42829. }
  42830. // SetBusinessID sets the "business_id" field.
  42831. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  42832. m.business_id = &u
  42833. m.addbusiness_id = nil
  42834. }
  42835. // BusinessID returns the value of the "business_id" field in the mutation.
  42836. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  42837. v := m.business_id
  42838. if v == nil {
  42839. return
  42840. }
  42841. return *v, true
  42842. }
  42843. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  42844. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42846. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  42847. if !m.op.Is(OpUpdateOne) {
  42848. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  42849. }
  42850. if m.id == nil || m.oldValue == nil {
  42851. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  42852. }
  42853. oldValue, err := m.oldValue(ctx)
  42854. if err != nil {
  42855. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  42856. }
  42857. return oldValue.BusinessID, nil
  42858. }
  42859. // AddBusinessID adds u to the "business_id" field.
  42860. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  42861. if m.addbusiness_id != nil {
  42862. *m.addbusiness_id += u
  42863. } else {
  42864. m.addbusiness_id = &u
  42865. }
  42866. }
  42867. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  42868. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  42869. v := m.addbusiness_id
  42870. if v == nil {
  42871. return
  42872. }
  42873. return *v, true
  42874. }
  42875. // ResetBusinessID resets all changes to the "business_id" field.
  42876. func (m *WhatsappChannelMutation) ResetBusinessID() {
  42877. m.business_id = nil
  42878. m.addbusiness_id = nil
  42879. }
  42880. // SetOrganizationID sets the "organization_id" field.
  42881. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  42882. m.organization_id = &u
  42883. m.addorganization_id = nil
  42884. }
  42885. // OrganizationID returns the value of the "organization_id" field in the mutation.
  42886. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  42887. v := m.organization_id
  42888. if v == nil {
  42889. return
  42890. }
  42891. return *v, true
  42892. }
  42893. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  42894. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42896. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  42897. if !m.op.Is(OpUpdateOne) {
  42898. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  42899. }
  42900. if m.id == nil || m.oldValue == nil {
  42901. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  42902. }
  42903. oldValue, err := m.oldValue(ctx)
  42904. if err != nil {
  42905. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  42906. }
  42907. return oldValue.OrganizationID, nil
  42908. }
  42909. // AddOrganizationID adds u to the "organization_id" field.
  42910. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  42911. if m.addorganization_id != nil {
  42912. *m.addorganization_id += u
  42913. } else {
  42914. m.addorganization_id = &u
  42915. }
  42916. }
  42917. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  42918. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  42919. v := m.addorganization_id
  42920. if v == nil {
  42921. return
  42922. }
  42923. return *v, true
  42924. }
  42925. // ClearOrganizationID clears the value of the "organization_id" field.
  42926. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  42927. m.organization_id = nil
  42928. m.addorganization_id = nil
  42929. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  42930. }
  42931. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  42932. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  42933. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  42934. return ok
  42935. }
  42936. // ResetOrganizationID resets all changes to the "organization_id" field.
  42937. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  42938. m.organization_id = nil
  42939. m.addorganization_id = nil
  42940. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  42941. }
  42942. // SetVerifyAccount sets the "verify_account" field.
  42943. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  42944. m.verify_account = &s
  42945. }
  42946. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  42947. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  42948. v := m.verify_account
  42949. if v == nil {
  42950. return
  42951. }
  42952. return *v, true
  42953. }
  42954. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  42955. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42957. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  42958. if !m.op.Is(OpUpdateOne) {
  42959. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  42960. }
  42961. if m.id == nil || m.oldValue == nil {
  42962. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  42963. }
  42964. oldValue, err := m.oldValue(ctx)
  42965. if err != nil {
  42966. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  42967. }
  42968. return oldValue.VerifyAccount, nil
  42969. }
  42970. // ResetVerifyAccount resets all changes to the "verify_account" field.
  42971. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  42972. m.verify_account = nil
  42973. }
  42974. // Where appends a list predicates to the WhatsappChannelMutation builder.
  42975. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  42976. m.predicates = append(m.predicates, ps...)
  42977. }
  42978. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  42979. // users can use type-assertion to append predicates that do not depend on any generated package.
  42980. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  42981. p := make([]predicate.WhatsappChannel, len(ps))
  42982. for i := range ps {
  42983. p[i] = ps[i]
  42984. }
  42985. m.Where(p...)
  42986. }
  42987. // Op returns the operation name.
  42988. func (m *WhatsappChannelMutation) Op() Op {
  42989. return m.op
  42990. }
  42991. // SetOp allows setting the mutation operation.
  42992. func (m *WhatsappChannelMutation) SetOp(op Op) {
  42993. m.op = op
  42994. }
  42995. // Type returns the node type of this mutation (WhatsappChannel).
  42996. func (m *WhatsappChannelMutation) Type() string {
  42997. return m.typ
  42998. }
  42999. // Fields returns all fields that were changed during this mutation. Note that in
  43000. // order to get all numeric fields that were incremented/decremented, call
  43001. // AddedFields().
  43002. func (m *WhatsappChannelMutation) Fields() []string {
  43003. fields := make([]string, 0, 12)
  43004. if m.created_at != nil {
  43005. fields = append(fields, whatsappchannel.FieldCreatedAt)
  43006. }
  43007. if m.updated_at != nil {
  43008. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  43009. }
  43010. if m.status != nil {
  43011. fields = append(fields, whatsappchannel.FieldStatus)
  43012. }
  43013. if m.deleted_at != nil {
  43014. fields = append(fields, whatsappchannel.FieldDeletedAt)
  43015. }
  43016. if m.ak != nil {
  43017. fields = append(fields, whatsappchannel.FieldAk)
  43018. }
  43019. if m.sk != nil {
  43020. fields = append(fields, whatsappchannel.FieldSk)
  43021. }
  43022. if m.wa_id != nil {
  43023. fields = append(fields, whatsappchannel.FieldWaID)
  43024. }
  43025. if m.wa_name != nil {
  43026. fields = append(fields, whatsappchannel.FieldWaName)
  43027. }
  43028. if m.waba_id != nil {
  43029. fields = append(fields, whatsappchannel.FieldWabaID)
  43030. }
  43031. if m.business_id != nil {
  43032. fields = append(fields, whatsappchannel.FieldBusinessID)
  43033. }
  43034. if m.organization_id != nil {
  43035. fields = append(fields, whatsappchannel.FieldOrganizationID)
  43036. }
  43037. if m.verify_account != nil {
  43038. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  43039. }
  43040. return fields
  43041. }
  43042. // Field returns the value of a field with the given name. The second boolean
  43043. // return value indicates that this field was not set, or was not defined in the
  43044. // schema.
  43045. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  43046. switch name {
  43047. case whatsappchannel.FieldCreatedAt:
  43048. return m.CreatedAt()
  43049. case whatsappchannel.FieldUpdatedAt:
  43050. return m.UpdatedAt()
  43051. case whatsappchannel.FieldStatus:
  43052. return m.Status()
  43053. case whatsappchannel.FieldDeletedAt:
  43054. return m.DeletedAt()
  43055. case whatsappchannel.FieldAk:
  43056. return m.Ak()
  43057. case whatsappchannel.FieldSk:
  43058. return m.Sk()
  43059. case whatsappchannel.FieldWaID:
  43060. return m.WaID()
  43061. case whatsappchannel.FieldWaName:
  43062. return m.WaName()
  43063. case whatsappchannel.FieldWabaID:
  43064. return m.WabaID()
  43065. case whatsappchannel.FieldBusinessID:
  43066. return m.BusinessID()
  43067. case whatsappchannel.FieldOrganizationID:
  43068. return m.OrganizationID()
  43069. case whatsappchannel.FieldVerifyAccount:
  43070. return m.VerifyAccount()
  43071. }
  43072. return nil, false
  43073. }
  43074. // OldField returns the old value of the field from the database. An error is
  43075. // returned if the mutation operation is not UpdateOne, or the query to the
  43076. // database failed.
  43077. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43078. switch name {
  43079. case whatsappchannel.FieldCreatedAt:
  43080. return m.OldCreatedAt(ctx)
  43081. case whatsappchannel.FieldUpdatedAt:
  43082. return m.OldUpdatedAt(ctx)
  43083. case whatsappchannel.FieldStatus:
  43084. return m.OldStatus(ctx)
  43085. case whatsappchannel.FieldDeletedAt:
  43086. return m.OldDeletedAt(ctx)
  43087. case whatsappchannel.FieldAk:
  43088. return m.OldAk(ctx)
  43089. case whatsappchannel.FieldSk:
  43090. return m.OldSk(ctx)
  43091. case whatsappchannel.FieldWaID:
  43092. return m.OldWaID(ctx)
  43093. case whatsappchannel.FieldWaName:
  43094. return m.OldWaName(ctx)
  43095. case whatsappchannel.FieldWabaID:
  43096. return m.OldWabaID(ctx)
  43097. case whatsappchannel.FieldBusinessID:
  43098. return m.OldBusinessID(ctx)
  43099. case whatsappchannel.FieldOrganizationID:
  43100. return m.OldOrganizationID(ctx)
  43101. case whatsappchannel.FieldVerifyAccount:
  43102. return m.OldVerifyAccount(ctx)
  43103. }
  43104. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  43105. }
  43106. // SetField sets the value of a field with the given name. It returns an error if
  43107. // the field is not defined in the schema, or if the type mismatched the field
  43108. // type.
  43109. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  43110. switch name {
  43111. case whatsappchannel.FieldCreatedAt:
  43112. v, ok := value.(time.Time)
  43113. if !ok {
  43114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43115. }
  43116. m.SetCreatedAt(v)
  43117. return nil
  43118. case whatsappchannel.FieldUpdatedAt:
  43119. v, ok := value.(time.Time)
  43120. if !ok {
  43121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43122. }
  43123. m.SetUpdatedAt(v)
  43124. return nil
  43125. case whatsappchannel.FieldStatus:
  43126. v, ok := value.(uint8)
  43127. if !ok {
  43128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43129. }
  43130. m.SetStatus(v)
  43131. return nil
  43132. case whatsappchannel.FieldDeletedAt:
  43133. v, ok := value.(time.Time)
  43134. if !ok {
  43135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43136. }
  43137. m.SetDeletedAt(v)
  43138. return nil
  43139. case whatsappchannel.FieldAk:
  43140. v, ok := value.(string)
  43141. if !ok {
  43142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43143. }
  43144. m.SetAk(v)
  43145. return nil
  43146. case whatsappchannel.FieldSk:
  43147. v, ok := value.(string)
  43148. if !ok {
  43149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43150. }
  43151. m.SetSk(v)
  43152. return nil
  43153. case whatsappchannel.FieldWaID:
  43154. v, ok := value.(string)
  43155. if !ok {
  43156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43157. }
  43158. m.SetWaID(v)
  43159. return nil
  43160. case whatsappchannel.FieldWaName:
  43161. v, ok := value.(string)
  43162. if !ok {
  43163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43164. }
  43165. m.SetWaName(v)
  43166. return nil
  43167. case whatsappchannel.FieldWabaID:
  43168. v, ok := value.(uint64)
  43169. if !ok {
  43170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43171. }
  43172. m.SetWabaID(v)
  43173. return nil
  43174. case whatsappchannel.FieldBusinessID:
  43175. v, ok := value.(uint64)
  43176. if !ok {
  43177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43178. }
  43179. m.SetBusinessID(v)
  43180. return nil
  43181. case whatsappchannel.FieldOrganizationID:
  43182. v, ok := value.(uint64)
  43183. if !ok {
  43184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43185. }
  43186. m.SetOrganizationID(v)
  43187. return nil
  43188. case whatsappchannel.FieldVerifyAccount:
  43189. v, ok := value.(string)
  43190. if !ok {
  43191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43192. }
  43193. m.SetVerifyAccount(v)
  43194. return nil
  43195. }
  43196. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  43197. }
  43198. // AddedFields returns all numeric fields that were incremented/decremented during
  43199. // this mutation.
  43200. func (m *WhatsappChannelMutation) AddedFields() []string {
  43201. var fields []string
  43202. if m.addstatus != nil {
  43203. fields = append(fields, whatsappchannel.FieldStatus)
  43204. }
  43205. if m.addwaba_id != nil {
  43206. fields = append(fields, whatsappchannel.FieldWabaID)
  43207. }
  43208. if m.addbusiness_id != nil {
  43209. fields = append(fields, whatsappchannel.FieldBusinessID)
  43210. }
  43211. if m.addorganization_id != nil {
  43212. fields = append(fields, whatsappchannel.FieldOrganizationID)
  43213. }
  43214. return fields
  43215. }
  43216. // AddedField returns the numeric value that was incremented/decremented on a field
  43217. // with the given name. The second boolean return value indicates that this field
  43218. // was not set, or was not defined in the schema.
  43219. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  43220. switch name {
  43221. case whatsappchannel.FieldStatus:
  43222. return m.AddedStatus()
  43223. case whatsappchannel.FieldWabaID:
  43224. return m.AddedWabaID()
  43225. case whatsappchannel.FieldBusinessID:
  43226. return m.AddedBusinessID()
  43227. case whatsappchannel.FieldOrganizationID:
  43228. return m.AddedOrganizationID()
  43229. }
  43230. return nil, false
  43231. }
  43232. // AddField adds the value to the field with the given name. It returns an error if
  43233. // the field is not defined in the schema, or if the type mismatched the field
  43234. // type.
  43235. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  43236. switch name {
  43237. case whatsappchannel.FieldStatus:
  43238. v, ok := value.(int8)
  43239. if !ok {
  43240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43241. }
  43242. m.AddStatus(v)
  43243. return nil
  43244. case whatsappchannel.FieldWabaID:
  43245. v, ok := value.(int64)
  43246. if !ok {
  43247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43248. }
  43249. m.AddWabaID(v)
  43250. return nil
  43251. case whatsappchannel.FieldBusinessID:
  43252. v, ok := value.(int64)
  43253. if !ok {
  43254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43255. }
  43256. m.AddBusinessID(v)
  43257. return nil
  43258. case whatsappchannel.FieldOrganizationID:
  43259. v, ok := value.(int64)
  43260. if !ok {
  43261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43262. }
  43263. m.AddOrganizationID(v)
  43264. return nil
  43265. }
  43266. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  43267. }
  43268. // ClearedFields returns all nullable fields that were cleared during this
  43269. // mutation.
  43270. func (m *WhatsappChannelMutation) ClearedFields() []string {
  43271. var fields []string
  43272. if m.FieldCleared(whatsappchannel.FieldStatus) {
  43273. fields = append(fields, whatsappchannel.FieldStatus)
  43274. }
  43275. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  43276. fields = append(fields, whatsappchannel.FieldDeletedAt)
  43277. }
  43278. if m.FieldCleared(whatsappchannel.FieldAk) {
  43279. fields = append(fields, whatsappchannel.FieldAk)
  43280. }
  43281. if m.FieldCleared(whatsappchannel.FieldWaID) {
  43282. fields = append(fields, whatsappchannel.FieldWaID)
  43283. }
  43284. if m.FieldCleared(whatsappchannel.FieldWaName) {
  43285. fields = append(fields, whatsappchannel.FieldWaName)
  43286. }
  43287. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  43288. fields = append(fields, whatsappchannel.FieldOrganizationID)
  43289. }
  43290. return fields
  43291. }
  43292. // FieldCleared returns a boolean indicating if a field with the given name was
  43293. // cleared in this mutation.
  43294. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  43295. _, ok := m.clearedFields[name]
  43296. return ok
  43297. }
  43298. // ClearField clears the value of the field with the given name. It returns an
  43299. // error if the field is not defined in the schema.
  43300. func (m *WhatsappChannelMutation) ClearField(name string) error {
  43301. switch name {
  43302. case whatsappchannel.FieldStatus:
  43303. m.ClearStatus()
  43304. return nil
  43305. case whatsappchannel.FieldDeletedAt:
  43306. m.ClearDeletedAt()
  43307. return nil
  43308. case whatsappchannel.FieldAk:
  43309. m.ClearAk()
  43310. return nil
  43311. case whatsappchannel.FieldWaID:
  43312. m.ClearWaID()
  43313. return nil
  43314. case whatsappchannel.FieldWaName:
  43315. m.ClearWaName()
  43316. return nil
  43317. case whatsappchannel.FieldOrganizationID:
  43318. m.ClearOrganizationID()
  43319. return nil
  43320. }
  43321. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  43322. }
  43323. // ResetField resets all changes in the mutation for the field with the given name.
  43324. // It returns an error if the field is not defined in the schema.
  43325. func (m *WhatsappChannelMutation) ResetField(name string) error {
  43326. switch name {
  43327. case whatsappchannel.FieldCreatedAt:
  43328. m.ResetCreatedAt()
  43329. return nil
  43330. case whatsappchannel.FieldUpdatedAt:
  43331. m.ResetUpdatedAt()
  43332. return nil
  43333. case whatsappchannel.FieldStatus:
  43334. m.ResetStatus()
  43335. return nil
  43336. case whatsappchannel.FieldDeletedAt:
  43337. m.ResetDeletedAt()
  43338. return nil
  43339. case whatsappchannel.FieldAk:
  43340. m.ResetAk()
  43341. return nil
  43342. case whatsappchannel.FieldSk:
  43343. m.ResetSk()
  43344. return nil
  43345. case whatsappchannel.FieldWaID:
  43346. m.ResetWaID()
  43347. return nil
  43348. case whatsappchannel.FieldWaName:
  43349. m.ResetWaName()
  43350. return nil
  43351. case whatsappchannel.FieldWabaID:
  43352. m.ResetWabaID()
  43353. return nil
  43354. case whatsappchannel.FieldBusinessID:
  43355. m.ResetBusinessID()
  43356. return nil
  43357. case whatsappchannel.FieldOrganizationID:
  43358. m.ResetOrganizationID()
  43359. return nil
  43360. case whatsappchannel.FieldVerifyAccount:
  43361. m.ResetVerifyAccount()
  43362. return nil
  43363. }
  43364. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  43365. }
  43366. // AddedEdges returns all edge names that were set/added in this mutation.
  43367. func (m *WhatsappChannelMutation) AddedEdges() []string {
  43368. edges := make([]string, 0, 0)
  43369. return edges
  43370. }
  43371. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43372. // name in this mutation.
  43373. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  43374. return nil
  43375. }
  43376. // RemovedEdges returns all edge names that were removed in this mutation.
  43377. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  43378. edges := make([]string, 0, 0)
  43379. return edges
  43380. }
  43381. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43382. // the given name in this mutation.
  43383. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  43384. return nil
  43385. }
  43386. // ClearedEdges returns all edge names that were cleared in this mutation.
  43387. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  43388. edges := make([]string, 0, 0)
  43389. return edges
  43390. }
  43391. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43392. // was cleared in this mutation.
  43393. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  43394. return false
  43395. }
  43396. // ClearEdge clears the value of the edge with the given name. It returns an error
  43397. // if that edge is not defined in the schema.
  43398. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  43399. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  43400. }
  43401. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43402. // It returns an error if the edge is not defined in the schema.
  43403. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  43404. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  43405. }
  43406. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  43407. type WorkExperienceMutation struct {
  43408. config
  43409. op Op
  43410. typ string
  43411. id *uint64
  43412. created_at *time.Time
  43413. updated_at *time.Time
  43414. deleted_at *time.Time
  43415. start_date *time.Time
  43416. end_date *time.Time
  43417. company *string
  43418. experience *string
  43419. organization_id *uint64
  43420. addorganization_id *int64
  43421. clearedFields map[string]struct{}
  43422. employee *uint64
  43423. clearedemployee bool
  43424. done bool
  43425. oldValue func(context.Context) (*WorkExperience, error)
  43426. predicates []predicate.WorkExperience
  43427. }
  43428. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  43429. // workexperienceOption allows management of the mutation configuration using functional options.
  43430. type workexperienceOption func(*WorkExperienceMutation)
  43431. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  43432. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  43433. m := &WorkExperienceMutation{
  43434. config: c,
  43435. op: op,
  43436. typ: TypeWorkExperience,
  43437. clearedFields: make(map[string]struct{}),
  43438. }
  43439. for _, opt := range opts {
  43440. opt(m)
  43441. }
  43442. return m
  43443. }
  43444. // withWorkExperienceID sets the ID field of the mutation.
  43445. func withWorkExperienceID(id uint64) workexperienceOption {
  43446. return func(m *WorkExperienceMutation) {
  43447. var (
  43448. err error
  43449. once sync.Once
  43450. value *WorkExperience
  43451. )
  43452. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  43453. once.Do(func() {
  43454. if m.done {
  43455. err = errors.New("querying old values post mutation is not allowed")
  43456. } else {
  43457. value, err = m.Client().WorkExperience.Get(ctx, id)
  43458. }
  43459. })
  43460. return value, err
  43461. }
  43462. m.id = &id
  43463. }
  43464. }
  43465. // withWorkExperience sets the old WorkExperience of the mutation.
  43466. func withWorkExperience(node *WorkExperience) workexperienceOption {
  43467. return func(m *WorkExperienceMutation) {
  43468. m.oldValue = func(context.Context) (*WorkExperience, error) {
  43469. return node, nil
  43470. }
  43471. m.id = &node.ID
  43472. }
  43473. }
  43474. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43475. // executed in a transaction (ent.Tx), a transactional client is returned.
  43476. func (m WorkExperienceMutation) Client() *Client {
  43477. client := &Client{config: m.config}
  43478. client.init()
  43479. return client
  43480. }
  43481. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43482. // it returns an error otherwise.
  43483. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  43484. if _, ok := m.driver.(*txDriver); !ok {
  43485. return nil, errors.New("ent: mutation is not running in a transaction")
  43486. }
  43487. tx := &Tx{config: m.config}
  43488. tx.init()
  43489. return tx, nil
  43490. }
  43491. // SetID sets the value of the id field. Note that this
  43492. // operation is only accepted on creation of WorkExperience entities.
  43493. func (m *WorkExperienceMutation) SetID(id uint64) {
  43494. m.id = &id
  43495. }
  43496. // ID returns the ID value in the mutation. Note that the ID is only available
  43497. // if it was provided to the builder or after it was returned from the database.
  43498. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  43499. if m.id == nil {
  43500. return
  43501. }
  43502. return *m.id, true
  43503. }
  43504. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43505. // That means, if the mutation is applied within a transaction with an isolation level such
  43506. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43507. // or updated by the mutation.
  43508. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  43509. switch {
  43510. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43511. id, exists := m.ID()
  43512. if exists {
  43513. return []uint64{id}, nil
  43514. }
  43515. fallthrough
  43516. case m.op.Is(OpUpdate | OpDelete):
  43517. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  43518. default:
  43519. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43520. }
  43521. }
  43522. // SetCreatedAt sets the "created_at" field.
  43523. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  43524. m.created_at = &t
  43525. }
  43526. // CreatedAt returns the value of the "created_at" field in the mutation.
  43527. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  43528. v := m.created_at
  43529. if v == nil {
  43530. return
  43531. }
  43532. return *v, true
  43533. }
  43534. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  43535. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43537. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43538. if !m.op.Is(OpUpdateOne) {
  43539. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43540. }
  43541. if m.id == nil || m.oldValue == nil {
  43542. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43543. }
  43544. oldValue, err := m.oldValue(ctx)
  43545. if err != nil {
  43546. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43547. }
  43548. return oldValue.CreatedAt, nil
  43549. }
  43550. // ResetCreatedAt resets all changes to the "created_at" field.
  43551. func (m *WorkExperienceMutation) ResetCreatedAt() {
  43552. m.created_at = nil
  43553. }
  43554. // SetUpdatedAt sets the "updated_at" field.
  43555. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  43556. m.updated_at = &t
  43557. }
  43558. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43559. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  43560. v := m.updated_at
  43561. if v == nil {
  43562. return
  43563. }
  43564. return *v, true
  43565. }
  43566. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  43567. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43569. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43570. if !m.op.Is(OpUpdateOne) {
  43571. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43572. }
  43573. if m.id == nil || m.oldValue == nil {
  43574. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43575. }
  43576. oldValue, err := m.oldValue(ctx)
  43577. if err != nil {
  43578. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43579. }
  43580. return oldValue.UpdatedAt, nil
  43581. }
  43582. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43583. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  43584. m.updated_at = nil
  43585. }
  43586. // SetDeletedAt sets the "deleted_at" field.
  43587. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  43588. m.deleted_at = &t
  43589. }
  43590. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43591. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  43592. v := m.deleted_at
  43593. if v == nil {
  43594. return
  43595. }
  43596. return *v, true
  43597. }
  43598. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  43599. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43601. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43602. if !m.op.Is(OpUpdateOne) {
  43603. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43604. }
  43605. if m.id == nil || m.oldValue == nil {
  43606. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43607. }
  43608. oldValue, err := m.oldValue(ctx)
  43609. if err != nil {
  43610. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43611. }
  43612. return oldValue.DeletedAt, nil
  43613. }
  43614. // ClearDeletedAt clears the value of the "deleted_at" field.
  43615. func (m *WorkExperienceMutation) ClearDeletedAt() {
  43616. m.deleted_at = nil
  43617. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  43618. }
  43619. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43620. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  43621. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  43622. return ok
  43623. }
  43624. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43625. func (m *WorkExperienceMutation) ResetDeletedAt() {
  43626. m.deleted_at = nil
  43627. delete(m.clearedFields, workexperience.FieldDeletedAt)
  43628. }
  43629. // SetEmployeeID sets the "employee_id" field.
  43630. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  43631. m.employee = &u
  43632. }
  43633. // EmployeeID returns the value of the "employee_id" field in the mutation.
  43634. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  43635. v := m.employee
  43636. if v == nil {
  43637. return
  43638. }
  43639. return *v, true
  43640. }
  43641. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  43642. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43644. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  43645. if !m.op.Is(OpUpdateOne) {
  43646. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  43647. }
  43648. if m.id == nil || m.oldValue == nil {
  43649. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  43650. }
  43651. oldValue, err := m.oldValue(ctx)
  43652. if err != nil {
  43653. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  43654. }
  43655. return oldValue.EmployeeID, nil
  43656. }
  43657. // ResetEmployeeID resets all changes to the "employee_id" field.
  43658. func (m *WorkExperienceMutation) ResetEmployeeID() {
  43659. m.employee = nil
  43660. }
  43661. // SetStartDate sets the "start_date" field.
  43662. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  43663. m.start_date = &t
  43664. }
  43665. // StartDate returns the value of the "start_date" field in the mutation.
  43666. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  43667. v := m.start_date
  43668. if v == nil {
  43669. return
  43670. }
  43671. return *v, true
  43672. }
  43673. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  43674. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43676. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  43677. if !m.op.Is(OpUpdateOne) {
  43678. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  43679. }
  43680. if m.id == nil || m.oldValue == nil {
  43681. return v, errors.New("OldStartDate requires an ID field in the mutation")
  43682. }
  43683. oldValue, err := m.oldValue(ctx)
  43684. if err != nil {
  43685. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  43686. }
  43687. return oldValue.StartDate, nil
  43688. }
  43689. // ResetStartDate resets all changes to the "start_date" field.
  43690. func (m *WorkExperienceMutation) ResetStartDate() {
  43691. m.start_date = nil
  43692. }
  43693. // SetEndDate sets the "end_date" field.
  43694. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  43695. m.end_date = &t
  43696. }
  43697. // EndDate returns the value of the "end_date" field in the mutation.
  43698. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  43699. v := m.end_date
  43700. if v == nil {
  43701. return
  43702. }
  43703. return *v, true
  43704. }
  43705. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  43706. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43708. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  43709. if !m.op.Is(OpUpdateOne) {
  43710. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  43711. }
  43712. if m.id == nil || m.oldValue == nil {
  43713. return v, errors.New("OldEndDate requires an ID field in the mutation")
  43714. }
  43715. oldValue, err := m.oldValue(ctx)
  43716. if err != nil {
  43717. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  43718. }
  43719. return oldValue.EndDate, nil
  43720. }
  43721. // ResetEndDate resets all changes to the "end_date" field.
  43722. func (m *WorkExperienceMutation) ResetEndDate() {
  43723. m.end_date = nil
  43724. }
  43725. // SetCompany sets the "company" field.
  43726. func (m *WorkExperienceMutation) SetCompany(s string) {
  43727. m.company = &s
  43728. }
  43729. // Company returns the value of the "company" field in the mutation.
  43730. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  43731. v := m.company
  43732. if v == nil {
  43733. return
  43734. }
  43735. return *v, true
  43736. }
  43737. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  43738. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43740. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  43741. if !m.op.Is(OpUpdateOne) {
  43742. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  43743. }
  43744. if m.id == nil || m.oldValue == nil {
  43745. return v, errors.New("OldCompany requires an ID field in the mutation")
  43746. }
  43747. oldValue, err := m.oldValue(ctx)
  43748. if err != nil {
  43749. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  43750. }
  43751. return oldValue.Company, nil
  43752. }
  43753. // ResetCompany resets all changes to the "company" field.
  43754. func (m *WorkExperienceMutation) ResetCompany() {
  43755. m.company = nil
  43756. }
  43757. // SetExperience sets the "experience" field.
  43758. func (m *WorkExperienceMutation) SetExperience(s string) {
  43759. m.experience = &s
  43760. }
  43761. // Experience returns the value of the "experience" field in the mutation.
  43762. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  43763. v := m.experience
  43764. if v == nil {
  43765. return
  43766. }
  43767. return *v, true
  43768. }
  43769. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  43770. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43772. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  43773. if !m.op.Is(OpUpdateOne) {
  43774. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  43775. }
  43776. if m.id == nil || m.oldValue == nil {
  43777. return v, errors.New("OldExperience requires an ID field in the mutation")
  43778. }
  43779. oldValue, err := m.oldValue(ctx)
  43780. if err != nil {
  43781. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  43782. }
  43783. return oldValue.Experience, nil
  43784. }
  43785. // ResetExperience resets all changes to the "experience" field.
  43786. func (m *WorkExperienceMutation) ResetExperience() {
  43787. m.experience = nil
  43788. }
  43789. // SetOrganizationID sets the "organization_id" field.
  43790. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  43791. m.organization_id = &u
  43792. m.addorganization_id = nil
  43793. }
  43794. // OrganizationID returns the value of the "organization_id" field in the mutation.
  43795. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  43796. v := m.organization_id
  43797. if v == nil {
  43798. return
  43799. }
  43800. return *v, true
  43801. }
  43802. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  43803. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43805. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  43806. if !m.op.Is(OpUpdateOne) {
  43807. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  43808. }
  43809. if m.id == nil || m.oldValue == nil {
  43810. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  43811. }
  43812. oldValue, err := m.oldValue(ctx)
  43813. if err != nil {
  43814. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  43815. }
  43816. return oldValue.OrganizationID, nil
  43817. }
  43818. // AddOrganizationID adds u to the "organization_id" field.
  43819. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  43820. if m.addorganization_id != nil {
  43821. *m.addorganization_id += u
  43822. } else {
  43823. m.addorganization_id = &u
  43824. }
  43825. }
  43826. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  43827. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  43828. v := m.addorganization_id
  43829. if v == nil {
  43830. return
  43831. }
  43832. return *v, true
  43833. }
  43834. // ResetOrganizationID resets all changes to the "organization_id" field.
  43835. func (m *WorkExperienceMutation) ResetOrganizationID() {
  43836. m.organization_id = nil
  43837. m.addorganization_id = nil
  43838. }
  43839. // ClearEmployee clears the "employee" edge to the Employee entity.
  43840. func (m *WorkExperienceMutation) ClearEmployee() {
  43841. m.clearedemployee = true
  43842. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  43843. }
  43844. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  43845. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  43846. return m.clearedemployee
  43847. }
  43848. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  43849. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43850. // EmployeeID instead. It exists only for internal usage by the builders.
  43851. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  43852. if id := m.employee; id != nil {
  43853. ids = append(ids, *id)
  43854. }
  43855. return
  43856. }
  43857. // ResetEmployee resets all changes to the "employee" edge.
  43858. func (m *WorkExperienceMutation) ResetEmployee() {
  43859. m.employee = nil
  43860. m.clearedemployee = false
  43861. }
  43862. // Where appends a list predicates to the WorkExperienceMutation builder.
  43863. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  43864. m.predicates = append(m.predicates, ps...)
  43865. }
  43866. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  43867. // users can use type-assertion to append predicates that do not depend on any generated package.
  43868. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  43869. p := make([]predicate.WorkExperience, len(ps))
  43870. for i := range ps {
  43871. p[i] = ps[i]
  43872. }
  43873. m.Where(p...)
  43874. }
  43875. // Op returns the operation name.
  43876. func (m *WorkExperienceMutation) Op() Op {
  43877. return m.op
  43878. }
  43879. // SetOp allows setting the mutation operation.
  43880. func (m *WorkExperienceMutation) SetOp(op Op) {
  43881. m.op = op
  43882. }
  43883. // Type returns the node type of this mutation (WorkExperience).
  43884. func (m *WorkExperienceMutation) Type() string {
  43885. return m.typ
  43886. }
  43887. // Fields returns all fields that were changed during this mutation. Note that in
  43888. // order to get all numeric fields that were incremented/decremented, call
  43889. // AddedFields().
  43890. func (m *WorkExperienceMutation) Fields() []string {
  43891. fields := make([]string, 0, 9)
  43892. if m.created_at != nil {
  43893. fields = append(fields, workexperience.FieldCreatedAt)
  43894. }
  43895. if m.updated_at != nil {
  43896. fields = append(fields, workexperience.FieldUpdatedAt)
  43897. }
  43898. if m.deleted_at != nil {
  43899. fields = append(fields, workexperience.FieldDeletedAt)
  43900. }
  43901. if m.employee != nil {
  43902. fields = append(fields, workexperience.FieldEmployeeID)
  43903. }
  43904. if m.start_date != nil {
  43905. fields = append(fields, workexperience.FieldStartDate)
  43906. }
  43907. if m.end_date != nil {
  43908. fields = append(fields, workexperience.FieldEndDate)
  43909. }
  43910. if m.company != nil {
  43911. fields = append(fields, workexperience.FieldCompany)
  43912. }
  43913. if m.experience != nil {
  43914. fields = append(fields, workexperience.FieldExperience)
  43915. }
  43916. if m.organization_id != nil {
  43917. fields = append(fields, workexperience.FieldOrganizationID)
  43918. }
  43919. return fields
  43920. }
  43921. // Field returns the value of a field with the given name. The second boolean
  43922. // return value indicates that this field was not set, or was not defined in the
  43923. // schema.
  43924. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  43925. switch name {
  43926. case workexperience.FieldCreatedAt:
  43927. return m.CreatedAt()
  43928. case workexperience.FieldUpdatedAt:
  43929. return m.UpdatedAt()
  43930. case workexperience.FieldDeletedAt:
  43931. return m.DeletedAt()
  43932. case workexperience.FieldEmployeeID:
  43933. return m.EmployeeID()
  43934. case workexperience.FieldStartDate:
  43935. return m.StartDate()
  43936. case workexperience.FieldEndDate:
  43937. return m.EndDate()
  43938. case workexperience.FieldCompany:
  43939. return m.Company()
  43940. case workexperience.FieldExperience:
  43941. return m.Experience()
  43942. case workexperience.FieldOrganizationID:
  43943. return m.OrganizationID()
  43944. }
  43945. return nil, false
  43946. }
  43947. // OldField returns the old value of the field from the database. An error is
  43948. // returned if the mutation operation is not UpdateOne, or the query to the
  43949. // database failed.
  43950. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43951. switch name {
  43952. case workexperience.FieldCreatedAt:
  43953. return m.OldCreatedAt(ctx)
  43954. case workexperience.FieldUpdatedAt:
  43955. return m.OldUpdatedAt(ctx)
  43956. case workexperience.FieldDeletedAt:
  43957. return m.OldDeletedAt(ctx)
  43958. case workexperience.FieldEmployeeID:
  43959. return m.OldEmployeeID(ctx)
  43960. case workexperience.FieldStartDate:
  43961. return m.OldStartDate(ctx)
  43962. case workexperience.FieldEndDate:
  43963. return m.OldEndDate(ctx)
  43964. case workexperience.FieldCompany:
  43965. return m.OldCompany(ctx)
  43966. case workexperience.FieldExperience:
  43967. return m.OldExperience(ctx)
  43968. case workexperience.FieldOrganizationID:
  43969. return m.OldOrganizationID(ctx)
  43970. }
  43971. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  43972. }
  43973. // SetField sets the value of a field with the given name. It returns an error if
  43974. // the field is not defined in the schema, or if the type mismatched the field
  43975. // type.
  43976. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  43977. switch name {
  43978. case workexperience.FieldCreatedAt:
  43979. v, ok := value.(time.Time)
  43980. if !ok {
  43981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43982. }
  43983. m.SetCreatedAt(v)
  43984. return nil
  43985. case workexperience.FieldUpdatedAt:
  43986. v, ok := value.(time.Time)
  43987. if !ok {
  43988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43989. }
  43990. m.SetUpdatedAt(v)
  43991. return nil
  43992. case workexperience.FieldDeletedAt:
  43993. v, ok := value.(time.Time)
  43994. if !ok {
  43995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43996. }
  43997. m.SetDeletedAt(v)
  43998. return nil
  43999. case workexperience.FieldEmployeeID:
  44000. v, ok := value.(uint64)
  44001. if !ok {
  44002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44003. }
  44004. m.SetEmployeeID(v)
  44005. return nil
  44006. case workexperience.FieldStartDate:
  44007. v, ok := value.(time.Time)
  44008. if !ok {
  44009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44010. }
  44011. m.SetStartDate(v)
  44012. return nil
  44013. case workexperience.FieldEndDate:
  44014. v, ok := value.(time.Time)
  44015. if !ok {
  44016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44017. }
  44018. m.SetEndDate(v)
  44019. return nil
  44020. case workexperience.FieldCompany:
  44021. v, ok := value.(string)
  44022. if !ok {
  44023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44024. }
  44025. m.SetCompany(v)
  44026. return nil
  44027. case workexperience.FieldExperience:
  44028. v, ok := value.(string)
  44029. if !ok {
  44030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44031. }
  44032. m.SetExperience(v)
  44033. return nil
  44034. case workexperience.FieldOrganizationID:
  44035. v, ok := value.(uint64)
  44036. if !ok {
  44037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44038. }
  44039. m.SetOrganizationID(v)
  44040. return nil
  44041. }
  44042. return fmt.Errorf("unknown WorkExperience field %s", name)
  44043. }
  44044. // AddedFields returns all numeric fields that were incremented/decremented during
  44045. // this mutation.
  44046. func (m *WorkExperienceMutation) AddedFields() []string {
  44047. var fields []string
  44048. if m.addorganization_id != nil {
  44049. fields = append(fields, workexperience.FieldOrganizationID)
  44050. }
  44051. return fields
  44052. }
  44053. // AddedField returns the numeric value that was incremented/decremented on a field
  44054. // with the given name. The second boolean return value indicates that this field
  44055. // was not set, or was not defined in the schema.
  44056. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  44057. switch name {
  44058. case workexperience.FieldOrganizationID:
  44059. return m.AddedOrganizationID()
  44060. }
  44061. return nil, false
  44062. }
  44063. // AddField adds the value to the field with the given name. It returns an error if
  44064. // the field is not defined in the schema, or if the type mismatched the field
  44065. // type.
  44066. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  44067. switch name {
  44068. case workexperience.FieldOrganizationID:
  44069. v, ok := value.(int64)
  44070. if !ok {
  44071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44072. }
  44073. m.AddOrganizationID(v)
  44074. return nil
  44075. }
  44076. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  44077. }
  44078. // ClearedFields returns all nullable fields that were cleared during this
  44079. // mutation.
  44080. func (m *WorkExperienceMutation) ClearedFields() []string {
  44081. var fields []string
  44082. if m.FieldCleared(workexperience.FieldDeletedAt) {
  44083. fields = append(fields, workexperience.FieldDeletedAt)
  44084. }
  44085. return fields
  44086. }
  44087. // FieldCleared returns a boolean indicating if a field with the given name was
  44088. // cleared in this mutation.
  44089. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  44090. _, ok := m.clearedFields[name]
  44091. return ok
  44092. }
  44093. // ClearField clears the value of the field with the given name. It returns an
  44094. // error if the field is not defined in the schema.
  44095. func (m *WorkExperienceMutation) ClearField(name string) error {
  44096. switch name {
  44097. case workexperience.FieldDeletedAt:
  44098. m.ClearDeletedAt()
  44099. return nil
  44100. }
  44101. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  44102. }
  44103. // ResetField resets all changes in the mutation for the field with the given name.
  44104. // It returns an error if the field is not defined in the schema.
  44105. func (m *WorkExperienceMutation) ResetField(name string) error {
  44106. switch name {
  44107. case workexperience.FieldCreatedAt:
  44108. m.ResetCreatedAt()
  44109. return nil
  44110. case workexperience.FieldUpdatedAt:
  44111. m.ResetUpdatedAt()
  44112. return nil
  44113. case workexperience.FieldDeletedAt:
  44114. m.ResetDeletedAt()
  44115. return nil
  44116. case workexperience.FieldEmployeeID:
  44117. m.ResetEmployeeID()
  44118. return nil
  44119. case workexperience.FieldStartDate:
  44120. m.ResetStartDate()
  44121. return nil
  44122. case workexperience.FieldEndDate:
  44123. m.ResetEndDate()
  44124. return nil
  44125. case workexperience.FieldCompany:
  44126. m.ResetCompany()
  44127. return nil
  44128. case workexperience.FieldExperience:
  44129. m.ResetExperience()
  44130. return nil
  44131. case workexperience.FieldOrganizationID:
  44132. m.ResetOrganizationID()
  44133. return nil
  44134. }
  44135. return fmt.Errorf("unknown WorkExperience field %s", name)
  44136. }
  44137. // AddedEdges returns all edge names that were set/added in this mutation.
  44138. func (m *WorkExperienceMutation) AddedEdges() []string {
  44139. edges := make([]string, 0, 1)
  44140. if m.employee != nil {
  44141. edges = append(edges, workexperience.EdgeEmployee)
  44142. }
  44143. return edges
  44144. }
  44145. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44146. // name in this mutation.
  44147. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  44148. switch name {
  44149. case workexperience.EdgeEmployee:
  44150. if id := m.employee; id != nil {
  44151. return []ent.Value{*id}
  44152. }
  44153. }
  44154. return nil
  44155. }
  44156. // RemovedEdges returns all edge names that were removed in this mutation.
  44157. func (m *WorkExperienceMutation) RemovedEdges() []string {
  44158. edges := make([]string, 0, 1)
  44159. return edges
  44160. }
  44161. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44162. // the given name in this mutation.
  44163. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  44164. return nil
  44165. }
  44166. // ClearedEdges returns all edge names that were cleared in this mutation.
  44167. func (m *WorkExperienceMutation) ClearedEdges() []string {
  44168. edges := make([]string, 0, 1)
  44169. if m.clearedemployee {
  44170. edges = append(edges, workexperience.EdgeEmployee)
  44171. }
  44172. return edges
  44173. }
  44174. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44175. // was cleared in this mutation.
  44176. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  44177. switch name {
  44178. case workexperience.EdgeEmployee:
  44179. return m.clearedemployee
  44180. }
  44181. return false
  44182. }
  44183. // ClearEdge clears the value of the edge with the given name. It returns an error
  44184. // if that edge is not defined in the schema.
  44185. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  44186. switch name {
  44187. case workexperience.EdgeEmployee:
  44188. m.ClearEmployee()
  44189. return nil
  44190. }
  44191. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  44192. }
  44193. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44194. // It returns an error if the edge is not defined in the schema.
  44195. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  44196. switch name {
  44197. case workexperience.EdgeEmployee:
  44198. m.ResetEmployee()
  44199. return nil
  44200. }
  44201. return fmt.Errorf("unknown WorkExperience edge %s", name)
  44202. }
  44203. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  44204. type WpChatroomMutation struct {
  44205. config
  44206. op Op
  44207. typ string
  44208. id *uint64
  44209. created_at *time.Time
  44210. updated_at *time.Time
  44211. status *uint8
  44212. addstatus *int8
  44213. wx_wxid *string
  44214. chatroom_id *string
  44215. nickname *string
  44216. owner *string
  44217. avatar *string
  44218. member_list *[]string
  44219. appendmember_list []string
  44220. clearedFields map[string]struct{}
  44221. done bool
  44222. oldValue func(context.Context) (*WpChatroom, error)
  44223. predicates []predicate.WpChatroom
  44224. }
  44225. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  44226. // wpchatroomOption allows management of the mutation configuration using functional options.
  44227. type wpchatroomOption func(*WpChatroomMutation)
  44228. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  44229. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  44230. m := &WpChatroomMutation{
  44231. config: c,
  44232. op: op,
  44233. typ: TypeWpChatroom,
  44234. clearedFields: make(map[string]struct{}),
  44235. }
  44236. for _, opt := range opts {
  44237. opt(m)
  44238. }
  44239. return m
  44240. }
  44241. // withWpChatroomID sets the ID field of the mutation.
  44242. func withWpChatroomID(id uint64) wpchatroomOption {
  44243. return func(m *WpChatroomMutation) {
  44244. var (
  44245. err error
  44246. once sync.Once
  44247. value *WpChatroom
  44248. )
  44249. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  44250. once.Do(func() {
  44251. if m.done {
  44252. err = errors.New("querying old values post mutation is not allowed")
  44253. } else {
  44254. value, err = m.Client().WpChatroom.Get(ctx, id)
  44255. }
  44256. })
  44257. return value, err
  44258. }
  44259. m.id = &id
  44260. }
  44261. }
  44262. // withWpChatroom sets the old WpChatroom of the mutation.
  44263. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  44264. return func(m *WpChatroomMutation) {
  44265. m.oldValue = func(context.Context) (*WpChatroom, error) {
  44266. return node, nil
  44267. }
  44268. m.id = &node.ID
  44269. }
  44270. }
  44271. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44272. // executed in a transaction (ent.Tx), a transactional client is returned.
  44273. func (m WpChatroomMutation) Client() *Client {
  44274. client := &Client{config: m.config}
  44275. client.init()
  44276. return client
  44277. }
  44278. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44279. // it returns an error otherwise.
  44280. func (m WpChatroomMutation) Tx() (*Tx, error) {
  44281. if _, ok := m.driver.(*txDriver); !ok {
  44282. return nil, errors.New("ent: mutation is not running in a transaction")
  44283. }
  44284. tx := &Tx{config: m.config}
  44285. tx.init()
  44286. return tx, nil
  44287. }
  44288. // SetID sets the value of the id field. Note that this
  44289. // operation is only accepted on creation of WpChatroom entities.
  44290. func (m *WpChatroomMutation) SetID(id uint64) {
  44291. m.id = &id
  44292. }
  44293. // ID returns the ID value in the mutation. Note that the ID is only available
  44294. // if it was provided to the builder or after it was returned from the database.
  44295. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  44296. if m.id == nil {
  44297. return
  44298. }
  44299. return *m.id, true
  44300. }
  44301. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44302. // That means, if the mutation is applied within a transaction with an isolation level such
  44303. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44304. // or updated by the mutation.
  44305. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  44306. switch {
  44307. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44308. id, exists := m.ID()
  44309. if exists {
  44310. return []uint64{id}, nil
  44311. }
  44312. fallthrough
  44313. case m.op.Is(OpUpdate | OpDelete):
  44314. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  44315. default:
  44316. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44317. }
  44318. }
  44319. // SetCreatedAt sets the "created_at" field.
  44320. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  44321. m.created_at = &t
  44322. }
  44323. // CreatedAt returns the value of the "created_at" field in the mutation.
  44324. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  44325. v := m.created_at
  44326. if v == nil {
  44327. return
  44328. }
  44329. return *v, true
  44330. }
  44331. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  44332. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44334. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44335. if !m.op.Is(OpUpdateOne) {
  44336. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44337. }
  44338. if m.id == nil || m.oldValue == nil {
  44339. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44340. }
  44341. oldValue, err := m.oldValue(ctx)
  44342. if err != nil {
  44343. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44344. }
  44345. return oldValue.CreatedAt, nil
  44346. }
  44347. // ResetCreatedAt resets all changes to the "created_at" field.
  44348. func (m *WpChatroomMutation) ResetCreatedAt() {
  44349. m.created_at = nil
  44350. }
  44351. // SetUpdatedAt sets the "updated_at" field.
  44352. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  44353. m.updated_at = &t
  44354. }
  44355. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44356. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  44357. v := m.updated_at
  44358. if v == nil {
  44359. return
  44360. }
  44361. return *v, true
  44362. }
  44363. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  44364. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44366. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44367. if !m.op.Is(OpUpdateOne) {
  44368. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44369. }
  44370. if m.id == nil || m.oldValue == nil {
  44371. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44372. }
  44373. oldValue, err := m.oldValue(ctx)
  44374. if err != nil {
  44375. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44376. }
  44377. return oldValue.UpdatedAt, nil
  44378. }
  44379. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44380. func (m *WpChatroomMutation) ResetUpdatedAt() {
  44381. m.updated_at = nil
  44382. }
  44383. // SetStatus sets the "status" field.
  44384. func (m *WpChatroomMutation) SetStatus(u uint8) {
  44385. m.status = &u
  44386. m.addstatus = nil
  44387. }
  44388. // Status returns the value of the "status" field in the mutation.
  44389. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  44390. v := m.status
  44391. if v == nil {
  44392. return
  44393. }
  44394. return *v, true
  44395. }
  44396. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  44397. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44399. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  44400. if !m.op.Is(OpUpdateOne) {
  44401. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  44402. }
  44403. if m.id == nil || m.oldValue == nil {
  44404. return v, errors.New("OldStatus requires an ID field in the mutation")
  44405. }
  44406. oldValue, err := m.oldValue(ctx)
  44407. if err != nil {
  44408. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  44409. }
  44410. return oldValue.Status, nil
  44411. }
  44412. // AddStatus adds u to the "status" field.
  44413. func (m *WpChatroomMutation) AddStatus(u int8) {
  44414. if m.addstatus != nil {
  44415. *m.addstatus += u
  44416. } else {
  44417. m.addstatus = &u
  44418. }
  44419. }
  44420. // AddedStatus returns the value that was added to the "status" field in this mutation.
  44421. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  44422. v := m.addstatus
  44423. if v == nil {
  44424. return
  44425. }
  44426. return *v, true
  44427. }
  44428. // ClearStatus clears the value of the "status" field.
  44429. func (m *WpChatroomMutation) ClearStatus() {
  44430. m.status = nil
  44431. m.addstatus = nil
  44432. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  44433. }
  44434. // StatusCleared returns if the "status" field was cleared in this mutation.
  44435. func (m *WpChatroomMutation) StatusCleared() bool {
  44436. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  44437. return ok
  44438. }
  44439. // ResetStatus resets all changes to the "status" field.
  44440. func (m *WpChatroomMutation) ResetStatus() {
  44441. m.status = nil
  44442. m.addstatus = nil
  44443. delete(m.clearedFields, wpchatroom.FieldStatus)
  44444. }
  44445. // SetWxWxid sets the "wx_wxid" field.
  44446. func (m *WpChatroomMutation) SetWxWxid(s string) {
  44447. m.wx_wxid = &s
  44448. }
  44449. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  44450. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  44451. v := m.wx_wxid
  44452. if v == nil {
  44453. return
  44454. }
  44455. return *v, true
  44456. }
  44457. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  44458. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44460. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  44461. if !m.op.Is(OpUpdateOne) {
  44462. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  44463. }
  44464. if m.id == nil || m.oldValue == nil {
  44465. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  44466. }
  44467. oldValue, err := m.oldValue(ctx)
  44468. if err != nil {
  44469. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  44470. }
  44471. return oldValue.WxWxid, nil
  44472. }
  44473. // ResetWxWxid resets all changes to the "wx_wxid" field.
  44474. func (m *WpChatroomMutation) ResetWxWxid() {
  44475. m.wx_wxid = nil
  44476. }
  44477. // SetChatroomID sets the "chatroom_id" field.
  44478. func (m *WpChatroomMutation) SetChatroomID(s string) {
  44479. m.chatroom_id = &s
  44480. }
  44481. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  44482. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  44483. v := m.chatroom_id
  44484. if v == nil {
  44485. return
  44486. }
  44487. return *v, true
  44488. }
  44489. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  44490. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44492. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  44493. if !m.op.Is(OpUpdateOne) {
  44494. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  44495. }
  44496. if m.id == nil || m.oldValue == nil {
  44497. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  44498. }
  44499. oldValue, err := m.oldValue(ctx)
  44500. if err != nil {
  44501. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  44502. }
  44503. return oldValue.ChatroomID, nil
  44504. }
  44505. // ResetChatroomID resets all changes to the "chatroom_id" field.
  44506. func (m *WpChatroomMutation) ResetChatroomID() {
  44507. m.chatroom_id = nil
  44508. }
  44509. // SetNickname sets the "nickname" field.
  44510. func (m *WpChatroomMutation) SetNickname(s string) {
  44511. m.nickname = &s
  44512. }
  44513. // Nickname returns the value of the "nickname" field in the mutation.
  44514. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  44515. v := m.nickname
  44516. if v == nil {
  44517. return
  44518. }
  44519. return *v, true
  44520. }
  44521. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  44522. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44524. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  44525. if !m.op.Is(OpUpdateOne) {
  44526. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44527. }
  44528. if m.id == nil || m.oldValue == nil {
  44529. return v, errors.New("OldNickname requires an ID field in the mutation")
  44530. }
  44531. oldValue, err := m.oldValue(ctx)
  44532. if err != nil {
  44533. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  44534. }
  44535. return oldValue.Nickname, nil
  44536. }
  44537. // ResetNickname resets all changes to the "nickname" field.
  44538. func (m *WpChatroomMutation) ResetNickname() {
  44539. m.nickname = nil
  44540. }
  44541. // SetOwner sets the "owner" field.
  44542. func (m *WpChatroomMutation) SetOwner(s string) {
  44543. m.owner = &s
  44544. }
  44545. // Owner returns the value of the "owner" field in the mutation.
  44546. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  44547. v := m.owner
  44548. if v == nil {
  44549. return
  44550. }
  44551. return *v, true
  44552. }
  44553. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  44554. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44556. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  44557. if !m.op.Is(OpUpdateOne) {
  44558. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  44559. }
  44560. if m.id == nil || m.oldValue == nil {
  44561. return v, errors.New("OldOwner requires an ID field in the mutation")
  44562. }
  44563. oldValue, err := m.oldValue(ctx)
  44564. if err != nil {
  44565. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  44566. }
  44567. return oldValue.Owner, nil
  44568. }
  44569. // ResetOwner resets all changes to the "owner" field.
  44570. func (m *WpChatroomMutation) ResetOwner() {
  44571. m.owner = nil
  44572. }
  44573. // SetAvatar sets the "avatar" field.
  44574. func (m *WpChatroomMutation) SetAvatar(s string) {
  44575. m.avatar = &s
  44576. }
  44577. // Avatar returns the value of the "avatar" field in the mutation.
  44578. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  44579. v := m.avatar
  44580. if v == nil {
  44581. return
  44582. }
  44583. return *v, true
  44584. }
  44585. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  44586. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44588. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44589. if !m.op.Is(OpUpdateOne) {
  44590. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44591. }
  44592. if m.id == nil || m.oldValue == nil {
  44593. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44594. }
  44595. oldValue, err := m.oldValue(ctx)
  44596. if err != nil {
  44597. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44598. }
  44599. return oldValue.Avatar, nil
  44600. }
  44601. // ResetAvatar resets all changes to the "avatar" field.
  44602. func (m *WpChatroomMutation) ResetAvatar() {
  44603. m.avatar = nil
  44604. }
  44605. // SetMemberList sets the "member_list" field.
  44606. func (m *WpChatroomMutation) SetMemberList(s []string) {
  44607. m.member_list = &s
  44608. m.appendmember_list = nil
  44609. }
  44610. // MemberList returns the value of the "member_list" field in the mutation.
  44611. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  44612. v := m.member_list
  44613. if v == nil {
  44614. return
  44615. }
  44616. return *v, true
  44617. }
  44618. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  44619. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44621. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  44622. if !m.op.Is(OpUpdateOne) {
  44623. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  44624. }
  44625. if m.id == nil || m.oldValue == nil {
  44626. return v, errors.New("OldMemberList requires an ID field in the mutation")
  44627. }
  44628. oldValue, err := m.oldValue(ctx)
  44629. if err != nil {
  44630. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  44631. }
  44632. return oldValue.MemberList, nil
  44633. }
  44634. // AppendMemberList adds s to the "member_list" field.
  44635. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  44636. m.appendmember_list = append(m.appendmember_list, s...)
  44637. }
  44638. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  44639. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  44640. if len(m.appendmember_list) == 0 {
  44641. return nil, false
  44642. }
  44643. return m.appendmember_list, true
  44644. }
  44645. // ResetMemberList resets all changes to the "member_list" field.
  44646. func (m *WpChatroomMutation) ResetMemberList() {
  44647. m.member_list = nil
  44648. m.appendmember_list = nil
  44649. }
  44650. // Where appends a list predicates to the WpChatroomMutation builder.
  44651. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  44652. m.predicates = append(m.predicates, ps...)
  44653. }
  44654. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  44655. // users can use type-assertion to append predicates that do not depend on any generated package.
  44656. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  44657. p := make([]predicate.WpChatroom, len(ps))
  44658. for i := range ps {
  44659. p[i] = ps[i]
  44660. }
  44661. m.Where(p...)
  44662. }
  44663. // Op returns the operation name.
  44664. func (m *WpChatroomMutation) Op() Op {
  44665. return m.op
  44666. }
  44667. // SetOp allows setting the mutation operation.
  44668. func (m *WpChatroomMutation) SetOp(op Op) {
  44669. m.op = op
  44670. }
  44671. // Type returns the node type of this mutation (WpChatroom).
  44672. func (m *WpChatroomMutation) Type() string {
  44673. return m.typ
  44674. }
  44675. // Fields returns all fields that were changed during this mutation. Note that in
  44676. // order to get all numeric fields that were incremented/decremented, call
  44677. // AddedFields().
  44678. func (m *WpChatroomMutation) Fields() []string {
  44679. fields := make([]string, 0, 9)
  44680. if m.created_at != nil {
  44681. fields = append(fields, wpchatroom.FieldCreatedAt)
  44682. }
  44683. if m.updated_at != nil {
  44684. fields = append(fields, wpchatroom.FieldUpdatedAt)
  44685. }
  44686. if m.status != nil {
  44687. fields = append(fields, wpchatroom.FieldStatus)
  44688. }
  44689. if m.wx_wxid != nil {
  44690. fields = append(fields, wpchatroom.FieldWxWxid)
  44691. }
  44692. if m.chatroom_id != nil {
  44693. fields = append(fields, wpchatroom.FieldChatroomID)
  44694. }
  44695. if m.nickname != nil {
  44696. fields = append(fields, wpchatroom.FieldNickname)
  44697. }
  44698. if m.owner != nil {
  44699. fields = append(fields, wpchatroom.FieldOwner)
  44700. }
  44701. if m.avatar != nil {
  44702. fields = append(fields, wpchatroom.FieldAvatar)
  44703. }
  44704. if m.member_list != nil {
  44705. fields = append(fields, wpchatroom.FieldMemberList)
  44706. }
  44707. return fields
  44708. }
  44709. // Field returns the value of a field with the given name. The second boolean
  44710. // return value indicates that this field was not set, or was not defined in the
  44711. // schema.
  44712. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  44713. switch name {
  44714. case wpchatroom.FieldCreatedAt:
  44715. return m.CreatedAt()
  44716. case wpchatroom.FieldUpdatedAt:
  44717. return m.UpdatedAt()
  44718. case wpchatroom.FieldStatus:
  44719. return m.Status()
  44720. case wpchatroom.FieldWxWxid:
  44721. return m.WxWxid()
  44722. case wpchatroom.FieldChatroomID:
  44723. return m.ChatroomID()
  44724. case wpchatroom.FieldNickname:
  44725. return m.Nickname()
  44726. case wpchatroom.FieldOwner:
  44727. return m.Owner()
  44728. case wpchatroom.FieldAvatar:
  44729. return m.Avatar()
  44730. case wpchatroom.FieldMemberList:
  44731. return m.MemberList()
  44732. }
  44733. return nil, false
  44734. }
  44735. // OldField returns the old value of the field from the database. An error is
  44736. // returned if the mutation operation is not UpdateOne, or the query to the
  44737. // database failed.
  44738. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44739. switch name {
  44740. case wpchatroom.FieldCreatedAt:
  44741. return m.OldCreatedAt(ctx)
  44742. case wpchatroom.FieldUpdatedAt:
  44743. return m.OldUpdatedAt(ctx)
  44744. case wpchatroom.FieldStatus:
  44745. return m.OldStatus(ctx)
  44746. case wpchatroom.FieldWxWxid:
  44747. return m.OldWxWxid(ctx)
  44748. case wpchatroom.FieldChatroomID:
  44749. return m.OldChatroomID(ctx)
  44750. case wpchatroom.FieldNickname:
  44751. return m.OldNickname(ctx)
  44752. case wpchatroom.FieldOwner:
  44753. return m.OldOwner(ctx)
  44754. case wpchatroom.FieldAvatar:
  44755. return m.OldAvatar(ctx)
  44756. case wpchatroom.FieldMemberList:
  44757. return m.OldMemberList(ctx)
  44758. }
  44759. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  44760. }
  44761. // SetField sets the value of a field with the given name. It returns an error if
  44762. // the field is not defined in the schema, or if the type mismatched the field
  44763. // type.
  44764. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  44765. switch name {
  44766. case wpchatroom.FieldCreatedAt:
  44767. v, ok := value.(time.Time)
  44768. if !ok {
  44769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44770. }
  44771. m.SetCreatedAt(v)
  44772. return nil
  44773. case wpchatroom.FieldUpdatedAt:
  44774. v, ok := value.(time.Time)
  44775. if !ok {
  44776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44777. }
  44778. m.SetUpdatedAt(v)
  44779. return nil
  44780. case wpchatroom.FieldStatus:
  44781. v, ok := value.(uint8)
  44782. if !ok {
  44783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44784. }
  44785. m.SetStatus(v)
  44786. return nil
  44787. case wpchatroom.FieldWxWxid:
  44788. v, ok := value.(string)
  44789. if !ok {
  44790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44791. }
  44792. m.SetWxWxid(v)
  44793. return nil
  44794. case wpchatroom.FieldChatroomID:
  44795. v, ok := value.(string)
  44796. if !ok {
  44797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44798. }
  44799. m.SetChatroomID(v)
  44800. return nil
  44801. case wpchatroom.FieldNickname:
  44802. v, ok := value.(string)
  44803. if !ok {
  44804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44805. }
  44806. m.SetNickname(v)
  44807. return nil
  44808. case wpchatroom.FieldOwner:
  44809. v, ok := value.(string)
  44810. if !ok {
  44811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44812. }
  44813. m.SetOwner(v)
  44814. return nil
  44815. case wpchatroom.FieldAvatar:
  44816. v, ok := value.(string)
  44817. if !ok {
  44818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44819. }
  44820. m.SetAvatar(v)
  44821. return nil
  44822. case wpchatroom.FieldMemberList:
  44823. v, ok := value.([]string)
  44824. if !ok {
  44825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44826. }
  44827. m.SetMemberList(v)
  44828. return nil
  44829. }
  44830. return fmt.Errorf("unknown WpChatroom field %s", name)
  44831. }
  44832. // AddedFields returns all numeric fields that were incremented/decremented during
  44833. // this mutation.
  44834. func (m *WpChatroomMutation) AddedFields() []string {
  44835. var fields []string
  44836. if m.addstatus != nil {
  44837. fields = append(fields, wpchatroom.FieldStatus)
  44838. }
  44839. return fields
  44840. }
  44841. // AddedField returns the numeric value that was incremented/decremented on a field
  44842. // with the given name. The second boolean return value indicates that this field
  44843. // was not set, or was not defined in the schema.
  44844. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  44845. switch name {
  44846. case wpchatroom.FieldStatus:
  44847. return m.AddedStatus()
  44848. }
  44849. return nil, false
  44850. }
  44851. // AddField adds the value to the field with the given name. It returns an error if
  44852. // the field is not defined in the schema, or if the type mismatched the field
  44853. // type.
  44854. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  44855. switch name {
  44856. case wpchatroom.FieldStatus:
  44857. v, ok := value.(int8)
  44858. if !ok {
  44859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44860. }
  44861. m.AddStatus(v)
  44862. return nil
  44863. }
  44864. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  44865. }
  44866. // ClearedFields returns all nullable fields that were cleared during this
  44867. // mutation.
  44868. func (m *WpChatroomMutation) ClearedFields() []string {
  44869. var fields []string
  44870. if m.FieldCleared(wpchatroom.FieldStatus) {
  44871. fields = append(fields, wpchatroom.FieldStatus)
  44872. }
  44873. return fields
  44874. }
  44875. // FieldCleared returns a boolean indicating if a field with the given name was
  44876. // cleared in this mutation.
  44877. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  44878. _, ok := m.clearedFields[name]
  44879. return ok
  44880. }
  44881. // ClearField clears the value of the field with the given name. It returns an
  44882. // error if the field is not defined in the schema.
  44883. func (m *WpChatroomMutation) ClearField(name string) error {
  44884. switch name {
  44885. case wpchatroom.FieldStatus:
  44886. m.ClearStatus()
  44887. return nil
  44888. }
  44889. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  44890. }
  44891. // ResetField resets all changes in the mutation for the field with the given name.
  44892. // It returns an error if the field is not defined in the schema.
  44893. func (m *WpChatroomMutation) ResetField(name string) error {
  44894. switch name {
  44895. case wpchatroom.FieldCreatedAt:
  44896. m.ResetCreatedAt()
  44897. return nil
  44898. case wpchatroom.FieldUpdatedAt:
  44899. m.ResetUpdatedAt()
  44900. return nil
  44901. case wpchatroom.FieldStatus:
  44902. m.ResetStatus()
  44903. return nil
  44904. case wpchatroom.FieldWxWxid:
  44905. m.ResetWxWxid()
  44906. return nil
  44907. case wpchatroom.FieldChatroomID:
  44908. m.ResetChatroomID()
  44909. return nil
  44910. case wpchatroom.FieldNickname:
  44911. m.ResetNickname()
  44912. return nil
  44913. case wpchatroom.FieldOwner:
  44914. m.ResetOwner()
  44915. return nil
  44916. case wpchatroom.FieldAvatar:
  44917. m.ResetAvatar()
  44918. return nil
  44919. case wpchatroom.FieldMemberList:
  44920. m.ResetMemberList()
  44921. return nil
  44922. }
  44923. return fmt.Errorf("unknown WpChatroom field %s", name)
  44924. }
  44925. // AddedEdges returns all edge names that were set/added in this mutation.
  44926. func (m *WpChatroomMutation) AddedEdges() []string {
  44927. edges := make([]string, 0, 0)
  44928. return edges
  44929. }
  44930. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44931. // name in this mutation.
  44932. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  44933. return nil
  44934. }
  44935. // RemovedEdges returns all edge names that were removed in this mutation.
  44936. func (m *WpChatroomMutation) RemovedEdges() []string {
  44937. edges := make([]string, 0, 0)
  44938. return edges
  44939. }
  44940. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44941. // the given name in this mutation.
  44942. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  44943. return nil
  44944. }
  44945. // ClearedEdges returns all edge names that were cleared in this mutation.
  44946. func (m *WpChatroomMutation) ClearedEdges() []string {
  44947. edges := make([]string, 0, 0)
  44948. return edges
  44949. }
  44950. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44951. // was cleared in this mutation.
  44952. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  44953. return false
  44954. }
  44955. // ClearEdge clears the value of the edge with the given name. It returns an error
  44956. // if that edge is not defined in the schema.
  44957. func (m *WpChatroomMutation) ClearEdge(name string) error {
  44958. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  44959. }
  44960. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44961. // It returns an error if the edge is not defined in the schema.
  44962. func (m *WpChatroomMutation) ResetEdge(name string) error {
  44963. return fmt.Errorf("unknown WpChatroom edge %s", name)
  44964. }
  44965. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  44966. type WpChatroomMemberMutation struct {
  44967. config
  44968. op Op
  44969. typ string
  44970. id *uint64
  44971. created_at *time.Time
  44972. updated_at *time.Time
  44973. status *uint8
  44974. addstatus *int8
  44975. wx_wxid *string
  44976. wxid *string
  44977. nickname *string
  44978. avatar *string
  44979. clearedFields map[string]struct{}
  44980. done bool
  44981. oldValue func(context.Context) (*WpChatroomMember, error)
  44982. predicates []predicate.WpChatroomMember
  44983. }
  44984. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  44985. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  44986. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  44987. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  44988. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  44989. m := &WpChatroomMemberMutation{
  44990. config: c,
  44991. op: op,
  44992. typ: TypeWpChatroomMember,
  44993. clearedFields: make(map[string]struct{}),
  44994. }
  44995. for _, opt := range opts {
  44996. opt(m)
  44997. }
  44998. return m
  44999. }
  45000. // withWpChatroomMemberID sets the ID field of the mutation.
  45001. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  45002. return func(m *WpChatroomMemberMutation) {
  45003. var (
  45004. err error
  45005. once sync.Once
  45006. value *WpChatroomMember
  45007. )
  45008. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  45009. once.Do(func() {
  45010. if m.done {
  45011. err = errors.New("querying old values post mutation is not allowed")
  45012. } else {
  45013. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  45014. }
  45015. })
  45016. return value, err
  45017. }
  45018. m.id = &id
  45019. }
  45020. }
  45021. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  45022. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  45023. return func(m *WpChatroomMemberMutation) {
  45024. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  45025. return node, nil
  45026. }
  45027. m.id = &node.ID
  45028. }
  45029. }
  45030. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45031. // executed in a transaction (ent.Tx), a transactional client is returned.
  45032. func (m WpChatroomMemberMutation) Client() *Client {
  45033. client := &Client{config: m.config}
  45034. client.init()
  45035. return client
  45036. }
  45037. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45038. // it returns an error otherwise.
  45039. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  45040. if _, ok := m.driver.(*txDriver); !ok {
  45041. return nil, errors.New("ent: mutation is not running in a transaction")
  45042. }
  45043. tx := &Tx{config: m.config}
  45044. tx.init()
  45045. return tx, nil
  45046. }
  45047. // SetID sets the value of the id field. Note that this
  45048. // operation is only accepted on creation of WpChatroomMember entities.
  45049. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  45050. m.id = &id
  45051. }
  45052. // ID returns the ID value in the mutation. Note that the ID is only available
  45053. // if it was provided to the builder or after it was returned from the database.
  45054. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  45055. if m.id == nil {
  45056. return
  45057. }
  45058. return *m.id, true
  45059. }
  45060. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45061. // That means, if the mutation is applied within a transaction with an isolation level such
  45062. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45063. // or updated by the mutation.
  45064. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  45065. switch {
  45066. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45067. id, exists := m.ID()
  45068. if exists {
  45069. return []uint64{id}, nil
  45070. }
  45071. fallthrough
  45072. case m.op.Is(OpUpdate | OpDelete):
  45073. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  45074. default:
  45075. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45076. }
  45077. }
  45078. // SetCreatedAt sets the "created_at" field.
  45079. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  45080. m.created_at = &t
  45081. }
  45082. // CreatedAt returns the value of the "created_at" field in the mutation.
  45083. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  45084. v := m.created_at
  45085. if v == nil {
  45086. return
  45087. }
  45088. return *v, true
  45089. }
  45090. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  45091. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45093. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45094. if !m.op.Is(OpUpdateOne) {
  45095. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45096. }
  45097. if m.id == nil || m.oldValue == nil {
  45098. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45099. }
  45100. oldValue, err := m.oldValue(ctx)
  45101. if err != nil {
  45102. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45103. }
  45104. return oldValue.CreatedAt, nil
  45105. }
  45106. // ResetCreatedAt resets all changes to the "created_at" field.
  45107. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  45108. m.created_at = nil
  45109. }
  45110. // SetUpdatedAt sets the "updated_at" field.
  45111. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  45112. m.updated_at = &t
  45113. }
  45114. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45115. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  45116. v := m.updated_at
  45117. if v == nil {
  45118. return
  45119. }
  45120. return *v, true
  45121. }
  45122. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  45123. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45125. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45126. if !m.op.Is(OpUpdateOne) {
  45127. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45128. }
  45129. if m.id == nil || m.oldValue == nil {
  45130. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45131. }
  45132. oldValue, err := m.oldValue(ctx)
  45133. if err != nil {
  45134. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45135. }
  45136. return oldValue.UpdatedAt, nil
  45137. }
  45138. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45139. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  45140. m.updated_at = nil
  45141. }
  45142. // SetStatus sets the "status" field.
  45143. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  45144. m.status = &u
  45145. m.addstatus = nil
  45146. }
  45147. // Status returns the value of the "status" field in the mutation.
  45148. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  45149. v := m.status
  45150. if v == nil {
  45151. return
  45152. }
  45153. return *v, true
  45154. }
  45155. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  45156. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45158. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45159. if !m.op.Is(OpUpdateOne) {
  45160. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45161. }
  45162. if m.id == nil || m.oldValue == nil {
  45163. return v, errors.New("OldStatus requires an ID field in the mutation")
  45164. }
  45165. oldValue, err := m.oldValue(ctx)
  45166. if err != nil {
  45167. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45168. }
  45169. return oldValue.Status, nil
  45170. }
  45171. // AddStatus adds u to the "status" field.
  45172. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  45173. if m.addstatus != nil {
  45174. *m.addstatus += u
  45175. } else {
  45176. m.addstatus = &u
  45177. }
  45178. }
  45179. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45180. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  45181. v := m.addstatus
  45182. if v == nil {
  45183. return
  45184. }
  45185. return *v, true
  45186. }
  45187. // ClearStatus clears the value of the "status" field.
  45188. func (m *WpChatroomMemberMutation) ClearStatus() {
  45189. m.status = nil
  45190. m.addstatus = nil
  45191. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  45192. }
  45193. // StatusCleared returns if the "status" field was cleared in this mutation.
  45194. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  45195. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  45196. return ok
  45197. }
  45198. // ResetStatus resets all changes to the "status" field.
  45199. func (m *WpChatroomMemberMutation) ResetStatus() {
  45200. m.status = nil
  45201. m.addstatus = nil
  45202. delete(m.clearedFields, wpchatroommember.FieldStatus)
  45203. }
  45204. // SetWxWxid sets the "wx_wxid" field.
  45205. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  45206. m.wx_wxid = &s
  45207. }
  45208. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  45209. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  45210. v := m.wx_wxid
  45211. if v == nil {
  45212. return
  45213. }
  45214. return *v, true
  45215. }
  45216. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  45217. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45219. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  45220. if !m.op.Is(OpUpdateOne) {
  45221. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  45222. }
  45223. if m.id == nil || m.oldValue == nil {
  45224. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  45225. }
  45226. oldValue, err := m.oldValue(ctx)
  45227. if err != nil {
  45228. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  45229. }
  45230. return oldValue.WxWxid, nil
  45231. }
  45232. // ResetWxWxid resets all changes to the "wx_wxid" field.
  45233. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  45234. m.wx_wxid = nil
  45235. }
  45236. // SetWxid sets the "wxid" field.
  45237. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  45238. m.wxid = &s
  45239. }
  45240. // Wxid returns the value of the "wxid" field in the mutation.
  45241. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  45242. v := m.wxid
  45243. if v == nil {
  45244. return
  45245. }
  45246. return *v, true
  45247. }
  45248. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  45249. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45251. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  45252. if !m.op.Is(OpUpdateOne) {
  45253. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  45254. }
  45255. if m.id == nil || m.oldValue == nil {
  45256. return v, errors.New("OldWxid requires an ID field in the mutation")
  45257. }
  45258. oldValue, err := m.oldValue(ctx)
  45259. if err != nil {
  45260. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  45261. }
  45262. return oldValue.Wxid, nil
  45263. }
  45264. // ResetWxid resets all changes to the "wxid" field.
  45265. func (m *WpChatroomMemberMutation) ResetWxid() {
  45266. m.wxid = nil
  45267. }
  45268. // SetNickname sets the "nickname" field.
  45269. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  45270. m.nickname = &s
  45271. }
  45272. // Nickname returns the value of the "nickname" field in the mutation.
  45273. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  45274. v := m.nickname
  45275. if v == nil {
  45276. return
  45277. }
  45278. return *v, true
  45279. }
  45280. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  45281. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45283. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  45284. if !m.op.Is(OpUpdateOne) {
  45285. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45286. }
  45287. if m.id == nil || m.oldValue == nil {
  45288. return v, errors.New("OldNickname requires an ID field in the mutation")
  45289. }
  45290. oldValue, err := m.oldValue(ctx)
  45291. if err != nil {
  45292. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45293. }
  45294. return oldValue.Nickname, nil
  45295. }
  45296. // ResetNickname resets all changes to the "nickname" field.
  45297. func (m *WpChatroomMemberMutation) ResetNickname() {
  45298. m.nickname = nil
  45299. }
  45300. // SetAvatar sets the "avatar" field.
  45301. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  45302. m.avatar = &s
  45303. }
  45304. // Avatar returns the value of the "avatar" field in the mutation.
  45305. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  45306. v := m.avatar
  45307. if v == nil {
  45308. return
  45309. }
  45310. return *v, true
  45311. }
  45312. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  45313. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45315. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  45316. if !m.op.Is(OpUpdateOne) {
  45317. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  45318. }
  45319. if m.id == nil || m.oldValue == nil {
  45320. return v, errors.New("OldAvatar requires an ID field in the mutation")
  45321. }
  45322. oldValue, err := m.oldValue(ctx)
  45323. if err != nil {
  45324. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  45325. }
  45326. return oldValue.Avatar, nil
  45327. }
  45328. // ResetAvatar resets all changes to the "avatar" field.
  45329. func (m *WpChatroomMemberMutation) ResetAvatar() {
  45330. m.avatar = nil
  45331. }
  45332. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  45333. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  45334. m.predicates = append(m.predicates, ps...)
  45335. }
  45336. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  45337. // users can use type-assertion to append predicates that do not depend on any generated package.
  45338. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  45339. p := make([]predicate.WpChatroomMember, len(ps))
  45340. for i := range ps {
  45341. p[i] = ps[i]
  45342. }
  45343. m.Where(p...)
  45344. }
  45345. // Op returns the operation name.
  45346. func (m *WpChatroomMemberMutation) Op() Op {
  45347. return m.op
  45348. }
  45349. // SetOp allows setting the mutation operation.
  45350. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  45351. m.op = op
  45352. }
  45353. // Type returns the node type of this mutation (WpChatroomMember).
  45354. func (m *WpChatroomMemberMutation) Type() string {
  45355. return m.typ
  45356. }
  45357. // Fields returns all fields that were changed during this mutation. Note that in
  45358. // order to get all numeric fields that were incremented/decremented, call
  45359. // AddedFields().
  45360. func (m *WpChatroomMemberMutation) Fields() []string {
  45361. fields := make([]string, 0, 7)
  45362. if m.created_at != nil {
  45363. fields = append(fields, wpchatroommember.FieldCreatedAt)
  45364. }
  45365. if m.updated_at != nil {
  45366. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  45367. }
  45368. if m.status != nil {
  45369. fields = append(fields, wpchatroommember.FieldStatus)
  45370. }
  45371. if m.wx_wxid != nil {
  45372. fields = append(fields, wpchatroommember.FieldWxWxid)
  45373. }
  45374. if m.wxid != nil {
  45375. fields = append(fields, wpchatroommember.FieldWxid)
  45376. }
  45377. if m.nickname != nil {
  45378. fields = append(fields, wpchatroommember.FieldNickname)
  45379. }
  45380. if m.avatar != nil {
  45381. fields = append(fields, wpchatroommember.FieldAvatar)
  45382. }
  45383. return fields
  45384. }
  45385. // Field returns the value of a field with the given name. The second boolean
  45386. // return value indicates that this field was not set, or was not defined in the
  45387. // schema.
  45388. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  45389. switch name {
  45390. case wpchatroommember.FieldCreatedAt:
  45391. return m.CreatedAt()
  45392. case wpchatroommember.FieldUpdatedAt:
  45393. return m.UpdatedAt()
  45394. case wpchatroommember.FieldStatus:
  45395. return m.Status()
  45396. case wpchatroommember.FieldWxWxid:
  45397. return m.WxWxid()
  45398. case wpchatroommember.FieldWxid:
  45399. return m.Wxid()
  45400. case wpchatroommember.FieldNickname:
  45401. return m.Nickname()
  45402. case wpchatroommember.FieldAvatar:
  45403. return m.Avatar()
  45404. }
  45405. return nil, false
  45406. }
  45407. // OldField returns the old value of the field from the database. An error is
  45408. // returned if the mutation operation is not UpdateOne, or the query to the
  45409. // database failed.
  45410. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45411. switch name {
  45412. case wpchatroommember.FieldCreatedAt:
  45413. return m.OldCreatedAt(ctx)
  45414. case wpchatroommember.FieldUpdatedAt:
  45415. return m.OldUpdatedAt(ctx)
  45416. case wpchatroommember.FieldStatus:
  45417. return m.OldStatus(ctx)
  45418. case wpchatroommember.FieldWxWxid:
  45419. return m.OldWxWxid(ctx)
  45420. case wpchatroommember.FieldWxid:
  45421. return m.OldWxid(ctx)
  45422. case wpchatroommember.FieldNickname:
  45423. return m.OldNickname(ctx)
  45424. case wpchatroommember.FieldAvatar:
  45425. return m.OldAvatar(ctx)
  45426. }
  45427. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  45428. }
  45429. // SetField sets the value of a field with the given name. It returns an error if
  45430. // the field is not defined in the schema, or if the type mismatched the field
  45431. // type.
  45432. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  45433. switch name {
  45434. case wpchatroommember.FieldCreatedAt:
  45435. v, ok := value.(time.Time)
  45436. if !ok {
  45437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45438. }
  45439. m.SetCreatedAt(v)
  45440. return nil
  45441. case wpchatroommember.FieldUpdatedAt:
  45442. v, ok := value.(time.Time)
  45443. if !ok {
  45444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45445. }
  45446. m.SetUpdatedAt(v)
  45447. return nil
  45448. case wpchatroommember.FieldStatus:
  45449. v, ok := value.(uint8)
  45450. if !ok {
  45451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45452. }
  45453. m.SetStatus(v)
  45454. return nil
  45455. case wpchatroommember.FieldWxWxid:
  45456. v, ok := value.(string)
  45457. if !ok {
  45458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45459. }
  45460. m.SetWxWxid(v)
  45461. return nil
  45462. case wpchatroommember.FieldWxid:
  45463. v, ok := value.(string)
  45464. if !ok {
  45465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45466. }
  45467. m.SetWxid(v)
  45468. return nil
  45469. case wpchatroommember.FieldNickname:
  45470. v, ok := value.(string)
  45471. if !ok {
  45472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45473. }
  45474. m.SetNickname(v)
  45475. return nil
  45476. case wpchatroommember.FieldAvatar:
  45477. v, ok := value.(string)
  45478. if !ok {
  45479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45480. }
  45481. m.SetAvatar(v)
  45482. return nil
  45483. }
  45484. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  45485. }
  45486. // AddedFields returns all numeric fields that were incremented/decremented during
  45487. // this mutation.
  45488. func (m *WpChatroomMemberMutation) AddedFields() []string {
  45489. var fields []string
  45490. if m.addstatus != nil {
  45491. fields = append(fields, wpchatroommember.FieldStatus)
  45492. }
  45493. return fields
  45494. }
  45495. // AddedField returns the numeric value that was incremented/decremented on a field
  45496. // with the given name. The second boolean return value indicates that this field
  45497. // was not set, or was not defined in the schema.
  45498. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  45499. switch name {
  45500. case wpchatroommember.FieldStatus:
  45501. return m.AddedStatus()
  45502. }
  45503. return nil, false
  45504. }
  45505. // AddField adds the value to the field with the given name. It returns an error if
  45506. // the field is not defined in the schema, or if the type mismatched the field
  45507. // type.
  45508. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  45509. switch name {
  45510. case wpchatroommember.FieldStatus:
  45511. v, ok := value.(int8)
  45512. if !ok {
  45513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45514. }
  45515. m.AddStatus(v)
  45516. return nil
  45517. }
  45518. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  45519. }
  45520. // ClearedFields returns all nullable fields that were cleared during this
  45521. // mutation.
  45522. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  45523. var fields []string
  45524. if m.FieldCleared(wpchatroommember.FieldStatus) {
  45525. fields = append(fields, wpchatroommember.FieldStatus)
  45526. }
  45527. return fields
  45528. }
  45529. // FieldCleared returns a boolean indicating if a field with the given name was
  45530. // cleared in this mutation.
  45531. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  45532. _, ok := m.clearedFields[name]
  45533. return ok
  45534. }
  45535. // ClearField clears the value of the field with the given name. It returns an
  45536. // error if the field is not defined in the schema.
  45537. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  45538. switch name {
  45539. case wpchatroommember.FieldStatus:
  45540. m.ClearStatus()
  45541. return nil
  45542. }
  45543. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  45544. }
  45545. // ResetField resets all changes in the mutation for the field with the given name.
  45546. // It returns an error if the field is not defined in the schema.
  45547. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  45548. switch name {
  45549. case wpchatroommember.FieldCreatedAt:
  45550. m.ResetCreatedAt()
  45551. return nil
  45552. case wpchatroommember.FieldUpdatedAt:
  45553. m.ResetUpdatedAt()
  45554. return nil
  45555. case wpchatroommember.FieldStatus:
  45556. m.ResetStatus()
  45557. return nil
  45558. case wpchatroommember.FieldWxWxid:
  45559. m.ResetWxWxid()
  45560. return nil
  45561. case wpchatroommember.FieldWxid:
  45562. m.ResetWxid()
  45563. return nil
  45564. case wpchatroommember.FieldNickname:
  45565. m.ResetNickname()
  45566. return nil
  45567. case wpchatroommember.FieldAvatar:
  45568. m.ResetAvatar()
  45569. return nil
  45570. }
  45571. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  45572. }
  45573. // AddedEdges returns all edge names that were set/added in this mutation.
  45574. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  45575. edges := make([]string, 0, 0)
  45576. return edges
  45577. }
  45578. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45579. // name in this mutation.
  45580. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  45581. return nil
  45582. }
  45583. // RemovedEdges returns all edge names that were removed in this mutation.
  45584. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  45585. edges := make([]string, 0, 0)
  45586. return edges
  45587. }
  45588. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45589. // the given name in this mutation.
  45590. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  45591. return nil
  45592. }
  45593. // ClearedEdges returns all edge names that were cleared in this mutation.
  45594. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  45595. edges := make([]string, 0, 0)
  45596. return edges
  45597. }
  45598. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45599. // was cleared in this mutation.
  45600. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  45601. return false
  45602. }
  45603. // ClearEdge clears the value of the edge with the given name. It returns an error
  45604. // if that edge is not defined in the schema.
  45605. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  45606. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  45607. }
  45608. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45609. // It returns an error if the edge is not defined in the schema.
  45610. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  45611. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  45612. }
  45613. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  45614. type WxMutation struct {
  45615. config
  45616. op Op
  45617. typ string
  45618. id *uint64
  45619. created_at *time.Time
  45620. updated_at *time.Time
  45621. status *uint8
  45622. addstatus *int8
  45623. deleted_at *time.Time
  45624. port *string
  45625. process_id *string
  45626. callback *string
  45627. wxid *string
  45628. account *string
  45629. nickname *string
  45630. tel *string
  45631. head_big *string
  45632. organization_id *uint64
  45633. addorganization_id *int64
  45634. api_base *string
  45635. api_key *string
  45636. allow_list *[]string
  45637. appendallow_list []string
  45638. group_allow_list *[]string
  45639. appendgroup_allow_list []string
  45640. block_list *[]string
  45641. appendblock_list []string
  45642. group_block_list *[]string
  45643. appendgroup_block_list []string
  45644. ctype *uint64
  45645. addctype *int64
  45646. clearedFields map[string]struct{}
  45647. server *uint64
  45648. clearedserver bool
  45649. agent *uint64
  45650. clearedagent bool
  45651. done bool
  45652. oldValue func(context.Context) (*Wx, error)
  45653. predicates []predicate.Wx
  45654. }
  45655. var _ ent.Mutation = (*WxMutation)(nil)
  45656. // wxOption allows management of the mutation configuration using functional options.
  45657. type wxOption func(*WxMutation)
  45658. // newWxMutation creates new mutation for the Wx entity.
  45659. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  45660. m := &WxMutation{
  45661. config: c,
  45662. op: op,
  45663. typ: TypeWx,
  45664. clearedFields: make(map[string]struct{}),
  45665. }
  45666. for _, opt := range opts {
  45667. opt(m)
  45668. }
  45669. return m
  45670. }
  45671. // withWxID sets the ID field of the mutation.
  45672. func withWxID(id uint64) wxOption {
  45673. return func(m *WxMutation) {
  45674. var (
  45675. err error
  45676. once sync.Once
  45677. value *Wx
  45678. )
  45679. m.oldValue = func(ctx context.Context) (*Wx, error) {
  45680. once.Do(func() {
  45681. if m.done {
  45682. err = errors.New("querying old values post mutation is not allowed")
  45683. } else {
  45684. value, err = m.Client().Wx.Get(ctx, id)
  45685. }
  45686. })
  45687. return value, err
  45688. }
  45689. m.id = &id
  45690. }
  45691. }
  45692. // withWx sets the old Wx of the mutation.
  45693. func withWx(node *Wx) wxOption {
  45694. return func(m *WxMutation) {
  45695. m.oldValue = func(context.Context) (*Wx, error) {
  45696. return node, nil
  45697. }
  45698. m.id = &node.ID
  45699. }
  45700. }
  45701. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45702. // executed in a transaction (ent.Tx), a transactional client is returned.
  45703. func (m WxMutation) Client() *Client {
  45704. client := &Client{config: m.config}
  45705. client.init()
  45706. return client
  45707. }
  45708. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45709. // it returns an error otherwise.
  45710. func (m WxMutation) Tx() (*Tx, error) {
  45711. if _, ok := m.driver.(*txDriver); !ok {
  45712. return nil, errors.New("ent: mutation is not running in a transaction")
  45713. }
  45714. tx := &Tx{config: m.config}
  45715. tx.init()
  45716. return tx, nil
  45717. }
  45718. // SetID sets the value of the id field. Note that this
  45719. // operation is only accepted on creation of Wx entities.
  45720. func (m *WxMutation) SetID(id uint64) {
  45721. m.id = &id
  45722. }
  45723. // ID returns the ID value in the mutation. Note that the ID is only available
  45724. // if it was provided to the builder or after it was returned from the database.
  45725. func (m *WxMutation) ID() (id uint64, exists bool) {
  45726. if m.id == nil {
  45727. return
  45728. }
  45729. return *m.id, true
  45730. }
  45731. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45732. // That means, if the mutation is applied within a transaction with an isolation level such
  45733. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45734. // or updated by the mutation.
  45735. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  45736. switch {
  45737. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45738. id, exists := m.ID()
  45739. if exists {
  45740. return []uint64{id}, nil
  45741. }
  45742. fallthrough
  45743. case m.op.Is(OpUpdate | OpDelete):
  45744. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  45745. default:
  45746. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45747. }
  45748. }
  45749. // SetCreatedAt sets the "created_at" field.
  45750. func (m *WxMutation) SetCreatedAt(t time.Time) {
  45751. m.created_at = &t
  45752. }
  45753. // CreatedAt returns the value of the "created_at" field in the mutation.
  45754. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  45755. v := m.created_at
  45756. if v == nil {
  45757. return
  45758. }
  45759. return *v, true
  45760. }
  45761. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  45762. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45764. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45765. if !m.op.Is(OpUpdateOne) {
  45766. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45767. }
  45768. if m.id == nil || m.oldValue == nil {
  45769. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45770. }
  45771. oldValue, err := m.oldValue(ctx)
  45772. if err != nil {
  45773. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45774. }
  45775. return oldValue.CreatedAt, nil
  45776. }
  45777. // ResetCreatedAt resets all changes to the "created_at" field.
  45778. func (m *WxMutation) ResetCreatedAt() {
  45779. m.created_at = nil
  45780. }
  45781. // SetUpdatedAt sets the "updated_at" field.
  45782. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  45783. m.updated_at = &t
  45784. }
  45785. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45786. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  45787. v := m.updated_at
  45788. if v == nil {
  45789. return
  45790. }
  45791. return *v, true
  45792. }
  45793. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  45794. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45796. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45797. if !m.op.Is(OpUpdateOne) {
  45798. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45799. }
  45800. if m.id == nil || m.oldValue == nil {
  45801. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45802. }
  45803. oldValue, err := m.oldValue(ctx)
  45804. if err != nil {
  45805. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45806. }
  45807. return oldValue.UpdatedAt, nil
  45808. }
  45809. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45810. func (m *WxMutation) ResetUpdatedAt() {
  45811. m.updated_at = nil
  45812. }
  45813. // SetStatus sets the "status" field.
  45814. func (m *WxMutation) SetStatus(u uint8) {
  45815. m.status = &u
  45816. m.addstatus = nil
  45817. }
  45818. // Status returns the value of the "status" field in the mutation.
  45819. func (m *WxMutation) Status() (r uint8, exists bool) {
  45820. v := m.status
  45821. if v == nil {
  45822. return
  45823. }
  45824. return *v, true
  45825. }
  45826. // OldStatus returns the old "status" field's value of the Wx entity.
  45827. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45829. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45830. if !m.op.Is(OpUpdateOne) {
  45831. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45832. }
  45833. if m.id == nil || m.oldValue == nil {
  45834. return v, errors.New("OldStatus requires an ID field in the mutation")
  45835. }
  45836. oldValue, err := m.oldValue(ctx)
  45837. if err != nil {
  45838. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45839. }
  45840. return oldValue.Status, nil
  45841. }
  45842. // AddStatus adds u to the "status" field.
  45843. func (m *WxMutation) AddStatus(u int8) {
  45844. if m.addstatus != nil {
  45845. *m.addstatus += u
  45846. } else {
  45847. m.addstatus = &u
  45848. }
  45849. }
  45850. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45851. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  45852. v := m.addstatus
  45853. if v == nil {
  45854. return
  45855. }
  45856. return *v, true
  45857. }
  45858. // ClearStatus clears the value of the "status" field.
  45859. func (m *WxMutation) ClearStatus() {
  45860. m.status = nil
  45861. m.addstatus = nil
  45862. m.clearedFields[wx.FieldStatus] = struct{}{}
  45863. }
  45864. // StatusCleared returns if the "status" field was cleared in this mutation.
  45865. func (m *WxMutation) StatusCleared() bool {
  45866. _, ok := m.clearedFields[wx.FieldStatus]
  45867. return ok
  45868. }
  45869. // ResetStatus resets all changes to the "status" field.
  45870. func (m *WxMutation) ResetStatus() {
  45871. m.status = nil
  45872. m.addstatus = nil
  45873. delete(m.clearedFields, wx.FieldStatus)
  45874. }
  45875. // SetDeletedAt sets the "deleted_at" field.
  45876. func (m *WxMutation) SetDeletedAt(t time.Time) {
  45877. m.deleted_at = &t
  45878. }
  45879. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45880. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  45881. v := m.deleted_at
  45882. if v == nil {
  45883. return
  45884. }
  45885. return *v, true
  45886. }
  45887. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  45888. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45890. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45891. if !m.op.Is(OpUpdateOne) {
  45892. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45893. }
  45894. if m.id == nil || m.oldValue == nil {
  45895. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45896. }
  45897. oldValue, err := m.oldValue(ctx)
  45898. if err != nil {
  45899. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45900. }
  45901. return oldValue.DeletedAt, nil
  45902. }
  45903. // ClearDeletedAt clears the value of the "deleted_at" field.
  45904. func (m *WxMutation) ClearDeletedAt() {
  45905. m.deleted_at = nil
  45906. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  45907. }
  45908. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45909. func (m *WxMutation) DeletedAtCleared() bool {
  45910. _, ok := m.clearedFields[wx.FieldDeletedAt]
  45911. return ok
  45912. }
  45913. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45914. func (m *WxMutation) ResetDeletedAt() {
  45915. m.deleted_at = nil
  45916. delete(m.clearedFields, wx.FieldDeletedAt)
  45917. }
  45918. // SetServerID sets the "server_id" field.
  45919. func (m *WxMutation) SetServerID(u uint64) {
  45920. m.server = &u
  45921. }
  45922. // ServerID returns the value of the "server_id" field in the mutation.
  45923. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  45924. v := m.server
  45925. if v == nil {
  45926. return
  45927. }
  45928. return *v, true
  45929. }
  45930. // OldServerID returns the old "server_id" field's value of the Wx entity.
  45931. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45933. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  45934. if !m.op.Is(OpUpdateOne) {
  45935. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  45936. }
  45937. if m.id == nil || m.oldValue == nil {
  45938. return v, errors.New("OldServerID requires an ID field in the mutation")
  45939. }
  45940. oldValue, err := m.oldValue(ctx)
  45941. if err != nil {
  45942. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  45943. }
  45944. return oldValue.ServerID, nil
  45945. }
  45946. // ClearServerID clears the value of the "server_id" field.
  45947. func (m *WxMutation) ClearServerID() {
  45948. m.server = nil
  45949. m.clearedFields[wx.FieldServerID] = struct{}{}
  45950. }
  45951. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  45952. func (m *WxMutation) ServerIDCleared() bool {
  45953. _, ok := m.clearedFields[wx.FieldServerID]
  45954. return ok
  45955. }
  45956. // ResetServerID resets all changes to the "server_id" field.
  45957. func (m *WxMutation) ResetServerID() {
  45958. m.server = nil
  45959. delete(m.clearedFields, wx.FieldServerID)
  45960. }
  45961. // SetPort sets the "port" field.
  45962. func (m *WxMutation) SetPort(s string) {
  45963. m.port = &s
  45964. }
  45965. // Port returns the value of the "port" field in the mutation.
  45966. func (m *WxMutation) Port() (r string, exists bool) {
  45967. v := m.port
  45968. if v == nil {
  45969. return
  45970. }
  45971. return *v, true
  45972. }
  45973. // OldPort returns the old "port" field's value of the Wx entity.
  45974. // If the Wx 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 *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  45977. if !m.op.Is(OpUpdateOne) {
  45978. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  45979. }
  45980. if m.id == nil || m.oldValue == nil {
  45981. return v, errors.New("OldPort 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 OldPort: %w", err)
  45986. }
  45987. return oldValue.Port, nil
  45988. }
  45989. // ResetPort resets all changes to the "port" field.
  45990. func (m *WxMutation) ResetPort() {
  45991. m.port = nil
  45992. }
  45993. // SetProcessID sets the "process_id" field.
  45994. func (m *WxMutation) SetProcessID(s string) {
  45995. m.process_id = &s
  45996. }
  45997. // ProcessID returns the value of the "process_id" field in the mutation.
  45998. func (m *WxMutation) ProcessID() (r string, exists bool) {
  45999. v := m.process_id
  46000. if v == nil {
  46001. return
  46002. }
  46003. return *v, true
  46004. }
  46005. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  46006. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46008. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  46009. if !m.op.Is(OpUpdateOne) {
  46010. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  46011. }
  46012. if m.id == nil || m.oldValue == nil {
  46013. return v, errors.New("OldProcessID requires an ID field in the mutation")
  46014. }
  46015. oldValue, err := m.oldValue(ctx)
  46016. if err != nil {
  46017. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  46018. }
  46019. return oldValue.ProcessID, nil
  46020. }
  46021. // ResetProcessID resets all changes to the "process_id" field.
  46022. func (m *WxMutation) ResetProcessID() {
  46023. m.process_id = nil
  46024. }
  46025. // SetCallback sets the "callback" field.
  46026. func (m *WxMutation) SetCallback(s string) {
  46027. m.callback = &s
  46028. }
  46029. // Callback returns the value of the "callback" field in the mutation.
  46030. func (m *WxMutation) Callback() (r string, exists bool) {
  46031. v := m.callback
  46032. if v == nil {
  46033. return
  46034. }
  46035. return *v, true
  46036. }
  46037. // OldCallback returns the old "callback" field's value of the Wx entity.
  46038. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46040. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  46041. if !m.op.Is(OpUpdateOne) {
  46042. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  46043. }
  46044. if m.id == nil || m.oldValue == nil {
  46045. return v, errors.New("OldCallback requires an ID field in the mutation")
  46046. }
  46047. oldValue, err := m.oldValue(ctx)
  46048. if err != nil {
  46049. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  46050. }
  46051. return oldValue.Callback, nil
  46052. }
  46053. // ResetCallback resets all changes to the "callback" field.
  46054. func (m *WxMutation) ResetCallback() {
  46055. m.callback = nil
  46056. }
  46057. // SetWxid sets the "wxid" field.
  46058. func (m *WxMutation) SetWxid(s string) {
  46059. m.wxid = &s
  46060. }
  46061. // Wxid returns the value of the "wxid" field in the mutation.
  46062. func (m *WxMutation) Wxid() (r string, exists bool) {
  46063. v := m.wxid
  46064. if v == nil {
  46065. return
  46066. }
  46067. return *v, true
  46068. }
  46069. // OldWxid returns the old "wxid" field's value of the Wx entity.
  46070. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46072. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  46073. if !m.op.Is(OpUpdateOne) {
  46074. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46075. }
  46076. if m.id == nil || m.oldValue == nil {
  46077. return v, errors.New("OldWxid requires an ID field in the mutation")
  46078. }
  46079. oldValue, err := m.oldValue(ctx)
  46080. if err != nil {
  46081. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46082. }
  46083. return oldValue.Wxid, nil
  46084. }
  46085. // ResetWxid resets all changes to the "wxid" field.
  46086. func (m *WxMutation) ResetWxid() {
  46087. m.wxid = nil
  46088. }
  46089. // SetAccount sets the "account" field.
  46090. func (m *WxMutation) SetAccount(s string) {
  46091. m.account = &s
  46092. }
  46093. // Account returns the value of the "account" field in the mutation.
  46094. func (m *WxMutation) Account() (r string, exists bool) {
  46095. v := m.account
  46096. if v == nil {
  46097. return
  46098. }
  46099. return *v, true
  46100. }
  46101. // OldAccount returns the old "account" field's value of the Wx entity.
  46102. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46104. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  46105. if !m.op.Is(OpUpdateOne) {
  46106. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  46107. }
  46108. if m.id == nil || m.oldValue == nil {
  46109. return v, errors.New("OldAccount requires an ID field in the mutation")
  46110. }
  46111. oldValue, err := m.oldValue(ctx)
  46112. if err != nil {
  46113. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  46114. }
  46115. return oldValue.Account, nil
  46116. }
  46117. // ResetAccount resets all changes to the "account" field.
  46118. func (m *WxMutation) ResetAccount() {
  46119. m.account = nil
  46120. }
  46121. // SetNickname sets the "nickname" field.
  46122. func (m *WxMutation) SetNickname(s string) {
  46123. m.nickname = &s
  46124. }
  46125. // Nickname returns the value of the "nickname" field in the mutation.
  46126. func (m *WxMutation) Nickname() (r string, exists bool) {
  46127. v := m.nickname
  46128. if v == nil {
  46129. return
  46130. }
  46131. return *v, true
  46132. }
  46133. // OldNickname returns the old "nickname" field's value of the Wx entity.
  46134. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46136. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  46137. if !m.op.Is(OpUpdateOne) {
  46138. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  46139. }
  46140. if m.id == nil || m.oldValue == nil {
  46141. return v, errors.New("OldNickname requires an ID field in the mutation")
  46142. }
  46143. oldValue, err := m.oldValue(ctx)
  46144. if err != nil {
  46145. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  46146. }
  46147. return oldValue.Nickname, nil
  46148. }
  46149. // ResetNickname resets all changes to the "nickname" field.
  46150. func (m *WxMutation) ResetNickname() {
  46151. m.nickname = nil
  46152. }
  46153. // SetTel sets the "tel" field.
  46154. func (m *WxMutation) SetTel(s string) {
  46155. m.tel = &s
  46156. }
  46157. // Tel returns the value of the "tel" field in the mutation.
  46158. func (m *WxMutation) Tel() (r string, exists bool) {
  46159. v := m.tel
  46160. if v == nil {
  46161. return
  46162. }
  46163. return *v, true
  46164. }
  46165. // OldTel returns the old "tel" field's value of the Wx entity.
  46166. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46168. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  46169. if !m.op.Is(OpUpdateOne) {
  46170. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  46171. }
  46172. if m.id == nil || m.oldValue == nil {
  46173. return v, errors.New("OldTel requires an ID field in the mutation")
  46174. }
  46175. oldValue, err := m.oldValue(ctx)
  46176. if err != nil {
  46177. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  46178. }
  46179. return oldValue.Tel, nil
  46180. }
  46181. // ResetTel resets all changes to the "tel" field.
  46182. func (m *WxMutation) ResetTel() {
  46183. m.tel = nil
  46184. }
  46185. // SetHeadBig sets the "head_big" field.
  46186. func (m *WxMutation) SetHeadBig(s string) {
  46187. m.head_big = &s
  46188. }
  46189. // HeadBig returns the value of the "head_big" field in the mutation.
  46190. func (m *WxMutation) HeadBig() (r string, exists bool) {
  46191. v := m.head_big
  46192. if v == nil {
  46193. return
  46194. }
  46195. return *v, true
  46196. }
  46197. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  46198. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46200. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  46201. if !m.op.Is(OpUpdateOne) {
  46202. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  46203. }
  46204. if m.id == nil || m.oldValue == nil {
  46205. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  46206. }
  46207. oldValue, err := m.oldValue(ctx)
  46208. if err != nil {
  46209. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  46210. }
  46211. return oldValue.HeadBig, nil
  46212. }
  46213. // ResetHeadBig resets all changes to the "head_big" field.
  46214. func (m *WxMutation) ResetHeadBig() {
  46215. m.head_big = nil
  46216. }
  46217. // SetOrganizationID sets the "organization_id" field.
  46218. func (m *WxMutation) SetOrganizationID(u uint64) {
  46219. m.organization_id = &u
  46220. m.addorganization_id = nil
  46221. }
  46222. // OrganizationID returns the value of the "organization_id" field in the mutation.
  46223. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  46224. v := m.organization_id
  46225. if v == nil {
  46226. return
  46227. }
  46228. return *v, true
  46229. }
  46230. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  46231. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46233. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  46234. if !m.op.Is(OpUpdateOne) {
  46235. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  46236. }
  46237. if m.id == nil || m.oldValue == nil {
  46238. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  46239. }
  46240. oldValue, err := m.oldValue(ctx)
  46241. if err != nil {
  46242. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  46243. }
  46244. return oldValue.OrganizationID, nil
  46245. }
  46246. // AddOrganizationID adds u to the "organization_id" field.
  46247. func (m *WxMutation) AddOrganizationID(u int64) {
  46248. if m.addorganization_id != nil {
  46249. *m.addorganization_id += u
  46250. } else {
  46251. m.addorganization_id = &u
  46252. }
  46253. }
  46254. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  46255. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  46256. v := m.addorganization_id
  46257. if v == nil {
  46258. return
  46259. }
  46260. return *v, true
  46261. }
  46262. // ClearOrganizationID clears the value of the "organization_id" field.
  46263. func (m *WxMutation) ClearOrganizationID() {
  46264. m.organization_id = nil
  46265. m.addorganization_id = nil
  46266. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  46267. }
  46268. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  46269. func (m *WxMutation) OrganizationIDCleared() bool {
  46270. _, ok := m.clearedFields[wx.FieldOrganizationID]
  46271. return ok
  46272. }
  46273. // ResetOrganizationID resets all changes to the "organization_id" field.
  46274. func (m *WxMutation) ResetOrganizationID() {
  46275. m.organization_id = nil
  46276. m.addorganization_id = nil
  46277. delete(m.clearedFields, wx.FieldOrganizationID)
  46278. }
  46279. // SetAgentID sets the "agent_id" field.
  46280. func (m *WxMutation) SetAgentID(u uint64) {
  46281. m.agent = &u
  46282. }
  46283. // AgentID returns the value of the "agent_id" field in the mutation.
  46284. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  46285. v := m.agent
  46286. if v == nil {
  46287. return
  46288. }
  46289. return *v, true
  46290. }
  46291. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  46292. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46294. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  46295. if !m.op.Is(OpUpdateOne) {
  46296. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  46297. }
  46298. if m.id == nil || m.oldValue == nil {
  46299. return v, errors.New("OldAgentID requires an ID field in the mutation")
  46300. }
  46301. oldValue, err := m.oldValue(ctx)
  46302. if err != nil {
  46303. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  46304. }
  46305. return oldValue.AgentID, nil
  46306. }
  46307. // ResetAgentID resets all changes to the "agent_id" field.
  46308. func (m *WxMutation) ResetAgentID() {
  46309. m.agent = nil
  46310. }
  46311. // SetAPIBase sets the "api_base" field.
  46312. func (m *WxMutation) SetAPIBase(s string) {
  46313. m.api_base = &s
  46314. }
  46315. // APIBase returns the value of the "api_base" field in the mutation.
  46316. func (m *WxMutation) APIBase() (r string, exists bool) {
  46317. v := m.api_base
  46318. if v == nil {
  46319. return
  46320. }
  46321. return *v, true
  46322. }
  46323. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  46324. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46326. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  46327. if !m.op.Is(OpUpdateOne) {
  46328. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  46329. }
  46330. if m.id == nil || m.oldValue == nil {
  46331. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  46332. }
  46333. oldValue, err := m.oldValue(ctx)
  46334. if err != nil {
  46335. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  46336. }
  46337. return oldValue.APIBase, nil
  46338. }
  46339. // ClearAPIBase clears the value of the "api_base" field.
  46340. func (m *WxMutation) ClearAPIBase() {
  46341. m.api_base = nil
  46342. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  46343. }
  46344. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  46345. func (m *WxMutation) APIBaseCleared() bool {
  46346. _, ok := m.clearedFields[wx.FieldAPIBase]
  46347. return ok
  46348. }
  46349. // ResetAPIBase resets all changes to the "api_base" field.
  46350. func (m *WxMutation) ResetAPIBase() {
  46351. m.api_base = nil
  46352. delete(m.clearedFields, wx.FieldAPIBase)
  46353. }
  46354. // SetAPIKey sets the "api_key" field.
  46355. func (m *WxMutation) SetAPIKey(s string) {
  46356. m.api_key = &s
  46357. }
  46358. // APIKey returns the value of the "api_key" field in the mutation.
  46359. func (m *WxMutation) APIKey() (r string, exists bool) {
  46360. v := m.api_key
  46361. if v == nil {
  46362. return
  46363. }
  46364. return *v, true
  46365. }
  46366. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  46367. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46369. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  46370. if !m.op.Is(OpUpdateOne) {
  46371. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  46372. }
  46373. if m.id == nil || m.oldValue == nil {
  46374. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  46375. }
  46376. oldValue, err := m.oldValue(ctx)
  46377. if err != nil {
  46378. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  46379. }
  46380. return oldValue.APIKey, nil
  46381. }
  46382. // ClearAPIKey clears the value of the "api_key" field.
  46383. func (m *WxMutation) ClearAPIKey() {
  46384. m.api_key = nil
  46385. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  46386. }
  46387. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  46388. func (m *WxMutation) APIKeyCleared() bool {
  46389. _, ok := m.clearedFields[wx.FieldAPIKey]
  46390. return ok
  46391. }
  46392. // ResetAPIKey resets all changes to the "api_key" field.
  46393. func (m *WxMutation) ResetAPIKey() {
  46394. m.api_key = nil
  46395. delete(m.clearedFields, wx.FieldAPIKey)
  46396. }
  46397. // SetAllowList sets the "allow_list" field.
  46398. func (m *WxMutation) SetAllowList(s []string) {
  46399. m.allow_list = &s
  46400. m.appendallow_list = nil
  46401. }
  46402. // AllowList returns the value of the "allow_list" field in the mutation.
  46403. func (m *WxMutation) AllowList() (r []string, exists bool) {
  46404. v := m.allow_list
  46405. if v == nil {
  46406. return
  46407. }
  46408. return *v, true
  46409. }
  46410. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  46411. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46413. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  46414. if !m.op.Is(OpUpdateOne) {
  46415. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  46416. }
  46417. if m.id == nil || m.oldValue == nil {
  46418. return v, errors.New("OldAllowList requires an ID field in the mutation")
  46419. }
  46420. oldValue, err := m.oldValue(ctx)
  46421. if err != nil {
  46422. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  46423. }
  46424. return oldValue.AllowList, nil
  46425. }
  46426. // AppendAllowList adds s to the "allow_list" field.
  46427. func (m *WxMutation) AppendAllowList(s []string) {
  46428. m.appendallow_list = append(m.appendallow_list, s...)
  46429. }
  46430. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  46431. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  46432. if len(m.appendallow_list) == 0 {
  46433. return nil, false
  46434. }
  46435. return m.appendallow_list, true
  46436. }
  46437. // ResetAllowList resets all changes to the "allow_list" field.
  46438. func (m *WxMutation) ResetAllowList() {
  46439. m.allow_list = nil
  46440. m.appendallow_list = nil
  46441. }
  46442. // SetGroupAllowList sets the "group_allow_list" field.
  46443. func (m *WxMutation) SetGroupAllowList(s []string) {
  46444. m.group_allow_list = &s
  46445. m.appendgroup_allow_list = nil
  46446. }
  46447. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  46448. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  46449. v := m.group_allow_list
  46450. if v == nil {
  46451. return
  46452. }
  46453. return *v, true
  46454. }
  46455. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  46456. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46458. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  46459. if !m.op.Is(OpUpdateOne) {
  46460. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  46461. }
  46462. if m.id == nil || m.oldValue == nil {
  46463. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  46464. }
  46465. oldValue, err := m.oldValue(ctx)
  46466. if err != nil {
  46467. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  46468. }
  46469. return oldValue.GroupAllowList, nil
  46470. }
  46471. // AppendGroupAllowList adds s to the "group_allow_list" field.
  46472. func (m *WxMutation) AppendGroupAllowList(s []string) {
  46473. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  46474. }
  46475. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  46476. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  46477. if len(m.appendgroup_allow_list) == 0 {
  46478. return nil, false
  46479. }
  46480. return m.appendgroup_allow_list, true
  46481. }
  46482. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  46483. func (m *WxMutation) ResetGroupAllowList() {
  46484. m.group_allow_list = nil
  46485. m.appendgroup_allow_list = nil
  46486. }
  46487. // SetBlockList sets the "block_list" field.
  46488. func (m *WxMutation) SetBlockList(s []string) {
  46489. m.block_list = &s
  46490. m.appendblock_list = nil
  46491. }
  46492. // BlockList returns the value of the "block_list" field in the mutation.
  46493. func (m *WxMutation) BlockList() (r []string, exists bool) {
  46494. v := m.block_list
  46495. if v == nil {
  46496. return
  46497. }
  46498. return *v, true
  46499. }
  46500. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  46501. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46503. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  46504. if !m.op.Is(OpUpdateOne) {
  46505. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  46506. }
  46507. if m.id == nil || m.oldValue == nil {
  46508. return v, errors.New("OldBlockList requires an ID field in the mutation")
  46509. }
  46510. oldValue, err := m.oldValue(ctx)
  46511. if err != nil {
  46512. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  46513. }
  46514. return oldValue.BlockList, nil
  46515. }
  46516. // AppendBlockList adds s to the "block_list" field.
  46517. func (m *WxMutation) AppendBlockList(s []string) {
  46518. m.appendblock_list = append(m.appendblock_list, s...)
  46519. }
  46520. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  46521. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  46522. if len(m.appendblock_list) == 0 {
  46523. return nil, false
  46524. }
  46525. return m.appendblock_list, true
  46526. }
  46527. // ResetBlockList resets all changes to the "block_list" field.
  46528. func (m *WxMutation) ResetBlockList() {
  46529. m.block_list = nil
  46530. m.appendblock_list = nil
  46531. }
  46532. // SetGroupBlockList sets the "group_block_list" field.
  46533. func (m *WxMutation) SetGroupBlockList(s []string) {
  46534. m.group_block_list = &s
  46535. m.appendgroup_block_list = nil
  46536. }
  46537. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  46538. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  46539. v := m.group_block_list
  46540. if v == nil {
  46541. return
  46542. }
  46543. return *v, true
  46544. }
  46545. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  46546. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46548. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  46549. if !m.op.Is(OpUpdateOne) {
  46550. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  46551. }
  46552. if m.id == nil || m.oldValue == nil {
  46553. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  46554. }
  46555. oldValue, err := m.oldValue(ctx)
  46556. if err != nil {
  46557. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  46558. }
  46559. return oldValue.GroupBlockList, nil
  46560. }
  46561. // AppendGroupBlockList adds s to the "group_block_list" field.
  46562. func (m *WxMutation) AppendGroupBlockList(s []string) {
  46563. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  46564. }
  46565. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  46566. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  46567. if len(m.appendgroup_block_list) == 0 {
  46568. return nil, false
  46569. }
  46570. return m.appendgroup_block_list, true
  46571. }
  46572. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  46573. func (m *WxMutation) ResetGroupBlockList() {
  46574. m.group_block_list = nil
  46575. m.appendgroup_block_list = nil
  46576. }
  46577. // SetCtype sets the "ctype" field.
  46578. func (m *WxMutation) SetCtype(u uint64) {
  46579. m.ctype = &u
  46580. m.addctype = nil
  46581. }
  46582. // Ctype returns the value of the "ctype" field in the mutation.
  46583. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  46584. v := m.ctype
  46585. if v == nil {
  46586. return
  46587. }
  46588. return *v, true
  46589. }
  46590. // OldCtype returns the old "ctype" field's value of the Wx entity.
  46591. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46593. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  46594. if !m.op.Is(OpUpdateOne) {
  46595. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  46596. }
  46597. if m.id == nil || m.oldValue == nil {
  46598. return v, errors.New("OldCtype requires an ID field in the mutation")
  46599. }
  46600. oldValue, err := m.oldValue(ctx)
  46601. if err != nil {
  46602. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  46603. }
  46604. return oldValue.Ctype, nil
  46605. }
  46606. // AddCtype adds u to the "ctype" field.
  46607. func (m *WxMutation) AddCtype(u int64) {
  46608. if m.addctype != nil {
  46609. *m.addctype += u
  46610. } else {
  46611. m.addctype = &u
  46612. }
  46613. }
  46614. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  46615. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  46616. v := m.addctype
  46617. if v == nil {
  46618. return
  46619. }
  46620. return *v, true
  46621. }
  46622. // ClearCtype clears the value of the "ctype" field.
  46623. func (m *WxMutation) ClearCtype() {
  46624. m.ctype = nil
  46625. m.addctype = nil
  46626. m.clearedFields[wx.FieldCtype] = struct{}{}
  46627. }
  46628. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  46629. func (m *WxMutation) CtypeCleared() bool {
  46630. _, ok := m.clearedFields[wx.FieldCtype]
  46631. return ok
  46632. }
  46633. // ResetCtype resets all changes to the "ctype" field.
  46634. func (m *WxMutation) ResetCtype() {
  46635. m.ctype = nil
  46636. m.addctype = nil
  46637. delete(m.clearedFields, wx.FieldCtype)
  46638. }
  46639. // ClearServer clears the "server" edge to the Server entity.
  46640. func (m *WxMutation) ClearServer() {
  46641. m.clearedserver = true
  46642. m.clearedFields[wx.FieldServerID] = struct{}{}
  46643. }
  46644. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  46645. func (m *WxMutation) ServerCleared() bool {
  46646. return m.ServerIDCleared() || m.clearedserver
  46647. }
  46648. // ServerIDs returns the "server" edge IDs in the mutation.
  46649. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  46650. // ServerID instead. It exists only for internal usage by the builders.
  46651. func (m *WxMutation) ServerIDs() (ids []uint64) {
  46652. if id := m.server; id != nil {
  46653. ids = append(ids, *id)
  46654. }
  46655. return
  46656. }
  46657. // ResetServer resets all changes to the "server" edge.
  46658. func (m *WxMutation) ResetServer() {
  46659. m.server = nil
  46660. m.clearedserver = false
  46661. }
  46662. // ClearAgent clears the "agent" edge to the Agent entity.
  46663. func (m *WxMutation) ClearAgent() {
  46664. m.clearedagent = true
  46665. m.clearedFields[wx.FieldAgentID] = struct{}{}
  46666. }
  46667. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  46668. func (m *WxMutation) AgentCleared() bool {
  46669. return m.clearedagent
  46670. }
  46671. // AgentIDs returns the "agent" edge IDs in the mutation.
  46672. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  46673. // AgentID instead. It exists only for internal usage by the builders.
  46674. func (m *WxMutation) AgentIDs() (ids []uint64) {
  46675. if id := m.agent; id != nil {
  46676. ids = append(ids, *id)
  46677. }
  46678. return
  46679. }
  46680. // ResetAgent resets all changes to the "agent" edge.
  46681. func (m *WxMutation) ResetAgent() {
  46682. m.agent = nil
  46683. m.clearedagent = false
  46684. }
  46685. // Where appends a list predicates to the WxMutation builder.
  46686. func (m *WxMutation) Where(ps ...predicate.Wx) {
  46687. m.predicates = append(m.predicates, ps...)
  46688. }
  46689. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  46690. // users can use type-assertion to append predicates that do not depend on any generated package.
  46691. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  46692. p := make([]predicate.Wx, len(ps))
  46693. for i := range ps {
  46694. p[i] = ps[i]
  46695. }
  46696. m.Where(p...)
  46697. }
  46698. // Op returns the operation name.
  46699. func (m *WxMutation) Op() Op {
  46700. return m.op
  46701. }
  46702. // SetOp allows setting the mutation operation.
  46703. func (m *WxMutation) SetOp(op Op) {
  46704. m.op = op
  46705. }
  46706. // Type returns the node type of this mutation (Wx).
  46707. func (m *WxMutation) Type() string {
  46708. return m.typ
  46709. }
  46710. // Fields returns all fields that were changed during this mutation. Note that in
  46711. // order to get all numeric fields that were incremented/decremented, call
  46712. // AddedFields().
  46713. func (m *WxMutation) Fields() []string {
  46714. fields := make([]string, 0, 22)
  46715. if m.created_at != nil {
  46716. fields = append(fields, wx.FieldCreatedAt)
  46717. }
  46718. if m.updated_at != nil {
  46719. fields = append(fields, wx.FieldUpdatedAt)
  46720. }
  46721. if m.status != nil {
  46722. fields = append(fields, wx.FieldStatus)
  46723. }
  46724. if m.deleted_at != nil {
  46725. fields = append(fields, wx.FieldDeletedAt)
  46726. }
  46727. if m.server != nil {
  46728. fields = append(fields, wx.FieldServerID)
  46729. }
  46730. if m.port != nil {
  46731. fields = append(fields, wx.FieldPort)
  46732. }
  46733. if m.process_id != nil {
  46734. fields = append(fields, wx.FieldProcessID)
  46735. }
  46736. if m.callback != nil {
  46737. fields = append(fields, wx.FieldCallback)
  46738. }
  46739. if m.wxid != nil {
  46740. fields = append(fields, wx.FieldWxid)
  46741. }
  46742. if m.account != nil {
  46743. fields = append(fields, wx.FieldAccount)
  46744. }
  46745. if m.nickname != nil {
  46746. fields = append(fields, wx.FieldNickname)
  46747. }
  46748. if m.tel != nil {
  46749. fields = append(fields, wx.FieldTel)
  46750. }
  46751. if m.head_big != nil {
  46752. fields = append(fields, wx.FieldHeadBig)
  46753. }
  46754. if m.organization_id != nil {
  46755. fields = append(fields, wx.FieldOrganizationID)
  46756. }
  46757. if m.agent != nil {
  46758. fields = append(fields, wx.FieldAgentID)
  46759. }
  46760. if m.api_base != nil {
  46761. fields = append(fields, wx.FieldAPIBase)
  46762. }
  46763. if m.api_key != nil {
  46764. fields = append(fields, wx.FieldAPIKey)
  46765. }
  46766. if m.allow_list != nil {
  46767. fields = append(fields, wx.FieldAllowList)
  46768. }
  46769. if m.group_allow_list != nil {
  46770. fields = append(fields, wx.FieldGroupAllowList)
  46771. }
  46772. if m.block_list != nil {
  46773. fields = append(fields, wx.FieldBlockList)
  46774. }
  46775. if m.group_block_list != nil {
  46776. fields = append(fields, wx.FieldGroupBlockList)
  46777. }
  46778. if m.ctype != nil {
  46779. fields = append(fields, wx.FieldCtype)
  46780. }
  46781. return fields
  46782. }
  46783. // Field returns the value of a field with the given name. The second boolean
  46784. // return value indicates that this field was not set, or was not defined in the
  46785. // schema.
  46786. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  46787. switch name {
  46788. case wx.FieldCreatedAt:
  46789. return m.CreatedAt()
  46790. case wx.FieldUpdatedAt:
  46791. return m.UpdatedAt()
  46792. case wx.FieldStatus:
  46793. return m.Status()
  46794. case wx.FieldDeletedAt:
  46795. return m.DeletedAt()
  46796. case wx.FieldServerID:
  46797. return m.ServerID()
  46798. case wx.FieldPort:
  46799. return m.Port()
  46800. case wx.FieldProcessID:
  46801. return m.ProcessID()
  46802. case wx.FieldCallback:
  46803. return m.Callback()
  46804. case wx.FieldWxid:
  46805. return m.Wxid()
  46806. case wx.FieldAccount:
  46807. return m.Account()
  46808. case wx.FieldNickname:
  46809. return m.Nickname()
  46810. case wx.FieldTel:
  46811. return m.Tel()
  46812. case wx.FieldHeadBig:
  46813. return m.HeadBig()
  46814. case wx.FieldOrganizationID:
  46815. return m.OrganizationID()
  46816. case wx.FieldAgentID:
  46817. return m.AgentID()
  46818. case wx.FieldAPIBase:
  46819. return m.APIBase()
  46820. case wx.FieldAPIKey:
  46821. return m.APIKey()
  46822. case wx.FieldAllowList:
  46823. return m.AllowList()
  46824. case wx.FieldGroupAllowList:
  46825. return m.GroupAllowList()
  46826. case wx.FieldBlockList:
  46827. return m.BlockList()
  46828. case wx.FieldGroupBlockList:
  46829. return m.GroupBlockList()
  46830. case wx.FieldCtype:
  46831. return m.Ctype()
  46832. }
  46833. return nil, false
  46834. }
  46835. // OldField returns the old value of the field from the database. An error is
  46836. // returned if the mutation operation is not UpdateOne, or the query to the
  46837. // database failed.
  46838. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46839. switch name {
  46840. case wx.FieldCreatedAt:
  46841. return m.OldCreatedAt(ctx)
  46842. case wx.FieldUpdatedAt:
  46843. return m.OldUpdatedAt(ctx)
  46844. case wx.FieldStatus:
  46845. return m.OldStatus(ctx)
  46846. case wx.FieldDeletedAt:
  46847. return m.OldDeletedAt(ctx)
  46848. case wx.FieldServerID:
  46849. return m.OldServerID(ctx)
  46850. case wx.FieldPort:
  46851. return m.OldPort(ctx)
  46852. case wx.FieldProcessID:
  46853. return m.OldProcessID(ctx)
  46854. case wx.FieldCallback:
  46855. return m.OldCallback(ctx)
  46856. case wx.FieldWxid:
  46857. return m.OldWxid(ctx)
  46858. case wx.FieldAccount:
  46859. return m.OldAccount(ctx)
  46860. case wx.FieldNickname:
  46861. return m.OldNickname(ctx)
  46862. case wx.FieldTel:
  46863. return m.OldTel(ctx)
  46864. case wx.FieldHeadBig:
  46865. return m.OldHeadBig(ctx)
  46866. case wx.FieldOrganizationID:
  46867. return m.OldOrganizationID(ctx)
  46868. case wx.FieldAgentID:
  46869. return m.OldAgentID(ctx)
  46870. case wx.FieldAPIBase:
  46871. return m.OldAPIBase(ctx)
  46872. case wx.FieldAPIKey:
  46873. return m.OldAPIKey(ctx)
  46874. case wx.FieldAllowList:
  46875. return m.OldAllowList(ctx)
  46876. case wx.FieldGroupAllowList:
  46877. return m.OldGroupAllowList(ctx)
  46878. case wx.FieldBlockList:
  46879. return m.OldBlockList(ctx)
  46880. case wx.FieldGroupBlockList:
  46881. return m.OldGroupBlockList(ctx)
  46882. case wx.FieldCtype:
  46883. return m.OldCtype(ctx)
  46884. }
  46885. return nil, fmt.Errorf("unknown Wx field %s", name)
  46886. }
  46887. // SetField sets the value of a field with the given name. It returns an error if
  46888. // the field is not defined in the schema, or if the type mismatched the field
  46889. // type.
  46890. func (m *WxMutation) SetField(name string, value ent.Value) error {
  46891. switch name {
  46892. case wx.FieldCreatedAt:
  46893. v, ok := value.(time.Time)
  46894. if !ok {
  46895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46896. }
  46897. m.SetCreatedAt(v)
  46898. return nil
  46899. case wx.FieldUpdatedAt:
  46900. v, ok := value.(time.Time)
  46901. if !ok {
  46902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46903. }
  46904. m.SetUpdatedAt(v)
  46905. return nil
  46906. case wx.FieldStatus:
  46907. v, ok := value.(uint8)
  46908. if !ok {
  46909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46910. }
  46911. m.SetStatus(v)
  46912. return nil
  46913. case wx.FieldDeletedAt:
  46914. v, ok := value.(time.Time)
  46915. if !ok {
  46916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46917. }
  46918. m.SetDeletedAt(v)
  46919. return nil
  46920. case wx.FieldServerID:
  46921. v, ok := value.(uint64)
  46922. if !ok {
  46923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46924. }
  46925. m.SetServerID(v)
  46926. return nil
  46927. case wx.FieldPort:
  46928. v, ok := value.(string)
  46929. if !ok {
  46930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46931. }
  46932. m.SetPort(v)
  46933. return nil
  46934. case wx.FieldProcessID:
  46935. v, ok := value.(string)
  46936. if !ok {
  46937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46938. }
  46939. m.SetProcessID(v)
  46940. return nil
  46941. case wx.FieldCallback:
  46942. v, ok := value.(string)
  46943. if !ok {
  46944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46945. }
  46946. m.SetCallback(v)
  46947. return nil
  46948. case wx.FieldWxid:
  46949. v, ok := value.(string)
  46950. if !ok {
  46951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46952. }
  46953. m.SetWxid(v)
  46954. return nil
  46955. case wx.FieldAccount:
  46956. v, ok := value.(string)
  46957. if !ok {
  46958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46959. }
  46960. m.SetAccount(v)
  46961. return nil
  46962. case wx.FieldNickname:
  46963. v, ok := value.(string)
  46964. if !ok {
  46965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46966. }
  46967. m.SetNickname(v)
  46968. return nil
  46969. case wx.FieldTel:
  46970. v, ok := value.(string)
  46971. if !ok {
  46972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46973. }
  46974. m.SetTel(v)
  46975. return nil
  46976. case wx.FieldHeadBig:
  46977. v, ok := value.(string)
  46978. if !ok {
  46979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46980. }
  46981. m.SetHeadBig(v)
  46982. return nil
  46983. case wx.FieldOrganizationID:
  46984. v, ok := value.(uint64)
  46985. if !ok {
  46986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46987. }
  46988. m.SetOrganizationID(v)
  46989. return nil
  46990. case wx.FieldAgentID:
  46991. v, ok := value.(uint64)
  46992. if !ok {
  46993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46994. }
  46995. m.SetAgentID(v)
  46996. return nil
  46997. case wx.FieldAPIBase:
  46998. v, ok := value.(string)
  46999. if !ok {
  47000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47001. }
  47002. m.SetAPIBase(v)
  47003. return nil
  47004. case wx.FieldAPIKey:
  47005. v, ok := value.(string)
  47006. if !ok {
  47007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47008. }
  47009. m.SetAPIKey(v)
  47010. return nil
  47011. case wx.FieldAllowList:
  47012. v, ok := value.([]string)
  47013. if !ok {
  47014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47015. }
  47016. m.SetAllowList(v)
  47017. return nil
  47018. case wx.FieldGroupAllowList:
  47019. v, ok := value.([]string)
  47020. if !ok {
  47021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47022. }
  47023. m.SetGroupAllowList(v)
  47024. return nil
  47025. case wx.FieldBlockList:
  47026. v, ok := value.([]string)
  47027. if !ok {
  47028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47029. }
  47030. m.SetBlockList(v)
  47031. return nil
  47032. case wx.FieldGroupBlockList:
  47033. v, ok := value.([]string)
  47034. if !ok {
  47035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47036. }
  47037. m.SetGroupBlockList(v)
  47038. return nil
  47039. case wx.FieldCtype:
  47040. v, ok := value.(uint64)
  47041. if !ok {
  47042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47043. }
  47044. m.SetCtype(v)
  47045. return nil
  47046. }
  47047. return fmt.Errorf("unknown Wx field %s", name)
  47048. }
  47049. // AddedFields returns all numeric fields that were incremented/decremented during
  47050. // this mutation.
  47051. func (m *WxMutation) AddedFields() []string {
  47052. var fields []string
  47053. if m.addstatus != nil {
  47054. fields = append(fields, wx.FieldStatus)
  47055. }
  47056. if m.addorganization_id != nil {
  47057. fields = append(fields, wx.FieldOrganizationID)
  47058. }
  47059. if m.addctype != nil {
  47060. fields = append(fields, wx.FieldCtype)
  47061. }
  47062. return fields
  47063. }
  47064. // AddedField returns the numeric value that was incremented/decremented on a field
  47065. // with the given name. The second boolean return value indicates that this field
  47066. // was not set, or was not defined in the schema.
  47067. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  47068. switch name {
  47069. case wx.FieldStatus:
  47070. return m.AddedStatus()
  47071. case wx.FieldOrganizationID:
  47072. return m.AddedOrganizationID()
  47073. case wx.FieldCtype:
  47074. return m.AddedCtype()
  47075. }
  47076. return nil, false
  47077. }
  47078. // AddField adds the value to the field with the given name. It returns an error if
  47079. // the field is not defined in the schema, or if the type mismatched the field
  47080. // type.
  47081. func (m *WxMutation) AddField(name string, value ent.Value) error {
  47082. switch name {
  47083. case wx.FieldStatus:
  47084. v, ok := value.(int8)
  47085. if !ok {
  47086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47087. }
  47088. m.AddStatus(v)
  47089. return nil
  47090. case wx.FieldOrganizationID:
  47091. v, ok := value.(int64)
  47092. if !ok {
  47093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47094. }
  47095. m.AddOrganizationID(v)
  47096. return nil
  47097. case wx.FieldCtype:
  47098. v, ok := value.(int64)
  47099. if !ok {
  47100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47101. }
  47102. m.AddCtype(v)
  47103. return nil
  47104. }
  47105. return fmt.Errorf("unknown Wx numeric field %s", name)
  47106. }
  47107. // ClearedFields returns all nullable fields that were cleared during this
  47108. // mutation.
  47109. func (m *WxMutation) ClearedFields() []string {
  47110. var fields []string
  47111. if m.FieldCleared(wx.FieldStatus) {
  47112. fields = append(fields, wx.FieldStatus)
  47113. }
  47114. if m.FieldCleared(wx.FieldDeletedAt) {
  47115. fields = append(fields, wx.FieldDeletedAt)
  47116. }
  47117. if m.FieldCleared(wx.FieldServerID) {
  47118. fields = append(fields, wx.FieldServerID)
  47119. }
  47120. if m.FieldCleared(wx.FieldOrganizationID) {
  47121. fields = append(fields, wx.FieldOrganizationID)
  47122. }
  47123. if m.FieldCleared(wx.FieldAPIBase) {
  47124. fields = append(fields, wx.FieldAPIBase)
  47125. }
  47126. if m.FieldCleared(wx.FieldAPIKey) {
  47127. fields = append(fields, wx.FieldAPIKey)
  47128. }
  47129. if m.FieldCleared(wx.FieldCtype) {
  47130. fields = append(fields, wx.FieldCtype)
  47131. }
  47132. return fields
  47133. }
  47134. // FieldCleared returns a boolean indicating if a field with the given name was
  47135. // cleared in this mutation.
  47136. func (m *WxMutation) FieldCleared(name string) bool {
  47137. _, ok := m.clearedFields[name]
  47138. return ok
  47139. }
  47140. // ClearField clears the value of the field with the given name. It returns an
  47141. // error if the field is not defined in the schema.
  47142. func (m *WxMutation) ClearField(name string) error {
  47143. switch name {
  47144. case wx.FieldStatus:
  47145. m.ClearStatus()
  47146. return nil
  47147. case wx.FieldDeletedAt:
  47148. m.ClearDeletedAt()
  47149. return nil
  47150. case wx.FieldServerID:
  47151. m.ClearServerID()
  47152. return nil
  47153. case wx.FieldOrganizationID:
  47154. m.ClearOrganizationID()
  47155. return nil
  47156. case wx.FieldAPIBase:
  47157. m.ClearAPIBase()
  47158. return nil
  47159. case wx.FieldAPIKey:
  47160. m.ClearAPIKey()
  47161. return nil
  47162. case wx.FieldCtype:
  47163. m.ClearCtype()
  47164. return nil
  47165. }
  47166. return fmt.Errorf("unknown Wx nullable field %s", name)
  47167. }
  47168. // ResetField resets all changes in the mutation for the field with the given name.
  47169. // It returns an error if the field is not defined in the schema.
  47170. func (m *WxMutation) ResetField(name string) error {
  47171. switch name {
  47172. case wx.FieldCreatedAt:
  47173. m.ResetCreatedAt()
  47174. return nil
  47175. case wx.FieldUpdatedAt:
  47176. m.ResetUpdatedAt()
  47177. return nil
  47178. case wx.FieldStatus:
  47179. m.ResetStatus()
  47180. return nil
  47181. case wx.FieldDeletedAt:
  47182. m.ResetDeletedAt()
  47183. return nil
  47184. case wx.FieldServerID:
  47185. m.ResetServerID()
  47186. return nil
  47187. case wx.FieldPort:
  47188. m.ResetPort()
  47189. return nil
  47190. case wx.FieldProcessID:
  47191. m.ResetProcessID()
  47192. return nil
  47193. case wx.FieldCallback:
  47194. m.ResetCallback()
  47195. return nil
  47196. case wx.FieldWxid:
  47197. m.ResetWxid()
  47198. return nil
  47199. case wx.FieldAccount:
  47200. m.ResetAccount()
  47201. return nil
  47202. case wx.FieldNickname:
  47203. m.ResetNickname()
  47204. return nil
  47205. case wx.FieldTel:
  47206. m.ResetTel()
  47207. return nil
  47208. case wx.FieldHeadBig:
  47209. m.ResetHeadBig()
  47210. return nil
  47211. case wx.FieldOrganizationID:
  47212. m.ResetOrganizationID()
  47213. return nil
  47214. case wx.FieldAgentID:
  47215. m.ResetAgentID()
  47216. return nil
  47217. case wx.FieldAPIBase:
  47218. m.ResetAPIBase()
  47219. return nil
  47220. case wx.FieldAPIKey:
  47221. m.ResetAPIKey()
  47222. return nil
  47223. case wx.FieldAllowList:
  47224. m.ResetAllowList()
  47225. return nil
  47226. case wx.FieldGroupAllowList:
  47227. m.ResetGroupAllowList()
  47228. return nil
  47229. case wx.FieldBlockList:
  47230. m.ResetBlockList()
  47231. return nil
  47232. case wx.FieldGroupBlockList:
  47233. m.ResetGroupBlockList()
  47234. return nil
  47235. case wx.FieldCtype:
  47236. m.ResetCtype()
  47237. return nil
  47238. }
  47239. return fmt.Errorf("unknown Wx field %s", name)
  47240. }
  47241. // AddedEdges returns all edge names that were set/added in this mutation.
  47242. func (m *WxMutation) AddedEdges() []string {
  47243. edges := make([]string, 0, 2)
  47244. if m.server != nil {
  47245. edges = append(edges, wx.EdgeServer)
  47246. }
  47247. if m.agent != nil {
  47248. edges = append(edges, wx.EdgeAgent)
  47249. }
  47250. return edges
  47251. }
  47252. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47253. // name in this mutation.
  47254. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  47255. switch name {
  47256. case wx.EdgeServer:
  47257. if id := m.server; id != nil {
  47258. return []ent.Value{*id}
  47259. }
  47260. case wx.EdgeAgent:
  47261. if id := m.agent; id != nil {
  47262. return []ent.Value{*id}
  47263. }
  47264. }
  47265. return nil
  47266. }
  47267. // RemovedEdges returns all edge names that were removed in this mutation.
  47268. func (m *WxMutation) RemovedEdges() []string {
  47269. edges := make([]string, 0, 2)
  47270. return edges
  47271. }
  47272. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47273. // the given name in this mutation.
  47274. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  47275. return nil
  47276. }
  47277. // ClearedEdges returns all edge names that were cleared in this mutation.
  47278. func (m *WxMutation) ClearedEdges() []string {
  47279. edges := make([]string, 0, 2)
  47280. if m.clearedserver {
  47281. edges = append(edges, wx.EdgeServer)
  47282. }
  47283. if m.clearedagent {
  47284. edges = append(edges, wx.EdgeAgent)
  47285. }
  47286. return edges
  47287. }
  47288. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47289. // was cleared in this mutation.
  47290. func (m *WxMutation) EdgeCleared(name string) bool {
  47291. switch name {
  47292. case wx.EdgeServer:
  47293. return m.clearedserver
  47294. case wx.EdgeAgent:
  47295. return m.clearedagent
  47296. }
  47297. return false
  47298. }
  47299. // ClearEdge clears the value of the edge with the given name. It returns an error
  47300. // if that edge is not defined in the schema.
  47301. func (m *WxMutation) ClearEdge(name string) error {
  47302. switch name {
  47303. case wx.EdgeServer:
  47304. m.ClearServer()
  47305. return nil
  47306. case wx.EdgeAgent:
  47307. m.ClearAgent()
  47308. return nil
  47309. }
  47310. return fmt.Errorf("unknown Wx unique edge %s", name)
  47311. }
  47312. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47313. // It returns an error if the edge is not defined in the schema.
  47314. func (m *WxMutation) ResetEdge(name string) error {
  47315. switch name {
  47316. case wx.EdgeServer:
  47317. m.ResetServer()
  47318. return nil
  47319. case wx.EdgeAgent:
  47320. m.ResetAgent()
  47321. return nil
  47322. }
  47323. return fmt.Errorf("unknown Wx edge %s", name)
  47324. }
  47325. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  47326. type WxCardMutation struct {
  47327. config
  47328. op Op
  47329. typ string
  47330. id *uint64
  47331. created_at *time.Time
  47332. updated_at *time.Time
  47333. deleted_at *time.Time
  47334. user_id *uint64
  47335. adduser_id *int64
  47336. wx_user_id *uint64
  47337. addwx_user_id *int64
  47338. avatar *string
  47339. logo *string
  47340. name *string
  47341. company *string
  47342. address *string
  47343. phone *string
  47344. official_account *string
  47345. wechat_account *string
  47346. email *string
  47347. api_base *string
  47348. api_key *string
  47349. ai_info *string
  47350. intro *string
  47351. clearedFields map[string]struct{}
  47352. done bool
  47353. oldValue func(context.Context) (*WxCard, error)
  47354. predicates []predicate.WxCard
  47355. }
  47356. var _ ent.Mutation = (*WxCardMutation)(nil)
  47357. // wxcardOption allows management of the mutation configuration using functional options.
  47358. type wxcardOption func(*WxCardMutation)
  47359. // newWxCardMutation creates new mutation for the WxCard entity.
  47360. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  47361. m := &WxCardMutation{
  47362. config: c,
  47363. op: op,
  47364. typ: TypeWxCard,
  47365. clearedFields: make(map[string]struct{}),
  47366. }
  47367. for _, opt := range opts {
  47368. opt(m)
  47369. }
  47370. return m
  47371. }
  47372. // withWxCardID sets the ID field of the mutation.
  47373. func withWxCardID(id uint64) wxcardOption {
  47374. return func(m *WxCardMutation) {
  47375. var (
  47376. err error
  47377. once sync.Once
  47378. value *WxCard
  47379. )
  47380. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  47381. once.Do(func() {
  47382. if m.done {
  47383. err = errors.New("querying old values post mutation is not allowed")
  47384. } else {
  47385. value, err = m.Client().WxCard.Get(ctx, id)
  47386. }
  47387. })
  47388. return value, err
  47389. }
  47390. m.id = &id
  47391. }
  47392. }
  47393. // withWxCard sets the old WxCard of the mutation.
  47394. func withWxCard(node *WxCard) wxcardOption {
  47395. return func(m *WxCardMutation) {
  47396. m.oldValue = func(context.Context) (*WxCard, error) {
  47397. return node, nil
  47398. }
  47399. m.id = &node.ID
  47400. }
  47401. }
  47402. // Client returns a new `ent.Client` from the mutation. If the mutation was
  47403. // executed in a transaction (ent.Tx), a transactional client is returned.
  47404. func (m WxCardMutation) Client() *Client {
  47405. client := &Client{config: m.config}
  47406. client.init()
  47407. return client
  47408. }
  47409. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  47410. // it returns an error otherwise.
  47411. func (m WxCardMutation) Tx() (*Tx, error) {
  47412. if _, ok := m.driver.(*txDriver); !ok {
  47413. return nil, errors.New("ent: mutation is not running in a transaction")
  47414. }
  47415. tx := &Tx{config: m.config}
  47416. tx.init()
  47417. return tx, nil
  47418. }
  47419. // SetID sets the value of the id field. Note that this
  47420. // operation is only accepted on creation of WxCard entities.
  47421. func (m *WxCardMutation) SetID(id uint64) {
  47422. m.id = &id
  47423. }
  47424. // ID returns the ID value in the mutation. Note that the ID is only available
  47425. // if it was provided to the builder or after it was returned from the database.
  47426. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  47427. if m.id == nil {
  47428. return
  47429. }
  47430. return *m.id, true
  47431. }
  47432. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  47433. // That means, if the mutation is applied within a transaction with an isolation level such
  47434. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  47435. // or updated by the mutation.
  47436. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  47437. switch {
  47438. case m.op.Is(OpUpdateOne | OpDeleteOne):
  47439. id, exists := m.ID()
  47440. if exists {
  47441. return []uint64{id}, nil
  47442. }
  47443. fallthrough
  47444. case m.op.Is(OpUpdate | OpDelete):
  47445. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  47446. default:
  47447. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47448. }
  47449. }
  47450. // SetCreatedAt sets the "created_at" field.
  47451. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  47452. m.created_at = &t
  47453. }
  47454. // CreatedAt returns the value of the "created_at" field in the mutation.
  47455. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  47456. v := m.created_at
  47457. if v == nil {
  47458. return
  47459. }
  47460. return *v, true
  47461. }
  47462. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  47463. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47465. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47466. if !m.op.Is(OpUpdateOne) {
  47467. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47468. }
  47469. if m.id == nil || m.oldValue == nil {
  47470. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  47471. }
  47472. oldValue, err := m.oldValue(ctx)
  47473. if err != nil {
  47474. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  47475. }
  47476. return oldValue.CreatedAt, nil
  47477. }
  47478. // ResetCreatedAt resets all changes to the "created_at" field.
  47479. func (m *WxCardMutation) ResetCreatedAt() {
  47480. m.created_at = nil
  47481. }
  47482. // SetUpdatedAt sets the "updated_at" field.
  47483. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  47484. m.updated_at = &t
  47485. }
  47486. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47487. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  47488. v := m.updated_at
  47489. if v == nil {
  47490. return
  47491. }
  47492. return *v, true
  47493. }
  47494. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  47495. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47497. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47498. if !m.op.Is(OpUpdateOne) {
  47499. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47500. }
  47501. if m.id == nil || m.oldValue == nil {
  47502. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  47503. }
  47504. oldValue, err := m.oldValue(ctx)
  47505. if err != nil {
  47506. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  47507. }
  47508. return oldValue.UpdatedAt, nil
  47509. }
  47510. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47511. func (m *WxCardMutation) ResetUpdatedAt() {
  47512. m.updated_at = nil
  47513. }
  47514. // SetDeletedAt sets the "deleted_at" field.
  47515. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  47516. m.deleted_at = &t
  47517. }
  47518. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47519. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  47520. v := m.deleted_at
  47521. if v == nil {
  47522. return
  47523. }
  47524. return *v, true
  47525. }
  47526. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  47527. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47529. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47530. if !m.op.Is(OpUpdateOne) {
  47531. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47532. }
  47533. if m.id == nil || m.oldValue == nil {
  47534. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47535. }
  47536. oldValue, err := m.oldValue(ctx)
  47537. if err != nil {
  47538. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47539. }
  47540. return oldValue.DeletedAt, nil
  47541. }
  47542. // ClearDeletedAt clears the value of the "deleted_at" field.
  47543. func (m *WxCardMutation) ClearDeletedAt() {
  47544. m.deleted_at = nil
  47545. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  47546. }
  47547. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47548. func (m *WxCardMutation) DeletedAtCleared() bool {
  47549. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  47550. return ok
  47551. }
  47552. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47553. func (m *WxCardMutation) ResetDeletedAt() {
  47554. m.deleted_at = nil
  47555. delete(m.clearedFields, wxcard.FieldDeletedAt)
  47556. }
  47557. // SetUserID sets the "user_id" field.
  47558. func (m *WxCardMutation) SetUserID(u uint64) {
  47559. m.user_id = &u
  47560. m.adduser_id = nil
  47561. }
  47562. // UserID returns the value of the "user_id" field in the mutation.
  47563. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  47564. v := m.user_id
  47565. if v == nil {
  47566. return
  47567. }
  47568. return *v, true
  47569. }
  47570. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  47571. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47573. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  47574. if !m.op.Is(OpUpdateOne) {
  47575. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  47576. }
  47577. if m.id == nil || m.oldValue == nil {
  47578. return v, errors.New("OldUserID requires an ID field in the mutation")
  47579. }
  47580. oldValue, err := m.oldValue(ctx)
  47581. if err != nil {
  47582. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  47583. }
  47584. return oldValue.UserID, nil
  47585. }
  47586. // AddUserID adds u to the "user_id" field.
  47587. func (m *WxCardMutation) AddUserID(u int64) {
  47588. if m.adduser_id != nil {
  47589. *m.adduser_id += u
  47590. } else {
  47591. m.adduser_id = &u
  47592. }
  47593. }
  47594. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  47595. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  47596. v := m.adduser_id
  47597. if v == nil {
  47598. return
  47599. }
  47600. return *v, true
  47601. }
  47602. // ClearUserID clears the value of the "user_id" field.
  47603. func (m *WxCardMutation) ClearUserID() {
  47604. m.user_id = nil
  47605. m.adduser_id = nil
  47606. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  47607. }
  47608. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  47609. func (m *WxCardMutation) UserIDCleared() bool {
  47610. _, ok := m.clearedFields[wxcard.FieldUserID]
  47611. return ok
  47612. }
  47613. // ResetUserID resets all changes to the "user_id" field.
  47614. func (m *WxCardMutation) ResetUserID() {
  47615. m.user_id = nil
  47616. m.adduser_id = nil
  47617. delete(m.clearedFields, wxcard.FieldUserID)
  47618. }
  47619. // SetWxUserID sets the "wx_user_id" field.
  47620. func (m *WxCardMutation) SetWxUserID(u uint64) {
  47621. m.wx_user_id = &u
  47622. m.addwx_user_id = nil
  47623. }
  47624. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  47625. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  47626. v := m.wx_user_id
  47627. if v == nil {
  47628. return
  47629. }
  47630. return *v, true
  47631. }
  47632. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  47633. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47635. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  47636. if !m.op.Is(OpUpdateOne) {
  47637. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  47638. }
  47639. if m.id == nil || m.oldValue == nil {
  47640. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  47641. }
  47642. oldValue, err := m.oldValue(ctx)
  47643. if err != nil {
  47644. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  47645. }
  47646. return oldValue.WxUserID, nil
  47647. }
  47648. // AddWxUserID adds u to the "wx_user_id" field.
  47649. func (m *WxCardMutation) AddWxUserID(u int64) {
  47650. if m.addwx_user_id != nil {
  47651. *m.addwx_user_id += u
  47652. } else {
  47653. m.addwx_user_id = &u
  47654. }
  47655. }
  47656. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  47657. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  47658. v := m.addwx_user_id
  47659. if v == nil {
  47660. return
  47661. }
  47662. return *v, true
  47663. }
  47664. // ClearWxUserID clears the value of the "wx_user_id" field.
  47665. func (m *WxCardMutation) ClearWxUserID() {
  47666. m.wx_user_id = nil
  47667. m.addwx_user_id = nil
  47668. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  47669. }
  47670. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  47671. func (m *WxCardMutation) WxUserIDCleared() bool {
  47672. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  47673. return ok
  47674. }
  47675. // ResetWxUserID resets all changes to the "wx_user_id" field.
  47676. func (m *WxCardMutation) ResetWxUserID() {
  47677. m.wx_user_id = nil
  47678. m.addwx_user_id = nil
  47679. delete(m.clearedFields, wxcard.FieldWxUserID)
  47680. }
  47681. // SetAvatar sets the "avatar" field.
  47682. func (m *WxCardMutation) SetAvatar(s string) {
  47683. m.avatar = &s
  47684. }
  47685. // Avatar returns the value of the "avatar" field in the mutation.
  47686. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  47687. v := m.avatar
  47688. if v == nil {
  47689. return
  47690. }
  47691. return *v, true
  47692. }
  47693. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  47694. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47696. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  47697. if !m.op.Is(OpUpdateOne) {
  47698. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  47699. }
  47700. if m.id == nil || m.oldValue == nil {
  47701. return v, errors.New("OldAvatar requires an ID field in the mutation")
  47702. }
  47703. oldValue, err := m.oldValue(ctx)
  47704. if err != nil {
  47705. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  47706. }
  47707. return oldValue.Avatar, nil
  47708. }
  47709. // ResetAvatar resets all changes to the "avatar" field.
  47710. func (m *WxCardMutation) ResetAvatar() {
  47711. m.avatar = nil
  47712. }
  47713. // SetLogo sets the "logo" field.
  47714. func (m *WxCardMutation) SetLogo(s string) {
  47715. m.logo = &s
  47716. }
  47717. // Logo returns the value of the "logo" field in the mutation.
  47718. func (m *WxCardMutation) Logo() (r string, exists bool) {
  47719. v := m.logo
  47720. if v == nil {
  47721. return
  47722. }
  47723. return *v, true
  47724. }
  47725. // OldLogo returns the old "logo" field's value of the WxCard entity.
  47726. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47728. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  47729. if !m.op.Is(OpUpdateOne) {
  47730. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  47731. }
  47732. if m.id == nil || m.oldValue == nil {
  47733. return v, errors.New("OldLogo requires an ID field in the mutation")
  47734. }
  47735. oldValue, err := m.oldValue(ctx)
  47736. if err != nil {
  47737. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  47738. }
  47739. return oldValue.Logo, nil
  47740. }
  47741. // ResetLogo resets all changes to the "logo" field.
  47742. func (m *WxCardMutation) ResetLogo() {
  47743. m.logo = nil
  47744. }
  47745. // SetName sets the "name" field.
  47746. func (m *WxCardMutation) SetName(s string) {
  47747. m.name = &s
  47748. }
  47749. // Name returns the value of the "name" field in the mutation.
  47750. func (m *WxCardMutation) Name() (r string, exists bool) {
  47751. v := m.name
  47752. if v == nil {
  47753. return
  47754. }
  47755. return *v, true
  47756. }
  47757. // OldName returns the old "name" field's value of the WxCard entity.
  47758. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47760. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  47761. if !m.op.Is(OpUpdateOne) {
  47762. return v, errors.New("OldName is only allowed on UpdateOne operations")
  47763. }
  47764. if m.id == nil || m.oldValue == nil {
  47765. return v, errors.New("OldName requires an ID field in the mutation")
  47766. }
  47767. oldValue, err := m.oldValue(ctx)
  47768. if err != nil {
  47769. return v, fmt.Errorf("querying old value for OldName: %w", err)
  47770. }
  47771. return oldValue.Name, nil
  47772. }
  47773. // ResetName resets all changes to the "name" field.
  47774. func (m *WxCardMutation) ResetName() {
  47775. m.name = nil
  47776. }
  47777. // SetCompany sets the "company" field.
  47778. func (m *WxCardMutation) SetCompany(s string) {
  47779. m.company = &s
  47780. }
  47781. // Company returns the value of the "company" field in the mutation.
  47782. func (m *WxCardMutation) Company() (r string, exists bool) {
  47783. v := m.company
  47784. if v == nil {
  47785. return
  47786. }
  47787. return *v, true
  47788. }
  47789. // OldCompany returns the old "company" field's value of the WxCard entity.
  47790. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47792. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  47793. if !m.op.Is(OpUpdateOne) {
  47794. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  47795. }
  47796. if m.id == nil || m.oldValue == nil {
  47797. return v, errors.New("OldCompany requires an ID field in the mutation")
  47798. }
  47799. oldValue, err := m.oldValue(ctx)
  47800. if err != nil {
  47801. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  47802. }
  47803. return oldValue.Company, nil
  47804. }
  47805. // ResetCompany resets all changes to the "company" field.
  47806. func (m *WxCardMutation) ResetCompany() {
  47807. m.company = nil
  47808. }
  47809. // SetAddress sets the "address" field.
  47810. func (m *WxCardMutation) SetAddress(s string) {
  47811. m.address = &s
  47812. }
  47813. // Address returns the value of the "address" field in the mutation.
  47814. func (m *WxCardMutation) Address() (r string, exists bool) {
  47815. v := m.address
  47816. if v == nil {
  47817. return
  47818. }
  47819. return *v, true
  47820. }
  47821. // OldAddress returns the old "address" field's value of the WxCard entity.
  47822. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47824. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  47825. if !m.op.Is(OpUpdateOne) {
  47826. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  47827. }
  47828. if m.id == nil || m.oldValue == nil {
  47829. return v, errors.New("OldAddress requires an ID field in the mutation")
  47830. }
  47831. oldValue, err := m.oldValue(ctx)
  47832. if err != nil {
  47833. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  47834. }
  47835. return oldValue.Address, nil
  47836. }
  47837. // ResetAddress resets all changes to the "address" field.
  47838. func (m *WxCardMutation) ResetAddress() {
  47839. m.address = nil
  47840. }
  47841. // SetPhone sets the "phone" field.
  47842. func (m *WxCardMutation) SetPhone(s string) {
  47843. m.phone = &s
  47844. }
  47845. // Phone returns the value of the "phone" field in the mutation.
  47846. func (m *WxCardMutation) Phone() (r string, exists bool) {
  47847. v := m.phone
  47848. if v == nil {
  47849. return
  47850. }
  47851. return *v, true
  47852. }
  47853. // OldPhone returns the old "phone" field's value of the WxCard entity.
  47854. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47856. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  47857. if !m.op.Is(OpUpdateOne) {
  47858. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  47859. }
  47860. if m.id == nil || m.oldValue == nil {
  47861. return v, errors.New("OldPhone requires an ID field in the mutation")
  47862. }
  47863. oldValue, err := m.oldValue(ctx)
  47864. if err != nil {
  47865. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  47866. }
  47867. return oldValue.Phone, nil
  47868. }
  47869. // ResetPhone resets all changes to the "phone" field.
  47870. func (m *WxCardMutation) ResetPhone() {
  47871. m.phone = nil
  47872. }
  47873. // SetOfficialAccount sets the "official_account" field.
  47874. func (m *WxCardMutation) SetOfficialAccount(s string) {
  47875. m.official_account = &s
  47876. }
  47877. // OfficialAccount returns the value of the "official_account" field in the mutation.
  47878. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  47879. v := m.official_account
  47880. if v == nil {
  47881. return
  47882. }
  47883. return *v, true
  47884. }
  47885. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  47886. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47888. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  47889. if !m.op.Is(OpUpdateOne) {
  47890. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  47891. }
  47892. if m.id == nil || m.oldValue == nil {
  47893. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  47894. }
  47895. oldValue, err := m.oldValue(ctx)
  47896. if err != nil {
  47897. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  47898. }
  47899. return oldValue.OfficialAccount, nil
  47900. }
  47901. // ResetOfficialAccount resets all changes to the "official_account" field.
  47902. func (m *WxCardMutation) ResetOfficialAccount() {
  47903. m.official_account = nil
  47904. }
  47905. // SetWechatAccount sets the "wechat_account" field.
  47906. func (m *WxCardMutation) SetWechatAccount(s string) {
  47907. m.wechat_account = &s
  47908. }
  47909. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  47910. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  47911. v := m.wechat_account
  47912. if v == nil {
  47913. return
  47914. }
  47915. return *v, true
  47916. }
  47917. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  47918. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47920. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  47921. if !m.op.Is(OpUpdateOne) {
  47922. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  47923. }
  47924. if m.id == nil || m.oldValue == nil {
  47925. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  47926. }
  47927. oldValue, err := m.oldValue(ctx)
  47928. if err != nil {
  47929. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  47930. }
  47931. return oldValue.WechatAccount, nil
  47932. }
  47933. // ResetWechatAccount resets all changes to the "wechat_account" field.
  47934. func (m *WxCardMutation) ResetWechatAccount() {
  47935. m.wechat_account = nil
  47936. }
  47937. // SetEmail sets the "email" field.
  47938. func (m *WxCardMutation) SetEmail(s string) {
  47939. m.email = &s
  47940. }
  47941. // Email returns the value of the "email" field in the mutation.
  47942. func (m *WxCardMutation) Email() (r string, exists bool) {
  47943. v := m.email
  47944. if v == nil {
  47945. return
  47946. }
  47947. return *v, true
  47948. }
  47949. // OldEmail returns the old "email" field's value of the WxCard entity.
  47950. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47952. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  47953. if !m.op.Is(OpUpdateOne) {
  47954. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  47955. }
  47956. if m.id == nil || m.oldValue == nil {
  47957. return v, errors.New("OldEmail requires an ID field in the mutation")
  47958. }
  47959. oldValue, err := m.oldValue(ctx)
  47960. if err != nil {
  47961. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  47962. }
  47963. return oldValue.Email, nil
  47964. }
  47965. // ClearEmail clears the value of the "email" field.
  47966. func (m *WxCardMutation) ClearEmail() {
  47967. m.email = nil
  47968. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  47969. }
  47970. // EmailCleared returns if the "email" field was cleared in this mutation.
  47971. func (m *WxCardMutation) EmailCleared() bool {
  47972. _, ok := m.clearedFields[wxcard.FieldEmail]
  47973. return ok
  47974. }
  47975. // ResetEmail resets all changes to the "email" field.
  47976. func (m *WxCardMutation) ResetEmail() {
  47977. m.email = nil
  47978. delete(m.clearedFields, wxcard.FieldEmail)
  47979. }
  47980. // SetAPIBase sets the "api_base" field.
  47981. func (m *WxCardMutation) SetAPIBase(s string) {
  47982. m.api_base = &s
  47983. }
  47984. // APIBase returns the value of the "api_base" field in the mutation.
  47985. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  47986. v := m.api_base
  47987. if v == nil {
  47988. return
  47989. }
  47990. return *v, true
  47991. }
  47992. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  47993. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47995. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  47996. if !m.op.Is(OpUpdateOne) {
  47997. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  47998. }
  47999. if m.id == nil || m.oldValue == nil {
  48000. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  48001. }
  48002. oldValue, err := m.oldValue(ctx)
  48003. if err != nil {
  48004. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  48005. }
  48006. return oldValue.APIBase, nil
  48007. }
  48008. // ClearAPIBase clears the value of the "api_base" field.
  48009. func (m *WxCardMutation) ClearAPIBase() {
  48010. m.api_base = nil
  48011. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  48012. }
  48013. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  48014. func (m *WxCardMutation) APIBaseCleared() bool {
  48015. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  48016. return ok
  48017. }
  48018. // ResetAPIBase resets all changes to the "api_base" field.
  48019. func (m *WxCardMutation) ResetAPIBase() {
  48020. m.api_base = nil
  48021. delete(m.clearedFields, wxcard.FieldAPIBase)
  48022. }
  48023. // SetAPIKey sets the "api_key" field.
  48024. func (m *WxCardMutation) SetAPIKey(s string) {
  48025. m.api_key = &s
  48026. }
  48027. // APIKey returns the value of the "api_key" field in the mutation.
  48028. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  48029. v := m.api_key
  48030. if v == nil {
  48031. return
  48032. }
  48033. return *v, true
  48034. }
  48035. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  48036. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48038. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  48039. if !m.op.Is(OpUpdateOne) {
  48040. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  48041. }
  48042. if m.id == nil || m.oldValue == nil {
  48043. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  48044. }
  48045. oldValue, err := m.oldValue(ctx)
  48046. if err != nil {
  48047. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  48048. }
  48049. return oldValue.APIKey, nil
  48050. }
  48051. // ClearAPIKey clears the value of the "api_key" field.
  48052. func (m *WxCardMutation) ClearAPIKey() {
  48053. m.api_key = nil
  48054. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  48055. }
  48056. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  48057. func (m *WxCardMutation) APIKeyCleared() bool {
  48058. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  48059. return ok
  48060. }
  48061. // ResetAPIKey resets all changes to the "api_key" field.
  48062. func (m *WxCardMutation) ResetAPIKey() {
  48063. m.api_key = nil
  48064. delete(m.clearedFields, wxcard.FieldAPIKey)
  48065. }
  48066. // SetAiInfo sets the "ai_info" field.
  48067. func (m *WxCardMutation) SetAiInfo(s string) {
  48068. m.ai_info = &s
  48069. }
  48070. // AiInfo returns the value of the "ai_info" field in the mutation.
  48071. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  48072. v := m.ai_info
  48073. if v == nil {
  48074. return
  48075. }
  48076. return *v, true
  48077. }
  48078. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  48079. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48081. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  48082. if !m.op.Is(OpUpdateOne) {
  48083. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  48084. }
  48085. if m.id == nil || m.oldValue == nil {
  48086. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  48087. }
  48088. oldValue, err := m.oldValue(ctx)
  48089. if err != nil {
  48090. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  48091. }
  48092. return oldValue.AiInfo, nil
  48093. }
  48094. // ClearAiInfo clears the value of the "ai_info" field.
  48095. func (m *WxCardMutation) ClearAiInfo() {
  48096. m.ai_info = nil
  48097. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  48098. }
  48099. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  48100. func (m *WxCardMutation) AiInfoCleared() bool {
  48101. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  48102. return ok
  48103. }
  48104. // ResetAiInfo resets all changes to the "ai_info" field.
  48105. func (m *WxCardMutation) ResetAiInfo() {
  48106. m.ai_info = nil
  48107. delete(m.clearedFields, wxcard.FieldAiInfo)
  48108. }
  48109. // SetIntro sets the "intro" field.
  48110. func (m *WxCardMutation) SetIntro(s string) {
  48111. m.intro = &s
  48112. }
  48113. // Intro returns the value of the "intro" field in the mutation.
  48114. func (m *WxCardMutation) Intro() (r string, exists bool) {
  48115. v := m.intro
  48116. if v == nil {
  48117. return
  48118. }
  48119. return *v, true
  48120. }
  48121. // OldIntro returns the old "intro" field's value of the WxCard entity.
  48122. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48124. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  48125. if !m.op.Is(OpUpdateOne) {
  48126. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  48127. }
  48128. if m.id == nil || m.oldValue == nil {
  48129. return v, errors.New("OldIntro requires an ID field in the mutation")
  48130. }
  48131. oldValue, err := m.oldValue(ctx)
  48132. if err != nil {
  48133. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  48134. }
  48135. return oldValue.Intro, nil
  48136. }
  48137. // ClearIntro clears the value of the "intro" field.
  48138. func (m *WxCardMutation) ClearIntro() {
  48139. m.intro = nil
  48140. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  48141. }
  48142. // IntroCleared returns if the "intro" field was cleared in this mutation.
  48143. func (m *WxCardMutation) IntroCleared() bool {
  48144. _, ok := m.clearedFields[wxcard.FieldIntro]
  48145. return ok
  48146. }
  48147. // ResetIntro resets all changes to the "intro" field.
  48148. func (m *WxCardMutation) ResetIntro() {
  48149. m.intro = nil
  48150. delete(m.clearedFields, wxcard.FieldIntro)
  48151. }
  48152. // Where appends a list predicates to the WxCardMutation builder.
  48153. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  48154. m.predicates = append(m.predicates, ps...)
  48155. }
  48156. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  48157. // users can use type-assertion to append predicates that do not depend on any generated package.
  48158. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  48159. p := make([]predicate.WxCard, len(ps))
  48160. for i := range ps {
  48161. p[i] = ps[i]
  48162. }
  48163. m.Where(p...)
  48164. }
  48165. // Op returns the operation name.
  48166. func (m *WxCardMutation) Op() Op {
  48167. return m.op
  48168. }
  48169. // SetOp allows setting the mutation operation.
  48170. func (m *WxCardMutation) SetOp(op Op) {
  48171. m.op = op
  48172. }
  48173. // Type returns the node type of this mutation (WxCard).
  48174. func (m *WxCardMutation) Type() string {
  48175. return m.typ
  48176. }
  48177. // Fields returns all fields that were changed during this mutation. Note that in
  48178. // order to get all numeric fields that were incremented/decremented, call
  48179. // AddedFields().
  48180. func (m *WxCardMutation) Fields() []string {
  48181. fields := make([]string, 0, 18)
  48182. if m.created_at != nil {
  48183. fields = append(fields, wxcard.FieldCreatedAt)
  48184. }
  48185. if m.updated_at != nil {
  48186. fields = append(fields, wxcard.FieldUpdatedAt)
  48187. }
  48188. if m.deleted_at != nil {
  48189. fields = append(fields, wxcard.FieldDeletedAt)
  48190. }
  48191. if m.user_id != nil {
  48192. fields = append(fields, wxcard.FieldUserID)
  48193. }
  48194. if m.wx_user_id != nil {
  48195. fields = append(fields, wxcard.FieldWxUserID)
  48196. }
  48197. if m.avatar != nil {
  48198. fields = append(fields, wxcard.FieldAvatar)
  48199. }
  48200. if m.logo != nil {
  48201. fields = append(fields, wxcard.FieldLogo)
  48202. }
  48203. if m.name != nil {
  48204. fields = append(fields, wxcard.FieldName)
  48205. }
  48206. if m.company != nil {
  48207. fields = append(fields, wxcard.FieldCompany)
  48208. }
  48209. if m.address != nil {
  48210. fields = append(fields, wxcard.FieldAddress)
  48211. }
  48212. if m.phone != nil {
  48213. fields = append(fields, wxcard.FieldPhone)
  48214. }
  48215. if m.official_account != nil {
  48216. fields = append(fields, wxcard.FieldOfficialAccount)
  48217. }
  48218. if m.wechat_account != nil {
  48219. fields = append(fields, wxcard.FieldWechatAccount)
  48220. }
  48221. if m.email != nil {
  48222. fields = append(fields, wxcard.FieldEmail)
  48223. }
  48224. if m.api_base != nil {
  48225. fields = append(fields, wxcard.FieldAPIBase)
  48226. }
  48227. if m.api_key != nil {
  48228. fields = append(fields, wxcard.FieldAPIKey)
  48229. }
  48230. if m.ai_info != nil {
  48231. fields = append(fields, wxcard.FieldAiInfo)
  48232. }
  48233. if m.intro != nil {
  48234. fields = append(fields, wxcard.FieldIntro)
  48235. }
  48236. return fields
  48237. }
  48238. // Field returns the value of a field with the given name. The second boolean
  48239. // return value indicates that this field was not set, or was not defined in the
  48240. // schema.
  48241. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  48242. switch name {
  48243. case wxcard.FieldCreatedAt:
  48244. return m.CreatedAt()
  48245. case wxcard.FieldUpdatedAt:
  48246. return m.UpdatedAt()
  48247. case wxcard.FieldDeletedAt:
  48248. return m.DeletedAt()
  48249. case wxcard.FieldUserID:
  48250. return m.UserID()
  48251. case wxcard.FieldWxUserID:
  48252. return m.WxUserID()
  48253. case wxcard.FieldAvatar:
  48254. return m.Avatar()
  48255. case wxcard.FieldLogo:
  48256. return m.Logo()
  48257. case wxcard.FieldName:
  48258. return m.Name()
  48259. case wxcard.FieldCompany:
  48260. return m.Company()
  48261. case wxcard.FieldAddress:
  48262. return m.Address()
  48263. case wxcard.FieldPhone:
  48264. return m.Phone()
  48265. case wxcard.FieldOfficialAccount:
  48266. return m.OfficialAccount()
  48267. case wxcard.FieldWechatAccount:
  48268. return m.WechatAccount()
  48269. case wxcard.FieldEmail:
  48270. return m.Email()
  48271. case wxcard.FieldAPIBase:
  48272. return m.APIBase()
  48273. case wxcard.FieldAPIKey:
  48274. return m.APIKey()
  48275. case wxcard.FieldAiInfo:
  48276. return m.AiInfo()
  48277. case wxcard.FieldIntro:
  48278. return m.Intro()
  48279. }
  48280. return nil, false
  48281. }
  48282. // OldField returns the old value of the field from the database. An error is
  48283. // returned if the mutation operation is not UpdateOne, or the query to the
  48284. // database failed.
  48285. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48286. switch name {
  48287. case wxcard.FieldCreatedAt:
  48288. return m.OldCreatedAt(ctx)
  48289. case wxcard.FieldUpdatedAt:
  48290. return m.OldUpdatedAt(ctx)
  48291. case wxcard.FieldDeletedAt:
  48292. return m.OldDeletedAt(ctx)
  48293. case wxcard.FieldUserID:
  48294. return m.OldUserID(ctx)
  48295. case wxcard.FieldWxUserID:
  48296. return m.OldWxUserID(ctx)
  48297. case wxcard.FieldAvatar:
  48298. return m.OldAvatar(ctx)
  48299. case wxcard.FieldLogo:
  48300. return m.OldLogo(ctx)
  48301. case wxcard.FieldName:
  48302. return m.OldName(ctx)
  48303. case wxcard.FieldCompany:
  48304. return m.OldCompany(ctx)
  48305. case wxcard.FieldAddress:
  48306. return m.OldAddress(ctx)
  48307. case wxcard.FieldPhone:
  48308. return m.OldPhone(ctx)
  48309. case wxcard.FieldOfficialAccount:
  48310. return m.OldOfficialAccount(ctx)
  48311. case wxcard.FieldWechatAccount:
  48312. return m.OldWechatAccount(ctx)
  48313. case wxcard.FieldEmail:
  48314. return m.OldEmail(ctx)
  48315. case wxcard.FieldAPIBase:
  48316. return m.OldAPIBase(ctx)
  48317. case wxcard.FieldAPIKey:
  48318. return m.OldAPIKey(ctx)
  48319. case wxcard.FieldAiInfo:
  48320. return m.OldAiInfo(ctx)
  48321. case wxcard.FieldIntro:
  48322. return m.OldIntro(ctx)
  48323. }
  48324. return nil, fmt.Errorf("unknown WxCard field %s", name)
  48325. }
  48326. // SetField sets the value of a field with the given name. It returns an error if
  48327. // the field is not defined in the schema, or if the type mismatched the field
  48328. // type.
  48329. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  48330. switch name {
  48331. case wxcard.FieldCreatedAt:
  48332. v, ok := value.(time.Time)
  48333. if !ok {
  48334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48335. }
  48336. m.SetCreatedAt(v)
  48337. return nil
  48338. case wxcard.FieldUpdatedAt:
  48339. v, ok := value.(time.Time)
  48340. if !ok {
  48341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48342. }
  48343. m.SetUpdatedAt(v)
  48344. return nil
  48345. case wxcard.FieldDeletedAt:
  48346. v, ok := value.(time.Time)
  48347. if !ok {
  48348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48349. }
  48350. m.SetDeletedAt(v)
  48351. return nil
  48352. case wxcard.FieldUserID:
  48353. v, ok := value.(uint64)
  48354. if !ok {
  48355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48356. }
  48357. m.SetUserID(v)
  48358. return nil
  48359. case wxcard.FieldWxUserID:
  48360. v, ok := value.(uint64)
  48361. if !ok {
  48362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48363. }
  48364. m.SetWxUserID(v)
  48365. return nil
  48366. case wxcard.FieldAvatar:
  48367. v, ok := value.(string)
  48368. if !ok {
  48369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48370. }
  48371. m.SetAvatar(v)
  48372. return nil
  48373. case wxcard.FieldLogo:
  48374. v, ok := value.(string)
  48375. if !ok {
  48376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48377. }
  48378. m.SetLogo(v)
  48379. return nil
  48380. case wxcard.FieldName:
  48381. v, ok := value.(string)
  48382. if !ok {
  48383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48384. }
  48385. m.SetName(v)
  48386. return nil
  48387. case wxcard.FieldCompany:
  48388. v, ok := value.(string)
  48389. if !ok {
  48390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48391. }
  48392. m.SetCompany(v)
  48393. return nil
  48394. case wxcard.FieldAddress:
  48395. v, ok := value.(string)
  48396. if !ok {
  48397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48398. }
  48399. m.SetAddress(v)
  48400. return nil
  48401. case wxcard.FieldPhone:
  48402. v, ok := value.(string)
  48403. if !ok {
  48404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48405. }
  48406. m.SetPhone(v)
  48407. return nil
  48408. case wxcard.FieldOfficialAccount:
  48409. v, ok := value.(string)
  48410. if !ok {
  48411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48412. }
  48413. m.SetOfficialAccount(v)
  48414. return nil
  48415. case wxcard.FieldWechatAccount:
  48416. v, ok := value.(string)
  48417. if !ok {
  48418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48419. }
  48420. m.SetWechatAccount(v)
  48421. return nil
  48422. case wxcard.FieldEmail:
  48423. v, ok := value.(string)
  48424. if !ok {
  48425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48426. }
  48427. m.SetEmail(v)
  48428. return nil
  48429. case wxcard.FieldAPIBase:
  48430. v, ok := value.(string)
  48431. if !ok {
  48432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48433. }
  48434. m.SetAPIBase(v)
  48435. return nil
  48436. case wxcard.FieldAPIKey:
  48437. v, ok := value.(string)
  48438. if !ok {
  48439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48440. }
  48441. m.SetAPIKey(v)
  48442. return nil
  48443. case wxcard.FieldAiInfo:
  48444. v, ok := value.(string)
  48445. if !ok {
  48446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48447. }
  48448. m.SetAiInfo(v)
  48449. return nil
  48450. case wxcard.FieldIntro:
  48451. v, ok := value.(string)
  48452. if !ok {
  48453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48454. }
  48455. m.SetIntro(v)
  48456. return nil
  48457. }
  48458. return fmt.Errorf("unknown WxCard field %s", name)
  48459. }
  48460. // AddedFields returns all numeric fields that were incremented/decremented during
  48461. // this mutation.
  48462. func (m *WxCardMutation) AddedFields() []string {
  48463. var fields []string
  48464. if m.adduser_id != nil {
  48465. fields = append(fields, wxcard.FieldUserID)
  48466. }
  48467. if m.addwx_user_id != nil {
  48468. fields = append(fields, wxcard.FieldWxUserID)
  48469. }
  48470. return fields
  48471. }
  48472. // AddedField returns the numeric value that was incremented/decremented on a field
  48473. // with the given name. The second boolean return value indicates that this field
  48474. // was not set, or was not defined in the schema.
  48475. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  48476. switch name {
  48477. case wxcard.FieldUserID:
  48478. return m.AddedUserID()
  48479. case wxcard.FieldWxUserID:
  48480. return m.AddedWxUserID()
  48481. }
  48482. return nil, false
  48483. }
  48484. // AddField adds the value to the field with the given name. It returns an error if
  48485. // the field is not defined in the schema, or if the type mismatched the field
  48486. // type.
  48487. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  48488. switch name {
  48489. case wxcard.FieldUserID:
  48490. v, ok := value.(int64)
  48491. if !ok {
  48492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48493. }
  48494. m.AddUserID(v)
  48495. return nil
  48496. case wxcard.FieldWxUserID:
  48497. v, ok := value.(int64)
  48498. if !ok {
  48499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48500. }
  48501. m.AddWxUserID(v)
  48502. return nil
  48503. }
  48504. return fmt.Errorf("unknown WxCard numeric field %s", name)
  48505. }
  48506. // ClearedFields returns all nullable fields that were cleared during this
  48507. // mutation.
  48508. func (m *WxCardMutation) ClearedFields() []string {
  48509. var fields []string
  48510. if m.FieldCleared(wxcard.FieldDeletedAt) {
  48511. fields = append(fields, wxcard.FieldDeletedAt)
  48512. }
  48513. if m.FieldCleared(wxcard.FieldUserID) {
  48514. fields = append(fields, wxcard.FieldUserID)
  48515. }
  48516. if m.FieldCleared(wxcard.FieldWxUserID) {
  48517. fields = append(fields, wxcard.FieldWxUserID)
  48518. }
  48519. if m.FieldCleared(wxcard.FieldEmail) {
  48520. fields = append(fields, wxcard.FieldEmail)
  48521. }
  48522. if m.FieldCleared(wxcard.FieldAPIBase) {
  48523. fields = append(fields, wxcard.FieldAPIBase)
  48524. }
  48525. if m.FieldCleared(wxcard.FieldAPIKey) {
  48526. fields = append(fields, wxcard.FieldAPIKey)
  48527. }
  48528. if m.FieldCleared(wxcard.FieldAiInfo) {
  48529. fields = append(fields, wxcard.FieldAiInfo)
  48530. }
  48531. if m.FieldCleared(wxcard.FieldIntro) {
  48532. fields = append(fields, wxcard.FieldIntro)
  48533. }
  48534. return fields
  48535. }
  48536. // FieldCleared returns a boolean indicating if a field with the given name was
  48537. // cleared in this mutation.
  48538. func (m *WxCardMutation) FieldCleared(name string) bool {
  48539. _, ok := m.clearedFields[name]
  48540. return ok
  48541. }
  48542. // ClearField clears the value of the field with the given name. It returns an
  48543. // error if the field is not defined in the schema.
  48544. func (m *WxCardMutation) ClearField(name string) error {
  48545. switch name {
  48546. case wxcard.FieldDeletedAt:
  48547. m.ClearDeletedAt()
  48548. return nil
  48549. case wxcard.FieldUserID:
  48550. m.ClearUserID()
  48551. return nil
  48552. case wxcard.FieldWxUserID:
  48553. m.ClearWxUserID()
  48554. return nil
  48555. case wxcard.FieldEmail:
  48556. m.ClearEmail()
  48557. return nil
  48558. case wxcard.FieldAPIBase:
  48559. m.ClearAPIBase()
  48560. return nil
  48561. case wxcard.FieldAPIKey:
  48562. m.ClearAPIKey()
  48563. return nil
  48564. case wxcard.FieldAiInfo:
  48565. m.ClearAiInfo()
  48566. return nil
  48567. case wxcard.FieldIntro:
  48568. m.ClearIntro()
  48569. return nil
  48570. }
  48571. return fmt.Errorf("unknown WxCard nullable field %s", name)
  48572. }
  48573. // ResetField resets all changes in the mutation for the field with the given name.
  48574. // It returns an error if the field is not defined in the schema.
  48575. func (m *WxCardMutation) ResetField(name string) error {
  48576. switch name {
  48577. case wxcard.FieldCreatedAt:
  48578. m.ResetCreatedAt()
  48579. return nil
  48580. case wxcard.FieldUpdatedAt:
  48581. m.ResetUpdatedAt()
  48582. return nil
  48583. case wxcard.FieldDeletedAt:
  48584. m.ResetDeletedAt()
  48585. return nil
  48586. case wxcard.FieldUserID:
  48587. m.ResetUserID()
  48588. return nil
  48589. case wxcard.FieldWxUserID:
  48590. m.ResetWxUserID()
  48591. return nil
  48592. case wxcard.FieldAvatar:
  48593. m.ResetAvatar()
  48594. return nil
  48595. case wxcard.FieldLogo:
  48596. m.ResetLogo()
  48597. return nil
  48598. case wxcard.FieldName:
  48599. m.ResetName()
  48600. return nil
  48601. case wxcard.FieldCompany:
  48602. m.ResetCompany()
  48603. return nil
  48604. case wxcard.FieldAddress:
  48605. m.ResetAddress()
  48606. return nil
  48607. case wxcard.FieldPhone:
  48608. m.ResetPhone()
  48609. return nil
  48610. case wxcard.FieldOfficialAccount:
  48611. m.ResetOfficialAccount()
  48612. return nil
  48613. case wxcard.FieldWechatAccount:
  48614. m.ResetWechatAccount()
  48615. return nil
  48616. case wxcard.FieldEmail:
  48617. m.ResetEmail()
  48618. return nil
  48619. case wxcard.FieldAPIBase:
  48620. m.ResetAPIBase()
  48621. return nil
  48622. case wxcard.FieldAPIKey:
  48623. m.ResetAPIKey()
  48624. return nil
  48625. case wxcard.FieldAiInfo:
  48626. m.ResetAiInfo()
  48627. return nil
  48628. case wxcard.FieldIntro:
  48629. m.ResetIntro()
  48630. return nil
  48631. }
  48632. return fmt.Errorf("unknown WxCard field %s", name)
  48633. }
  48634. // AddedEdges returns all edge names that were set/added in this mutation.
  48635. func (m *WxCardMutation) AddedEdges() []string {
  48636. edges := make([]string, 0, 0)
  48637. return edges
  48638. }
  48639. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48640. // name in this mutation.
  48641. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  48642. return nil
  48643. }
  48644. // RemovedEdges returns all edge names that were removed in this mutation.
  48645. func (m *WxCardMutation) RemovedEdges() []string {
  48646. edges := make([]string, 0, 0)
  48647. return edges
  48648. }
  48649. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48650. // the given name in this mutation.
  48651. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  48652. return nil
  48653. }
  48654. // ClearedEdges returns all edge names that were cleared in this mutation.
  48655. func (m *WxCardMutation) ClearedEdges() []string {
  48656. edges := make([]string, 0, 0)
  48657. return edges
  48658. }
  48659. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48660. // was cleared in this mutation.
  48661. func (m *WxCardMutation) EdgeCleared(name string) bool {
  48662. return false
  48663. }
  48664. // ClearEdge clears the value of the edge with the given name. It returns an error
  48665. // if that edge is not defined in the schema.
  48666. func (m *WxCardMutation) ClearEdge(name string) error {
  48667. return fmt.Errorf("unknown WxCard unique edge %s", name)
  48668. }
  48669. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48670. // It returns an error if the edge is not defined in the schema.
  48671. func (m *WxCardMutation) ResetEdge(name string) error {
  48672. return fmt.Errorf("unknown WxCard edge %s", name)
  48673. }
  48674. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  48675. type WxCardUserMutation struct {
  48676. config
  48677. op Op
  48678. typ string
  48679. id *uint64
  48680. created_at *time.Time
  48681. updated_at *time.Time
  48682. deleted_at *time.Time
  48683. wxid *string
  48684. account *string
  48685. avatar *string
  48686. nickname *string
  48687. remark *string
  48688. phone *string
  48689. open_id *string
  48690. union_id *string
  48691. session_key *string
  48692. is_vip *int
  48693. addis_vip *int
  48694. clearedFields map[string]struct{}
  48695. done bool
  48696. oldValue func(context.Context) (*WxCardUser, error)
  48697. predicates []predicate.WxCardUser
  48698. }
  48699. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  48700. // wxcarduserOption allows management of the mutation configuration using functional options.
  48701. type wxcarduserOption func(*WxCardUserMutation)
  48702. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  48703. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  48704. m := &WxCardUserMutation{
  48705. config: c,
  48706. op: op,
  48707. typ: TypeWxCardUser,
  48708. clearedFields: make(map[string]struct{}),
  48709. }
  48710. for _, opt := range opts {
  48711. opt(m)
  48712. }
  48713. return m
  48714. }
  48715. // withWxCardUserID sets the ID field of the mutation.
  48716. func withWxCardUserID(id uint64) wxcarduserOption {
  48717. return func(m *WxCardUserMutation) {
  48718. var (
  48719. err error
  48720. once sync.Once
  48721. value *WxCardUser
  48722. )
  48723. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  48724. once.Do(func() {
  48725. if m.done {
  48726. err = errors.New("querying old values post mutation is not allowed")
  48727. } else {
  48728. value, err = m.Client().WxCardUser.Get(ctx, id)
  48729. }
  48730. })
  48731. return value, err
  48732. }
  48733. m.id = &id
  48734. }
  48735. }
  48736. // withWxCardUser sets the old WxCardUser of the mutation.
  48737. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  48738. return func(m *WxCardUserMutation) {
  48739. m.oldValue = func(context.Context) (*WxCardUser, error) {
  48740. return node, nil
  48741. }
  48742. m.id = &node.ID
  48743. }
  48744. }
  48745. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48746. // executed in a transaction (ent.Tx), a transactional client is returned.
  48747. func (m WxCardUserMutation) Client() *Client {
  48748. client := &Client{config: m.config}
  48749. client.init()
  48750. return client
  48751. }
  48752. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48753. // it returns an error otherwise.
  48754. func (m WxCardUserMutation) Tx() (*Tx, error) {
  48755. if _, ok := m.driver.(*txDriver); !ok {
  48756. return nil, errors.New("ent: mutation is not running in a transaction")
  48757. }
  48758. tx := &Tx{config: m.config}
  48759. tx.init()
  48760. return tx, nil
  48761. }
  48762. // SetID sets the value of the id field. Note that this
  48763. // operation is only accepted on creation of WxCardUser entities.
  48764. func (m *WxCardUserMutation) SetID(id uint64) {
  48765. m.id = &id
  48766. }
  48767. // ID returns the ID value in the mutation. Note that the ID is only available
  48768. // if it was provided to the builder or after it was returned from the database.
  48769. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  48770. if m.id == nil {
  48771. return
  48772. }
  48773. return *m.id, true
  48774. }
  48775. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48776. // That means, if the mutation is applied within a transaction with an isolation level such
  48777. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48778. // or updated by the mutation.
  48779. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  48780. switch {
  48781. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48782. id, exists := m.ID()
  48783. if exists {
  48784. return []uint64{id}, nil
  48785. }
  48786. fallthrough
  48787. case m.op.Is(OpUpdate | OpDelete):
  48788. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  48789. default:
  48790. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48791. }
  48792. }
  48793. // SetCreatedAt sets the "created_at" field.
  48794. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  48795. m.created_at = &t
  48796. }
  48797. // CreatedAt returns the value of the "created_at" field in the mutation.
  48798. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  48799. v := m.created_at
  48800. if v == nil {
  48801. return
  48802. }
  48803. return *v, true
  48804. }
  48805. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  48806. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48808. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48809. if !m.op.Is(OpUpdateOne) {
  48810. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48811. }
  48812. if m.id == nil || m.oldValue == nil {
  48813. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48814. }
  48815. oldValue, err := m.oldValue(ctx)
  48816. if err != nil {
  48817. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48818. }
  48819. return oldValue.CreatedAt, nil
  48820. }
  48821. // ResetCreatedAt resets all changes to the "created_at" field.
  48822. func (m *WxCardUserMutation) ResetCreatedAt() {
  48823. m.created_at = nil
  48824. }
  48825. // SetUpdatedAt sets the "updated_at" field.
  48826. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  48827. m.updated_at = &t
  48828. }
  48829. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48830. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  48831. v := m.updated_at
  48832. if v == nil {
  48833. return
  48834. }
  48835. return *v, true
  48836. }
  48837. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  48838. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48840. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48841. if !m.op.Is(OpUpdateOne) {
  48842. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48843. }
  48844. if m.id == nil || m.oldValue == nil {
  48845. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48846. }
  48847. oldValue, err := m.oldValue(ctx)
  48848. if err != nil {
  48849. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48850. }
  48851. return oldValue.UpdatedAt, nil
  48852. }
  48853. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48854. func (m *WxCardUserMutation) ResetUpdatedAt() {
  48855. m.updated_at = nil
  48856. }
  48857. // SetDeletedAt sets the "deleted_at" field.
  48858. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  48859. m.deleted_at = &t
  48860. }
  48861. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48862. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  48863. v := m.deleted_at
  48864. if v == nil {
  48865. return
  48866. }
  48867. return *v, true
  48868. }
  48869. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  48870. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48872. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48873. if !m.op.Is(OpUpdateOne) {
  48874. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48875. }
  48876. if m.id == nil || m.oldValue == nil {
  48877. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48878. }
  48879. oldValue, err := m.oldValue(ctx)
  48880. if err != nil {
  48881. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48882. }
  48883. return oldValue.DeletedAt, nil
  48884. }
  48885. // ClearDeletedAt clears the value of the "deleted_at" field.
  48886. func (m *WxCardUserMutation) ClearDeletedAt() {
  48887. m.deleted_at = nil
  48888. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  48889. }
  48890. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48891. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  48892. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  48893. return ok
  48894. }
  48895. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48896. func (m *WxCardUserMutation) ResetDeletedAt() {
  48897. m.deleted_at = nil
  48898. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  48899. }
  48900. // SetWxid sets the "wxid" field.
  48901. func (m *WxCardUserMutation) SetWxid(s string) {
  48902. m.wxid = &s
  48903. }
  48904. // Wxid returns the value of the "wxid" field in the mutation.
  48905. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  48906. v := m.wxid
  48907. if v == nil {
  48908. return
  48909. }
  48910. return *v, true
  48911. }
  48912. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  48913. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48915. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  48916. if !m.op.Is(OpUpdateOne) {
  48917. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  48918. }
  48919. if m.id == nil || m.oldValue == nil {
  48920. return v, errors.New("OldWxid requires an ID field in the mutation")
  48921. }
  48922. oldValue, err := m.oldValue(ctx)
  48923. if err != nil {
  48924. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  48925. }
  48926. return oldValue.Wxid, nil
  48927. }
  48928. // ResetWxid resets all changes to the "wxid" field.
  48929. func (m *WxCardUserMutation) ResetWxid() {
  48930. m.wxid = nil
  48931. }
  48932. // SetAccount sets the "account" field.
  48933. func (m *WxCardUserMutation) SetAccount(s string) {
  48934. m.account = &s
  48935. }
  48936. // Account returns the value of the "account" field in the mutation.
  48937. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  48938. v := m.account
  48939. if v == nil {
  48940. return
  48941. }
  48942. return *v, true
  48943. }
  48944. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  48945. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48947. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  48948. if !m.op.Is(OpUpdateOne) {
  48949. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  48950. }
  48951. if m.id == nil || m.oldValue == nil {
  48952. return v, errors.New("OldAccount requires an ID field in the mutation")
  48953. }
  48954. oldValue, err := m.oldValue(ctx)
  48955. if err != nil {
  48956. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  48957. }
  48958. return oldValue.Account, nil
  48959. }
  48960. // ResetAccount resets all changes to the "account" field.
  48961. func (m *WxCardUserMutation) ResetAccount() {
  48962. m.account = nil
  48963. }
  48964. // SetAvatar sets the "avatar" field.
  48965. func (m *WxCardUserMutation) SetAvatar(s string) {
  48966. m.avatar = &s
  48967. }
  48968. // Avatar returns the value of the "avatar" field in the mutation.
  48969. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  48970. v := m.avatar
  48971. if v == nil {
  48972. return
  48973. }
  48974. return *v, true
  48975. }
  48976. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  48977. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48979. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  48980. if !m.op.Is(OpUpdateOne) {
  48981. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  48982. }
  48983. if m.id == nil || m.oldValue == nil {
  48984. return v, errors.New("OldAvatar requires an ID field in the mutation")
  48985. }
  48986. oldValue, err := m.oldValue(ctx)
  48987. if err != nil {
  48988. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  48989. }
  48990. return oldValue.Avatar, nil
  48991. }
  48992. // ResetAvatar resets all changes to the "avatar" field.
  48993. func (m *WxCardUserMutation) ResetAvatar() {
  48994. m.avatar = nil
  48995. }
  48996. // SetNickname sets the "nickname" field.
  48997. func (m *WxCardUserMutation) SetNickname(s string) {
  48998. m.nickname = &s
  48999. }
  49000. // Nickname returns the value of the "nickname" field in the mutation.
  49001. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  49002. v := m.nickname
  49003. if v == nil {
  49004. return
  49005. }
  49006. return *v, true
  49007. }
  49008. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  49009. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49011. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  49012. if !m.op.Is(OpUpdateOne) {
  49013. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  49014. }
  49015. if m.id == nil || m.oldValue == nil {
  49016. return v, errors.New("OldNickname requires an ID field in the mutation")
  49017. }
  49018. oldValue, err := m.oldValue(ctx)
  49019. if err != nil {
  49020. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  49021. }
  49022. return oldValue.Nickname, nil
  49023. }
  49024. // ResetNickname resets all changes to the "nickname" field.
  49025. func (m *WxCardUserMutation) ResetNickname() {
  49026. m.nickname = nil
  49027. }
  49028. // SetRemark sets the "remark" field.
  49029. func (m *WxCardUserMutation) SetRemark(s string) {
  49030. m.remark = &s
  49031. }
  49032. // Remark returns the value of the "remark" field in the mutation.
  49033. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  49034. v := m.remark
  49035. if v == nil {
  49036. return
  49037. }
  49038. return *v, true
  49039. }
  49040. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  49041. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49043. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  49044. if !m.op.Is(OpUpdateOne) {
  49045. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  49046. }
  49047. if m.id == nil || m.oldValue == nil {
  49048. return v, errors.New("OldRemark requires an ID field in the mutation")
  49049. }
  49050. oldValue, err := m.oldValue(ctx)
  49051. if err != nil {
  49052. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  49053. }
  49054. return oldValue.Remark, nil
  49055. }
  49056. // ResetRemark resets all changes to the "remark" field.
  49057. func (m *WxCardUserMutation) ResetRemark() {
  49058. m.remark = nil
  49059. }
  49060. // SetPhone sets the "phone" field.
  49061. func (m *WxCardUserMutation) SetPhone(s string) {
  49062. m.phone = &s
  49063. }
  49064. // Phone returns the value of the "phone" field in the mutation.
  49065. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  49066. v := m.phone
  49067. if v == nil {
  49068. return
  49069. }
  49070. return *v, true
  49071. }
  49072. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  49073. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49075. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  49076. if !m.op.Is(OpUpdateOne) {
  49077. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  49078. }
  49079. if m.id == nil || m.oldValue == nil {
  49080. return v, errors.New("OldPhone requires an ID field in the mutation")
  49081. }
  49082. oldValue, err := m.oldValue(ctx)
  49083. if err != nil {
  49084. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  49085. }
  49086. return oldValue.Phone, nil
  49087. }
  49088. // ResetPhone resets all changes to the "phone" field.
  49089. func (m *WxCardUserMutation) ResetPhone() {
  49090. m.phone = nil
  49091. }
  49092. // SetOpenID sets the "open_id" field.
  49093. func (m *WxCardUserMutation) SetOpenID(s string) {
  49094. m.open_id = &s
  49095. }
  49096. // OpenID returns the value of the "open_id" field in the mutation.
  49097. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  49098. v := m.open_id
  49099. if v == nil {
  49100. return
  49101. }
  49102. return *v, true
  49103. }
  49104. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  49105. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49107. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  49108. if !m.op.Is(OpUpdateOne) {
  49109. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  49110. }
  49111. if m.id == nil || m.oldValue == nil {
  49112. return v, errors.New("OldOpenID requires an ID field in the mutation")
  49113. }
  49114. oldValue, err := m.oldValue(ctx)
  49115. if err != nil {
  49116. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  49117. }
  49118. return oldValue.OpenID, nil
  49119. }
  49120. // ResetOpenID resets all changes to the "open_id" field.
  49121. func (m *WxCardUserMutation) ResetOpenID() {
  49122. m.open_id = nil
  49123. }
  49124. // SetUnionID sets the "union_id" field.
  49125. func (m *WxCardUserMutation) SetUnionID(s string) {
  49126. m.union_id = &s
  49127. }
  49128. // UnionID returns the value of the "union_id" field in the mutation.
  49129. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  49130. v := m.union_id
  49131. if v == nil {
  49132. return
  49133. }
  49134. return *v, true
  49135. }
  49136. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  49137. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49139. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  49140. if !m.op.Is(OpUpdateOne) {
  49141. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  49142. }
  49143. if m.id == nil || m.oldValue == nil {
  49144. return v, errors.New("OldUnionID requires an ID field in the mutation")
  49145. }
  49146. oldValue, err := m.oldValue(ctx)
  49147. if err != nil {
  49148. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  49149. }
  49150. return oldValue.UnionID, nil
  49151. }
  49152. // ResetUnionID resets all changes to the "union_id" field.
  49153. func (m *WxCardUserMutation) ResetUnionID() {
  49154. m.union_id = nil
  49155. }
  49156. // SetSessionKey sets the "session_key" field.
  49157. func (m *WxCardUserMutation) SetSessionKey(s string) {
  49158. m.session_key = &s
  49159. }
  49160. // SessionKey returns the value of the "session_key" field in the mutation.
  49161. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  49162. v := m.session_key
  49163. if v == nil {
  49164. return
  49165. }
  49166. return *v, true
  49167. }
  49168. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  49169. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49171. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  49172. if !m.op.Is(OpUpdateOne) {
  49173. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  49174. }
  49175. if m.id == nil || m.oldValue == nil {
  49176. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  49177. }
  49178. oldValue, err := m.oldValue(ctx)
  49179. if err != nil {
  49180. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  49181. }
  49182. return oldValue.SessionKey, nil
  49183. }
  49184. // ResetSessionKey resets all changes to the "session_key" field.
  49185. func (m *WxCardUserMutation) ResetSessionKey() {
  49186. m.session_key = nil
  49187. }
  49188. // SetIsVip sets the "is_vip" field.
  49189. func (m *WxCardUserMutation) SetIsVip(i int) {
  49190. m.is_vip = &i
  49191. m.addis_vip = nil
  49192. }
  49193. // IsVip returns the value of the "is_vip" field in the mutation.
  49194. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  49195. v := m.is_vip
  49196. if v == nil {
  49197. return
  49198. }
  49199. return *v, true
  49200. }
  49201. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  49202. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49204. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  49205. if !m.op.Is(OpUpdateOne) {
  49206. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  49207. }
  49208. if m.id == nil || m.oldValue == nil {
  49209. return v, errors.New("OldIsVip requires an ID field in the mutation")
  49210. }
  49211. oldValue, err := m.oldValue(ctx)
  49212. if err != nil {
  49213. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  49214. }
  49215. return oldValue.IsVip, nil
  49216. }
  49217. // AddIsVip adds i to the "is_vip" field.
  49218. func (m *WxCardUserMutation) AddIsVip(i int) {
  49219. if m.addis_vip != nil {
  49220. *m.addis_vip += i
  49221. } else {
  49222. m.addis_vip = &i
  49223. }
  49224. }
  49225. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  49226. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  49227. v := m.addis_vip
  49228. if v == nil {
  49229. return
  49230. }
  49231. return *v, true
  49232. }
  49233. // ResetIsVip resets all changes to the "is_vip" field.
  49234. func (m *WxCardUserMutation) ResetIsVip() {
  49235. m.is_vip = nil
  49236. m.addis_vip = nil
  49237. }
  49238. // Where appends a list predicates to the WxCardUserMutation builder.
  49239. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  49240. m.predicates = append(m.predicates, ps...)
  49241. }
  49242. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  49243. // users can use type-assertion to append predicates that do not depend on any generated package.
  49244. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  49245. p := make([]predicate.WxCardUser, len(ps))
  49246. for i := range ps {
  49247. p[i] = ps[i]
  49248. }
  49249. m.Where(p...)
  49250. }
  49251. // Op returns the operation name.
  49252. func (m *WxCardUserMutation) Op() Op {
  49253. return m.op
  49254. }
  49255. // SetOp allows setting the mutation operation.
  49256. func (m *WxCardUserMutation) SetOp(op Op) {
  49257. m.op = op
  49258. }
  49259. // Type returns the node type of this mutation (WxCardUser).
  49260. func (m *WxCardUserMutation) Type() string {
  49261. return m.typ
  49262. }
  49263. // Fields returns all fields that were changed during this mutation. Note that in
  49264. // order to get all numeric fields that were incremented/decremented, call
  49265. // AddedFields().
  49266. func (m *WxCardUserMutation) Fields() []string {
  49267. fields := make([]string, 0, 13)
  49268. if m.created_at != nil {
  49269. fields = append(fields, wxcarduser.FieldCreatedAt)
  49270. }
  49271. if m.updated_at != nil {
  49272. fields = append(fields, wxcarduser.FieldUpdatedAt)
  49273. }
  49274. if m.deleted_at != nil {
  49275. fields = append(fields, wxcarduser.FieldDeletedAt)
  49276. }
  49277. if m.wxid != nil {
  49278. fields = append(fields, wxcarduser.FieldWxid)
  49279. }
  49280. if m.account != nil {
  49281. fields = append(fields, wxcarduser.FieldAccount)
  49282. }
  49283. if m.avatar != nil {
  49284. fields = append(fields, wxcarduser.FieldAvatar)
  49285. }
  49286. if m.nickname != nil {
  49287. fields = append(fields, wxcarduser.FieldNickname)
  49288. }
  49289. if m.remark != nil {
  49290. fields = append(fields, wxcarduser.FieldRemark)
  49291. }
  49292. if m.phone != nil {
  49293. fields = append(fields, wxcarduser.FieldPhone)
  49294. }
  49295. if m.open_id != nil {
  49296. fields = append(fields, wxcarduser.FieldOpenID)
  49297. }
  49298. if m.union_id != nil {
  49299. fields = append(fields, wxcarduser.FieldUnionID)
  49300. }
  49301. if m.session_key != nil {
  49302. fields = append(fields, wxcarduser.FieldSessionKey)
  49303. }
  49304. if m.is_vip != nil {
  49305. fields = append(fields, wxcarduser.FieldIsVip)
  49306. }
  49307. return fields
  49308. }
  49309. // Field returns the value of a field with the given name. The second boolean
  49310. // return value indicates that this field was not set, or was not defined in the
  49311. // schema.
  49312. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  49313. switch name {
  49314. case wxcarduser.FieldCreatedAt:
  49315. return m.CreatedAt()
  49316. case wxcarduser.FieldUpdatedAt:
  49317. return m.UpdatedAt()
  49318. case wxcarduser.FieldDeletedAt:
  49319. return m.DeletedAt()
  49320. case wxcarduser.FieldWxid:
  49321. return m.Wxid()
  49322. case wxcarduser.FieldAccount:
  49323. return m.Account()
  49324. case wxcarduser.FieldAvatar:
  49325. return m.Avatar()
  49326. case wxcarduser.FieldNickname:
  49327. return m.Nickname()
  49328. case wxcarduser.FieldRemark:
  49329. return m.Remark()
  49330. case wxcarduser.FieldPhone:
  49331. return m.Phone()
  49332. case wxcarduser.FieldOpenID:
  49333. return m.OpenID()
  49334. case wxcarduser.FieldUnionID:
  49335. return m.UnionID()
  49336. case wxcarduser.FieldSessionKey:
  49337. return m.SessionKey()
  49338. case wxcarduser.FieldIsVip:
  49339. return m.IsVip()
  49340. }
  49341. return nil, false
  49342. }
  49343. // OldField returns the old value of the field from the database. An error is
  49344. // returned if the mutation operation is not UpdateOne, or the query to the
  49345. // database failed.
  49346. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49347. switch name {
  49348. case wxcarduser.FieldCreatedAt:
  49349. return m.OldCreatedAt(ctx)
  49350. case wxcarduser.FieldUpdatedAt:
  49351. return m.OldUpdatedAt(ctx)
  49352. case wxcarduser.FieldDeletedAt:
  49353. return m.OldDeletedAt(ctx)
  49354. case wxcarduser.FieldWxid:
  49355. return m.OldWxid(ctx)
  49356. case wxcarduser.FieldAccount:
  49357. return m.OldAccount(ctx)
  49358. case wxcarduser.FieldAvatar:
  49359. return m.OldAvatar(ctx)
  49360. case wxcarduser.FieldNickname:
  49361. return m.OldNickname(ctx)
  49362. case wxcarduser.FieldRemark:
  49363. return m.OldRemark(ctx)
  49364. case wxcarduser.FieldPhone:
  49365. return m.OldPhone(ctx)
  49366. case wxcarduser.FieldOpenID:
  49367. return m.OldOpenID(ctx)
  49368. case wxcarduser.FieldUnionID:
  49369. return m.OldUnionID(ctx)
  49370. case wxcarduser.FieldSessionKey:
  49371. return m.OldSessionKey(ctx)
  49372. case wxcarduser.FieldIsVip:
  49373. return m.OldIsVip(ctx)
  49374. }
  49375. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  49376. }
  49377. // SetField sets the value of a field with the given name. It returns an error if
  49378. // the field is not defined in the schema, or if the type mismatched the field
  49379. // type.
  49380. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  49381. switch name {
  49382. case wxcarduser.FieldCreatedAt:
  49383. v, ok := value.(time.Time)
  49384. if !ok {
  49385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49386. }
  49387. m.SetCreatedAt(v)
  49388. return nil
  49389. case wxcarduser.FieldUpdatedAt:
  49390. v, ok := value.(time.Time)
  49391. if !ok {
  49392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49393. }
  49394. m.SetUpdatedAt(v)
  49395. return nil
  49396. case wxcarduser.FieldDeletedAt:
  49397. v, ok := value.(time.Time)
  49398. if !ok {
  49399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49400. }
  49401. m.SetDeletedAt(v)
  49402. return nil
  49403. case wxcarduser.FieldWxid:
  49404. v, ok := value.(string)
  49405. if !ok {
  49406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49407. }
  49408. m.SetWxid(v)
  49409. return nil
  49410. case wxcarduser.FieldAccount:
  49411. v, ok := value.(string)
  49412. if !ok {
  49413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49414. }
  49415. m.SetAccount(v)
  49416. return nil
  49417. case wxcarduser.FieldAvatar:
  49418. v, ok := value.(string)
  49419. if !ok {
  49420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49421. }
  49422. m.SetAvatar(v)
  49423. return nil
  49424. case wxcarduser.FieldNickname:
  49425. v, ok := value.(string)
  49426. if !ok {
  49427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49428. }
  49429. m.SetNickname(v)
  49430. return nil
  49431. case wxcarduser.FieldRemark:
  49432. v, ok := value.(string)
  49433. if !ok {
  49434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49435. }
  49436. m.SetRemark(v)
  49437. return nil
  49438. case wxcarduser.FieldPhone:
  49439. v, ok := value.(string)
  49440. if !ok {
  49441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49442. }
  49443. m.SetPhone(v)
  49444. return nil
  49445. case wxcarduser.FieldOpenID:
  49446. v, ok := value.(string)
  49447. if !ok {
  49448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49449. }
  49450. m.SetOpenID(v)
  49451. return nil
  49452. case wxcarduser.FieldUnionID:
  49453. v, ok := value.(string)
  49454. if !ok {
  49455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49456. }
  49457. m.SetUnionID(v)
  49458. return nil
  49459. case wxcarduser.FieldSessionKey:
  49460. v, ok := value.(string)
  49461. if !ok {
  49462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49463. }
  49464. m.SetSessionKey(v)
  49465. return nil
  49466. case wxcarduser.FieldIsVip:
  49467. v, ok := value.(int)
  49468. if !ok {
  49469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49470. }
  49471. m.SetIsVip(v)
  49472. return nil
  49473. }
  49474. return fmt.Errorf("unknown WxCardUser field %s", name)
  49475. }
  49476. // AddedFields returns all numeric fields that were incremented/decremented during
  49477. // this mutation.
  49478. func (m *WxCardUserMutation) AddedFields() []string {
  49479. var fields []string
  49480. if m.addis_vip != nil {
  49481. fields = append(fields, wxcarduser.FieldIsVip)
  49482. }
  49483. return fields
  49484. }
  49485. // AddedField returns the numeric value that was incremented/decremented on a field
  49486. // with the given name. The second boolean return value indicates that this field
  49487. // was not set, or was not defined in the schema.
  49488. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  49489. switch name {
  49490. case wxcarduser.FieldIsVip:
  49491. return m.AddedIsVip()
  49492. }
  49493. return nil, false
  49494. }
  49495. // AddField adds the value to the field with the given name. It returns an error if
  49496. // the field is not defined in the schema, or if the type mismatched the field
  49497. // type.
  49498. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  49499. switch name {
  49500. case wxcarduser.FieldIsVip:
  49501. v, ok := value.(int)
  49502. if !ok {
  49503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49504. }
  49505. m.AddIsVip(v)
  49506. return nil
  49507. }
  49508. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  49509. }
  49510. // ClearedFields returns all nullable fields that were cleared during this
  49511. // mutation.
  49512. func (m *WxCardUserMutation) ClearedFields() []string {
  49513. var fields []string
  49514. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  49515. fields = append(fields, wxcarduser.FieldDeletedAt)
  49516. }
  49517. return fields
  49518. }
  49519. // FieldCleared returns a boolean indicating if a field with the given name was
  49520. // cleared in this mutation.
  49521. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  49522. _, ok := m.clearedFields[name]
  49523. return ok
  49524. }
  49525. // ClearField clears the value of the field with the given name. It returns an
  49526. // error if the field is not defined in the schema.
  49527. func (m *WxCardUserMutation) ClearField(name string) error {
  49528. switch name {
  49529. case wxcarduser.FieldDeletedAt:
  49530. m.ClearDeletedAt()
  49531. return nil
  49532. }
  49533. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  49534. }
  49535. // ResetField resets all changes in the mutation for the field with the given name.
  49536. // It returns an error if the field is not defined in the schema.
  49537. func (m *WxCardUserMutation) ResetField(name string) error {
  49538. switch name {
  49539. case wxcarduser.FieldCreatedAt:
  49540. m.ResetCreatedAt()
  49541. return nil
  49542. case wxcarduser.FieldUpdatedAt:
  49543. m.ResetUpdatedAt()
  49544. return nil
  49545. case wxcarduser.FieldDeletedAt:
  49546. m.ResetDeletedAt()
  49547. return nil
  49548. case wxcarduser.FieldWxid:
  49549. m.ResetWxid()
  49550. return nil
  49551. case wxcarduser.FieldAccount:
  49552. m.ResetAccount()
  49553. return nil
  49554. case wxcarduser.FieldAvatar:
  49555. m.ResetAvatar()
  49556. return nil
  49557. case wxcarduser.FieldNickname:
  49558. m.ResetNickname()
  49559. return nil
  49560. case wxcarduser.FieldRemark:
  49561. m.ResetRemark()
  49562. return nil
  49563. case wxcarduser.FieldPhone:
  49564. m.ResetPhone()
  49565. return nil
  49566. case wxcarduser.FieldOpenID:
  49567. m.ResetOpenID()
  49568. return nil
  49569. case wxcarduser.FieldUnionID:
  49570. m.ResetUnionID()
  49571. return nil
  49572. case wxcarduser.FieldSessionKey:
  49573. m.ResetSessionKey()
  49574. return nil
  49575. case wxcarduser.FieldIsVip:
  49576. m.ResetIsVip()
  49577. return nil
  49578. }
  49579. return fmt.Errorf("unknown WxCardUser field %s", name)
  49580. }
  49581. // AddedEdges returns all edge names that were set/added in this mutation.
  49582. func (m *WxCardUserMutation) AddedEdges() []string {
  49583. edges := make([]string, 0, 0)
  49584. return edges
  49585. }
  49586. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49587. // name in this mutation.
  49588. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  49589. return nil
  49590. }
  49591. // RemovedEdges returns all edge names that were removed in this mutation.
  49592. func (m *WxCardUserMutation) RemovedEdges() []string {
  49593. edges := make([]string, 0, 0)
  49594. return edges
  49595. }
  49596. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49597. // the given name in this mutation.
  49598. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  49599. return nil
  49600. }
  49601. // ClearedEdges returns all edge names that were cleared in this mutation.
  49602. func (m *WxCardUserMutation) ClearedEdges() []string {
  49603. edges := make([]string, 0, 0)
  49604. return edges
  49605. }
  49606. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49607. // was cleared in this mutation.
  49608. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  49609. return false
  49610. }
  49611. // ClearEdge clears the value of the edge with the given name. It returns an error
  49612. // if that edge is not defined in the schema.
  49613. func (m *WxCardUserMutation) ClearEdge(name string) error {
  49614. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  49615. }
  49616. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49617. // It returns an error if the edge is not defined in the schema.
  49618. func (m *WxCardUserMutation) ResetEdge(name string) error {
  49619. return fmt.Errorf("unknown WxCardUser edge %s", name)
  49620. }
  49621. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  49622. type WxCardVisitMutation struct {
  49623. config
  49624. op Op
  49625. typ string
  49626. id *uint64
  49627. created_at *time.Time
  49628. updated_at *time.Time
  49629. deleted_at *time.Time
  49630. user_id *uint64
  49631. adduser_id *int64
  49632. bot_id *uint64
  49633. addbot_id *int64
  49634. bot_type *uint8
  49635. addbot_type *int8
  49636. clearedFields map[string]struct{}
  49637. done bool
  49638. oldValue func(context.Context) (*WxCardVisit, error)
  49639. predicates []predicate.WxCardVisit
  49640. }
  49641. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  49642. // wxcardvisitOption allows management of the mutation configuration using functional options.
  49643. type wxcardvisitOption func(*WxCardVisitMutation)
  49644. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  49645. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  49646. m := &WxCardVisitMutation{
  49647. config: c,
  49648. op: op,
  49649. typ: TypeWxCardVisit,
  49650. clearedFields: make(map[string]struct{}),
  49651. }
  49652. for _, opt := range opts {
  49653. opt(m)
  49654. }
  49655. return m
  49656. }
  49657. // withWxCardVisitID sets the ID field of the mutation.
  49658. func withWxCardVisitID(id uint64) wxcardvisitOption {
  49659. return func(m *WxCardVisitMutation) {
  49660. var (
  49661. err error
  49662. once sync.Once
  49663. value *WxCardVisit
  49664. )
  49665. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  49666. once.Do(func() {
  49667. if m.done {
  49668. err = errors.New("querying old values post mutation is not allowed")
  49669. } else {
  49670. value, err = m.Client().WxCardVisit.Get(ctx, id)
  49671. }
  49672. })
  49673. return value, err
  49674. }
  49675. m.id = &id
  49676. }
  49677. }
  49678. // withWxCardVisit sets the old WxCardVisit of the mutation.
  49679. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  49680. return func(m *WxCardVisitMutation) {
  49681. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  49682. return node, nil
  49683. }
  49684. m.id = &node.ID
  49685. }
  49686. }
  49687. // Client returns a new `ent.Client` from the mutation. If the mutation was
  49688. // executed in a transaction (ent.Tx), a transactional client is returned.
  49689. func (m WxCardVisitMutation) Client() *Client {
  49690. client := &Client{config: m.config}
  49691. client.init()
  49692. return client
  49693. }
  49694. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  49695. // it returns an error otherwise.
  49696. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  49697. if _, ok := m.driver.(*txDriver); !ok {
  49698. return nil, errors.New("ent: mutation is not running in a transaction")
  49699. }
  49700. tx := &Tx{config: m.config}
  49701. tx.init()
  49702. return tx, nil
  49703. }
  49704. // SetID sets the value of the id field. Note that this
  49705. // operation is only accepted on creation of WxCardVisit entities.
  49706. func (m *WxCardVisitMutation) SetID(id uint64) {
  49707. m.id = &id
  49708. }
  49709. // ID returns the ID value in the mutation. Note that the ID is only available
  49710. // if it was provided to the builder or after it was returned from the database.
  49711. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  49712. if m.id == nil {
  49713. return
  49714. }
  49715. return *m.id, true
  49716. }
  49717. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  49718. // That means, if the mutation is applied within a transaction with an isolation level such
  49719. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  49720. // or updated by the mutation.
  49721. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  49722. switch {
  49723. case m.op.Is(OpUpdateOne | OpDeleteOne):
  49724. id, exists := m.ID()
  49725. if exists {
  49726. return []uint64{id}, nil
  49727. }
  49728. fallthrough
  49729. case m.op.Is(OpUpdate | OpDelete):
  49730. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  49731. default:
  49732. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  49733. }
  49734. }
  49735. // SetCreatedAt sets the "created_at" field.
  49736. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  49737. m.created_at = &t
  49738. }
  49739. // CreatedAt returns the value of the "created_at" field in the mutation.
  49740. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  49741. v := m.created_at
  49742. if v == nil {
  49743. return
  49744. }
  49745. return *v, true
  49746. }
  49747. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  49748. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49750. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  49751. if !m.op.Is(OpUpdateOne) {
  49752. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  49753. }
  49754. if m.id == nil || m.oldValue == nil {
  49755. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  49756. }
  49757. oldValue, err := m.oldValue(ctx)
  49758. if err != nil {
  49759. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  49760. }
  49761. return oldValue.CreatedAt, nil
  49762. }
  49763. // ResetCreatedAt resets all changes to the "created_at" field.
  49764. func (m *WxCardVisitMutation) ResetCreatedAt() {
  49765. m.created_at = nil
  49766. }
  49767. // SetUpdatedAt sets the "updated_at" field.
  49768. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  49769. m.updated_at = &t
  49770. }
  49771. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  49772. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  49773. v := m.updated_at
  49774. if v == nil {
  49775. return
  49776. }
  49777. return *v, true
  49778. }
  49779. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  49780. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49782. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  49783. if !m.op.Is(OpUpdateOne) {
  49784. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  49785. }
  49786. if m.id == nil || m.oldValue == nil {
  49787. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  49788. }
  49789. oldValue, err := m.oldValue(ctx)
  49790. if err != nil {
  49791. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  49792. }
  49793. return oldValue.UpdatedAt, nil
  49794. }
  49795. // ResetUpdatedAt resets all changes to the "updated_at" field.
  49796. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  49797. m.updated_at = nil
  49798. }
  49799. // SetDeletedAt sets the "deleted_at" field.
  49800. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  49801. m.deleted_at = &t
  49802. }
  49803. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  49804. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  49805. v := m.deleted_at
  49806. if v == nil {
  49807. return
  49808. }
  49809. return *v, true
  49810. }
  49811. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  49812. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49814. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  49815. if !m.op.Is(OpUpdateOne) {
  49816. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  49817. }
  49818. if m.id == nil || m.oldValue == nil {
  49819. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  49820. }
  49821. oldValue, err := m.oldValue(ctx)
  49822. if err != nil {
  49823. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  49824. }
  49825. return oldValue.DeletedAt, nil
  49826. }
  49827. // ClearDeletedAt clears the value of the "deleted_at" field.
  49828. func (m *WxCardVisitMutation) ClearDeletedAt() {
  49829. m.deleted_at = nil
  49830. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  49831. }
  49832. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  49833. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  49834. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  49835. return ok
  49836. }
  49837. // ResetDeletedAt resets all changes to the "deleted_at" field.
  49838. func (m *WxCardVisitMutation) ResetDeletedAt() {
  49839. m.deleted_at = nil
  49840. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  49841. }
  49842. // SetUserID sets the "user_id" field.
  49843. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  49844. m.user_id = &u
  49845. m.adduser_id = nil
  49846. }
  49847. // UserID returns the value of the "user_id" field in the mutation.
  49848. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  49849. v := m.user_id
  49850. if v == nil {
  49851. return
  49852. }
  49853. return *v, true
  49854. }
  49855. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  49856. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49858. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  49859. if !m.op.Is(OpUpdateOne) {
  49860. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  49861. }
  49862. if m.id == nil || m.oldValue == nil {
  49863. return v, errors.New("OldUserID requires an ID field in the mutation")
  49864. }
  49865. oldValue, err := m.oldValue(ctx)
  49866. if err != nil {
  49867. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  49868. }
  49869. return oldValue.UserID, nil
  49870. }
  49871. // AddUserID adds u to the "user_id" field.
  49872. func (m *WxCardVisitMutation) AddUserID(u int64) {
  49873. if m.adduser_id != nil {
  49874. *m.adduser_id += u
  49875. } else {
  49876. m.adduser_id = &u
  49877. }
  49878. }
  49879. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  49880. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  49881. v := m.adduser_id
  49882. if v == nil {
  49883. return
  49884. }
  49885. return *v, true
  49886. }
  49887. // ClearUserID clears the value of the "user_id" field.
  49888. func (m *WxCardVisitMutation) ClearUserID() {
  49889. m.user_id = nil
  49890. m.adduser_id = nil
  49891. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  49892. }
  49893. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  49894. func (m *WxCardVisitMutation) UserIDCleared() bool {
  49895. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  49896. return ok
  49897. }
  49898. // ResetUserID resets all changes to the "user_id" field.
  49899. func (m *WxCardVisitMutation) ResetUserID() {
  49900. m.user_id = nil
  49901. m.adduser_id = nil
  49902. delete(m.clearedFields, wxcardvisit.FieldUserID)
  49903. }
  49904. // SetBotID sets the "bot_id" field.
  49905. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  49906. m.bot_id = &u
  49907. m.addbot_id = nil
  49908. }
  49909. // BotID returns the value of the "bot_id" field in the mutation.
  49910. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  49911. v := m.bot_id
  49912. if v == nil {
  49913. return
  49914. }
  49915. return *v, true
  49916. }
  49917. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  49918. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49920. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  49921. if !m.op.Is(OpUpdateOne) {
  49922. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  49923. }
  49924. if m.id == nil || m.oldValue == nil {
  49925. return v, errors.New("OldBotID requires an ID field in the mutation")
  49926. }
  49927. oldValue, err := m.oldValue(ctx)
  49928. if err != nil {
  49929. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  49930. }
  49931. return oldValue.BotID, nil
  49932. }
  49933. // AddBotID adds u to the "bot_id" field.
  49934. func (m *WxCardVisitMutation) AddBotID(u int64) {
  49935. if m.addbot_id != nil {
  49936. *m.addbot_id += u
  49937. } else {
  49938. m.addbot_id = &u
  49939. }
  49940. }
  49941. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  49942. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  49943. v := m.addbot_id
  49944. if v == nil {
  49945. return
  49946. }
  49947. return *v, true
  49948. }
  49949. // ResetBotID resets all changes to the "bot_id" field.
  49950. func (m *WxCardVisitMutation) ResetBotID() {
  49951. m.bot_id = nil
  49952. m.addbot_id = nil
  49953. }
  49954. // SetBotType sets the "bot_type" field.
  49955. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  49956. m.bot_type = &u
  49957. m.addbot_type = nil
  49958. }
  49959. // BotType returns the value of the "bot_type" field in the mutation.
  49960. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  49961. v := m.bot_type
  49962. if v == nil {
  49963. return
  49964. }
  49965. return *v, true
  49966. }
  49967. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  49968. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49970. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  49971. if !m.op.Is(OpUpdateOne) {
  49972. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  49973. }
  49974. if m.id == nil || m.oldValue == nil {
  49975. return v, errors.New("OldBotType requires an ID field in the mutation")
  49976. }
  49977. oldValue, err := m.oldValue(ctx)
  49978. if err != nil {
  49979. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  49980. }
  49981. return oldValue.BotType, nil
  49982. }
  49983. // AddBotType adds u to the "bot_type" field.
  49984. func (m *WxCardVisitMutation) AddBotType(u int8) {
  49985. if m.addbot_type != nil {
  49986. *m.addbot_type += u
  49987. } else {
  49988. m.addbot_type = &u
  49989. }
  49990. }
  49991. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  49992. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  49993. v := m.addbot_type
  49994. if v == nil {
  49995. return
  49996. }
  49997. return *v, true
  49998. }
  49999. // ResetBotType resets all changes to the "bot_type" field.
  50000. func (m *WxCardVisitMutation) ResetBotType() {
  50001. m.bot_type = nil
  50002. m.addbot_type = nil
  50003. }
  50004. // Where appends a list predicates to the WxCardVisitMutation builder.
  50005. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  50006. m.predicates = append(m.predicates, ps...)
  50007. }
  50008. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  50009. // users can use type-assertion to append predicates that do not depend on any generated package.
  50010. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  50011. p := make([]predicate.WxCardVisit, len(ps))
  50012. for i := range ps {
  50013. p[i] = ps[i]
  50014. }
  50015. m.Where(p...)
  50016. }
  50017. // Op returns the operation name.
  50018. func (m *WxCardVisitMutation) Op() Op {
  50019. return m.op
  50020. }
  50021. // SetOp allows setting the mutation operation.
  50022. func (m *WxCardVisitMutation) SetOp(op Op) {
  50023. m.op = op
  50024. }
  50025. // Type returns the node type of this mutation (WxCardVisit).
  50026. func (m *WxCardVisitMutation) Type() string {
  50027. return m.typ
  50028. }
  50029. // Fields returns all fields that were changed during this mutation. Note that in
  50030. // order to get all numeric fields that were incremented/decremented, call
  50031. // AddedFields().
  50032. func (m *WxCardVisitMutation) Fields() []string {
  50033. fields := make([]string, 0, 6)
  50034. if m.created_at != nil {
  50035. fields = append(fields, wxcardvisit.FieldCreatedAt)
  50036. }
  50037. if m.updated_at != nil {
  50038. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  50039. }
  50040. if m.deleted_at != nil {
  50041. fields = append(fields, wxcardvisit.FieldDeletedAt)
  50042. }
  50043. if m.user_id != nil {
  50044. fields = append(fields, wxcardvisit.FieldUserID)
  50045. }
  50046. if m.bot_id != nil {
  50047. fields = append(fields, wxcardvisit.FieldBotID)
  50048. }
  50049. if m.bot_type != nil {
  50050. fields = append(fields, wxcardvisit.FieldBotType)
  50051. }
  50052. return fields
  50053. }
  50054. // Field returns the value of a field with the given name. The second boolean
  50055. // return value indicates that this field was not set, or was not defined in the
  50056. // schema.
  50057. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  50058. switch name {
  50059. case wxcardvisit.FieldCreatedAt:
  50060. return m.CreatedAt()
  50061. case wxcardvisit.FieldUpdatedAt:
  50062. return m.UpdatedAt()
  50063. case wxcardvisit.FieldDeletedAt:
  50064. return m.DeletedAt()
  50065. case wxcardvisit.FieldUserID:
  50066. return m.UserID()
  50067. case wxcardvisit.FieldBotID:
  50068. return m.BotID()
  50069. case wxcardvisit.FieldBotType:
  50070. return m.BotType()
  50071. }
  50072. return nil, false
  50073. }
  50074. // OldField returns the old value of the field from the database. An error is
  50075. // returned if the mutation operation is not UpdateOne, or the query to the
  50076. // database failed.
  50077. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  50078. switch name {
  50079. case wxcardvisit.FieldCreatedAt:
  50080. return m.OldCreatedAt(ctx)
  50081. case wxcardvisit.FieldUpdatedAt:
  50082. return m.OldUpdatedAt(ctx)
  50083. case wxcardvisit.FieldDeletedAt:
  50084. return m.OldDeletedAt(ctx)
  50085. case wxcardvisit.FieldUserID:
  50086. return m.OldUserID(ctx)
  50087. case wxcardvisit.FieldBotID:
  50088. return m.OldBotID(ctx)
  50089. case wxcardvisit.FieldBotType:
  50090. return m.OldBotType(ctx)
  50091. }
  50092. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  50093. }
  50094. // SetField sets the value of a field with the given name. It returns an error if
  50095. // the field is not defined in the schema, or if the type mismatched the field
  50096. // type.
  50097. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  50098. switch name {
  50099. case wxcardvisit.FieldCreatedAt:
  50100. v, ok := value.(time.Time)
  50101. if !ok {
  50102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50103. }
  50104. m.SetCreatedAt(v)
  50105. return nil
  50106. case wxcardvisit.FieldUpdatedAt:
  50107. v, ok := value.(time.Time)
  50108. if !ok {
  50109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50110. }
  50111. m.SetUpdatedAt(v)
  50112. return nil
  50113. case wxcardvisit.FieldDeletedAt:
  50114. v, ok := value.(time.Time)
  50115. if !ok {
  50116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50117. }
  50118. m.SetDeletedAt(v)
  50119. return nil
  50120. case wxcardvisit.FieldUserID:
  50121. v, ok := value.(uint64)
  50122. if !ok {
  50123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50124. }
  50125. m.SetUserID(v)
  50126. return nil
  50127. case wxcardvisit.FieldBotID:
  50128. v, ok := value.(uint64)
  50129. if !ok {
  50130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50131. }
  50132. m.SetBotID(v)
  50133. return nil
  50134. case wxcardvisit.FieldBotType:
  50135. v, ok := value.(uint8)
  50136. if !ok {
  50137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50138. }
  50139. m.SetBotType(v)
  50140. return nil
  50141. }
  50142. return fmt.Errorf("unknown WxCardVisit field %s", name)
  50143. }
  50144. // AddedFields returns all numeric fields that were incremented/decremented during
  50145. // this mutation.
  50146. func (m *WxCardVisitMutation) AddedFields() []string {
  50147. var fields []string
  50148. if m.adduser_id != nil {
  50149. fields = append(fields, wxcardvisit.FieldUserID)
  50150. }
  50151. if m.addbot_id != nil {
  50152. fields = append(fields, wxcardvisit.FieldBotID)
  50153. }
  50154. if m.addbot_type != nil {
  50155. fields = append(fields, wxcardvisit.FieldBotType)
  50156. }
  50157. return fields
  50158. }
  50159. // AddedField returns the numeric value that was incremented/decremented on a field
  50160. // with the given name. The second boolean return value indicates that this field
  50161. // was not set, or was not defined in the schema.
  50162. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  50163. switch name {
  50164. case wxcardvisit.FieldUserID:
  50165. return m.AddedUserID()
  50166. case wxcardvisit.FieldBotID:
  50167. return m.AddedBotID()
  50168. case wxcardvisit.FieldBotType:
  50169. return m.AddedBotType()
  50170. }
  50171. return nil, false
  50172. }
  50173. // AddField adds the value to the field with the given name. It returns an error if
  50174. // the field is not defined in the schema, or if the type mismatched the field
  50175. // type.
  50176. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  50177. switch name {
  50178. case wxcardvisit.FieldUserID:
  50179. v, ok := value.(int64)
  50180. if !ok {
  50181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50182. }
  50183. m.AddUserID(v)
  50184. return nil
  50185. case wxcardvisit.FieldBotID:
  50186. v, ok := value.(int64)
  50187. if !ok {
  50188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50189. }
  50190. m.AddBotID(v)
  50191. return nil
  50192. case wxcardvisit.FieldBotType:
  50193. v, ok := value.(int8)
  50194. if !ok {
  50195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50196. }
  50197. m.AddBotType(v)
  50198. return nil
  50199. }
  50200. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  50201. }
  50202. // ClearedFields returns all nullable fields that were cleared during this
  50203. // mutation.
  50204. func (m *WxCardVisitMutation) ClearedFields() []string {
  50205. var fields []string
  50206. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  50207. fields = append(fields, wxcardvisit.FieldDeletedAt)
  50208. }
  50209. if m.FieldCleared(wxcardvisit.FieldUserID) {
  50210. fields = append(fields, wxcardvisit.FieldUserID)
  50211. }
  50212. return fields
  50213. }
  50214. // FieldCleared returns a boolean indicating if a field with the given name was
  50215. // cleared in this mutation.
  50216. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  50217. _, ok := m.clearedFields[name]
  50218. return ok
  50219. }
  50220. // ClearField clears the value of the field with the given name. It returns an
  50221. // error if the field is not defined in the schema.
  50222. func (m *WxCardVisitMutation) ClearField(name string) error {
  50223. switch name {
  50224. case wxcardvisit.FieldDeletedAt:
  50225. m.ClearDeletedAt()
  50226. return nil
  50227. case wxcardvisit.FieldUserID:
  50228. m.ClearUserID()
  50229. return nil
  50230. }
  50231. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  50232. }
  50233. // ResetField resets all changes in the mutation for the field with the given name.
  50234. // It returns an error if the field is not defined in the schema.
  50235. func (m *WxCardVisitMutation) ResetField(name string) error {
  50236. switch name {
  50237. case wxcardvisit.FieldCreatedAt:
  50238. m.ResetCreatedAt()
  50239. return nil
  50240. case wxcardvisit.FieldUpdatedAt:
  50241. m.ResetUpdatedAt()
  50242. return nil
  50243. case wxcardvisit.FieldDeletedAt:
  50244. m.ResetDeletedAt()
  50245. return nil
  50246. case wxcardvisit.FieldUserID:
  50247. m.ResetUserID()
  50248. return nil
  50249. case wxcardvisit.FieldBotID:
  50250. m.ResetBotID()
  50251. return nil
  50252. case wxcardvisit.FieldBotType:
  50253. m.ResetBotType()
  50254. return nil
  50255. }
  50256. return fmt.Errorf("unknown WxCardVisit field %s", name)
  50257. }
  50258. // AddedEdges returns all edge names that were set/added in this mutation.
  50259. func (m *WxCardVisitMutation) AddedEdges() []string {
  50260. edges := make([]string, 0, 0)
  50261. return edges
  50262. }
  50263. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  50264. // name in this mutation.
  50265. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  50266. return nil
  50267. }
  50268. // RemovedEdges returns all edge names that were removed in this mutation.
  50269. func (m *WxCardVisitMutation) RemovedEdges() []string {
  50270. edges := make([]string, 0, 0)
  50271. return edges
  50272. }
  50273. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  50274. // the given name in this mutation.
  50275. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  50276. return nil
  50277. }
  50278. // ClearedEdges returns all edge names that were cleared in this mutation.
  50279. func (m *WxCardVisitMutation) ClearedEdges() []string {
  50280. edges := make([]string, 0, 0)
  50281. return edges
  50282. }
  50283. // EdgeCleared returns a boolean which indicates if the edge with the given name
  50284. // was cleared in this mutation.
  50285. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  50286. return false
  50287. }
  50288. // ClearEdge clears the value of the edge with the given name. It returns an error
  50289. // if that edge is not defined in the schema.
  50290. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  50291. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  50292. }
  50293. // ResetEdge resets all changes to the edge with the given name in this mutation.
  50294. // It returns an error if the edge is not defined in the schema.
  50295. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  50296. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  50297. }
  50298. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  50299. type XunjiMutation struct {
  50300. config
  50301. op Op
  50302. typ string
  50303. id *uint64
  50304. created_at *time.Time
  50305. updated_at *time.Time
  50306. status *uint8
  50307. addstatus *int8
  50308. deleted_at *time.Time
  50309. app_key *string
  50310. app_secret *string
  50311. token *string
  50312. encoding_key *string
  50313. organization_id *uint64
  50314. addorganization_id *int64
  50315. clearedFields map[string]struct{}
  50316. done bool
  50317. oldValue func(context.Context) (*Xunji, error)
  50318. predicates []predicate.Xunji
  50319. }
  50320. var _ ent.Mutation = (*XunjiMutation)(nil)
  50321. // xunjiOption allows management of the mutation configuration using functional options.
  50322. type xunjiOption func(*XunjiMutation)
  50323. // newXunjiMutation creates new mutation for the Xunji entity.
  50324. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  50325. m := &XunjiMutation{
  50326. config: c,
  50327. op: op,
  50328. typ: TypeXunji,
  50329. clearedFields: make(map[string]struct{}),
  50330. }
  50331. for _, opt := range opts {
  50332. opt(m)
  50333. }
  50334. return m
  50335. }
  50336. // withXunjiID sets the ID field of the mutation.
  50337. func withXunjiID(id uint64) xunjiOption {
  50338. return func(m *XunjiMutation) {
  50339. var (
  50340. err error
  50341. once sync.Once
  50342. value *Xunji
  50343. )
  50344. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  50345. once.Do(func() {
  50346. if m.done {
  50347. err = errors.New("querying old values post mutation is not allowed")
  50348. } else {
  50349. value, err = m.Client().Xunji.Get(ctx, id)
  50350. }
  50351. })
  50352. return value, err
  50353. }
  50354. m.id = &id
  50355. }
  50356. }
  50357. // withXunji sets the old Xunji of the mutation.
  50358. func withXunji(node *Xunji) xunjiOption {
  50359. return func(m *XunjiMutation) {
  50360. m.oldValue = func(context.Context) (*Xunji, error) {
  50361. return node, nil
  50362. }
  50363. m.id = &node.ID
  50364. }
  50365. }
  50366. // Client returns a new `ent.Client` from the mutation. If the mutation was
  50367. // executed in a transaction (ent.Tx), a transactional client is returned.
  50368. func (m XunjiMutation) Client() *Client {
  50369. client := &Client{config: m.config}
  50370. client.init()
  50371. return client
  50372. }
  50373. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  50374. // it returns an error otherwise.
  50375. func (m XunjiMutation) Tx() (*Tx, error) {
  50376. if _, ok := m.driver.(*txDriver); !ok {
  50377. return nil, errors.New("ent: mutation is not running in a transaction")
  50378. }
  50379. tx := &Tx{config: m.config}
  50380. tx.init()
  50381. return tx, nil
  50382. }
  50383. // SetID sets the value of the id field. Note that this
  50384. // operation is only accepted on creation of Xunji entities.
  50385. func (m *XunjiMutation) SetID(id uint64) {
  50386. m.id = &id
  50387. }
  50388. // ID returns the ID value in the mutation. Note that the ID is only available
  50389. // if it was provided to the builder or after it was returned from the database.
  50390. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  50391. if m.id == nil {
  50392. return
  50393. }
  50394. return *m.id, true
  50395. }
  50396. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  50397. // That means, if the mutation is applied within a transaction with an isolation level such
  50398. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  50399. // or updated by the mutation.
  50400. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  50401. switch {
  50402. case m.op.Is(OpUpdateOne | OpDeleteOne):
  50403. id, exists := m.ID()
  50404. if exists {
  50405. return []uint64{id}, nil
  50406. }
  50407. fallthrough
  50408. case m.op.Is(OpUpdate | OpDelete):
  50409. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  50410. default:
  50411. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  50412. }
  50413. }
  50414. // SetCreatedAt sets the "created_at" field.
  50415. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  50416. m.created_at = &t
  50417. }
  50418. // CreatedAt returns the value of the "created_at" field in the mutation.
  50419. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  50420. v := m.created_at
  50421. if v == nil {
  50422. return
  50423. }
  50424. return *v, true
  50425. }
  50426. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  50427. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50429. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  50430. if !m.op.Is(OpUpdateOne) {
  50431. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  50432. }
  50433. if m.id == nil || m.oldValue == nil {
  50434. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  50435. }
  50436. oldValue, err := m.oldValue(ctx)
  50437. if err != nil {
  50438. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  50439. }
  50440. return oldValue.CreatedAt, nil
  50441. }
  50442. // ResetCreatedAt resets all changes to the "created_at" field.
  50443. func (m *XunjiMutation) ResetCreatedAt() {
  50444. m.created_at = nil
  50445. }
  50446. // SetUpdatedAt sets the "updated_at" field.
  50447. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  50448. m.updated_at = &t
  50449. }
  50450. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  50451. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  50452. v := m.updated_at
  50453. if v == nil {
  50454. return
  50455. }
  50456. return *v, true
  50457. }
  50458. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  50459. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50461. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  50462. if !m.op.Is(OpUpdateOne) {
  50463. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  50464. }
  50465. if m.id == nil || m.oldValue == nil {
  50466. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  50467. }
  50468. oldValue, err := m.oldValue(ctx)
  50469. if err != nil {
  50470. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  50471. }
  50472. return oldValue.UpdatedAt, nil
  50473. }
  50474. // ResetUpdatedAt resets all changes to the "updated_at" field.
  50475. func (m *XunjiMutation) ResetUpdatedAt() {
  50476. m.updated_at = nil
  50477. }
  50478. // SetStatus sets the "status" field.
  50479. func (m *XunjiMutation) SetStatus(u uint8) {
  50480. m.status = &u
  50481. m.addstatus = nil
  50482. }
  50483. // Status returns the value of the "status" field in the mutation.
  50484. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  50485. v := m.status
  50486. if v == nil {
  50487. return
  50488. }
  50489. return *v, true
  50490. }
  50491. // OldStatus returns the old "status" field's value of the Xunji entity.
  50492. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50494. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  50495. if !m.op.Is(OpUpdateOne) {
  50496. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  50497. }
  50498. if m.id == nil || m.oldValue == nil {
  50499. return v, errors.New("OldStatus requires an ID field in the mutation")
  50500. }
  50501. oldValue, err := m.oldValue(ctx)
  50502. if err != nil {
  50503. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  50504. }
  50505. return oldValue.Status, nil
  50506. }
  50507. // AddStatus adds u to the "status" field.
  50508. func (m *XunjiMutation) AddStatus(u int8) {
  50509. if m.addstatus != nil {
  50510. *m.addstatus += u
  50511. } else {
  50512. m.addstatus = &u
  50513. }
  50514. }
  50515. // AddedStatus returns the value that was added to the "status" field in this mutation.
  50516. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  50517. v := m.addstatus
  50518. if v == nil {
  50519. return
  50520. }
  50521. return *v, true
  50522. }
  50523. // ClearStatus clears the value of the "status" field.
  50524. func (m *XunjiMutation) ClearStatus() {
  50525. m.status = nil
  50526. m.addstatus = nil
  50527. m.clearedFields[xunji.FieldStatus] = struct{}{}
  50528. }
  50529. // StatusCleared returns if the "status" field was cleared in this mutation.
  50530. func (m *XunjiMutation) StatusCleared() bool {
  50531. _, ok := m.clearedFields[xunji.FieldStatus]
  50532. return ok
  50533. }
  50534. // ResetStatus resets all changes to the "status" field.
  50535. func (m *XunjiMutation) ResetStatus() {
  50536. m.status = nil
  50537. m.addstatus = nil
  50538. delete(m.clearedFields, xunji.FieldStatus)
  50539. }
  50540. // SetDeletedAt sets the "deleted_at" field.
  50541. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  50542. m.deleted_at = &t
  50543. }
  50544. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  50545. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  50546. v := m.deleted_at
  50547. if v == nil {
  50548. return
  50549. }
  50550. return *v, true
  50551. }
  50552. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  50553. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50555. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  50556. if !m.op.Is(OpUpdateOne) {
  50557. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  50558. }
  50559. if m.id == nil || m.oldValue == nil {
  50560. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  50561. }
  50562. oldValue, err := m.oldValue(ctx)
  50563. if err != nil {
  50564. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  50565. }
  50566. return oldValue.DeletedAt, nil
  50567. }
  50568. // ClearDeletedAt clears the value of the "deleted_at" field.
  50569. func (m *XunjiMutation) ClearDeletedAt() {
  50570. m.deleted_at = nil
  50571. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  50572. }
  50573. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  50574. func (m *XunjiMutation) DeletedAtCleared() bool {
  50575. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  50576. return ok
  50577. }
  50578. // ResetDeletedAt resets all changes to the "deleted_at" field.
  50579. func (m *XunjiMutation) ResetDeletedAt() {
  50580. m.deleted_at = nil
  50581. delete(m.clearedFields, xunji.FieldDeletedAt)
  50582. }
  50583. // SetAppKey sets the "app_key" field.
  50584. func (m *XunjiMutation) SetAppKey(s string) {
  50585. m.app_key = &s
  50586. }
  50587. // AppKey returns the value of the "app_key" field in the mutation.
  50588. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  50589. v := m.app_key
  50590. if v == nil {
  50591. return
  50592. }
  50593. return *v, true
  50594. }
  50595. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  50596. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50598. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  50599. if !m.op.Is(OpUpdateOne) {
  50600. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  50601. }
  50602. if m.id == nil || m.oldValue == nil {
  50603. return v, errors.New("OldAppKey requires an ID field in the mutation")
  50604. }
  50605. oldValue, err := m.oldValue(ctx)
  50606. if err != nil {
  50607. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  50608. }
  50609. return oldValue.AppKey, nil
  50610. }
  50611. // ClearAppKey clears the value of the "app_key" field.
  50612. func (m *XunjiMutation) ClearAppKey() {
  50613. m.app_key = nil
  50614. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  50615. }
  50616. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  50617. func (m *XunjiMutation) AppKeyCleared() bool {
  50618. _, ok := m.clearedFields[xunji.FieldAppKey]
  50619. return ok
  50620. }
  50621. // ResetAppKey resets all changes to the "app_key" field.
  50622. func (m *XunjiMutation) ResetAppKey() {
  50623. m.app_key = nil
  50624. delete(m.clearedFields, xunji.FieldAppKey)
  50625. }
  50626. // SetAppSecret sets the "app_secret" field.
  50627. func (m *XunjiMutation) SetAppSecret(s string) {
  50628. m.app_secret = &s
  50629. }
  50630. // AppSecret returns the value of the "app_secret" field in the mutation.
  50631. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  50632. v := m.app_secret
  50633. if v == nil {
  50634. return
  50635. }
  50636. return *v, true
  50637. }
  50638. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  50639. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50641. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  50642. if !m.op.Is(OpUpdateOne) {
  50643. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  50644. }
  50645. if m.id == nil || m.oldValue == nil {
  50646. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  50647. }
  50648. oldValue, err := m.oldValue(ctx)
  50649. if err != nil {
  50650. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  50651. }
  50652. return oldValue.AppSecret, nil
  50653. }
  50654. // ClearAppSecret clears the value of the "app_secret" field.
  50655. func (m *XunjiMutation) ClearAppSecret() {
  50656. m.app_secret = nil
  50657. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  50658. }
  50659. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  50660. func (m *XunjiMutation) AppSecretCleared() bool {
  50661. _, ok := m.clearedFields[xunji.FieldAppSecret]
  50662. return ok
  50663. }
  50664. // ResetAppSecret resets all changes to the "app_secret" field.
  50665. func (m *XunjiMutation) ResetAppSecret() {
  50666. m.app_secret = nil
  50667. delete(m.clearedFields, xunji.FieldAppSecret)
  50668. }
  50669. // SetToken sets the "token" field.
  50670. func (m *XunjiMutation) SetToken(s string) {
  50671. m.token = &s
  50672. }
  50673. // Token returns the value of the "token" field in the mutation.
  50674. func (m *XunjiMutation) Token() (r string, exists bool) {
  50675. v := m.token
  50676. if v == nil {
  50677. return
  50678. }
  50679. return *v, true
  50680. }
  50681. // OldToken returns the old "token" field's value of the Xunji entity.
  50682. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50684. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  50685. if !m.op.Is(OpUpdateOne) {
  50686. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  50687. }
  50688. if m.id == nil || m.oldValue == nil {
  50689. return v, errors.New("OldToken requires an ID field in the mutation")
  50690. }
  50691. oldValue, err := m.oldValue(ctx)
  50692. if err != nil {
  50693. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  50694. }
  50695. return oldValue.Token, nil
  50696. }
  50697. // ClearToken clears the value of the "token" field.
  50698. func (m *XunjiMutation) ClearToken() {
  50699. m.token = nil
  50700. m.clearedFields[xunji.FieldToken] = struct{}{}
  50701. }
  50702. // TokenCleared returns if the "token" field was cleared in this mutation.
  50703. func (m *XunjiMutation) TokenCleared() bool {
  50704. _, ok := m.clearedFields[xunji.FieldToken]
  50705. return ok
  50706. }
  50707. // ResetToken resets all changes to the "token" field.
  50708. func (m *XunjiMutation) ResetToken() {
  50709. m.token = nil
  50710. delete(m.clearedFields, xunji.FieldToken)
  50711. }
  50712. // SetEncodingKey sets the "encoding_key" field.
  50713. func (m *XunjiMutation) SetEncodingKey(s string) {
  50714. m.encoding_key = &s
  50715. }
  50716. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  50717. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  50718. v := m.encoding_key
  50719. if v == nil {
  50720. return
  50721. }
  50722. return *v, true
  50723. }
  50724. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  50725. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50727. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  50728. if !m.op.Is(OpUpdateOne) {
  50729. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  50730. }
  50731. if m.id == nil || m.oldValue == nil {
  50732. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  50733. }
  50734. oldValue, err := m.oldValue(ctx)
  50735. if err != nil {
  50736. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  50737. }
  50738. return oldValue.EncodingKey, nil
  50739. }
  50740. // ClearEncodingKey clears the value of the "encoding_key" field.
  50741. func (m *XunjiMutation) ClearEncodingKey() {
  50742. m.encoding_key = nil
  50743. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  50744. }
  50745. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  50746. func (m *XunjiMutation) EncodingKeyCleared() bool {
  50747. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  50748. return ok
  50749. }
  50750. // ResetEncodingKey resets all changes to the "encoding_key" field.
  50751. func (m *XunjiMutation) ResetEncodingKey() {
  50752. m.encoding_key = nil
  50753. delete(m.clearedFields, xunji.FieldEncodingKey)
  50754. }
  50755. // SetOrganizationID sets the "organization_id" field.
  50756. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  50757. m.organization_id = &u
  50758. m.addorganization_id = nil
  50759. }
  50760. // OrganizationID returns the value of the "organization_id" field in the mutation.
  50761. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  50762. v := m.organization_id
  50763. if v == nil {
  50764. return
  50765. }
  50766. return *v, true
  50767. }
  50768. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  50769. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50771. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  50772. if !m.op.Is(OpUpdateOne) {
  50773. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  50774. }
  50775. if m.id == nil || m.oldValue == nil {
  50776. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  50777. }
  50778. oldValue, err := m.oldValue(ctx)
  50779. if err != nil {
  50780. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  50781. }
  50782. return oldValue.OrganizationID, nil
  50783. }
  50784. // AddOrganizationID adds u to the "organization_id" field.
  50785. func (m *XunjiMutation) AddOrganizationID(u int64) {
  50786. if m.addorganization_id != nil {
  50787. *m.addorganization_id += u
  50788. } else {
  50789. m.addorganization_id = &u
  50790. }
  50791. }
  50792. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  50793. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  50794. v := m.addorganization_id
  50795. if v == nil {
  50796. return
  50797. }
  50798. return *v, true
  50799. }
  50800. // ResetOrganizationID resets all changes to the "organization_id" field.
  50801. func (m *XunjiMutation) ResetOrganizationID() {
  50802. m.organization_id = nil
  50803. m.addorganization_id = nil
  50804. }
  50805. // Where appends a list predicates to the XunjiMutation builder.
  50806. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  50807. m.predicates = append(m.predicates, ps...)
  50808. }
  50809. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  50810. // users can use type-assertion to append predicates that do not depend on any generated package.
  50811. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  50812. p := make([]predicate.Xunji, len(ps))
  50813. for i := range ps {
  50814. p[i] = ps[i]
  50815. }
  50816. m.Where(p...)
  50817. }
  50818. // Op returns the operation name.
  50819. func (m *XunjiMutation) Op() Op {
  50820. return m.op
  50821. }
  50822. // SetOp allows setting the mutation operation.
  50823. func (m *XunjiMutation) SetOp(op Op) {
  50824. m.op = op
  50825. }
  50826. // Type returns the node type of this mutation (Xunji).
  50827. func (m *XunjiMutation) Type() string {
  50828. return m.typ
  50829. }
  50830. // Fields returns all fields that were changed during this mutation. Note that in
  50831. // order to get all numeric fields that were incremented/decremented, call
  50832. // AddedFields().
  50833. func (m *XunjiMutation) Fields() []string {
  50834. fields := make([]string, 0, 9)
  50835. if m.created_at != nil {
  50836. fields = append(fields, xunji.FieldCreatedAt)
  50837. }
  50838. if m.updated_at != nil {
  50839. fields = append(fields, xunji.FieldUpdatedAt)
  50840. }
  50841. if m.status != nil {
  50842. fields = append(fields, xunji.FieldStatus)
  50843. }
  50844. if m.deleted_at != nil {
  50845. fields = append(fields, xunji.FieldDeletedAt)
  50846. }
  50847. if m.app_key != nil {
  50848. fields = append(fields, xunji.FieldAppKey)
  50849. }
  50850. if m.app_secret != nil {
  50851. fields = append(fields, xunji.FieldAppSecret)
  50852. }
  50853. if m.token != nil {
  50854. fields = append(fields, xunji.FieldToken)
  50855. }
  50856. if m.encoding_key != nil {
  50857. fields = append(fields, xunji.FieldEncodingKey)
  50858. }
  50859. if m.organization_id != nil {
  50860. fields = append(fields, xunji.FieldOrganizationID)
  50861. }
  50862. return fields
  50863. }
  50864. // Field returns the value of a field with the given name. The second boolean
  50865. // return value indicates that this field was not set, or was not defined in the
  50866. // schema.
  50867. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  50868. switch name {
  50869. case xunji.FieldCreatedAt:
  50870. return m.CreatedAt()
  50871. case xunji.FieldUpdatedAt:
  50872. return m.UpdatedAt()
  50873. case xunji.FieldStatus:
  50874. return m.Status()
  50875. case xunji.FieldDeletedAt:
  50876. return m.DeletedAt()
  50877. case xunji.FieldAppKey:
  50878. return m.AppKey()
  50879. case xunji.FieldAppSecret:
  50880. return m.AppSecret()
  50881. case xunji.FieldToken:
  50882. return m.Token()
  50883. case xunji.FieldEncodingKey:
  50884. return m.EncodingKey()
  50885. case xunji.FieldOrganizationID:
  50886. return m.OrganizationID()
  50887. }
  50888. return nil, false
  50889. }
  50890. // OldField returns the old value of the field from the database. An error is
  50891. // returned if the mutation operation is not UpdateOne, or the query to the
  50892. // database failed.
  50893. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  50894. switch name {
  50895. case xunji.FieldCreatedAt:
  50896. return m.OldCreatedAt(ctx)
  50897. case xunji.FieldUpdatedAt:
  50898. return m.OldUpdatedAt(ctx)
  50899. case xunji.FieldStatus:
  50900. return m.OldStatus(ctx)
  50901. case xunji.FieldDeletedAt:
  50902. return m.OldDeletedAt(ctx)
  50903. case xunji.FieldAppKey:
  50904. return m.OldAppKey(ctx)
  50905. case xunji.FieldAppSecret:
  50906. return m.OldAppSecret(ctx)
  50907. case xunji.FieldToken:
  50908. return m.OldToken(ctx)
  50909. case xunji.FieldEncodingKey:
  50910. return m.OldEncodingKey(ctx)
  50911. case xunji.FieldOrganizationID:
  50912. return m.OldOrganizationID(ctx)
  50913. }
  50914. return nil, fmt.Errorf("unknown Xunji field %s", name)
  50915. }
  50916. // SetField sets the value of a field with the given name. It returns an error if
  50917. // the field is not defined in the schema, or if the type mismatched the field
  50918. // type.
  50919. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  50920. switch name {
  50921. case xunji.FieldCreatedAt:
  50922. v, ok := value.(time.Time)
  50923. if !ok {
  50924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50925. }
  50926. m.SetCreatedAt(v)
  50927. return nil
  50928. case xunji.FieldUpdatedAt:
  50929. v, ok := value.(time.Time)
  50930. if !ok {
  50931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50932. }
  50933. m.SetUpdatedAt(v)
  50934. return nil
  50935. case xunji.FieldStatus:
  50936. v, ok := value.(uint8)
  50937. if !ok {
  50938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50939. }
  50940. m.SetStatus(v)
  50941. return nil
  50942. case xunji.FieldDeletedAt:
  50943. v, ok := value.(time.Time)
  50944. if !ok {
  50945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50946. }
  50947. m.SetDeletedAt(v)
  50948. return nil
  50949. case xunji.FieldAppKey:
  50950. v, ok := value.(string)
  50951. if !ok {
  50952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50953. }
  50954. m.SetAppKey(v)
  50955. return nil
  50956. case xunji.FieldAppSecret:
  50957. v, ok := value.(string)
  50958. if !ok {
  50959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50960. }
  50961. m.SetAppSecret(v)
  50962. return nil
  50963. case xunji.FieldToken:
  50964. v, ok := value.(string)
  50965. if !ok {
  50966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50967. }
  50968. m.SetToken(v)
  50969. return nil
  50970. case xunji.FieldEncodingKey:
  50971. v, ok := value.(string)
  50972. if !ok {
  50973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50974. }
  50975. m.SetEncodingKey(v)
  50976. return nil
  50977. case xunji.FieldOrganizationID:
  50978. v, ok := value.(uint64)
  50979. if !ok {
  50980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50981. }
  50982. m.SetOrganizationID(v)
  50983. return nil
  50984. }
  50985. return fmt.Errorf("unknown Xunji field %s", name)
  50986. }
  50987. // AddedFields returns all numeric fields that were incremented/decremented during
  50988. // this mutation.
  50989. func (m *XunjiMutation) AddedFields() []string {
  50990. var fields []string
  50991. if m.addstatus != nil {
  50992. fields = append(fields, xunji.FieldStatus)
  50993. }
  50994. if m.addorganization_id != nil {
  50995. fields = append(fields, xunji.FieldOrganizationID)
  50996. }
  50997. return fields
  50998. }
  50999. // AddedField returns the numeric value that was incremented/decremented on a field
  51000. // with the given name. The second boolean return value indicates that this field
  51001. // was not set, or was not defined in the schema.
  51002. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  51003. switch name {
  51004. case xunji.FieldStatus:
  51005. return m.AddedStatus()
  51006. case xunji.FieldOrganizationID:
  51007. return m.AddedOrganizationID()
  51008. }
  51009. return nil, false
  51010. }
  51011. // AddField adds the value to the field with the given name. It returns an error if
  51012. // the field is not defined in the schema, or if the type mismatched the field
  51013. // type.
  51014. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  51015. switch name {
  51016. case xunji.FieldStatus:
  51017. v, ok := value.(int8)
  51018. if !ok {
  51019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51020. }
  51021. m.AddStatus(v)
  51022. return nil
  51023. case xunji.FieldOrganizationID:
  51024. v, ok := value.(int64)
  51025. if !ok {
  51026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51027. }
  51028. m.AddOrganizationID(v)
  51029. return nil
  51030. }
  51031. return fmt.Errorf("unknown Xunji numeric field %s", name)
  51032. }
  51033. // ClearedFields returns all nullable fields that were cleared during this
  51034. // mutation.
  51035. func (m *XunjiMutation) ClearedFields() []string {
  51036. var fields []string
  51037. if m.FieldCleared(xunji.FieldStatus) {
  51038. fields = append(fields, xunji.FieldStatus)
  51039. }
  51040. if m.FieldCleared(xunji.FieldDeletedAt) {
  51041. fields = append(fields, xunji.FieldDeletedAt)
  51042. }
  51043. if m.FieldCleared(xunji.FieldAppKey) {
  51044. fields = append(fields, xunji.FieldAppKey)
  51045. }
  51046. if m.FieldCleared(xunji.FieldAppSecret) {
  51047. fields = append(fields, xunji.FieldAppSecret)
  51048. }
  51049. if m.FieldCleared(xunji.FieldToken) {
  51050. fields = append(fields, xunji.FieldToken)
  51051. }
  51052. if m.FieldCleared(xunji.FieldEncodingKey) {
  51053. fields = append(fields, xunji.FieldEncodingKey)
  51054. }
  51055. return fields
  51056. }
  51057. // FieldCleared returns a boolean indicating if a field with the given name was
  51058. // cleared in this mutation.
  51059. func (m *XunjiMutation) FieldCleared(name string) bool {
  51060. _, ok := m.clearedFields[name]
  51061. return ok
  51062. }
  51063. // ClearField clears the value of the field with the given name. It returns an
  51064. // error if the field is not defined in the schema.
  51065. func (m *XunjiMutation) ClearField(name string) error {
  51066. switch name {
  51067. case xunji.FieldStatus:
  51068. m.ClearStatus()
  51069. return nil
  51070. case xunji.FieldDeletedAt:
  51071. m.ClearDeletedAt()
  51072. return nil
  51073. case xunji.FieldAppKey:
  51074. m.ClearAppKey()
  51075. return nil
  51076. case xunji.FieldAppSecret:
  51077. m.ClearAppSecret()
  51078. return nil
  51079. case xunji.FieldToken:
  51080. m.ClearToken()
  51081. return nil
  51082. case xunji.FieldEncodingKey:
  51083. m.ClearEncodingKey()
  51084. return nil
  51085. }
  51086. return fmt.Errorf("unknown Xunji nullable field %s", name)
  51087. }
  51088. // ResetField resets all changes in the mutation for the field with the given name.
  51089. // It returns an error if the field is not defined in the schema.
  51090. func (m *XunjiMutation) ResetField(name string) error {
  51091. switch name {
  51092. case xunji.FieldCreatedAt:
  51093. m.ResetCreatedAt()
  51094. return nil
  51095. case xunji.FieldUpdatedAt:
  51096. m.ResetUpdatedAt()
  51097. return nil
  51098. case xunji.FieldStatus:
  51099. m.ResetStatus()
  51100. return nil
  51101. case xunji.FieldDeletedAt:
  51102. m.ResetDeletedAt()
  51103. return nil
  51104. case xunji.FieldAppKey:
  51105. m.ResetAppKey()
  51106. return nil
  51107. case xunji.FieldAppSecret:
  51108. m.ResetAppSecret()
  51109. return nil
  51110. case xunji.FieldToken:
  51111. m.ResetToken()
  51112. return nil
  51113. case xunji.FieldEncodingKey:
  51114. m.ResetEncodingKey()
  51115. return nil
  51116. case xunji.FieldOrganizationID:
  51117. m.ResetOrganizationID()
  51118. return nil
  51119. }
  51120. return fmt.Errorf("unknown Xunji field %s", name)
  51121. }
  51122. // AddedEdges returns all edge names that were set/added in this mutation.
  51123. func (m *XunjiMutation) AddedEdges() []string {
  51124. edges := make([]string, 0, 0)
  51125. return edges
  51126. }
  51127. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  51128. // name in this mutation.
  51129. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  51130. return nil
  51131. }
  51132. // RemovedEdges returns all edge names that were removed in this mutation.
  51133. func (m *XunjiMutation) RemovedEdges() []string {
  51134. edges := make([]string, 0, 0)
  51135. return edges
  51136. }
  51137. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  51138. // the given name in this mutation.
  51139. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  51140. return nil
  51141. }
  51142. // ClearedEdges returns all edge names that were cleared in this mutation.
  51143. func (m *XunjiMutation) ClearedEdges() []string {
  51144. edges := make([]string, 0, 0)
  51145. return edges
  51146. }
  51147. // EdgeCleared returns a boolean which indicates if the edge with the given name
  51148. // was cleared in this mutation.
  51149. func (m *XunjiMutation) EdgeCleared(name string) bool {
  51150. return false
  51151. }
  51152. // ClearEdge clears the value of the edge with the given name. It returns an error
  51153. // if that edge is not defined in the schema.
  51154. func (m *XunjiMutation) ClearEdge(name string) error {
  51155. return fmt.Errorf("unknown Xunji unique edge %s", name)
  51156. }
  51157. // ResetEdge resets all changes to the edge with the given name in this mutation.
  51158. // It returns an error if the edge is not defined in the schema.
  51159. func (m *XunjiMutation) ResetEdge(name string) error {
  51160. return fmt.Errorf("unknown Xunji edge %s", name)
  51161. }
  51162. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  51163. type XunjiServiceMutation struct {
  51164. config
  51165. op Op
  51166. typ string
  51167. id *uint64
  51168. created_at *time.Time
  51169. updated_at *time.Time
  51170. status *uint8
  51171. addstatus *int8
  51172. deleted_at *time.Time
  51173. xunji_id *uint64
  51174. addxunji_id *int64
  51175. organization_id *uint64
  51176. addorganization_id *int64
  51177. wxid *string
  51178. api_base *string
  51179. api_key *string
  51180. clearedFields map[string]struct{}
  51181. agent *uint64
  51182. clearedagent bool
  51183. done bool
  51184. oldValue func(context.Context) (*XunjiService, error)
  51185. predicates []predicate.XunjiService
  51186. }
  51187. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  51188. // xunjiserviceOption allows management of the mutation configuration using functional options.
  51189. type xunjiserviceOption func(*XunjiServiceMutation)
  51190. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  51191. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  51192. m := &XunjiServiceMutation{
  51193. config: c,
  51194. op: op,
  51195. typ: TypeXunjiService,
  51196. clearedFields: make(map[string]struct{}),
  51197. }
  51198. for _, opt := range opts {
  51199. opt(m)
  51200. }
  51201. return m
  51202. }
  51203. // withXunjiServiceID sets the ID field of the mutation.
  51204. func withXunjiServiceID(id uint64) xunjiserviceOption {
  51205. return func(m *XunjiServiceMutation) {
  51206. var (
  51207. err error
  51208. once sync.Once
  51209. value *XunjiService
  51210. )
  51211. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  51212. once.Do(func() {
  51213. if m.done {
  51214. err = errors.New("querying old values post mutation is not allowed")
  51215. } else {
  51216. value, err = m.Client().XunjiService.Get(ctx, id)
  51217. }
  51218. })
  51219. return value, err
  51220. }
  51221. m.id = &id
  51222. }
  51223. }
  51224. // withXunjiService sets the old XunjiService of the mutation.
  51225. func withXunjiService(node *XunjiService) xunjiserviceOption {
  51226. return func(m *XunjiServiceMutation) {
  51227. m.oldValue = func(context.Context) (*XunjiService, error) {
  51228. return node, nil
  51229. }
  51230. m.id = &node.ID
  51231. }
  51232. }
  51233. // Client returns a new `ent.Client` from the mutation. If the mutation was
  51234. // executed in a transaction (ent.Tx), a transactional client is returned.
  51235. func (m XunjiServiceMutation) Client() *Client {
  51236. client := &Client{config: m.config}
  51237. client.init()
  51238. return client
  51239. }
  51240. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  51241. // it returns an error otherwise.
  51242. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  51243. if _, ok := m.driver.(*txDriver); !ok {
  51244. return nil, errors.New("ent: mutation is not running in a transaction")
  51245. }
  51246. tx := &Tx{config: m.config}
  51247. tx.init()
  51248. return tx, nil
  51249. }
  51250. // SetID sets the value of the id field. Note that this
  51251. // operation is only accepted on creation of XunjiService entities.
  51252. func (m *XunjiServiceMutation) SetID(id uint64) {
  51253. m.id = &id
  51254. }
  51255. // ID returns the ID value in the mutation. Note that the ID is only available
  51256. // if it was provided to the builder or after it was returned from the database.
  51257. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  51258. if m.id == nil {
  51259. return
  51260. }
  51261. return *m.id, true
  51262. }
  51263. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  51264. // That means, if the mutation is applied within a transaction with an isolation level such
  51265. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  51266. // or updated by the mutation.
  51267. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  51268. switch {
  51269. case m.op.Is(OpUpdateOne | OpDeleteOne):
  51270. id, exists := m.ID()
  51271. if exists {
  51272. return []uint64{id}, nil
  51273. }
  51274. fallthrough
  51275. case m.op.Is(OpUpdate | OpDelete):
  51276. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  51277. default:
  51278. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  51279. }
  51280. }
  51281. // SetCreatedAt sets the "created_at" field.
  51282. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  51283. m.created_at = &t
  51284. }
  51285. // CreatedAt returns the value of the "created_at" field in the mutation.
  51286. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  51287. v := m.created_at
  51288. if v == nil {
  51289. return
  51290. }
  51291. return *v, true
  51292. }
  51293. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  51294. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51296. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  51297. if !m.op.Is(OpUpdateOne) {
  51298. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  51299. }
  51300. if m.id == nil || m.oldValue == nil {
  51301. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  51302. }
  51303. oldValue, err := m.oldValue(ctx)
  51304. if err != nil {
  51305. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  51306. }
  51307. return oldValue.CreatedAt, nil
  51308. }
  51309. // ResetCreatedAt resets all changes to the "created_at" field.
  51310. func (m *XunjiServiceMutation) ResetCreatedAt() {
  51311. m.created_at = nil
  51312. }
  51313. // SetUpdatedAt sets the "updated_at" field.
  51314. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  51315. m.updated_at = &t
  51316. }
  51317. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  51318. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  51319. v := m.updated_at
  51320. if v == nil {
  51321. return
  51322. }
  51323. return *v, true
  51324. }
  51325. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  51326. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51328. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  51329. if !m.op.Is(OpUpdateOne) {
  51330. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  51331. }
  51332. if m.id == nil || m.oldValue == nil {
  51333. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  51334. }
  51335. oldValue, err := m.oldValue(ctx)
  51336. if err != nil {
  51337. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  51338. }
  51339. return oldValue.UpdatedAt, nil
  51340. }
  51341. // ResetUpdatedAt resets all changes to the "updated_at" field.
  51342. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  51343. m.updated_at = nil
  51344. }
  51345. // SetStatus sets the "status" field.
  51346. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  51347. m.status = &u
  51348. m.addstatus = nil
  51349. }
  51350. // Status returns the value of the "status" field in the mutation.
  51351. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  51352. v := m.status
  51353. if v == nil {
  51354. return
  51355. }
  51356. return *v, true
  51357. }
  51358. // OldStatus returns the old "status" field's value of the XunjiService entity.
  51359. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51361. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  51362. if !m.op.Is(OpUpdateOne) {
  51363. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  51364. }
  51365. if m.id == nil || m.oldValue == nil {
  51366. return v, errors.New("OldStatus requires an ID field in the mutation")
  51367. }
  51368. oldValue, err := m.oldValue(ctx)
  51369. if err != nil {
  51370. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  51371. }
  51372. return oldValue.Status, nil
  51373. }
  51374. // AddStatus adds u to the "status" field.
  51375. func (m *XunjiServiceMutation) AddStatus(u int8) {
  51376. if m.addstatus != nil {
  51377. *m.addstatus += u
  51378. } else {
  51379. m.addstatus = &u
  51380. }
  51381. }
  51382. // AddedStatus returns the value that was added to the "status" field in this mutation.
  51383. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  51384. v := m.addstatus
  51385. if v == nil {
  51386. return
  51387. }
  51388. return *v, true
  51389. }
  51390. // ClearStatus clears the value of the "status" field.
  51391. func (m *XunjiServiceMutation) ClearStatus() {
  51392. m.status = nil
  51393. m.addstatus = nil
  51394. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  51395. }
  51396. // StatusCleared returns if the "status" field was cleared in this mutation.
  51397. func (m *XunjiServiceMutation) StatusCleared() bool {
  51398. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  51399. return ok
  51400. }
  51401. // ResetStatus resets all changes to the "status" field.
  51402. func (m *XunjiServiceMutation) ResetStatus() {
  51403. m.status = nil
  51404. m.addstatus = nil
  51405. delete(m.clearedFields, xunjiservice.FieldStatus)
  51406. }
  51407. // SetDeletedAt sets the "deleted_at" field.
  51408. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  51409. m.deleted_at = &t
  51410. }
  51411. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  51412. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  51413. v := m.deleted_at
  51414. if v == nil {
  51415. return
  51416. }
  51417. return *v, true
  51418. }
  51419. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  51420. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51422. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  51423. if !m.op.Is(OpUpdateOne) {
  51424. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  51425. }
  51426. if m.id == nil || m.oldValue == nil {
  51427. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  51428. }
  51429. oldValue, err := m.oldValue(ctx)
  51430. if err != nil {
  51431. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  51432. }
  51433. return oldValue.DeletedAt, nil
  51434. }
  51435. // ClearDeletedAt clears the value of the "deleted_at" field.
  51436. func (m *XunjiServiceMutation) ClearDeletedAt() {
  51437. m.deleted_at = nil
  51438. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  51439. }
  51440. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  51441. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  51442. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  51443. return ok
  51444. }
  51445. // ResetDeletedAt resets all changes to the "deleted_at" field.
  51446. func (m *XunjiServiceMutation) ResetDeletedAt() {
  51447. m.deleted_at = nil
  51448. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  51449. }
  51450. // SetXunjiID sets the "xunji_id" field.
  51451. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  51452. m.xunji_id = &u
  51453. m.addxunji_id = nil
  51454. }
  51455. // XunjiID returns the value of the "xunji_id" field in the mutation.
  51456. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  51457. v := m.xunji_id
  51458. if v == nil {
  51459. return
  51460. }
  51461. return *v, true
  51462. }
  51463. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  51464. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51466. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  51467. if !m.op.Is(OpUpdateOne) {
  51468. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  51469. }
  51470. if m.id == nil || m.oldValue == nil {
  51471. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  51472. }
  51473. oldValue, err := m.oldValue(ctx)
  51474. if err != nil {
  51475. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  51476. }
  51477. return oldValue.XunjiID, nil
  51478. }
  51479. // AddXunjiID adds u to the "xunji_id" field.
  51480. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  51481. if m.addxunji_id != nil {
  51482. *m.addxunji_id += u
  51483. } else {
  51484. m.addxunji_id = &u
  51485. }
  51486. }
  51487. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  51488. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  51489. v := m.addxunji_id
  51490. if v == nil {
  51491. return
  51492. }
  51493. return *v, true
  51494. }
  51495. // ResetXunjiID resets all changes to the "xunji_id" field.
  51496. func (m *XunjiServiceMutation) ResetXunjiID() {
  51497. m.xunji_id = nil
  51498. m.addxunji_id = nil
  51499. }
  51500. // SetAgentID sets the "agent_id" field.
  51501. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  51502. m.agent = &u
  51503. }
  51504. // AgentID returns the value of the "agent_id" field in the mutation.
  51505. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  51506. v := m.agent
  51507. if v == nil {
  51508. return
  51509. }
  51510. return *v, true
  51511. }
  51512. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  51513. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51515. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  51516. if !m.op.Is(OpUpdateOne) {
  51517. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  51518. }
  51519. if m.id == nil || m.oldValue == nil {
  51520. return v, errors.New("OldAgentID requires an ID field in the mutation")
  51521. }
  51522. oldValue, err := m.oldValue(ctx)
  51523. if err != nil {
  51524. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  51525. }
  51526. return oldValue.AgentID, nil
  51527. }
  51528. // ResetAgentID resets all changes to the "agent_id" field.
  51529. func (m *XunjiServiceMutation) ResetAgentID() {
  51530. m.agent = nil
  51531. }
  51532. // SetOrganizationID sets the "organization_id" field.
  51533. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  51534. m.organization_id = &u
  51535. m.addorganization_id = nil
  51536. }
  51537. // OrganizationID returns the value of the "organization_id" field in the mutation.
  51538. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  51539. v := m.organization_id
  51540. if v == nil {
  51541. return
  51542. }
  51543. return *v, true
  51544. }
  51545. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  51546. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51548. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  51549. if !m.op.Is(OpUpdateOne) {
  51550. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  51551. }
  51552. if m.id == nil || m.oldValue == nil {
  51553. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  51554. }
  51555. oldValue, err := m.oldValue(ctx)
  51556. if err != nil {
  51557. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  51558. }
  51559. return oldValue.OrganizationID, nil
  51560. }
  51561. // AddOrganizationID adds u to the "organization_id" field.
  51562. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  51563. if m.addorganization_id != nil {
  51564. *m.addorganization_id += u
  51565. } else {
  51566. m.addorganization_id = &u
  51567. }
  51568. }
  51569. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  51570. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  51571. v := m.addorganization_id
  51572. if v == nil {
  51573. return
  51574. }
  51575. return *v, true
  51576. }
  51577. // ResetOrganizationID resets all changes to the "organization_id" field.
  51578. func (m *XunjiServiceMutation) ResetOrganizationID() {
  51579. m.organization_id = nil
  51580. m.addorganization_id = nil
  51581. }
  51582. // SetWxid sets the "wxid" field.
  51583. func (m *XunjiServiceMutation) SetWxid(s string) {
  51584. m.wxid = &s
  51585. }
  51586. // Wxid returns the value of the "wxid" field in the mutation.
  51587. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  51588. v := m.wxid
  51589. if v == nil {
  51590. return
  51591. }
  51592. return *v, true
  51593. }
  51594. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  51595. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51597. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  51598. if !m.op.Is(OpUpdateOne) {
  51599. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  51600. }
  51601. if m.id == nil || m.oldValue == nil {
  51602. return v, errors.New("OldWxid requires an ID field in the mutation")
  51603. }
  51604. oldValue, err := m.oldValue(ctx)
  51605. if err != nil {
  51606. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  51607. }
  51608. return oldValue.Wxid, nil
  51609. }
  51610. // ResetWxid resets all changes to the "wxid" field.
  51611. func (m *XunjiServiceMutation) ResetWxid() {
  51612. m.wxid = nil
  51613. }
  51614. // SetAPIBase sets the "api_base" field.
  51615. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  51616. m.api_base = &s
  51617. }
  51618. // APIBase returns the value of the "api_base" field in the mutation.
  51619. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  51620. v := m.api_base
  51621. if v == nil {
  51622. return
  51623. }
  51624. return *v, true
  51625. }
  51626. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  51627. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51629. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  51630. if !m.op.Is(OpUpdateOne) {
  51631. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  51632. }
  51633. if m.id == nil || m.oldValue == nil {
  51634. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  51635. }
  51636. oldValue, err := m.oldValue(ctx)
  51637. if err != nil {
  51638. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  51639. }
  51640. return oldValue.APIBase, nil
  51641. }
  51642. // ClearAPIBase clears the value of the "api_base" field.
  51643. func (m *XunjiServiceMutation) ClearAPIBase() {
  51644. m.api_base = nil
  51645. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  51646. }
  51647. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  51648. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  51649. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  51650. return ok
  51651. }
  51652. // ResetAPIBase resets all changes to the "api_base" field.
  51653. func (m *XunjiServiceMutation) ResetAPIBase() {
  51654. m.api_base = nil
  51655. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  51656. }
  51657. // SetAPIKey sets the "api_key" field.
  51658. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  51659. m.api_key = &s
  51660. }
  51661. // APIKey returns the value of the "api_key" field in the mutation.
  51662. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  51663. v := m.api_key
  51664. if v == nil {
  51665. return
  51666. }
  51667. return *v, true
  51668. }
  51669. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  51670. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51672. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  51673. if !m.op.Is(OpUpdateOne) {
  51674. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  51675. }
  51676. if m.id == nil || m.oldValue == nil {
  51677. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  51678. }
  51679. oldValue, err := m.oldValue(ctx)
  51680. if err != nil {
  51681. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  51682. }
  51683. return oldValue.APIKey, nil
  51684. }
  51685. // ClearAPIKey clears the value of the "api_key" field.
  51686. func (m *XunjiServiceMutation) ClearAPIKey() {
  51687. m.api_key = nil
  51688. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  51689. }
  51690. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  51691. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  51692. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  51693. return ok
  51694. }
  51695. // ResetAPIKey resets all changes to the "api_key" field.
  51696. func (m *XunjiServiceMutation) ResetAPIKey() {
  51697. m.api_key = nil
  51698. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  51699. }
  51700. // ClearAgent clears the "agent" edge to the Agent entity.
  51701. func (m *XunjiServiceMutation) ClearAgent() {
  51702. m.clearedagent = true
  51703. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  51704. }
  51705. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  51706. func (m *XunjiServiceMutation) AgentCleared() bool {
  51707. return m.clearedagent
  51708. }
  51709. // AgentIDs returns the "agent" edge IDs in the mutation.
  51710. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  51711. // AgentID instead. It exists only for internal usage by the builders.
  51712. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  51713. if id := m.agent; id != nil {
  51714. ids = append(ids, *id)
  51715. }
  51716. return
  51717. }
  51718. // ResetAgent resets all changes to the "agent" edge.
  51719. func (m *XunjiServiceMutation) ResetAgent() {
  51720. m.agent = nil
  51721. m.clearedagent = false
  51722. }
  51723. // Where appends a list predicates to the XunjiServiceMutation builder.
  51724. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  51725. m.predicates = append(m.predicates, ps...)
  51726. }
  51727. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  51728. // users can use type-assertion to append predicates that do not depend on any generated package.
  51729. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  51730. p := make([]predicate.XunjiService, len(ps))
  51731. for i := range ps {
  51732. p[i] = ps[i]
  51733. }
  51734. m.Where(p...)
  51735. }
  51736. // Op returns the operation name.
  51737. func (m *XunjiServiceMutation) Op() Op {
  51738. return m.op
  51739. }
  51740. // SetOp allows setting the mutation operation.
  51741. func (m *XunjiServiceMutation) SetOp(op Op) {
  51742. m.op = op
  51743. }
  51744. // Type returns the node type of this mutation (XunjiService).
  51745. func (m *XunjiServiceMutation) Type() string {
  51746. return m.typ
  51747. }
  51748. // Fields returns all fields that were changed during this mutation. Note that in
  51749. // order to get all numeric fields that were incremented/decremented, call
  51750. // AddedFields().
  51751. func (m *XunjiServiceMutation) Fields() []string {
  51752. fields := make([]string, 0, 10)
  51753. if m.created_at != nil {
  51754. fields = append(fields, xunjiservice.FieldCreatedAt)
  51755. }
  51756. if m.updated_at != nil {
  51757. fields = append(fields, xunjiservice.FieldUpdatedAt)
  51758. }
  51759. if m.status != nil {
  51760. fields = append(fields, xunjiservice.FieldStatus)
  51761. }
  51762. if m.deleted_at != nil {
  51763. fields = append(fields, xunjiservice.FieldDeletedAt)
  51764. }
  51765. if m.xunji_id != nil {
  51766. fields = append(fields, xunjiservice.FieldXunjiID)
  51767. }
  51768. if m.agent != nil {
  51769. fields = append(fields, xunjiservice.FieldAgentID)
  51770. }
  51771. if m.organization_id != nil {
  51772. fields = append(fields, xunjiservice.FieldOrganizationID)
  51773. }
  51774. if m.wxid != nil {
  51775. fields = append(fields, xunjiservice.FieldWxid)
  51776. }
  51777. if m.api_base != nil {
  51778. fields = append(fields, xunjiservice.FieldAPIBase)
  51779. }
  51780. if m.api_key != nil {
  51781. fields = append(fields, xunjiservice.FieldAPIKey)
  51782. }
  51783. return fields
  51784. }
  51785. // Field returns the value of a field with the given name. The second boolean
  51786. // return value indicates that this field was not set, or was not defined in the
  51787. // schema.
  51788. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  51789. switch name {
  51790. case xunjiservice.FieldCreatedAt:
  51791. return m.CreatedAt()
  51792. case xunjiservice.FieldUpdatedAt:
  51793. return m.UpdatedAt()
  51794. case xunjiservice.FieldStatus:
  51795. return m.Status()
  51796. case xunjiservice.FieldDeletedAt:
  51797. return m.DeletedAt()
  51798. case xunjiservice.FieldXunjiID:
  51799. return m.XunjiID()
  51800. case xunjiservice.FieldAgentID:
  51801. return m.AgentID()
  51802. case xunjiservice.FieldOrganizationID:
  51803. return m.OrganizationID()
  51804. case xunjiservice.FieldWxid:
  51805. return m.Wxid()
  51806. case xunjiservice.FieldAPIBase:
  51807. return m.APIBase()
  51808. case xunjiservice.FieldAPIKey:
  51809. return m.APIKey()
  51810. }
  51811. return nil, false
  51812. }
  51813. // OldField returns the old value of the field from the database. An error is
  51814. // returned if the mutation operation is not UpdateOne, or the query to the
  51815. // database failed.
  51816. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  51817. switch name {
  51818. case xunjiservice.FieldCreatedAt:
  51819. return m.OldCreatedAt(ctx)
  51820. case xunjiservice.FieldUpdatedAt:
  51821. return m.OldUpdatedAt(ctx)
  51822. case xunjiservice.FieldStatus:
  51823. return m.OldStatus(ctx)
  51824. case xunjiservice.FieldDeletedAt:
  51825. return m.OldDeletedAt(ctx)
  51826. case xunjiservice.FieldXunjiID:
  51827. return m.OldXunjiID(ctx)
  51828. case xunjiservice.FieldAgentID:
  51829. return m.OldAgentID(ctx)
  51830. case xunjiservice.FieldOrganizationID:
  51831. return m.OldOrganizationID(ctx)
  51832. case xunjiservice.FieldWxid:
  51833. return m.OldWxid(ctx)
  51834. case xunjiservice.FieldAPIBase:
  51835. return m.OldAPIBase(ctx)
  51836. case xunjiservice.FieldAPIKey:
  51837. return m.OldAPIKey(ctx)
  51838. }
  51839. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  51840. }
  51841. // SetField sets the value of a field with the given name. It returns an error if
  51842. // the field is not defined in the schema, or if the type mismatched the field
  51843. // type.
  51844. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  51845. switch name {
  51846. case xunjiservice.FieldCreatedAt:
  51847. v, ok := value.(time.Time)
  51848. if !ok {
  51849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51850. }
  51851. m.SetCreatedAt(v)
  51852. return nil
  51853. case xunjiservice.FieldUpdatedAt:
  51854. v, ok := value.(time.Time)
  51855. if !ok {
  51856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51857. }
  51858. m.SetUpdatedAt(v)
  51859. return nil
  51860. case xunjiservice.FieldStatus:
  51861. v, ok := value.(uint8)
  51862. if !ok {
  51863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51864. }
  51865. m.SetStatus(v)
  51866. return nil
  51867. case xunjiservice.FieldDeletedAt:
  51868. v, ok := value.(time.Time)
  51869. if !ok {
  51870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51871. }
  51872. m.SetDeletedAt(v)
  51873. return nil
  51874. case xunjiservice.FieldXunjiID:
  51875. v, ok := value.(uint64)
  51876. if !ok {
  51877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51878. }
  51879. m.SetXunjiID(v)
  51880. return nil
  51881. case xunjiservice.FieldAgentID:
  51882. v, ok := value.(uint64)
  51883. if !ok {
  51884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51885. }
  51886. m.SetAgentID(v)
  51887. return nil
  51888. case xunjiservice.FieldOrganizationID:
  51889. v, ok := value.(uint64)
  51890. if !ok {
  51891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51892. }
  51893. m.SetOrganizationID(v)
  51894. return nil
  51895. case xunjiservice.FieldWxid:
  51896. v, ok := value.(string)
  51897. if !ok {
  51898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51899. }
  51900. m.SetWxid(v)
  51901. return nil
  51902. case xunjiservice.FieldAPIBase:
  51903. v, ok := value.(string)
  51904. if !ok {
  51905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51906. }
  51907. m.SetAPIBase(v)
  51908. return nil
  51909. case xunjiservice.FieldAPIKey:
  51910. v, ok := value.(string)
  51911. if !ok {
  51912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51913. }
  51914. m.SetAPIKey(v)
  51915. return nil
  51916. }
  51917. return fmt.Errorf("unknown XunjiService field %s", name)
  51918. }
  51919. // AddedFields returns all numeric fields that were incremented/decremented during
  51920. // this mutation.
  51921. func (m *XunjiServiceMutation) AddedFields() []string {
  51922. var fields []string
  51923. if m.addstatus != nil {
  51924. fields = append(fields, xunjiservice.FieldStatus)
  51925. }
  51926. if m.addxunji_id != nil {
  51927. fields = append(fields, xunjiservice.FieldXunjiID)
  51928. }
  51929. if m.addorganization_id != nil {
  51930. fields = append(fields, xunjiservice.FieldOrganizationID)
  51931. }
  51932. return fields
  51933. }
  51934. // AddedField returns the numeric value that was incremented/decremented on a field
  51935. // with the given name. The second boolean return value indicates that this field
  51936. // was not set, or was not defined in the schema.
  51937. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  51938. switch name {
  51939. case xunjiservice.FieldStatus:
  51940. return m.AddedStatus()
  51941. case xunjiservice.FieldXunjiID:
  51942. return m.AddedXunjiID()
  51943. case xunjiservice.FieldOrganizationID:
  51944. return m.AddedOrganizationID()
  51945. }
  51946. return nil, false
  51947. }
  51948. // AddField adds the value to the field with the given name. It returns an error if
  51949. // the field is not defined in the schema, or if the type mismatched the field
  51950. // type.
  51951. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  51952. switch name {
  51953. case xunjiservice.FieldStatus:
  51954. v, ok := value.(int8)
  51955. if !ok {
  51956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51957. }
  51958. m.AddStatus(v)
  51959. return nil
  51960. case xunjiservice.FieldXunjiID:
  51961. v, ok := value.(int64)
  51962. if !ok {
  51963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51964. }
  51965. m.AddXunjiID(v)
  51966. return nil
  51967. case xunjiservice.FieldOrganizationID:
  51968. v, ok := value.(int64)
  51969. if !ok {
  51970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51971. }
  51972. m.AddOrganizationID(v)
  51973. return nil
  51974. }
  51975. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  51976. }
  51977. // ClearedFields returns all nullable fields that were cleared during this
  51978. // mutation.
  51979. func (m *XunjiServiceMutation) ClearedFields() []string {
  51980. var fields []string
  51981. if m.FieldCleared(xunjiservice.FieldStatus) {
  51982. fields = append(fields, xunjiservice.FieldStatus)
  51983. }
  51984. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  51985. fields = append(fields, xunjiservice.FieldDeletedAt)
  51986. }
  51987. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  51988. fields = append(fields, xunjiservice.FieldAPIBase)
  51989. }
  51990. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  51991. fields = append(fields, xunjiservice.FieldAPIKey)
  51992. }
  51993. return fields
  51994. }
  51995. // FieldCleared returns a boolean indicating if a field with the given name was
  51996. // cleared in this mutation.
  51997. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  51998. _, ok := m.clearedFields[name]
  51999. return ok
  52000. }
  52001. // ClearField clears the value of the field with the given name. It returns an
  52002. // error if the field is not defined in the schema.
  52003. func (m *XunjiServiceMutation) ClearField(name string) error {
  52004. switch name {
  52005. case xunjiservice.FieldStatus:
  52006. m.ClearStatus()
  52007. return nil
  52008. case xunjiservice.FieldDeletedAt:
  52009. m.ClearDeletedAt()
  52010. return nil
  52011. case xunjiservice.FieldAPIBase:
  52012. m.ClearAPIBase()
  52013. return nil
  52014. case xunjiservice.FieldAPIKey:
  52015. m.ClearAPIKey()
  52016. return nil
  52017. }
  52018. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  52019. }
  52020. // ResetField resets all changes in the mutation for the field with the given name.
  52021. // It returns an error if the field is not defined in the schema.
  52022. func (m *XunjiServiceMutation) ResetField(name string) error {
  52023. switch name {
  52024. case xunjiservice.FieldCreatedAt:
  52025. m.ResetCreatedAt()
  52026. return nil
  52027. case xunjiservice.FieldUpdatedAt:
  52028. m.ResetUpdatedAt()
  52029. return nil
  52030. case xunjiservice.FieldStatus:
  52031. m.ResetStatus()
  52032. return nil
  52033. case xunjiservice.FieldDeletedAt:
  52034. m.ResetDeletedAt()
  52035. return nil
  52036. case xunjiservice.FieldXunjiID:
  52037. m.ResetXunjiID()
  52038. return nil
  52039. case xunjiservice.FieldAgentID:
  52040. m.ResetAgentID()
  52041. return nil
  52042. case xunjiservice.FieldOrganizationID:
  52043. m.ResetOrganizationID()
  52044. return nil
  52045. case xunjiservice.FieldWxid:
  52046. m.ResetWxid()
  52047. return nil
  52048. case xunjiservice.FieldAPIBase:
  52049. m.ResetAPIBase()
  52050. return nil
  52051. case xunjiservice.FieldAPIKey:
  52052. m.ResetAPIKey()
  52053. return nil
  52054. }
  52055. return fmt.Errorf("unknown XunjiService field %s", name)
  52056. }
  52057. // AddedEdges returns all edge names that were set/added in this mutation.
  52058. func (m *XunjiServiceMutation) AddedEdges() []string {
  52059. edges := make([]string, 0, 1)
  52060. if m.agent != nil {
  52061. edges = append(edges, xunjiservice.EdgeAgent)
  52062. }
  52063. return edges
  52064. }
  52065. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  52066. // name in this mutation.
  52067. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  52068. switch name {
  52069. case xunjiservice.EdgeAgent:
  52070. if id := m.agent; id != nil {
  52071. return []ent.Value{*id}
  52072. }
  52073. }
  52074. return nil
  52075. }
  52076. // RemovedEdges returns all edge names that were removed in this mutation.
  52077. func (m *XunjiServiceMutation) RemovedEdges() []string {
  52078. edges := make([]string, 0, 1)
  52079. return edges
  52080. }
  52081. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  52082. // the given name in this mutation.
  52083. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  52084. return nil
  52085. }
  52086. // ClearedEdges returns all edge names that were cleared in this mutation.
  52087. func (m *XunjiServiceMutation) ClearedEdges() []string {
  52088. edges := make([]string, 0, 1)
  52089. if m.clearedagent {
  52090. edges = append(edges, xunjiservice.EdgeAgent)
  52091. }
  52092. return edges
  52093. }
  52094. // EdgeCleared returns a boolean which indicates if the edge with the given name
  52095. // was cleared in this mutation.
  52096. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  52097. switch name {
  52098. case xunjiservice.EdgeAgent:
  52099. return m.clearedagent
  52100. }
  52101. return false
  52102. }
  52103. // ClearEdge clears the value of the edge with the given name. It returns an error
  52104. // if that edge is not defined in the schema.
  52105. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  52106. switch name {
  52107. case xunjiservice.EdgeAgent:
  52108. m.ClearAgent()
  52109. return nil
  52110. }
  52111. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  52112. }
  52113. // ResetEdge resets all changes to the edge with the given name in this mutation.
  52114. // It returns an error if the edge is not defined in the schema.
  52115. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  52116. switch name {
  52117. case xunjiservice.EdgeAgent:
  52118. m.ResetAgent()
  52119. return nil
  52120. }
  52121. return fmt.Errorf("unknown XunjiService edge %s", name)
  52122. }