mutation.go 1.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205
  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. credits *float64
  39627. addcredits *float64
  39628. start_index *uint64
  39629. addstart_index *int64
  39630. end_index *uint64
  39631. addend_index *int64
  39632. organization_id *uint64
  39633. addorganization_id *int64
  39634. clearedFields map[string]struct{}
  39635. done bool
  39636. oldValue func(context.Context) (*UsageTotal, error)
  39637. predicates []predicate.UsageTotal
  39638. }
  39639. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  39640. // usagetotalOption allows management of the mutation configuration using functional options.
  39641. type usagetotalOption func(*UsageTotalMutation)
  39642. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  39643. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  39644. m := &UsageTotalMutation{
  39645. config: c,
  39646. op: op,
  39647. typ: TypeUsageTotal,
  39648. clearedFields: make(map[string]struct{}),
  39649. }
  39650. for _, opt := range opts {
  39651. opt(m)
  39652. }
  39653. return m
  39654. }
  39655. // withUsageTotalID sets the ID field of the mutation.
  39656. func withUsageTotalID(id uint64) usagetotalOption {
  39657. return func(m *UsageTotalMutation) {
  39658. var (
  39659. err error
  39660. once sync.Once
  39661. value *UsageTotal
  39662. )
  39663. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  39664. once.Do(func() {
  39665. if m.done {
  39666. err = errors.New("querying old values post mutation is not allowed")
  39667. } else {
  39668. value, err = m.Client().UsageTotal.Get(ctx, id)
  39669. }
  39670. })
  39671. return value, err
  39672. }
  39673. m.id = &id
  39674. }
  39675. }
  39676. // withUsageTotal sets the old UsageTotal of the mutation.
  39677. func withUsageTotal(node *UsageTotal) usagetotalOption {
  39678. return func(m *UsageTotalMutation) {
  39679. m.oldValue = func(context.Context) (*UsageTotal, error) {
  39680. return node, nil
  39681. }
  39682. m.id = &node.ID
  39683. }
  39684. }
  39685. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39686. // executed in a transaction (ent.Tx), a transactional client is returned.
  39687. func (m UsageTotalMutation) Client() *Client {
  39688. client := &Client{config: m.config}
  39689. client.init()
  39690. return client
  39691. }
  39692. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39693. // it returns an error otherwise.
  39694. func (m UsageTotalMutation) Tx() (*Tx, error) {
  39695. if _, ok := m.driver.(*txDriver); !ok {
  39696. return nil, errors.New("ent: mutation is not running in a transaction")
  39697. }
  39698. tx := &Tx{config: m.config}
  39699. tx.init()
  39700. return tx, nil
  39701. }
  39702. // SetID sets the value of the id field. Note that this
  39703. // operation is only accepted on creation of UsageTotal entities.
  39704. func (m *UsageTotalMutation) SetID(id uint64) {
  39705. m.id = &id
  39706. }
  39707. // ID returns the ID value in the mutation. Note that the ID is only available
  39708. // if it was provided to the builder or after it was returned from the database.
  39709. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  39710. if m.id == nil {
  39711. return
  39712. }
  39713. return *m.id, true
  39714. }
  39715. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39716. // That means, if the mutation is applied within a transaction with an isolation level such
  39717. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39718. // or updated by the mutation.
  39719. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  39720. switch {
  39721. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39722. id, exists := m.ID()
  39723. if exists {
  39724. return []uint64{id}, nil
  39725. }
  39726. fallthrough
  39727. case m.op.Is(OpUpdate | OpDelete):
  39728. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  39729. default:
  39730. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39731. }
  39732. }
  39733. // SetCreatedAt sets the "created_at" field.
  39734. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  39735. m.created_at = &t
  39736. }
  39737. // CreatedAt returns the value of the "created_at" field in the mutation.
  39738. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  39739. v := m.created_at
  39740. if v == nil {
  39741. return
  39742. }
  39743. return *v, true
  39744. }
  39745. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  39746. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39748. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39749. if !m.op.Is(OpUpdateOne) {
  39750. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39751. }
  39752. if m.id == nil || m.oldValue == nil {
  39753. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39754. }
  39755. oldValue, err := m.oldValue(ctx)
  39756. if err != nil {
  39757. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39758. }
  39759. return oldValue.CreatedAt, nil
  39760. }
  39761. // ResetCreatedAt resets all changes to the "created_at" field.
  39762. func (m *UsageTotalMutation) ResetCreatedAt() {
  39763. m.created_at = nil
  39764. }
  39765. // SetUpdatedAt sets the "updated_at" field.
  39766. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  39767. m.updated_at = &t
  39768. }
  39769. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39770. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  39771. v := m.updated_at
  39772. if v == nil {
  39773. return
  39774. }
  39775. return *v, true
  39776. }
  39777. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  39778. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39780. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39781. if !m.op.Is(OpUpdateOne) {
  39782. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39783. }
  39784. if m.id == nil || m.oldValue == nil {
  39785. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39786. }
  39787. oldValue, err := m.oldValue(ctx)
  39788. if err != nil {
  39789. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39790. }
  39791. return oldValue.UpdatedAt, nil
  39792. }
  39793. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39794. func (m *UsageTotalMutation) ResetUpdatedAt() {
  39795. m.updated_at = nil
  39796. }
  39797. // SetStatus sets the "status" field.
  39798. func (m *UsageTotalMutation) SetStatus(u uint8) {
  39799. m.status = &u
  39800. m.addstatus = nil
  39801. }
  39802. // Status returns the value of the "status" field in the mutation.
  39803. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  39804. v := m.status
  39805. if v == nil {
  39806. return
  39807. }
  39808. return *v, true
  39809. }
  39810. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  39811. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39813. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39814. if !m.op.Is(OpUpdateOne) {
  39815. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39816. }
  39817. if m.id == nil || m.oldValue == nil {
  39818. return v, errors.New("OldStatus requires an ID field in the mutation")
  39819. }
  39820. oldValue, err := m.oldValue(ctx)
  39821. if err != nil {
  39822. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39823. }
  39824. return oldValue.Status, nil
  39825. }
  39826. // AddStatus adds u to the "status" field.
  39827. func (m *UsageTotalMutation) AddStatus(u int8) {
  39828. if m.addstatus != nil {
  39829. *m.addstatus += u
  39830. } else {
  39831. m.addstatus = &u
  39832. }
  39833. }
  39834. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39835. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  39836. v := m.addstatus
  39837. if v == nil {
  39838. return
  39839. }
  39840. return *v, true
  39841. }
  39842. // ClearStatus clears the value of the "status" field.
  39843. func (m *UsageTotalMutation) ClearStatus() {
  39844. m.status = nil
  39845. m.addstatus = nil
  39846. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  39847. }
  39848. // StatusCleared returns if the "status" field was cleared in this mutation.
  39849. func (m *UsageTotalMutation) StatusCleared() bool {
  39850. _, ok := m.clearedFields[usagetotal.FieldStatus]
  39851. return ok
  39852. }
  39853. // ResetStatus resets all changes to the "status" field.
  39854. func (m *UsageTotalMutation) ResetStatus() {
  39855. m.status = nil
  39856. m.addstatus = nil
  39857. delete(m.clearedFields, usagetotal.FieldStatus)
  39858. }
  39859. // SetType sets the "type" field.
  39860. func (m *UsageTotalMutation) SetType(i int) {
  39861. m._type = &i
  39862. m.add_type = nil
  39863. }
  39864. // GetType returns the value of the "type" field in the mutation.
  39865. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  39866. v := m._type
  39867. if v == nil {
  39868. return
  39869. }
  39870. return *v, true
  39871. }
  39872. // OldType returns the old "type" field's value of the UsageTotal entity.
  39873. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39875. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  39876. if !m.op.Is(OpUpdateOne) {
  39877. return v, errors.New("OldType is only allowed on UpdateOne operations")
  39878. }
  39879. if m.id == nil || m.oldValue == nil {
  39880. return v, errors.New("OldType requires an ID field in the mutation")
  39881. }
  39882. oldValue, err := m.oldValue(ctx)
  39883. if err != nil {
  39884. return v, fmt.Errorf("querying old value for OldType: %w", err)
  39885. }
  39886. return oldValue.Type, nil
  39887. }
  39888. // AddType adds i to the "type" field.
  39889. func (m *UsageTotalMutation) AddType(i int) {
  39890. if m.add_type != nil {
  39891. *m.add_type += i
  39892. } else {
  39893. m.add_type = &i
  39894. }
  39895. }
  39896. // AddedType returns the value that was added to the "type" field in this mutation.
  39897. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  39898. v := m.add_type
  39899. if v == nil {
  39900. return
  39901. }
  39902. return *v, true
  39903. }
  39904. // ClearType clears the value of the "type" field.
  39905. func (m *UsageTotalMutation) ClearType() {
  39906. m._type = nil
  39907. m.add_type = nil
  39908. m.clearedFields[usagetotal.FieldType] = struct{}{}
  39909. }
  39910. // TypeCleared returns if the "type" field was cleared in this mutation.
  39911. func (m *UsageTotalMutation) TypeCleared() bool {
  39912. _, ok := m.clearedFields[usagetotal.FieldType]
  39913. return ok
  39914. }
  39915. // ResetType resets all changes to the "type" field.
  39916. func (m *UsageTotalMutation) ResetType() {
  39917. m._type = nil
  39918. m.add_type = nil
  39919. delete(m.clearedFields, usagetotal.FieldType)
  39920. }
  39921. // SetBotID sets the "bot_id" field.
  39922. func (m *UsageTotalMutation) SetBotID(s string) {
  39923. m.bot_id = &s
  39924. }
  39925. // BotID returns the value of the "bot_id" field in the mutation.
  39926. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  39927. v := m.bot_id
  39928. if v == nil {
  39929. return
  39930. }
  39931. return *v, true
  39932. }
  39933. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  39934. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39936. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  39937. if !m.op.Is(OpUpdateOne) {
  39938. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  39939. }
  39940. if m.id == nil || m.oldValue == nil {
  39941. return v, errors.New("OldBotID requires an ID field in the mutation")
  39942. }
  39943. oldValue, err := m.oldValue(ctx)
  39944. if err != nil {
  39945. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  39946. }
  39947. return oldValue.BotID, nil
  39948. }
  39949. // ResetBotID resets all changes to the "bot_id" field.
  39950. func (m *UsageTotalMutation) ResetBotID() {
  39951. m.bot_id = nil
  39952. }
  39953. // SetTotalTokens sets the "total_tokens" field.
  39954. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  39955. m.total_tokens = &u
  39956. m.addtotal_tokens = nil
  39957. }
  39958. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  39959. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  39960. v := m.total_tokens
  39961. if v == nil {
  39962. return
  39963. }
  39964. return *v, true
  39965. }
  39966. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  39967. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39969. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  39970. if !m.op.Is(OpUpdateOne) {
  39971. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  39972. }
  39973. if m.id == nil || m.oldValue == nil {
  39974. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  39975. }
  39976. oldValue, err := m.oldValue(ctx)
  39977. if err != nil {
  39978. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  39979. }
  39980. return oldValue.TotalTokens, nil
  39981. }
  39982. // AddTotalTokens adds u to the "total_tokens" field.
  39983. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  39984. if m.addtotal_tokens != nil {
  39985. *m.addtotal_tokens += u
  39986. } else {
  39987. m.addtotal_tokens = &u
  39988. }
  39989. }
  39990. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  39991. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  39992. v := m.addtotal_tokens
  39993. if v == nil {
  39994. return
  39995. }
  39996. return *v, true
  39997. }
  39998. // ClearTotalTokens clears the value of the "total_tokens" field.
  39999. func (m *UsageTotalMutation) ClearTotalTokens() {
  40000. m.total_tokens = nil
  40001. m.addtotal_tokens = nil
  40002. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  40003. }
  40004. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  40005. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  40006. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  40007. return ok
  40008. }
  40009. // ResetTotalTokens resets all changes to the "total_tokens" field.
  40010. func (m *UsageTotalMutation) ResetTotalTokens() {
  40011. m.total_tokens = nil
  40012. m.addtotal_tokens = nil
  40013. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  40014. }
  40015. // SetCredits sets the "credits" field.
  40016. func (m *UsageTotalMutation) SetCredits(f float64) {
  40017. m.credits = &f
  40018. m.addcredits = nil
  40019. }
  40020. // Credits returns the value of the "credits" field in the mutation.
  40021. func (m *UsageTotalMutation) Credits() (r float64, exists bool) {
  40022. v := m.credits
  40023. if v == nil {
  40024. return
  40025. }
  40026. return *v, true
  40027. }
  40028. // OldCredits returns the old "credits" field's value of the UsageTotal entity.
  40029. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40031. func (m *UsageTotalMutation) OldCredits(ctx context.Context) (v float64, err error) {
  40032. if !m.op.Is(OpUpdateOne) {
  40033. return v, errors.New("OldCredits is only allowed on UpdateOne operations")
  40034. }
  40035. if m.id == nil || m.oldValue == nil {
  40036. return v, errors.New("OldCredits requires an ID field in the mutation")
  40037. }
  40038. oldValue, err := m.oldValue(ctx)
  40039. if err != nil {
  40040. return v, fmt.Errorf("querying old value for OldCredits: %w", err)
  40041. }
  40042. return oldValue.Credits, nil
  40043. }
  40044. // AddCredits adds f to the "credits" field.
  40045. func (m *UsageTotalMutation) AddCredits(f float64) {
  40046. if m.addcredits != nil {
  40047. *m.addcredits += f
  40048. } else {
  40049. m.addcredits = &f
  40050. }
  40051. }
  40052. // AddedCredits returns the value that was added to the "credits" field in this mutation.
  40053. func (m *UsageTotalMutation) AddedCredits() (r float64, exists bool) {
  40054. v := m.addcredits
  40055. if v == nil {
  40056. return
  40057. }
  40058. return *v, true
  40059. }
  40060. // ClearCredits clears the value of the "credits" field.
  40061. func (m *UsageTotalMutation) ClearCredits() {
  40062. m.credits = nil
  40063. m.addcredits = nil
  40064. m.clearedFields[usagetotal.FieldCredits] = struct{}{}
  40065. }
  40066. // CreditsCleared returns if the "credits" field was cleared in this mutation.
  40067. func (m *UsageTotalMutation) CreditsCleared() bool {
  40068. _, ok := m.clearedFields[usagetotal.FieldCredits]
  40069. return ok
  40070. }
  40071. // ResetCredits resets all changes to the "credits" field.
  40072. func (m *UsageTotalMutation) ResetCredits() {
  40073. m.credits = nil
  40074. m.addcredits = nil
  40075. delete(m.clearedFields, usagetotal.FieldCredits)
  40076. }
  40077. // SetStartIndex sets the "start_index" field.
  40078. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  40079. m.start_index = &u
  40080. m.addstart_index = nil
  40081. }
  40082. // StartIndex returns the value of the "start_index" field in the mutation.
  40083. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  40084. v := m.start_index
  40085. if v == nil {
  40086. return
  40087. }
  40088. return *v, true
  40089. }
  40090. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  40091. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40093. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  40094. if !m.op.Is(OpUpdateOne) {
  40095. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  40096. }
  40097. if m.id == nil || m.oldValue == nil {
  40098. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  40099. }
  40100. oldValue, err := m.oldValue(ctx)
  40101. if err != nil {
  40102. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  40103. }
  40104. return oldValue.StartIndex, nil
  40105. }
  40106. // AddStartIndex adds u to the "start_index" field.
  40107. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  40108. if m.addstart_index != nil {
  40109. *m.addstart_index += u
  40110. } else {
  40111. m.addstart_index = &u
  40112. }
  40113. }
  40114. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  40115. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  40116. v := m.addstart_index
  40117. if v == nil {
  40118. return
  40119. }
  40120. return *v, true
  40121. }
  40122. // ClearStartIndex clears the value of the "start_index" field.
  40123. func (m *UsageTotalMutation) ClearStartIndex() {
  40124. m.start_index = nil
  40125. m.addstart_index = nil
  40126. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  40127. }
  40128. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  40129. func (m *UsageTotalMutation) StartIndexCleared() bool {
  40130. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  40131. return ok
  40132. }
  40133. // ResetStartIndex resets all changes to the "start_index" field.
  40134. func (m *UsageTotalMutation) ResetStartIndex() {
  40135. m.start_index = nil
  40136. m.addstart_index = nil
  40137. delete(m.clearedFields, usagetotal.FieldStartIndex)
  40138. }
  40139. // SetEndIndex sets the "end_index" field.
  40140. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  40141. m.end_index = &u
  40142. m.addend_index = nil
  40143. }
  40144. // EndIndex returns the value of the "end_index" field in the mutation.
  40145. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  40146. v := m.end_index
  40147. if v == nil {
  40148. return
  40149. }
  40150. return *v, true
  40151. }
  40152. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  40153. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40155. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  40156. if !m.op.Is(OpUpdateOne) {
  40157. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  40158. }
  40159. if m.id == nil || m.oldValue == nil {
  40160. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  40161. }
  40162. oldValue, err := m.oldValue(ctx)
  40163. if err != nil {
  40164. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  40165. }
  40166. return oldValue.EndIndex, nil
  40167. }
  40168. // AddEndIndex adds u to the "end_index" field.
  40169. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  40170. if m.addend_index != nil {
  40171. *m.addend_index += u
  40172. } else {
  40173. m.addend_index = &u
  40174. }
  40175. }
  40176. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  40177. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  40178. v := m.addend_index
  40179. if v == nil {
  40180. return
  40181. }
  40182. return *v, true
  40183. }
  40184. // ClearEndIndex clears the value of the "end_index" field.
  40185. func (m *UsageTotalMutation) ClearEndIndex() {
  40186. m.end_index = nil
  40187. m.addend_index = nil
  40188. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  40189. }
  40190. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  40191. func (m *UsageTotalMutation) EndIndexCleared() bool {
  40192. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  40193. return ok
  40194. }
  40195. // ResetEndIndex resets all changes to the "end_index" field.
  40196. func (m *UsageTotalMutation) ResetEndIndex() {
  40197. m.end_index = nil
  40198. m.addend_index = nil
  40199. delete(m.clearedFields, usagetotal.FieldEndIndex)
  40200. }
  40201. // SetOrganizationID sets the "organization_id" field.
  40202. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  40203. m.organization_id = &u
  40204. m.addorganization_id = nil
  40205. }
  40206. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40207. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  40208. v := m.organization_id
  40209. if v == nil {
  40210. return
  40211. }
  40212. return *v, true
  40213. }
  40214. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  40215. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40217. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40218. if !m.op.Is(OpUpdateOne) {
  40219. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40220. }
  40221. if m.id == nil || m.oldValue == nil {
  40222. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40223. }
  40224. oldValue, err := m.oldValue(ctx)
  40225. if err != nil {
  40226. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40227. }
  40228. return oldValue.OrganizationID, nil
  40229. }
  40230. // AddOrganizationID adds u to the "organization_id" field.
  40231. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  40232. if m.addorganization_id != nil {
  40233. *m.addorganization_id += u
  40234. } else {
  40235. m.addorganization_id = &u
  40236. }
  40237. }
  40238. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40239. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  40240. v := m.addorganization_id
  40241. if v == nil {
  40242. return
  40243. }
  40244. return *v, true
  40245. }
  40246. // ClearOrganizationID clears the value of the "organization_id" field.
  40247. func (m *UsageTotalMutation) ClearOrganizationID() {
  40248. m.organization_id = nil
  40249. m.addorganization_id = nil
  40250. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  40251. }
  40252. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40253. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  40254. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  40255. return ok
  40256. }
  40257. // ResetOrganizationID resets all changes to the "organization_id" field.
  40258. func (m *UsageTotalMutation) ResetOrganizationID() {
  40259. m.organization_id = nil
  40260. m.addorganization_id = nil
  40261. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  40262. }
  40263. // Where appends a list predicates to the UsageTotalMutation builder.
  40264. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  40265. m.predicates = append(m.predicates, ps...)
  40266. }
  40267. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  40268. // users can use type-assertion to append predicates that do not depend on any generated package.
  40269. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  40270. p := make([]predicate.UsageTotal, len(ps))
  40271. for i := range ps {
  40272. p[i] = ps[i]
  40273. }
  40274. m.Where(p...)
  40275. }
  40276. // Op returns the operation name.
  40277. func (m *UsageTotalMutation) Op() Op {
  40278. return m.op
  40279. }
  40280. // SetOp allows setting the mutation operation.
  40281. func (m *UsageTotalMutation) SetOp(op Op) {
  40282. m.op = op
  40283. }
  40284. // Type returns the node type of this mutation (UsageTotal).
  40285. func (m *UsageTotalMutation) Type() string {
  40286. return m.typ
  40287. }
  40288. // Fields returns all fields that were changed during this mutation. Note that in
  40289. // order to get all numeric fields that were incremented/decremented, call
  40290. // AddedFields().
  40291. func (m *UsageTotalMutation) Fields() []string {
  40292. fields := make([]string, 0, 10)
  40293. if m.created_at != nil {
  40294. fields = append(fields, usagetotal.FieldCreatedAt)
  40295. }
  40296. if m.updated_at != nil {
  40297. fields = append(fields, usagetotal.FieldUpdatedAt)
  40298. }
  40299. if m.status != nil {
  40300. fields = append(fields, usagetotal.FieldStatus)
  40301. }
  40302. if m._type != nil {
  40303. fields = append(fields, usagetotal.FieldType)
  40304. }
  40305. if m.bot_id != nil {
  40306. fields = append(fields, usagetotal.FieldBotID)
  40307. }
  40308. if m.total_tokens != nil {
  40309. fields = append(fields, usagetotal.FieldTotalTokens)
  40310. }
  40311. if m.credits != nil {
  40312. fields = append(fields, usagetotal.FieldCredits)
  40313. }
  40314. if m.start_index != nil {
  40315. fields = append(fields, usagetotal.FieldStartIndex)
  40316. }
  40317. if m.end_index != nil {
  40318. fields = append(fields, usagetotal.FieldEndIndex)
  40319. }
  40320. if m.organization_id != nil {
  40321. fields = append(fields, usagetotal.FieldOrganizationID)
  40322. }
  40323. return fields
  40324. }
  40325. // Field returns the value of a field with the given name. The second boolean
  40326. // return value indicates that this field was not set, or was not defined in the
  40327. // schema.
  40328. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  40329. switch name {
  40330. case usagetotal.FieldCreatedAt:
  40331. return m.CreatedAt()
  40332. case usagetotal.FieldUpdatedAt:
  40333. return m.UpdatedAt()
  40334. case usagetotal.FieldStatus:
  40335. return m.Status()
  40336. case usagetotal.FieldType:
  40337. return m.GetType()
  40338. case usagetotal.FieldBotID:
  40339. return m.BotID()
  40340. case usagetotal.FieldTotalTokens:
  40341. return m.TotalTokens()
  40342. case usagetotal.FieldCredits:
  40343. return m.Credits()
  40344. case usagetotal.FieldStartIndex:
  40345. return m.StartIndex()
  40346. case usagetotal.FieldEndIndex:
  40347. return m.EndIndex()
  40348. case usagetotal.FieldOrganizationID:
  40349. return m.OrganizationID()
  40350. }
  40351. return nil, false
  40352. }
  40353. // OldField returns the old value of the field from the database. An error is
  40354. // returned if the mutation operation is not UpdateOne, or the query to the
  40355. // database failed.
  40356. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40357. switch name {
  40358. case usagetotal.FieldCreatedAt:
  40359. return m.OldCreatedAt(ctx)
  40360. case usagetotal.FieldUpdatedAt:
  40361. return m.OldUpdatedAt(ctx)
  40362. case usagetotal.FieldStatus:
  40363. return m.OldStatus(ctx)
  40364. case usagetotal.FieldType:
  40365. return m.OldType(ctx)
  40366. case usagetotal.FieldBotID:
  40367. return m.OldBotID(ctx)
  40368. case usagetotal.FieldTotalTokens:
  40369. return m.OldTotalTokens(ctx)
  40370. case usagetotal.FieldCredits:
  40371. return m.OldCredits(ctx)
  40372. case usagetotal.FieldStartIndex:
  40373. return m.OldStartIndex(ctx)
  40374. case usagetotal.FieldEndIndex:
  40375. return m.OldEndIndex(ctx)
  40376. case usagetotal.FieldOrganizationID:
  40377. return m.OldOrganizationID(ctx)
  40378. }
  40379. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  40380. }
  40381. // SetField sets the value of a field with the given name. It returns an error if
  40382. // the field is not defined in the schema, or if the type mismatched the field
  40383. // type.
  40384. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  40385. switch name {
  40386. case usagetotal.FieldCreatedAt:
  40387. v, ok := value.(time.Time)
  40388. if !ok {
  40389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40390. }
  40391. m.SetCreatedAt(v)
  40392. return nil
  40393. case usagetotal.FieldUpdatedAt:
  40394. v, ok := value.(time.Time)
  40395. if !ok {
  40396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40397. }
  40398. m.SetUpdatedAt(v)
  40399. return nil
  40400. case usagetotal.FieldStatus:
  40401. v, ok := value.(uint8)
  40402. if !ok {
  40403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40404. }
  40405. m.SetStatus(v)
  40406. return nil
  40407. case usagetotal.FieldType:
  40408. v, ok := value.(int)
  40409. if !ok {
  40410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40411. }
  40412. m.SetType(v)
  40413. return nil
  40414. case usagetotal.FieldBotID:
  40415. v, ok := value.(string)
  40416. if !ok {
  40417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40418. }
  40419. m.SetBotID(v)
  40420. return nil
  40421. case usagetotal.FieldTotalTokens:
  40422. v, ok := value.(uint64)
  40423. if !ok {
  40424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40425. }
  40426. m.SetTotalTokens(v)
  40427. return nil
  40428. case usagetotal.FieldCredits:
  40429. v, ok := value.(float64)
  40430. if !ok {
  40431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40432. }
  40433. m.SetCredits(v)
  40434. return nil
  40435. case usagetotal.FieldStartIndex:
  40436. v, ok := value.(uint64)
  40437. if !ok {
  40438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40439. }
  40440. m.SetStartIndex(v)
  40441. return nil
  40442. case usagetotal.FieldEndIndex:
  40443. v, ok := value.(uint64)
  40444. if !ok {
  40445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40446. }
  40447. m.SetEndIndex(v)
  40448. return nil
  40449. case usagetotal.FieldOrganizationID:
  40450. v, ok := value.(uint64)
  40451. if !ok {
  40452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40453. }
  40454. m.SetOrganizationID(v)
  40455. return nil
  40456. }
  40457. return fmt.Errorf("unknown UsageTotal field %s", name)
  40458. }
  40459. // AddedFields returns all numeric fields that were incremented/decremented during
  40460. // this mutation.
  40461. func (m *UsageTotalMutation) AddedFields() []string {
  40462. var fields []string
  40463. if m.addstatus != nil {
  40464. fields = append(fields, usagetotal.FieldStatus)
  40465. }
  40466. if m.add_type != nil {
  40467. fields = append(fields, usagetotal.FieldType)
  40468. }
  40469. if m.addtotal_tokens != nil {
  40470. fields = append(fields, usagetotal.FieldTotalTokens)
  40471. }
  40472. if m.addcredits != nil {
  40473. fields = append(fields, usagetotal.FieldCredits)
  40474. }
  40475. if m.addstart_index != nil {
  40476. fields = append(fields, usagetotal.FieldStartIndex)
  40477. }
  40478. if m.addend_index != nil {
  40479. fields = append(fields, usagetotal.FieldEndIndex)
  40480. }
  40481. if m.addorganization_id != nil {
  40482. fields = append(fields, usagetotal.FieldOrganizationID)
  40483. }
  40484. return fields
  40485. }
  40486. // AddedField returns the numeric value that was incremented/decremented on a field
  40487. // with the given name. The second boolean return value indicates that this field
  40488. // was not set, or was not defined in the schema.
  40489. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  40490. switch name {
  40491. case usagetotal.FieldStatus:
  40492. return m.AddedStatus()
  40493. case usagetotal.FieldType:
  40494. return m.AddedType()
  40495. case usagetotal.FieldTotalTokens:
  40496. return m.AddedTotalTokens()
  40497. case usagetotal.FieldCredits:
  40498. return m.AddedCredits()
  40499. case usagetotal.FieldStartIndex:
  40500. return m.AddedStartIndex()
  40501. case usagetotal.FieldEndIndex:
  40502. return m.AddedEndIndex()
  40503. case usagetotal.FieldOrganizationID:
  40504. return m.AddedOrganizationID()
  40505. }
  40506. return nil, false
  40507. }
  40508. // AddField adds the value to the field with the given name. It returns an error if
  40509. // the field is not defined in the schema, or if the type mismatched the field
  40510. // type.
  40511. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  40512. switch name {
  40513. case usagetotal.FieldStatus:
  40514. v, ok := value.(int8)
  40515. if !ok {
  40516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40517. }
  40518. m.AddStatus(v)
  40519. return nil
  40520. case usagetotal.FieldType:
  40521. v, ok := value.(int)
  40522. if !ok {
  40523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40524. }
  40525. m.AddType(v)
  40526. return nil
  40527. case usagetotal.FieldTotalTokens:
  40528. v, ok := value.(int64)
  40529. if !ok {
  40530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40531. }
  40532. m.AddTotalTokens(v)
  40533. return nil
  40534. case usagetotal.FieldCredits:
  40535. v, ok := value.(float64)
  40536. if !ok {
  40537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40538. }
  40539. m.AddCredits(v)
  40540. return nil
  40541. case usagetotal.FieldStartIndex:
  40542. v, ok := value.(int64)
  40543. if !ok {
  40544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40545. }
  40546. m.AddStartIndex(v)
  40547. return nil
  40548. case usagetotal.FieldEndIndex:
  40549. v, ok := value.(int64)
  40550. if !ok {
  40551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40552. }
  40553. m.AddEndIndex(v)
  40554. return nil
  40555. case usagetotal.FieldOrganizationID:
  40556. v, ok := value.(int64)
  40557. if !ok {
  40558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40559. }
  40560. m.AddOrganizationID(v)
  40561. return nil
  40562. }
  40563. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  40564. }
  40565. // ClearedFields returns all nullable fields that were cleared during this
  40566. // mutation.
  40567. func (m *UsageTotalMutation) ClearedFields() []string {
  40568. var fields []string
  40569. if m.FieldCleared(usagetotal.FieldStatus) {
  40570. fields = append(fields, usagetotal.FieldStatus)
  40571. }
  40572. if m.FieldCleared(usagetotal.FieldType) {
  40573. fields = append(fields, usagetotal.FieldType)
  40574. }
  40575. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  40576. fields = append(fields, usagetotal.FieldTotalTokens)
  40577. }
  40578. if m.FieldCleared(usagetotal.FieldCredits) {
  40579. fields = append(fields, usagetotal.FieldCredits)
  40580. }
  40581. if m.FieldCleared(usagetotal.FieldStartIndex) {
  40582. fields = append(fields, usagetotal.FieldStartIndex)
  40583. }
  40584. if m.FieldCleared(usagetotal.FieldEndIndex) {
  40585. fields = append(fields, usagetotal.FieldEndIndex)
  40586. }
  40587. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  40588. fields = append(fields, usagetotal.FieldOrganizationID)
  40589. }
  40590. return fields
  40591. }
  40592. // FieldCleared returns a boolean indicating if a field with the given name was
  40593. // cleared in this mutation.
  40594. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  40595. _, ok := m.clearedFields[name]
  40596. return ok
  40597. }
  40598. // ClearField clears the value of the field with the given name. It returns an
  40599. // error if the field is not defined in the schema.
  40600. func (m *UsageTotalMutation) ClearField(name string) error {
  40601. switch name {
  40602. case usagetotal.FieldStatus:
  40603. m.ClearStatus()
  40604. return nil
  40605. case usagetotal.FieldType:
  40606. m.ClearType()
  40607. return nil
  40608. case usagetotal.FieldTotalTokens:
  40609. m.ClearTotalTokens()
  40610. return nil
  40611. case usagetotal.FieldCredits:
  40612. m.ClearCredits()
  40613. return nil
  40614. case usagetotal.FieldStartIndex:
  40615. m.ClearStartIndex()
  40616. return nil
  40617. case usagetotal.FieldEndIndex:
  40618. m.ClearEndIndex()
  40619. return nil
  40620. case usagetotal.FieldOrganizationID:
  40621. m.ClearOrganizationID()
  40622. return nil
  40623. }
  40624. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  40625. }
  40626. // ResetField resets all changes in the mutation for the field with the given name.
  40627. // It returns an error if the field is not defined in the schema.
  40628. func (m *UsageTotalMutation) ResetField(name string) error {
  40629. switch name {
  40630. case usagetotal.FieldCreatedAt:
  40631. m.ResetCreatedAt()
  40632. return nil
  40633. case usagetotal.FieldUpdatedAt:
  40634. m.ResetUpdatedAt()
  40635. return nil
  40636. case usagetotal.FieldStatus:
  40637. m.ResetStatus()
  40638. return nil
  40639. case usagetotal.FieldType:
  40640. m.ResetType()
  40641. return nil
  40642. case usagetotal.FieldBotID:
  40643. m.ResetBotID()
  40644. return nil
  40645. case usagetotal.FieldTotalTokens:
  40646. m.ResetTotalTokens()
  40647. return nil
  40648. case usagetotal.FieldCredits:
  40649. m.ResetCredits()
  40650. return nil
  40651. case usagetotal.FieldStartIndex:
  40652. m.ResetStartIndex()
  40653. return nil
  40654. case usagetotal.FieldEndIndex:
  40655. m.ResetEndIndex()
  40656. return nil
  40657. case usagetotal.FieldOrganizationID:
  40658. m.ResetOrganizationID()
  40659. return nil
  40660. }
  40661. return fmt.Errorf("unknown UsageTotal field %s", name)
  40662. }
  40663. // AddedEdges returns all edge names that were set/added in this mutation.
  40664. func (m *UsageTotalMutation) AddedEdges() []string {
  40665. edges := make([]string, 0, 0)
  40666. return edges
  40667. }
  40668. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40669. // name in this mutation.
  40670. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  40671. return nil
  40672. }
  40673. // RemovedEdges returns all edge names that were removed in this mutation.
  40674. func (m *UsageTotalMutation) RemovedEdges() []string {
  40675. edges := make([]string, 0, 0)
  40676. return edges
  40677. }
  40678. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40679. // the given name in this mutation.
  40680. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  40681. return nil
  40682. }
  40683. // ClearedEdges returns all edge names that were cleared in this mutation.
  40684. func (m *UsageTotalMutation) ClearedEdges() []string {
  40685. edges := make([]string, 0, 0)
  40686. return edges
  40687. }
  40688. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40689. // was cleared in this mutation.
  40690. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  40691. return false
  40692. }
  40693. // ClearEdge clears the value of the edge with the given name. It returns an error
  40694. // if that edge is not defined in the schema.
  40695. func (m *UsageTotalMutation) ClearEdge(name string) error {
  40696. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  40697. }
  40698. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40699. // It returns an error if the edge is not defined in the schema.
  40700. func (m *UsageTotalMutation) ResetEdge(name string) error {
  40701. return fmt.Errorf("unknown UsageTotal edge %s", name)
  40702. }
  40703. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  40704. type WhatsappMutation struct {
  40705. config
  40706. op Op
  40707. typ string
  40708. id *uint64
  40709. created_at *time.Time
  40710. updated_at *time.Time
  40711. status *uint8
  40712. addstatus *int8
  40713. deleted_at *time.Time
  40714. wa_id *string
  40715. wa_name *string
  40716. callback *string
  40717. account *string
  40718. cc *string
  40719. phone *string
  40720. cc_phone *string
  40721. phone_name *string
  40722. phone_status *int8
  40723. addphone_status *int8
  40724. organization_id *uint64
  40725. addorganization_id *int64
  40726. api_base *string
  40727. api_key *string
  40728. allow_list *[]string
  40729. appendallow_list []string
  40730. group_allow_list *[]string
  40731. appendgroup_allow_list []string
  40732. block_list *[]string
  40733. appendblock_list []string
  40734. group_block_list *[]string
  40735. appendgroup_block_list []string
  40736. clearedFields map[string]struct{}
  40737. agent *uint64
  40738. clearedagent bool
  40739. done bool
  40740. oldValue func(context.Context) (*Whatsapp, error)
  40741. predicates []predicate.Whatsapp
  40742. }
  40743. var _ ent.Mutation = (*WhatsappMutation)(nil)
  40744. // whatsappOption allows management of the mutation configuration using functional options.
  40745. type whatsappOption func(*WhatsappMutation)
  40746. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  40747. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  40748. m := &WhatsappMutation{
  40749. config: c,
  40750. op: op,
  40751. typ: TypeWhatsapp,
  40752. clearedFields: make(map[string]struct{}),
  40753. }
  40754. for _, opt := range opts {
  40755. opt(m)
  40756. }
  40757. return m
  40758. }
  40759. // withWhatsappID sets the ID field of the mutation.
  40760. func withWhatsappID(id uint64) whatsappOption {
  40761. return func(m *WhatsappMutation) {
  40762. var (
  40763. err error
  40764. once sync.Once
  40765. value *Whatsapp
  40766. )
  40767. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  40768. once.Do(func() {
  40769. if m.done {
  40770. err = errors.New("querying old values post mutation is not allowed")
  40771. } else {
  40772. value, err = m.Client().Whatsapp.Get(ctx, id)
  40773. }
  40774. })
  40775. return value, err
  40776. }
  40777. m.id = &id
  40778. }
  40779. }
  40780. // withWhatsapp sets the old Whatsapp of the mutation.
  40781. func withWhatsapp(node *Whatsapp) whatsappOption {
  40782. return func(m *WhatsappMutation) {
  40783. m.oldValue = func(context.Context) (*Whatsapp, error) {
  40784. return node, nil
  40785. }
  40786. m.id = &node.ID
  40787. }
  40788. }
  40789. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40790. // executed in a transaction (ent.Tx), a transactional client is returned.
  40791. func (m WhatsappMutation) Client() *Client {
  40792. client := &Client{config: m.config}
  40793. client.init()
  40794. return client
  40795. }
  40796. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40797. // it returns an error otherwise.
  40798. func (m WhatsappMutation) Tx() (*Tx, error) {
  40799. if _, ok := m.driver.(*txDriver); !ok {
  40800. return nil, errors.New("ent: mutation is not running in a transaction")
  40801. }
  40802. tx := &Tx{config: m.config}
  40803. tx.init()
  40804. return tx, nil
  40805. }
  40806. // SetID sets the value of the id field. Note that this
  40807. // operation is only accepted on creation of Whatsapp entities.
  40808. func (m *WhatsappMutation) SetID(id uint64) {
  40809. m.id = &id
  40810. }
  40811. // ID returns the ID value in the mutation. Note that the ID is only available
  40812. // if it was provided to the builder or after it was returned from the database.
  40813. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  40814. if m.id == nil {
  40815. return
  40816. }
  40817. return *m.id, true
  40818. }
  40819. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40820. // That means, if the mutation is applied within a transaction with an isolation level such
  40821. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40822. // or updated by the mutation.
  40823. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  40824. switch {
  40825. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40826. id, exists := m.ID()
  40827. if exists {
  40828. return []uint64{id}, nil
  40829. }
  40830. fallthrough
  40831. case m.op.Is(OpUpdate | OpDelete):
  40832. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  40833. default:
  40834. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40835. }
  40836. }
  40837. // SetCreatedAt sets the "created_at" field.
  40838. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  40839. m.created_at = &t
  40840. }
  40841. // CreatedAt returns the value of the "created_at" field in the mutation.
  40842. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  40843. v := m.created_at
  40844. if v == nil {
  40845. return
  40846. }
  40847. return *v, true
  40848. }
  40849. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  40850. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40852. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40853. if !m.op.Is(OpUpdateOne) {
  40854. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40855. }
  40856. if m.id == nil || m.oldValue == nil {
  40857. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40858. }
  40859. oldValue, err := m.oldValue(ctx)
  40860. if err != nil {
  40861. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40862. }
  40863. return oldValue.CreatedAt, nil
  40864. }
  40865. // ResetCreatedAt resets all changes to the "created_at" field.
  40866. func (m *WhatsappMutation) ResetCreatedAt() {
  40867. m.created_at = nil
  40868. }
  40869. // SetUpdatedAt sets the "updated_at" field.
  40870. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  40871. m.updated_at = &t
  40872. }
  40873. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40874. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  40875. v := m.updated_at
  40876. if v == nil {
  40877. return
  40878. }
  40879. return *v, true
  40880. }
  40881. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  40882. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40884. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40885. if !m.op.Is(OpUpdateOne) {
  40886. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40887. }
  40888. if m.id == nil || m.oldValue == nil {
  40889. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40890. }
  40891. oldValue, err := m.oldValue(ctx)
  40892. if err != nil {
  40893. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40894. }
  40895. return oldValue.UpdatedAt, nil
  40896. }
  40897. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40898. func (m *WhatsappMutation) ResetUpdatedAt() {
  40899. m.updated_at = nil
  40900. }
  40901. // SetStatus sets the "status" field.
  40902. func (m *WhatsappMutation) SetStatus(u uint8) {
  40903. m.status = &u
  40904. m.addstatus = nil
  40905. }
  40906. // Status returns the value of the "status" field in the mutation.
  40907. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  40908. v := m.status
  40909. if v == nil {
  40910. return
  40911. }
  40912. return *v, true
  40913. }
  40914. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  40915. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40917. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40918. if !m.op.Is(OpUpdateOne) {
  40919. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40920. }
  40921. if m.id == nil || m.oldValue == nil {
  40922. return v, errors.New("OldStatus requires an ID field in the mutation")
  40923. }
  40924. oldValue, err := m.oldValue(ctx)
  40925. if err != nil {
  40926. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40927. }
  40928. return oldValue.Status, nil
  40929. }
  40930. // AddStatus adds u to the "status" field.
  40931. func (m *WhatsappMutation) AddStatus(u int8) {
  40932. if m.addstatus != nil {
  40933. *m.addstatus += u
  40934. } else {
  40935. m.addstatus = &u
  40936. }
  40937. }
  40938. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40939. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  40940. v := m.addstatus
  40941. if v == nil {
  40942. return
  40943. }
  40944. return *v, true
  40945. }
  40946. // ClearStatus clears the value of the "status" field.
  40947. func (m *WhatsappMutation) ClearStatus() {
  40948. m.status = nil
  40949. m.addstatus = nil
  40950. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  40951. }
  40952. // StatusCleared returns if the "status" field was cleared in this mutation.
  40953. func (m *WhatsappMutation) StatusCleared() bool {
  40954. _, ok := m.clearedFields[whatsapp.FieldStatus]
  40955. return ok
  40956. }
  40957. // ResetStatus resets all changes to the "status" field.
  40958. func (m *WhatsappMutation) ResetStatus() {
  40959. m.status = nil
  40960. m.addstatus = nil
  40961. delete(m.clearedFields, whatsapp.FieldStatus)
  40962. }
  40963. // SetDeletedAt sets the "deleted_at" field.
  40964. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  40965. m.deleted_at = &t
  40966. }
  40967. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40968. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  40969. v := m.deleted_at
  40970. if v == nil {
  40971. return
  40972. }
  40973. return *v, true
  40974. }
  40975. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  40976. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40978. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40979. if !m.op.Is(OpUpdateOne) {
  40980. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40981. }
  40982. if m.id == nil || m.oldValue == nil {
  40983. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40984. }
  40985. oldValue, err := m.oldValue(ctx)
  40986. if err != nil {
  40987. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40988. }
  40989. return oldValue.DeletedAt, nil
  40990. }
  40991. // ClearDeletedAt clears the value of the "deleted_at" field.
  40992. func (m *WhatsappMutation) ClearDeletedAt() {
  40993. m.deleted_at = nil
  40994. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  40995. }
  40996. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40997. func (m *WhatsappMutation) DeletedAtCleared() bool {
  40998. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  40999. return ok
  41000. }
  41001. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41002. func (m *WhatsappMutation) ResetDeletedAt() {
  41003. m.deleted_at = nil
  41004. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  41005. }
  41006. // SetWaID sets the "wa_id" field.
  41007. func (m *WhatsappMutation) SetWaID(s string) {
  41008. m.wa_id = &s
  41009. }
  41010. // WaID returns the value of the "wa_id" field in the mutation.
  41011. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  41012. v := m.wa_id
  41013. if v == nil {
  41014. return
  41015. }
  41016. return *v, true
  41017. }
  41018. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  41019. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41021. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  41022. if !m.op.Is(OpUpdateOne) {
  41023. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  41024. }
  41025. if m.id == nil || m.oldValue == nil {
  41026. return v, errors.New("OldWaID requires an ID field in the mutation")
  41027. }
  41028. oldValue, err := m.oldValue(ctx)
  41029. if err != nil {
  41030. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  41031. }
  41032. return oldValue.WaID, nil
  41033. }
  41034. // ClearWaID clears the value of the "wa_id" field.
  41035. func (m *WhatsappMutation) ClearWaID() {
  41036. m.wa_id = nil
  41037. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  41038. }
  41039. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  41040. func (m *WhatsappMutation) WaIDCleared() bool {
  41041. _, ok := m.clearedFields[whatsapp.FieldWaID]
  41042. return ok
  41043. }
  41044. // ResetWaID resets all changes to the "wa_id" field.
  41045. func (m *WhatsappMutation) ResetWaID() {
  41046. m.wa_id = nil
  41047. delete(m.clearedFields, whatsapp.FieldWaID)
  41048. }
  41049. // SetWaName sets the "wa_name" field.
  41050. func (m *WhatsappMutation) SetWaName(s string) {
  41051. m.wa_name = &s
  41052. }
  41053. // WaName returns the value of the "wa_name" field in the mutation.
  41054. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  41055. v := m.wa_name
  41056. if v == nil {
  41057. return
  41058. }
  41059. return *v, true
  41060. }
  41061. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  41062. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41064. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  41065. if !m.op.Is(OpUpdateOne) {
  41066. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  41067. }
  41068. if m.id == nil || m.oldValue == nil {
  41069. return v, errors.New("OldWaName requires an ID field in the mutation")
  41070. }
  41071. oldValue, err := m.oldValue(ctx)
  41072. if err != nil {
  41073. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  41074. }
  41075. return oldValue.WaName, nil
  41076. }
  41077. // ClearWaName clears the value of the "wa_name" field.
  41078. func (m *WhatsappMutation) ClearWaName() {
  41079. m.wa_name = nil
  41080. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  41081. }
  41082. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  41083. func (m *WhatsappMutation) WaNameCleared() bool {
  41084. _, ok := m.clearedFields[whatsapp.FieldWaName]
  41085. return ok
  41086. }
  41087. // ResetWaName resets all changes to the "wa_name" field.
  41088. func (m *WhatsappMutation) ResetWaName() {
  41089. m.wa_name = nil
  41090. delete(m.clearedFields, whatsapp.FieldWaName)
  41091. }
  41092. // SetCallback sets the "callback" field.
  41093. func (m *WhatsappMutation) SetCallback(s string) {
  41094. m.callback = &s
  41095. }
  41096. // Callback returns the value of the "callback" field in the mutation.
  41097. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  41098. v := m.callback
  41099. if v == nil {
  41100. return
  41101. }
  41102. return *v, true
  41103. }
  41104. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  41105. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41107. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  41108. if !m.op.Is(OpUpdateOne) {
  41109. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  41110. }
  41111. if m.id == nil || m.oldValue == nil {
  41112. return v, errors.New("OldCallback requires an ID field in the mutation")
  41113. }
  41114. oldValue, err := m.oldValue(ctx)
  41115. if err != nil {
  41116. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  41117. }
  41118. return oldValue.Callback, nil
  41119. }
  41120. // ClearCallback clears the value of the "callback" field.
  41121. func (m *WhatsappMutation) ClearCallback() {
  41122. m.callback = nil
  41123. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  41124. }
  41125. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  41126. func (m *WhatsappMutation) CallbackCleared() bool {
  41127. _, ok := m.clearedFields[whatsapp.FieldCallback]
  41128. return ok
  41129. }
  41130. // ResetCallback resets all changes to the "callback" field.
  41131. func (m *WhatsappMutation) ResetCallback() {
  41132. m.callback = nil
  41133. delete(m.clearedFields, whatsapp.FieldCallback)
  41134. }
  41135. // SetAgentID sets the "agent_id" field.
  41136. func (m *WhatsappMutation) SetAgentID(u uint64) {
  41137. m.agent = &u
  41138. }
  41139. // AgentID returns the value of the "agent_id" field in the mutation.
  41140. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  41141. v := m.agent
  41142. if v == nil {
  41143. return
  41144. }
  41145. return *v, true
  41146. }
  41147. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  41148. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41150. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  41151. if !m.op.Is(OpUpdateOne) {
  41152. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  41153. }
  41154. if m.id == nil || m.oldValue == nil {
  41155. return v, errors.New("OldAgentID requires an ID field in the mutation")
  41156. }
  41157. oldValue, err := m.oldValue(ctx)
  41158. if err != nil {
  41159. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  41160. }
  41161. return oldValue.AgentID, nil
  41162. }
  41163. // ResetAgentID resets all changes to the "agent_id" field.
  41164. func (m *WhatsappMutation) ResetAgentID() {
  41165. m.agent = nil
  41166. }
  41167. // SetAccount sets the "account" field.
  41168. func (m *WhatsappMutation) SetAccount(s string) {
  41169. m.account = &s
  41170. }
  41171. // Account returns the value of the "account" field in the mutation.
  41172. func (m *WhatsappMutation) Account() (r string, exists bool) {
  41173. v := m.account
  41174. if v == nil {
  41175. return
  41176. }
  41177. return *v, true
  41178. }
  41179. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  41180. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41182. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  41183. if !m.op.Is(OpUpdateOne) {
  41184. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41185. }
  41186. if m.id == nil || m.oldValue == nil {
  41187. return v, errors.New("OldAccount requires an ID field in the mutation")
  41188. }
  41189. oldValue, err := m.oldValue(ctx)
  41190. if err != nil {
  41191. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  41192. }
  41193. return oldValue.Account, nil
  41194. }
  41195. // ClearAccount clears the value of the "account" field.
  41196. func (m *WhatsappMutation) ClearAccount() {
  41197. m.account = nil
  41198. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  41199. }
  41200. // AccountCleared returns if the "account" field was cleared in this mutation.
  41201. func (m *WhatsappMutation) AccountCleared() bool {
  41202. _, ok := m.clearedFields[whatsapp.FieldAccount]
  41203. return ok
  41204. }
  41205. // ResetAccount resets all changes to the "account" field.
  41206. func (m *WhatsappMutation) ResetAccount() {
  41207. m.account = nil
  41208. delete(m.clearedFields, whatsapp.FieldAccount)
  41209. }
  41210. // SetCc sets the "cc" field.
  41211. func (m *WhatsappMutation) SetCc(s string) {
  41212. m.cc = &s
  41213. }
  41214. // Cc returns the value of the "cc" field in the mutation.
  41215. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  41216. v := m.cc
  41217. if v == nil {
  41218. return
  41219. }
  41220. return *v, true
  41221. }
  41222. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  41223. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41225. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  41226. if !m.op.Is(OpUpdateOne) {
  41227. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  41228. }
  41229. if m.id == nil || m.oldValue == nil {
  41230. return v, errors.New("OldCc requires an ID field in the mutation")
  41231. }
  41232. oldValue, err := m.oldValue(ctx)
  41233. if err != nil {
  41234. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  41235. }
  41236. return oldValue.Cc, nil
  41237. }
  41238. // ResetCc resets all changes to the "cc" field.
  41239. func (m *WhatsappMutation) ResetCc() {
  41240. m.cc = nil
  41241. }
  41242. // SetPhone sets the "phone" field.
  41243. func (m *WhatsappMutation) SetPhone(s string) {
  41244. m.phone = &s
  41245. }
  41246. // Phone returns the value of the "phone" field in the mutation.
  41247. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  41248. v := m.phone
  41249. if v == nil {
  41250. return
  41251. }
  41252. return *v, true
  41253. }
  41254. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  41255. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41257. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  41258. if !m.op.Is(OpUpdateOne) {
  41259. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  41260. }
  41261. if m.id == nil || m.oldValue == nil {
  41262. return v, errors.New("OldPhone requires an ID field in the mutation")
  41263. }
  41264. oldValue, err := m.oldValue(ctx)
  41265. if err != nil {
  41266. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  41267. }
  41268. return oldValue.Phone, nil
  41269. }
  41270. // ResetPhone resets all changes to the "phone" field.
  41271. func (m *WhatsappMutation) ResetPhone() {
  41272. m.phone = nil
  41273. }
  41274. // SetCcPhone sets the "cc_phone" field.
  41275. func (m *WhatsappMutation) SetCcPhone(s string) {
  41276. m.cc_phone = &s
  41277. }
  41278. // CcPhone returns the value of the "cc_phone" field in the mutation.
  41279. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  41280. v := m.cc_phone
  41281. if v == nil {
  41282. return
  41283. }
  41284. return *v, true
  41285. }
  41286. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  41287. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41289. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  41290. if !m.op.Is(OpUpdateOne) {
  41291. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  41292. }
  41293. if m.id == nil || m.oldValue == nil {
  41294. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  41295. }
  41296. oldValue, err := m.oldValue(ctx)
  41297. if err != nil {
  41298. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  41299. }
  41300. return oldValue.CcPhone, nil
  41301. }
  41302. // ResetCcPhone resets all changes to the "cc_phone" field.
  41303. func (m *WhatsappMutation) ResetCcPhone() {
  41304. m.cc_phone = nil
  41305. }
  41306. // SetPhoneName sets the "phone_name" field.
  41307. func (m *WhatsappMutation) SetPhoneName(s string) {
  41308. m.phone_name = &s
  41309. }
  41310. // PhoneName returns the value of the "phone_name" field in the mutation.
  41311. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  41312. v := m.phone_name
  41313. if v == nil {
  41314. return
  41315. }
  41316. return *v, true
  41317. }
  41318. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  41319. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41321. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  41322. if !m.op.Is(OpUpdateOne) {
  41323. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  41324. }
  41325. if m.id == nil || m.oldValue == nil {
  41326. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  41327. }
  41328. oldValue, err := m.oldValue(ctx)
  41329. if err != nil {
  41330. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  41331. }
  41332. return oldValue.PhoneName, nil
  41333. }
  41334. // ResetPhoneName resets all changes to the "phone_name" field.
  41335. func (m *WhatsappMutation) ResetPhoneName() {
  41336. m.phone_name = nil
  41337. }
  41338. // SetPhoneStatus sets the "phone_status" field.
  41339. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  41340. m.phone_status = &i
  41341. m.addphone_status = nil
  41342. }
  41343. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  41344. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  41345. v := m.phone_status
  41346. if v == nil {
  41347. return
  41348. }
  41349. return *v, true
  41350. }
  41351. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  41352. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41354. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  41355. if !m.op.Is(OpUpdateOne) {
  41356. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  41357. }
  41358. if m.id == nil || m.oldValue == nil {
  41359. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  41360. }
  41361. oldValue, err := m.oldValue(ctx)
  41362. if err != nil {
  41363. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  41364. }
  41365. return oldValue.PhoneStatus, nil
  41366. }
  41367. // AddPhoneStatus adds i to the "phone_status" field.
  41368. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  41369. if m.addphone_status != nil {
  41370. *m.addphone_status += i
  41371. } else {
  41372. m.addphone_status = &i
  41373. }
  41374. }
  41375. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  41376. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  41377. v := m.addphone_status
  41378. if v == nil {
  41379. return
  41380. }
  41381. return *v, true
  41382. }
  41383. // ResetPhoneStatus resets all changes to the "phone_status" field.
  41384. func (m *WhatsappMutation) ResetPhoneStatus() {
  41385. m.phone_status = nil
  41386. m.addphone_status = nil
  41387. }
  41388. // SetOrganizationID sets the "organization_id" field.
  41389. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  41390. m.organization_id = &u
  41391. m.addorganization_id = nil
  41392. }
  41393. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41394. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  41395. v := m.organization_id
  41396. if v == nil {
  41397. return
  41398. }
  41399. return *v, true
  41400. }
  41401. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  41402. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41404. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41405. if !m.op.Is(OpUpdateOne) {
  41406. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41407. }
  41408. if m.id == nil || m.oldValue == nil {
  41409. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41410. }
  41411. oldValue, err := m.oldValue(ctx)
  41412. if err != nil {
  41413. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41414. }
  41415. return oldValue.OrganizationID, nil
  41416. }
  41417. // AddOrganizationID adds u to the "organization_id" field.
  41418. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  41419. if m.addorganization_id != nil {
  41420. *m.addorganization_id += u
  41421. } else {
  41422. m.addorganization_id = &u
  41423. }
  41424. }
  41425. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41426. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  41427. v := m.addorganization_id
  41428. if v == nil {
  41429. return
  41430. }
  41431. return *v, true
  41432. }
  41433. // ClearOrganizationID clears the value of the "organization_id" field.
  41434. func (m *WhatsappMutation) ClearOrganizationID() {
  41435. m.organization_id = nil
  41436. m.addorganization_id = nil
  41437. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  41438. }
  41439. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41440. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  41441. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  41442. return ok
  41443. }
  41444. // ResetOrganizationID resets all changes to the "organization_id" field.
  41445. func (m *WhatsappMutation) ResetOrganizationID() {
  41446. m.organization_id = nil
  41447. m.addorganization_id = nil
  41448. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  41449. }
  41450. // SetAPIBase sets the "api_base" field.
  41451. func (m *WhatsappMutation) SetAPIBase(s string) {
  41452. m.api_base = &s
  41453. }
  41454. // APIBase returns the value of the "api_base" field in the mutation.
  41455. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  41456. v := m.api_base
  41457. if v == nil {
  41458. return
  41459. }
  41460. return *v, true
  41461. }
  41462. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  41463. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41465. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  41466. if !m.op.Is(OpUpdateOne) {
  41467. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  41468. }
  41469. if m.id == nil || m.oldValue == nil {
  41470. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  41471. }
  41472. oldValue, err := m.oldValue(ctx)
  41473. if err != nil {
  41474. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  41475. }
  41476. return oldValue.APIBase, nil
  41477. }
  41478. // ClearAPIBase clears the value of the "api_base" field.
  41479. func (m *WhatsappMutation) ClearAPIBase() {
  41480. m.api_base = nil
  41481. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  41482. }
  41483. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  41484. func (m *WhatsappMutation) APIBaseCleared() bool {
  41485. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  41486. return ok
  41487. }
  41488. // ResetAPIBase resets all changes to the "api_base" field.
  41489. func (m *WhatsappMutation) ResetAPIBase() {
  41490. m.api_base = nil
  41491. delete(m.clearedFields, whatsapp.FieldAPIBase)
  41492. }
  41493. // SetAPIKey sets the "api_key" field.
  41494. func (m *WhatsappMutation) SetAPIKey(s string) {
  41495. m.api_key = &s
  41496. }
  41497. // APIKey returns the value of the "api_key" field in the mutation.
  41498. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  41499. v := m.api_key
  41500. if v == nil {
  41501. return
  41502. }
  41503. return *v, true
  41504. }
  41505. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  41506. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41508. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  41509. if !m.op.Is(OpUpdateOne) {
  41510. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  41511. }
  41512. if m.id == nil || m.oldValue == nil {
  41513. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  41514. }
  41515. oldValue, err := m.oldValue(ctx)
  41516. if err != nil {
  41517. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  41518. }
  41519. return oldValue.APIKey, nil
  41520. }
  41521. // ClearAPIKey clears the value of the "api_key" field.
  41522. func (m *WhatsappMutation) ClearAPIKey() {
  41523. m.api_key = nil
  41524. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  41525. }
  41526. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  41527. func (m *WhatsappMutation) APIKeyCleared() bool {
  41528. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  41529. return ok
  41530. }
  41531. // ResetAPIKey resets all changes to the "api_key" field.
  41532. func (m *WhatsappMutation) ResetAPIKey() {
  41533. m.api_key = nil
  41534. delete(m.clearedFields, whatsapp.FieldAPIKey)
  41535. }
  41536. // SetAllowList sets the "allow_list" field.
  41537. func (m *WhatsappMutation) SetAllowList(s []string) {
  41538. m.allow_list = &s
  41539. m.appendallow_list = nil
  41540. }
  41541. // AllowList returns the value of the "allow_list" field in the mutation.
  41542. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  41543. v := m.allow_list
  41544. if v == nil {
  41545. return
  41546. }
  41547. return *v, true
  41548. }
  41549. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  41550. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41552. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  41553. if !m.op.Is(OpUpdateOne) {
  41554. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  41555. }
  41556. if m.id == nil || m.oldValue == nil {
  41557. return v, errors.New("OldAllowList requires an ID field in the mutation")
  41558. }
  41559. oldValue, err := m.oldValue(ctx)
  41560. if err != nil {
  41561. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  41562. }
  41563. return oldValue.AllowList, nil
  41564. }
  41565. // AppendAllowList adds s to the "allow_list" field.
  41566. func (m *WhatsappMutation) AppendAllowList(s []string) {
  41567. m.appendallow_list = append(m.appendallow_list, s...)
  41568. }
  41569. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  41570. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  41571. if len(m.appendallow_list) == 0 {
  41572. return nil, false
  41573. }
  41574. return m.appendallow_list, true
  41575. }
  41576. // ClearAllowList clears the value of the "allow_list" field.
  41577. func (m *WhatsappMutation) ClearAllowList() {
  41578. m.allow_list = nil
  41579. m.appendallow_list = nil
  41580. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  41581. }
  41582. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  41583. func (m *WhatsappMutation) AllowListCleared() bool {
  41584. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  41585. return ok
  41586. }
  41587. // ResetAllowList resets all changes to the "allow_list" field.
  41588. func (m *WhatsappMutation) ResetAllowList() {
  41589. m.allow_list = nil
  41590. m.appendallow_list = nil
  41591. delete(m.clearedFields, whatsapp.FieldAllowList)
  41592. }
  41593. // SetGroupAllowList sets the "group_allow_list" field.
  41594. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  41595. m.group_allow_list = &s
  41596. m.appendgroup_allow_list = nil
  41597. }
  41598. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  41599. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  41600. v := m.group_allow_list
  41601. if v == nil {
  41602. return
  41603. }
  41604. return *v, true
  41605. }
  41606. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  41607. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41609. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  41610. if !m.op.Is(OpUpdateOne) {
  41611. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  41612. }
  41613. if m.id == nil || m.oldValue == nil {
  41614. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  41615. }
  41616. oldValue, err := m.oldValue(ctx)
  41617. if err != nil {
  41618. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  41619. }
  41620. return oldValue.GroupAllowList, nil
  41621. }
  41622. // AppendGroupAllowList adds s to the "group_allow_list" field.
  41623. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  41624. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  41625. }
  41626. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  41627. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  41628. if len(m.appendgroup_allow_list) == 0 {
  41629. return nil, false
  41630. }
  41631. return m.appendgroup_allow_list, true
  41632. }
  41633. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  41634. func (m *WhatsappMutation) ClearGroupAllowList() {
  41635. m.group_allow_list = nil
  41636. m.appendgroup_allow_list = nil
  41637. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  41638. }
  41639. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  41640. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  41641. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  41642. return ok
  41643. }
  41644. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  41645. func (m *WhatsappMutation) ResetGroupAllowList() {
  41646. m.group_allow_list = nil
  41647. m.appendgroup_allow_list = nil
  41648. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  41649. }
  41650. // SetBlockList sets the "block_list" field.
  41651. func (m *WhatsappMutation) SetBlockList(s []string) {
  41652. m.block_list = &s
  41653. m.appendblock_list = nil
  41654. }
  41655. // BlockList returns the value of the "block_list" field in the mutation.
  41656. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  41657. v := m.block_list
  41658. if v == nil {
  41659. return
  41660. }
  41661. return *v, true
  41662. }
  41663. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  41664. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41666. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  41667. if !m.op.Is(OpUpdateOne) {
  41668. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  41669. }
  41670. if m.id == nil || m.oldValue == nil {
  41671. return v, errors.New("OldBlockList requires an ID field in the mutation")
  41672. }
  41673. oldValue, err := m.oldValue(ctx)
  41674. if err != nil {
  41675. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  41676. }
  41677. return oldValue.BlockList, nil
  41678. }
  41679. // AppendBlockList adds s to the "block_list" field.
  41680. func (m *WhatsappMutation) AppendBlockList(s []string) {
  41681. m.appendblock_list = append(m.appendblock_list, s...)
  41682. }
  41683. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  41684. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  41685. if len(m.appendblock_list) == 0 {
  41686. return nil, false
  41687. }
  41688. return m.appendblock_list, true
  41689. }
  41690. // ClearBlockList clears the value of the "block_list" field.
  41691. func (m *WhatsappMutation) ClearBlockList() {
  41692. m.block_list = nil
  41693. m.appendblock_list = nil
  41694. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  41695. }
  41696. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  41697. func (m *WhatsappMutation) BlockListCleared() bool {
  41698. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  41699. return ok
  41700. }
  41701. // ResetBlockList resets all changes to the "block_list" field.
  41702. func (m *WhatsappMutation) ResetBlockList() {
  41703. m.block_list = nil
  41704. m.appendblock_list = nil
  41705. delete(m.clearedFields, whatsapp.FieldBlockList)
  41706. }
  41707. // SetGroupBlockList sets the "group_block_list" field.
  41708. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  41709. m.group_block_list = &s
  41710. m.appendgroup_block_list = nil
  41711. }
  41712. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  41713. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  41714. v := m.group_block_list
  41715. if v == nil {
  41716. return
  41717. }
  41718. return *v, true
  41719. }
  41720. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  41721. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41723. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  41724. if !m.op.Is(OpUpdateOne) {
  41725. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  41726. }
  41727. if m.id == nil || m.oldValue == nil {
  41728. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  41729. }
  41730. oldValue, err := m.oldValue(ctx)
  41731. if err != nil {
  41732. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  41733. }
  41734. return oldValue.GroupBlockList, nil
  41735. }
  41736. // AppendGroupBlockList adds s to the "group_block_list" field.
  41737. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  41738. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  41739. }
  41740. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  41741. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  41742. if len(m.appendgroup_block_list) == 0 {
  41743. return nil, false
  41744. }
  41745. return m.appendgroup_block_list, true
  41746. }
  41747. // ClearGroupBlockList clears the value of the "group_block_list" field.
  41748. func (m *WhatsappMutation) ClearGroupBlockList() {
  41749. m.group_block_list = nil
  41750. m.appendgroup_block_list = nil
  41751. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  41752. }
  41753. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  41754. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  41755. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  41756. return ok
  41757. }
  41758. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  41759. func (m *WhatsappMutation) ResetGroupBlockList() {
  41760. m.group_block_list = nil
  41761. m.appendgroup_block_list = nil
  41762. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  41763. }
  41764. // ClearAgent clears the "agent" edge to the Agent entity.
  41765. func (m *WhatsappMutation) ClearAgent() {
  41766. m.clearedagent = true
  41767. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  41768. }
  41769. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  41770. func (m *WhatsappMutation) AgentCleared() bool {
  41771. return m.clearedagent
  41772. }
  41773. // AgentIDs returns the "agent" edge IDs in the mutation.
  41774. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  41775. // AgentID instead. It exists only for internal usage by the builders.
  41776. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  41777. if id := m.agent; id != nil {
  41778. ids = append(ids, *id)
  41779. }
  41780. return
  41781. }
  41782. // ResetAgent resets all changes to the "agent" edge.
  41783. func (m *WhatsappMutation) ResetAgent() {
  41784. m.agent = nil
  41785. m.clearedagent = false
  41786. }
  41787. // Where appends a list predicates to the WhatsappMutation builder.
  41788. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  41789. m.predicates = append(m.predicates, ps...)
  41790. }
  41791. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  41792. // users can use type-assertion to append predicates that do not depend on any generated package.
  41793. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  41794. p := make([]predicate.Whatsapp, len(ps))
  41795. for i := range ps {
  41796. p[i] = ps[i]
  41797. }
  41798. m.Where(p...)
  41799. }
  41800. // Op returns the operation name.
  41801. func (m *WhatsappMutation) Op() Op {
  41802. return m.op
  41803. }
  41804. // SetOp allows setting the mutation operation.
  41805. func (m *WhatsappMutation) SetOp(op Op) {
  41806. m.op = op
  41807. }
  41808. // Type returns the node type of this mutation (Whatsapp).
  41809. func (m *WhatsappMutation) Type() string {
  41810. return m.typ
  41811. }
  41812. // Fields returns all fields that were changed during this mutation. Note that in
  41813. // order to get all numeric fields that were incremented/decremented, call
  41814. // AddedFields().
  41815. func (m *WhatsappMutation) Fields() []string {
  41816. fields := make([]string, 0, 21)
  41817. if m.created_at != nil {
  41818. fields = append(fields, whatsapp.FieldCreatedAt)
  41819. }
  41820. if m.updated_at != nil {
  41821. fields = append(fields, whatsapp.FieldUpdatedAt)
  41822. }
  41823. if m.status != nil {
  41824. fields = append(fields, whatsapp.FieldStatus)
  41825. }
  41826. if m.deleted_at != nil {
  41827. fields = append(fields, whatsapp.FieldDeletedAt)
  41828. }
  41829. if m.wa_id != nil {
  41830. fields = append(fields, whatsapp.FieldWaID)
  41831. }
  41832. if m.wa_name != nil {
  41833. fields = append(fields, whatsapp.FieldWaName)
  41834. }
  41835. if m.callback != nil {
  41836. fields = append(fields, whatsapp.FieldCallback)
  41837. }
  41838. if m.agent != nil {
  41839. fields = append(fields, whatsapp.FieldAgentID)
  41840. }
  41841. if m.account != nil {
  41842. fields = append(fields, whatsapp.FieldAccount)
  41843. }
  41844. if m.cc != nil {
  41845. fields = append(fields, whatsapp.FieldCc)
  41846. }
  41847. if m.phone != nil {
  41848. fields = append(fields, whatsapp.FieldPhone)
  41849. }
  41850. if m.cc_phone != nil {
  41851. fields = append(fields, whatsapp.FieldCcPhone)
  41852. }
  41853. if m.phone_name != nil {
  41854. fields = append(fields, whatsapp.FieldPhoneName)
  41855. }
  41856. if m.phone_status != nil {
  41857. fields = append(fields, whatsapp.FieldPhoneStatus)
  41858. }
  41859. if m.organization_id != nil {
  41860. fields = append(fields, whatsapp.FieldOrganizationID)
  41861. }
  41862. if m.api_base != nil {
  41863. fields = append(fields, whatsapp.FieldAPIBase)
  41864. }
  41865. if m.api_key != nil {
  41866. fields = append(fields, whatsapp.FieldAPIKey)
  41867. }
  41868. if m.allow_list != nil {
  41869. fields = append(fields, whatsapp.FieldAllowList)
  41870. }
  41871. if m.group_allow_list != nil {
  41872. fields = append(fields, whatsapp.FieldGroupAllowList)
  41873. }
  41874. if m.block_list != nil {
  41875. fields = append(fields, whatsapp.FieldBlockList)
  41876. }
  41877. if m.group_block_list != nil {
  41878. fields = append(fields, whatsapp.FieldGroupBlockList)
  41879. }
  41880. return fields
  41881. }
  41882. // Field returns the value of a field with the given name. The second boolean
  41883. // return value indicates that this field was not set, or was not defined in the
  41884. // schema.
  41885. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  41886. switch name {
  41887. case whatsapp.FieldCreatedAt:
  41888. return m.CreatedAt()
  41889. case whatsapp.FieldUpdatedAt:
  41890. return m.UpdatedAt()
  41891. case whatsapp.FieldStatus:
  41892. return m.Status()
  41893. case whatsapp.FieldDeletedAt:
  41894. return m.DeletedAt()
  41895. case whatsapp.FieldWaID:
  41896. return m.WaID()
  41897. case whatsapp.FieldWaName:
  41898. return m.WaName()
  41899. case whatsapp.FieldCallback:
  41900. return m.Callback()
  41901. case whatsapp.FieldAgentID:
  41902. return m.AgentID()
  41903. case whatsapp.FieldAccount:
  41904. return m.Account()
  41905. case whatsapp.FieldCc:
  41906. return m.Cc()
  41907. case whatsapp.FieldPhone:
  41908. return m.Phone()
  41909. case whatsapp.FieldCcPhone:
  41910. return m.CcPhone()
  41911. case whatsapp.FieldPhoneName:
  41912. return m.PhoneName()
  41913. case whatsapp.FieldPhoneStatus:
  41914. return m.PhoneStatus()
  41915. case whatsapp.FieldOrganizationID:
  41916. return m.OrganizationID()
  41917. case whatsapp.FieldAPIBase:
  41918. return m.APIBase()
  41919. case whatsapp.FieldAPIKey:
  41920. return m.APIKey()
  41921. case whatsapp.FieldAllowList:
  41922. return m.AllowList()
  41923. case whatsapp.FieldGroupAllowList:
  41924. return m.GroupAllowList()
  41925. case whatsapp.FieldBlockList:
  41926. return m.BlockList()
  41927. case whatsapp.FieldGroupBlockList:
  41928. return m.GroupBlockList()
  41929. }
  41930. return nil, false
  41931. }
  41932. // OldField returns the old value of the field from the database. An error is
  41933. // returned if the mutation operation is not UpdateOne, or the query to the
  41934. // database failed.
  41935. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41936. switch name {
  41937. case whatsapp.FieldCreatedAt:
  41938. return m.OldCreatedAt(ctx)
  41939. case whatsapp.FieldUpdatedAt:
  41940. return m.OldUpdatedAt(ctx)
  41941. case whatsapp.FieldStatus:
  41942. return m.OldStatus(ctx)
  41943. case whatsapp.FieldDeletedAt:
  41944. return m.OldDeletedAt(ctx)
  41945. case whatsapp.FieldWaID:
  41946. return m.OldWaID(ctx)
  41947. case whatsapp.FieldWaName:
  41948. return m.OldWaName(ctx)
  41949. case whatsapp.FieldCallback:
  41950. return m.OldCallback(ctx)
  41951. case whatsapp.FieldAgentID:
  41952. return m.OldAgentID(ctx)
  41953. case whatsapp.FieldAccount:
  41954. return m.OldAccount(ctx)
  41955. case whatsapp.FieldCc:
  41956. return m.OldCc(ctx)
  41957. case whatsapp.FieldPhone:
  41958. return m.OldPhone(ctx)
  41959. case whatsapp.FieldCcPhone:
  41960. return m.OldCcPhone(ctx)
  41961. case whatsapp.FieldPhoneName:
  41962. return m.OldPhoneName(ctx)
  41963. case whatsapp.FieldPhoneStatus:
  41964. return m.OldPhoneStatus(ctx)
  41965. case whatsapp.FieldOrganizationID:
  41966. return m.OldOrganizationID(ctx)
  41967. case whatsapp.FieldAPIBase:
  41968. return m.OldAPIBase(ctx)
  41969. case whatsapp.FieldAPIKey:
  41970. return m.OldAPIKey(ctx)
  41971. case whatsapp.FieldAllowList:
  41972. return m.OldAllowList(ctx)
  41973. case whatsapp.FieldGroupAllowList:
  41974. return m.OldGroupAllowList(ctx)
  41975. case whatsapp.FieldBlockList:
  41976. return m.OldBlockList(ctx)
  41977. case whatsapp.FieldGroupBlockList:
  41978. return m.OldGroupBlockList(ctx)
  41979. }
  41980. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  41981. }
  41982. // SetField sets the value of a field with the given name. It returns an error if
  41983. // the field is not defined in the schema, or if the type mismatched the field
  41984. // type.
  41985. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  41986. switch name {
  41987. case whatsapp.FieldCreatedAt:
  41988. v, ok := value.(time.Time)
  41989. if !ok {
  41990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41991. }
  41992. m.SetCreatedAt(v)
  41993. return nil
  41994. case whatsapp.FieldUpdatedAt:
  41995. v, ok := value.(time.Time)
  41996. if !ok {
  41997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41998. }
  41999. m.SetUpdatedAt(v)
  42000. return nil
  42001. case whatsapp.FieldStatus:
  42002. v, ok := value.(uint8)
  42003. if !ok {
  42004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42005. }
  42006. m.SetStatus(v)
  42007. return nil
  42008. case whatsapp.FieldDeletedAt:
  42009. v, ok := value.(time.Time)
  42010. if !ok {
  42011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42012. }
  42013. m.SetDeletedAt(v)
  42014. return nil
  42015. case whatsapp.FieldWaID:
  42016. v, ok := value.(string)
  42017. if !ok {
  42018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42019. }
  42020. m.SetWaID(v)
  42021. return nil
  42022. case whatsapp.FieldWaName:
  42023. v, ok := value.(string)
  42024. if !ok {
  42025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42026. }
  42027. m.SetWaName(v)
  42028. return nil
  42029. case whatsapp.FieldCallback:
  42030. v, ok := value.(string)
  42031. if !ok {
  42032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42033. }
  42034. m.SetCallback(v)
  42035. return nil
  42036. case whatsapp.FieldAgentID:
  42037. v, ok := value.(uint64)
  42038. if !ok {
  42039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42040. }
  42041. m.SetAgentID(v)
  42042. return nil
  42043. case whatsapp.FieldAccount:
  42044. v, ok := value.(string)
  42045. if !ok {
  42046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42047. }
  42048. m.SetAccount(v)
  42049. return nil
  42050. case whatsapp.FieldCc:
  42051. v, ok := value.(string)
  42052. if !ok {
  42053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42054. }
  42055. m.SetCc(v)
  42056. return nil
  42057. case whatsapp.FieldPhone:
  42058. v, ok := value.(string)
  42059. if !ok {
  42060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42061. }
  42062. m.SetPhone(v)
  42063. return nil
  42064. case whatsapp.FieldCcPhone:
  42065. v, ok := value.(string)
  42066. if !ok {
  42067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42068. }
  42069. m.SetCcPhone(v)
  42070. return nil
  42071. case whatsapp.FieldPhoneName:
  42072. v, ok := value.(string)
  42073. if !ok {
  42074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42075. }
  42076. m.SetPhoneName(v)
  42077. return nil
  42078. case whatsapp.FieldPhoneStatus:
  42079. v, ok := value.(int8)
  42080. if !ok {
  42081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42082. }
  42083. m.SetPhoneStatus(v)
  42084. return nil
  42085. case whatsapp.FieldOrganizationID:
  42086. v, ok := value.(uint64)
  42087. if !ok {
  42088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42089. }
  42090. m.SetOrganizationID(v)
  42091. return nil
  42092. case whatsapp.FieldAPIBase:
  42093. v, ok := value.(string)
  42094. if !ok {
  42095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42096. }
  42097. m.SetAPIBase(v)
  42098. return nil
  42099. case whatsapp.FieldAPIKey:
  42100. v, ok := value.(string)
  42101. if !ok {
  42102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42103. }
  42104. m.SetAPIKey(v)
  42105. return nil
  42106. case whatsapp.FieldAllowList:
  42107. v, ok := value.([]string)
  42108. if !ok {
  42109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42110. }
  42111. m.SetAllowList(v)
  42112. return nil
  42113. case whatsapp.FieldGroupAllowList:
  42114. v, ok := value.([]string)
  42115. if !ok {
  42116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42117. }
  42118. m.SetGroupAllowList(v)
  42119. return nil
  42120. case whatsapp.FieldBlockList:
  42121. v, ok := value.([]string)
  42122. if !ok {
  42123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42124. }
  42125. m.SetBlockList(v)
  42126. return nil
  42127. case whatsapp.FieldGroupBlockList:
  42128. v, ok := value.([]string)
  42129. if !ok {
  42130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42131. }
  42132. m.SetGroupBlockList(v)
  42133. return nil
  42134. }
  42135. return fmt.Errorf("unknown Whatsapp field %s", name)
  42136. }
  42137. // AddedFields returns all numeric fields that were incremented/decremented during
  42138. // this mutation.
  42139. func (m *WhatsappMutation) AddedFields() []string {
  42140. var fields []string
  42141. if m.addstatus != nil {
  42142. fields = append(fields, whatsapp.FieldStatus)
  42143. }
  42144. if m.addphone_status != nil {
  42145. fields = append(fields, whatsapp.FieldPhoneStatus)
  42146. }
  42147. if m.addorganization_id != nil {
  42148. fields = append(fields, whatsapp.FieldOrganizationID)
  42149. }
  42150. return fields
  42151. }
  42152. // AddedField returns the numeric value that was incremented/decremented on a field
  42153. // with the given name. The second boolean return value indicates that this field
  42154. // was not set, or was not defined in the schema.
  42155. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  42156. switch name {
  42157. case whatsapp.FieldStatus:
  42158. return m.AddedStatus()
  42159. case whatsapp.FieldPhoneStatus:
  42160. return m.AddedPhoneStatus()
  42161. case whatsapp.FieldOrganizationID:
  42162. return m.AddedOrganizationID()
  42163. }
  42164. return nil, false
  42165. }
  42166. // AddField adds the value to the field with the given name. It returns an error if
  42167. // the field is not defined in the schema, or if the type mismatched the field
  42168. // type.
  42169. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  42170. switch name {
  42171. case whatsapp.FieldStatus:
  42172. v, ok := value.(int8)
  42173. if !ok {
  42174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42175. }
  42176. m.AddStatus(v)
  42177. return nil
  42178. case whatsapp.FieldPhoneStatus:
  42179. v, ok := value.(int8)
  42180. if !ok {
  42181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42182. }
  42183. m.AddPhoneStatus(v)
  42184. return nil
  42185. case whatsapp.FieldOrganizationID:
  42186. v, ok := value.(int64)
  42187. if !ok {
  42188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42189. }
  42190. m.AddOrganizationID(v)
  42191. return nil
  42192. }
  42193. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  42194. }
  42195. // ClearedFields returns all nullable fields that were cleared during this
  42196. // mutation.
  42197. func (m *WhatsappMutation) ClearedFields() []string {
  42198. var fields []string
  42199. if m.FieldCleared(whatsapp.FieldStatus) {
  42200. fields = append(fields, whatsapp.FieldStatus)
  42201. }
  42202. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  42203. fields = append(fields, whatsapp.FieldDeletedAt)
  42204. }
  42205. if m.FieldCleared(whatsapp.FieldWaID) {
  42206. fields = append(fields, whatsapp.FieldWaID)
  42207. }
  42208. if m.FieldCleared(whatsapp.FieldWaName) {
  42209. fields = append(fields, whatsapp.FieldWaName)
  42210. }
  42211. if m.FieldCleared(whatsapp.FieldCallback) {
  42212. fields = append(fields, whatsapp.FieldCallback)
  42213. }
  42214. if m.FieldCleared(whatsapp.FieldAccount) {
  42215. fields = append(fields, whatsapp.FieldAccount)
  42216. }
  42217. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  42218. fields = append(fields, whatsapp.FieldOrganizationID)
  42219. }
  42220. if m.FieldCleared(whatsapp.FieldAPIBase) {
  42221. fields = append(fields, whatsapp.FieldAPIBase)
  42222. }
  42223. if m.FieldCleared(whatsapp.FieldAPIKey) {
  42224. fields = append(fields, whatsapp.FieldAPIKey)
  42225. }
  42226. if m.FieldCleared(whatsapp.FieldAllowList) {
  42227. fields = append(fields, whatsapp.FieldAllowList)
  42228. }
  42229. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  42230. fields = append(fields, whatsapp.FieldGroupAllowList)
  42231. }
  42232. if m.FieldCleared(whatsapp.FieldBlockList) {
  42233. fields = append(fields, whatsapp.FieldBlockList)
  42234. }
  42235. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  42236. fields = append(fields, whatsapp.FieldGroupBlockList)
  42237. }
  42238. return fields
  42239. }
  42240. // FieldCleared returns a boolean indicating if a field with the given name was
  42241. // cleared in this mutation.
  42242. func (m *WhatsappMutation) FieldCleared(name string) bool {
  42243. _, ok := m.clearedFields[name]
  42244. return ok
  42245. }
  42246. // ClearField clears the value of the field with the given name. It returns an
  42247. // error if the field is not defined in the schema.
  42248. func (m *WhatsappMutation) ClearField(name string) error {
  42249. switch name {
  42250. case whatsapp.FieldStatus:
  42251. m.ClearStatus()
  42252. return nil
  42253. case whatsapp.FieldDeletedAt:
  42254. m.ClearDeletedAt()
  42255. return nil
  42256. case whatsapp.FieldWaID:
  42257. m.ClearWaID()
  42258. return nil
  42259. case whatsapp.FieldWaName:
  42260. m.ClearWaName()
  42261. return nil
  42262. case whatsapp.FieldCallback:
  42263. m.ClearCallback()
  42264. return nil
  42265. case whatsapp.FieldAccount:
  42266. m.ClearAccount()
  42267. return nil
  42268. case whatsapp.FieldOrganizationID:
  42269. m.ClearOrganizationID()
  42270. return nil
  42271. case whatsapp.FieldAPIBase:
  42272. m.ClearAPIBase()
  42273. return nil
  42274. case whatsapp.FieldAPIKey:
  42275. m.ClearAPIKey()
  42276. return nil
  42277. case whatsapp.FieldAllowList:
  42278. m.ClearAllowList()
  42279. return nil
  42280. case whatsapp.FieldGroupAllowList:
  42281. m.ClearGroupAllowList()
  42282. return nil
  42283. case whatsapp.FieldBlockList:
  42284. m.ClearBlockList()
  42285. return nil
  42286. case whatsapp.FieldGroupBlockList:
  42287. m.ClearGroupBlockList()
  42288. return nil
  42289. }
  42290. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  42291. }
  42292. // ResetField resets all changes in the mutation for the field with the given name.
  42293. // It returns an error if the field is not defined in the schema.
  42294. func (m *WhatsappMutation) ResetField(name string) error {
  42295. switch name {
  42296. case whatsapp.FieldCreatedAt:
  42297. m.ResetCreatedAt()
  42298. return nil
  42299. case whatsapp.FieldUpdatedAt:
  42300. m.ResetUpdatedAt()
  42301. return nil
  42302. case whatsapp.FieldStatus:
  42303. m.ResetStatus()
  42304. return nil
  42305. case whatsapp.FieldDeletedAt:
  42306. m.ResetDeletedAt()
  42307. return nil
  42308. case whatsapp.FieldWaID:
  42309. m.ResetWaID()
  42310. return nil
  42311. case whatsapp.FieldWaName:
  42312. m.ResetWaName()
  42313. return nil
  42314. case whatsapp.FieldCallback:
  42315. m.ResetCallback()
  42316. return nil
  42317. case whatsapp.FieldAgentID:
  42318. m.ResetAgentID()
  42319. return nil
  42320. case whatsapp.FieldAccount:
  42321. m.ResetAccount()
  42322. return nil
  42323. case whatsapp.FieldCc:
  42324. m.ResetCc()
  42325. return nil
  42326. case whatsapp.FieldPhone:
  42327. m.ResetPhone()
  42328. return nil
  42329. case whatsapp.FieldCcPhone:
  42330. m.ResetCcPhone()
  42331. return nil
  42332. case whatsapp.FieldPhoneName:
  42333. m.ResetPhoneName()
  42334. return nil
  42335. case whatsapp.FieldPhoneStatus:
  42336. m.ResetPhoneStatus()
  42337. return nil
  42338. case whatsapp.FieldOrganizationID:
  42339. m.ResetOrganizationID()
  42340. return nil
  42341. case whatsapp.FieldAPIBase:
  42342. m.ResetAPIBase()
  42343. return nil
  42344. case whatsapp.FieldAPIKey:
  42345. m.ResetAPIKey()
  42346. return nil
  42347. case whatsapp.FieldAllowList:
  42348. m.ResetAllowList()
  42349. return nil
  42350. case whatsapp.FieldGroupAllowList:
  42351. m.ResetGroupAllowList()
  42352. return nil
  42353. case whatsapp.FieldBlockList:
  42354. m.ResetBlockList()
  42355. return nil
  42356. case whatsapp.FieldGroupBlockList:
  42357. m.ResetGroupBlockList()
  42358. return nil
  42359. }
  42360. return fmt.Errorf("unknown Whatsapp field %s", name)
  42361. }
  42362. // AddedEdges returns all edge names that were set/added in this mutation.
  42363. func (m *WhatsappMutation) AddedEdges() []string {
  42364. edges := make([]string, 0, 1)
  42365. if m.agent != nil {
  42366. edges = append(edges, whatsapp.EdgeAgent)
  42367. }
  42368. return edges
  42369. }
  42370. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42371. // name in this mutation.
  42372. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  42373. switch name {
  42374. case whatsapp.EdgeAgent:
  42375. if id := m.agent; id != nil {
  42376. return []ent.Value{*id}
  42377. }
  42378. }
  42379. return nil
  42380. }
  42381. // RemovedEdges returns all edge names that were removed in this mutation.
  42382. func (m *WhatsappMutation) RemovedEdges() []string {
  42383. edges := make([]string, 0, 1)
  42384. return edges
  42385. }
  42386. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42387. // the given name in this mutation.
  42388. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  42389. return nil
  42390. }
  42391. // ClearedEdges returns all edge names that were cleared in this mutation.
  42392. func (m *WhatsappMutation) ClearedEdges() []string {
  42393. edges := make([]string, 0, 1)
  42394. if m.clearedagent {
  42395. edges = append(edges, whatsapp.EdgeAgent)
  42396. }
  42397. return edges
  42398. }
  42399. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42400. // was cleared in this mutation.
  42401. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  42402. switch name {
  42403. case whatsapp.EdgeAgent:
  42404. return m.clearedagent
  42405. }
  42406. return false
  42407. }
  42408. // ClearEdge clears the value of the edge with the given name. It returns an error
  42409. // if that edge is not defined in the schema.
  42410. func (m *WhatsappMutation) ClearEdge(name string) error {
  42411. switch name {
  42412. case whatsapp.EdgeAgent:
  42413. m.ClearAgent()
  42414. return nil
  42415. }
  42416. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  42417. }
  42418. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42419. // It returns an error if the edge is not defined in the schema.
  42420. func (m *WhatsappMutation) ResetEdge(name string) error {
  42421. switch name {
  42422. case whatsapp.EdgeAgent:
  42423. m.ResetAgent()
  42424. return nil
  42425. }
  42426. return fmt.Errorf("unknown Whatsapp edge %s", name)
  42427. }
  42428. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  42429. type WhatsappChannelMutation struct {
  42430. config
  42431. op Op
  42432. typ string
  42433. id *uint64
  42434. created_at *time.Time
  42435. updated_at *time.Time
  42436. status *uint8
  42437. addstatus *int8
  42438. deleted_at *time.Time
  42439. ak *string
  42440. sk *string
  42441. wa_id *string
  42442. wa_name *string
  42443. waba_id *uint64
  42444. addwaba_id *int64
  42445. business_id *uint64
  42446. addbusiness_id *int64
  42447. organization_id *uint64
  42448. addorganization_id *int64
  42449. verify_account *string
  42450. clearedFields map[string]struct{}
  42451. done bool
  42452. oldValue func(context.Context) (*WhatsappChannel, error)
  42453. predicates []predicate.WhatsappChannel
  42454. }
  42455. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  42456. // whatsappchannelOption allows management of the mutation configuration using functional options.
  42457. type whatsappchannelOption func(*WhatsappChannelMutation)
  42458. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  42459. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  42460. m := &WhatsappChannelMutation{
  42461. config: c,
  42462. op: op,
  42463. typ: TypeWhatsappChannel,
  42464. clearedFields: make(map[string]struct{}),
  42465. }
  42466. for _, opt := range opts {
  42467. opt(m)
  42468. }
  42469. return m
  42470. }
  42471. // withWhatsappChannelID sets the ID field of the mutation.
  42472. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  42473. return func(m *WhatsappChannelMutation) {
  42474. var (
  42475. err error
  42476. once sync.Once
  42477. value *WhatsappChannel
  42478. )
  42479. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  42480. once.Do(func() {
  42481. if m.done {
  42482. err = errors.New("querying old values post mutation is not allowed")
  42483. } else {
  42484. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  42485. }
  42486. })
  42487. return value, err
  42488. }
  42489. m.id = &id
  42490. }
  42491. }
  42492. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  42493. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  42494. return func(m *WhatsappChannelMutation) {
  42495. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  42496. return node, nil
  42497. }
  42498. m.id = &node.ID
  42499. }
  42500. }
  42501. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42502. // executed in a transaction (ent.Tx), a transactional client is returned.
  42503. func (m WhatsappChannelMutation) Client() *Client {
  42504. client := &Client{config: m.config}
  42505. client.init()
  42506. return client
  42507. }
  42508. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42509. // it returns an error otherwise.
  42510. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  42511. if _, ok := m.driver.(*txDriver); !ok {
  42512. return nil, errors.New("ent: mutation is not running in a transaction")
  42513. }
  42514. tx := &Tx{config: m.config}
  42515. tx.init()
  42516. return tx, nil
  42517. }
  42518. // SetID sets the value of the id field. Note that this
  42519. // operation is only accepted on creation of WhatsappChannel entities.
  42520. func (m *WhatsappChannelMutation) SetID(id uint64) {
  42521. m.id = &id
  42522. }
  42523. // ID returns the ID value in the mutation. Note that the ID is only available
  42524. // if it was provided to the builder or after it was returned from the database.
  42525. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  42526. if m.id == nil {
  42527. return
  42528. }
  42529. return *m.id, true
  42530. }
  42531. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42532. // That means, if the mutation is applied within a transaction with an isolation level such
  42533. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42534. // or updated by the mutation.
  42535. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  42536. switch {
  42537. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42538. id, exists := m.ID()
  42539. if exists {
  42540. return []uint64{id}, nil
  42541. }
  42542. fallthrough
  42543. case m.op.Is(OpUpdate | OpDelete):
  42544. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  42545. default:
  42546. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42547. }
  42548. }
  42549. // SetCreatedAt sets the "created_at" field.
  42550. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  42551. m.created_at = &t
  42552. }
  42553. // CreatedAt returns the value of the "created_at" field in the mutation.
  42554. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  42555. v := m.created_at
  42556. if v == nil {
  42557. return
  42558. }
  42559. return *v, true
  42560. }
  42561. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  42562. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42564. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42565. if !m.op.Is(OpUpdateOne) {
  42566. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42567. }
  42568. if m.id == nil || m.oldValue == nil {
  42569. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42570. }
  42571. oldValue, err := m.oldValue(ctx)
  42572. if err != nil {
  42573. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42574. }
  42575. return oldValue.CreatedAt, nil
  42576. }
  42577. // ResetCreatedAt resets all changes to the "created_at" field.
  42578. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  42579. m.created_at = nil
  42580. }
  42581. // SetUpdatedAt sets the "updated_at" field.
  42582. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  42583. m.updated_at = &t
  42584. }
  42585. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42586. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  42587. v := m.updated_at
  42588. if v == nil {
  42589. return
  42590. }
  42591. return *v, true
  42592. }
  42593. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  42594. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42596. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42597. if !m.op.Is(OpUpdateOne) {
  42598. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42599. }
  42600. if m.id == nil || m.oldValue == nil {
  42601. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42602. }
  42603. oldValue, err := m.oldValue(ctx)
  42604. if err != nil {
  42605. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42606. }
  42607. return oldValue.UpdatedAt, nil
  42608. }
  42609. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42610. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  42611. m.updated_at = nil
  42612. }
  42613. // SetStatus sets the "status" field.
  42614. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  42615. m.status = &u
  42616. m.addstatus = nil
  42617. }
  42618. // Status returns the value of the "status" field in the mutation.
  42619. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  42620. v := m.status
  42621. if v == nil {
  42622. return
  42623. }
  42624. return *v, true
  42625. }
  42626. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  42627. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42629. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42630. if !m.op.Is(OpUpdateOne) {
  42631. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42632. }
  42633. if m.id == nil || m.oldValue == nil {
  42634. return v, errors.New("OldStatus requires an ID field in the mutation")
  42635. }
  42636. oldValue, err := m.oldValue(ctx)
  42637. if err != nil {
  42638. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42639. }
  42640. return oldValue.Status, nil
  42641. }
  42642. // AddStatus adds u to the "status" field.
  42643. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  42644. if m.addstatus != nil {
  42645. *m.addstatus += u
  42646. } else {
  42647. m.addstatus = &u
  42648. }
  42649. }
  42650. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42651. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  42652. v := m.addstatus
  42653. if v == nil {
  42654. return
  42655. }
  42656. return *v, true
  42657. }
  42658. // ClearStatus clears the value of the "status" field.
  42659. func (m *WhatsappChannelMutation) ClearStatus() {
  42660. m.status = nil
  42661. m.addstatus = nil
  42662. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  42663. }
  42664. // StatusCleared returns if the "status" field was cleared in this mutation.
  42665. func (m *WhatsappChannelMutation) StatusCleared() bool {
  42666. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  42667. return ok
  42668. }
  42669. // ResetStatus resets all changes to the "status" field.
  42670. func (m *WhatsappChannelMutation) ResetStatus() {
  42671. m.status = nil
  42672. m.addstatus = nil
  42673. delete(m.clearedFields, whatsappchannel.FieldStatus)
  42674. }
  42675. // SetDeletedAt sets the "deleted_at" field.
  42676. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  42677. m.deleted_at = &t
  42678. }
  42679. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42680. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  42681. v := m.deleted_at
  42682. if v == nil {
  42683. return
  42684. }
  42685. return *v, true
  42686. }
  42687. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  42688. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42690. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42691. if !m.op.Is(OpUpdateOne) {
  42692. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42693. }
  42694. if m.id == nil || m.oldValue == nil {
  42695. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42696. }
  42697. oldValue, err := m.oldValue(ctx)
  42698. if err != nil {
  42699. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42700. }
  42701. return oldValue.DeletedAt, nil
  42702. }
  42703. // ClearDeletedAt clears the value of the "deleted_at" field.
  42704. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  42705. m.deleted_at = nil
  42706. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  42707. }
  42708. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42709. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  42710. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  42711. return ok
  42712. }
  42713. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42714. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  42715. m.deleted_at = nil
  42716. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  42717. }
  42718. // SetAk sets the "ak" field.
  42719. func (m *WhatsappChannelMutation) SetAk(s string) {
  42720. m.ak = &s
  42721. }
  42722. // Ak returns the value of the "ak" field in the mutation.
  42723. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  42724. v := m.ak
  42725. if v == nil {
  42726. return
  42727. }
  42728. return *v, true
  42729. }
  42730. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  42731. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42733. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  42734. if !m.op.Is(OpUpdateOne) {
  42735. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  42736. }
  42737. if m.id == nil || m.oldValue == nil {
  42738. return v, errors.New("OldAk requires an ID field in the mutation")
  42739. }
  42740. oldValue, err := m.oldValue(ctx)
  42741. if err != nil {
  42742. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  42743. }
  42744. return oldValue.Ak, nil
  42745. }
  42746. // ClearAk clears the value of the "ak" field.
  42747. func (m *WhatsappChannelMutation) ClearAk() {
  42748. m.ak = nil
  42749. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  42750. }
  42751. // AkCleared returns if the "ak" field was cleared in this mutation.
  42752. func (m *WhatsappChannelMutation) AkCleared() bool {
  42753. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  42754. return ok
  42755. }
  42756. // ResetAk resets all changes to the "ak" field.
  42757. func (m *WhatsappChannelMutation) ResetAk() {
  42758. m.ak = nil
  42759. delete(m.clearedFields, whatsappchannel.FieldAk)
  42760. }
  42761. // SetSk sets the "sk" field.
  42762. func (m *WhatsappChannelMutation) SetSk(s string) {
  42763. m.sk = &s
  42764. }
  42765. // Sk returns the value of the "sk" field in the mutation.
  42766. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  42767. v := m.sk
  42768. if v == nil {
  42769. return
  42770. }
  42771. return *v, true
  42772. }
  42773. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  42774. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42776. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  42777. if !m.op.Is(OpUpdateOne) {
  42778. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  42779. }
  42780. if m.id == nil || m.oldValue == nil {
  42781. return v, errors.New("OldSk requires an ID field in the mutation")
  42782. }
  42783. oldValue, err := m.oldValue(ctx)
  42784. if err != nil {
  42785. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  42786. }
  42787. return oldValue.Sk, nil
  42788. }
  42789. // ResetSk resets all changes to the "sk" field.
  42790. func (m *WhatsappChannelMutation) ResetSk() {
  42791. m.sk = nil
  42792. }
  42793. // SetWaID sets the "wa_id" field.
  42794. func (m *WhatsappChannelMutation) SetWaID(s string) {
  42795. m.wa_id = &s
  42796. }
  42797. // WaID returns the value of the "wa_id" field in the mutation.
  42798. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  42799. v := m.wa_id
  42800. if v == nil {
  42801. return
  42802. }
  42803. return *v, true
  42804. }
  42805. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  42806. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42808. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  42809. if !m.op.Is(OpUpdateOne) {
  42810. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  42811. }
  42812. if m.id == nil || m.oldValue == nil {
  42813. return v, errors.New("OldWaID requires an ID field in the mutation")
  42814. }
  42815. oldValue, err := m.oldValue(ctx)
  42816. if err != nil {
  42817. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  42818. }
  42819. return oldValue.WaID, nil
  42820. }
  42821. // ClearWaID clears the value of the "wa_id" field.
  42822. func (m *WhatsappChannelMutation) ClearWaID() {
  42823. m.wa_id = nil
  42824. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  42825. }
  42826. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  42827. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  42828. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  42829. return ok
  42830. }
  42831. // ResetWaID resets all changes to the "wa_id" field.
  42832. func (m *WhatsappChannelMutation) ResetWaID() {
  42833. m.wa_id = nil
  42834. delete(m.clearedFields, whatsappchannel.FieldWaID)
  42835. }
  42836. // SetWaName sets the "wa_name" field.
  42837. func (m *WhatsappChannelMutation) SetWaName(s string) {
  42838. m.wa_name = &s
  42839. }
  42840. // WaName returns the value of the "wa_name" field in the mutation.
  42841. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  42842. v := m.wa_name
  42843. if v == nil {
  42844. return
  42845. }
  42846. return *v, true
  42847. }
  42848. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  42849. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42851. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  42852. if !m.op.Is(OpUpdateOne) {
  42853. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  42854. }
  42855. if m.id == nil || m.oldValue == nil {
  42856. return v, errors.New("OldWaName requires an ID field in the mutation")
  42857. }
  42858. oldValue, err := m.oldValue(ctx)
  42859. if err != nil {
  42860. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  42861. }
  42862. return oldValue.WaName, nil
  42863. }
  42864. // ClearWaName clears the value of the "wa_name" field.
  42865. func (m *WhatsappChannelMutation) ClearWaName() {
  42866. m.wa_name = nil
  42867. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  42868. }
  42869. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  42870. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  42871. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  42872. return ok
  42873. }
  42874. // ResetWaName resets all changes to the "wa_name" field.
  42875. func (m *WhatsappChannelMutation) ResetWaName() {
  42876. m.wa_name = nil
  42877. delete(m.clearedFields, whatsappchannel.FieldWaName)
  42878. }
  42879. // SetWabaID sets the "waba_id" field.
  42880. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  42881. m.waba_id = &u
  42882. m.addwaba_id = nil
  42883. }
  42884. // WabaID returns the value of the "waba_id" field in the mutation.
  42885. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  42886. v := m.waba_id
  42887. if v == nil {
  42888. return
  42889. }
  42890. return *v, true
  42891. }
  42892. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  42893. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42895. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  42896. if !m.op.Is(OpUpdateOne) {
  42897. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  42898. }
  42899. if m.id == nil || m.oldValue == nil {
  42900. return v, errors.New("OldWabaID requires an ID field in the mutation")
  42901. }
  42902. oldValue, err := m.oldValue(ctx)
  42903. if err != nil {
  42904. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  42905. }
  42906. return oldValue.WabaID, nil
  42907. }
  42908. // AddWabaID adds u to the "waba_id" field.
  42909. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  42910. if m.addwaba_id != nil {
  42911. *m.addwaba_id += u
  42912. } else {
  42913. m.addwaba_id = &u
  42914. }
  42915. }
  42916. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  42917. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  42918. v := m.addwaba_id
  42919. if v == nil {
  42920. return
  42921. }
  42922. return *v, true
  42923. }
  42924. // ResetWabaID resets all changes to the "waba_id" field.
  42925. func (m *WhatsappChannelMutation) ResetWabaID() {
  42926. m.waba_id = nil
  42927. m.addwaba_id = nil
  42928. }
  42929. // SetBusinessID sets the "business_id" field.
  42930. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  42931. m.business_id = &u
  42932. m.addbusiness_id = nil
  42933. }
  42934. // BusinessID returns the value of the "business_id" field in the mutation.
  42935. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  42936. v := m.business_id
  42937. if v == nil {
  42938. return
  42939. }
  42940. return *v, true
  42941. }
  42942. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  42943. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42945. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  42946. if !m.op.Is(OpUpdateOne) {
  42947. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  42948. }
  42949. if m.id == nil || m.oldValue == nil {
  42950. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  42951. }
  42952. oldValue, err := m.oldValue(ctx)
  42953. if err != nil {
  42954. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  42955. }
  42956. return oldValue.BusinessID, nil
  42957. }
  42958. // AddBusinessID adds u to the "business_id" field.
  42959. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  42960. if m.addbusiness_id != nil {
  42961. *m.addbusiness_id += u
  42962. } else {
  42963. m.addbusiness_id = &u
  42964. }
  42965. }
  42966. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  42967. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  42968. v := m.addbusiness_id
  42969. if v == nil {
  42970. return
  42971. }
  42972. return *v, true
  42973. }
  42974. // ResetBusinessID resets all changes to the "business_id" field.
  42975. func (m *WhatsappChannelMutation) ResetBusinessID() {
  42976. m.business_id = nil
  42977. m.addbusiness_id = nil
  42978. }
  42979. // SetOrganizationID sets the "organization_id" field.
  42980. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  42981. m.organization_id = &u
  42982. m.addorganization_id = nil
  42983. }
  42984. // OrganizationID returns the value of the "organization_id" field in the mutation.
  42985. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  42986. v := m.organization_id
  42987. if v == nil {
  42988. return
  42989. }
  42990. return *v, true
  42991. }
  42992. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  42993. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42995. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  42996. if !m.op.Is(OpUpdateOne) {
  42997. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  42998. }
  42999. if m.id == nil || m.oldValue == nil {
  43000. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  43001. }
  43002. oldValue, err := m.oldValue(ctx)
  43003. if err != nil {
  43004. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  43005. }
  43006. return oldValue.OrganizationID, nil
  43007. }
  43008. // AddOrganizationID adds u to the "organization_id" field.
  43009. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  43010. if m.addorganization_id != nil {
  43011. *m.addorganization_id += u
  43012. } else {
  43013. m.addorganization_id = &u
  43014. }
  43015. }
  43016. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  43017. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  43018. v := m.addorganization_id
  43019. if v == nil {
  43020. return
  43021. }
  43022. return *v, true
  43023. }
  43024. // ClearOrganizationID clears the value of the "organization_id" field.
  43025. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  43026. m.organization_id = nil
  43027. m.addorganization_id = nil
  43028. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  43029. }
  43030. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  43031. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  43032. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  43033. return ok
  43034. }
  43035. // ResetOrganizationID resets all changes to the "organization_id" field.
  43036. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  43037. m.organization_id = nil
  43038. m.addorganization_id = nil
  43039. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  43040. }
  43041. // SetVerifyAccount sets the "verify_account" field.
  43042. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  43043. m.verify_account = &s
  43044. }
  43045. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  43046. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  43047. v := m.verify_account
  43048. if v == nil {
  43049. return
  43050. }
  43051. return *v, true
  43052. }
  43053. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  43054. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43056. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  43057. if !m.op.Is(OpUpdateOne) {
  43058. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  43059. }
  43060. if m.id == nil || m.oldValue == nil {
  43061. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  43062. }
  43063. oldValue, err := m.oldValue(ctx)
  43064. if err != nil {
  43065. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  43066. }
  43067. return oldValue.VerifyAccount, nil
  43068. }
  43069. // ResetVerifyAccount resets all changes to the "verify_account" field.
  43070. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  43071. m.verify_account = nil
  43072. }
  43073. // Where appends a list predicates to the WhatsappChannelMutation builder.
  43074. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  43075. m.predicates = append(m.predicates, ps...)
  43076. }
  43077. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  43078. // users can use type-assertion to append predicates that do not depend on any generated package.
  43079. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  43080. p := make([]predicate.WhatsappChannel, len(ps))
  43081. for i := range ps {
  43082. p[i] = ps[i]
  43083. }
  43084. m.Where(p...)
  43085. }
  43086. // Op returns the operation name.
  43087. func (m *WhatsappChannelMutation) Op() Op {
  43088. return m.op
  43089. }
  43090. // SetOp allows setting the mutation operation.
  43091. func (m *WhatsappChannelMutation) SetOp(op Op) {
  43092. m.op = op
  43093. }
  43094. // Type returns the node type of this mutation (WhatsappChannel).
  43095. func (m *WhatsappChannelMutation) Type() string {
  43096. return m.typ
  43097. }
  43098. // Fields returns all fields that were changed during this mutation. Note that in
  43099. // order to get all numeric fields that were incremented/decremented, call
  43100. // AddedFields().
  43101. func (m *WhatsappChannelMutation) Fields() []string {
  43102. fields := make([]string, 0, 12)
  43103. if m.created_at != nil {
  43104. fields = append(fields, whatsappchannel.FieldCreatedAt)
  43105. }
  43106. if m.updated_at != nil {
  43107. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  43108. }
  43109. if m.status != nil {
  43110. fields = append(fields, whatsappchannel.FieldStatus)
  43111. }
  43112. if m.deleted_at != nil {
  43113. fields = append(fields, whatsappchannel.FieldDeletedAt)
  43114. }
  43115. if m.ak != nil {
  43116. fields = append(fields, whatsappchannel.FieldAk)
  43117. }
  43118. if m.sk != nil {
  43119. fields = append(fields, whatsappchannel.FieldSk)
  43120. }
  43121. if m.wa_id != nil {
  43122. fields = append(fields, whatsappchannel.FieldWaID)
  43123. }
  43124. if m.wa_name != nil {
  43125. fields = append(fields, whatsappchannel.FieldWaName)
  43126. }
  43127. if m.waba_id != nil {
  43128. fields = append(fields, whatsappchannel.FieldWabaID)
  43129. }
  43130. if m.business_id != nil {
  43131. fields = append(fields, whatsappchannel.FieldBusinessID)
  43132. }
  43133. if m.organization_id != nil {
  43134. fields = append(fields, whatsappchannel.FieldOrganizationID)
  43135. }
  43136. if m.verify_account != nil {
  43137. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  43138. }
  43139. return fields
  43140. }
  43141. // Field returns the value of a field with the given name. The second boolean
  43142. // return value indicates that this field was not set, or was not defined in the
  43143. // schema.
  43144. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  43145. switch name {
  43146. case whatsappchannel.FieldCreatedAt:
  43147. return m.CreatedAt()
  43148. case whatsappchannel.FieldUpdatedAt:
  43149. return m.UpdatedAt()
  43150. case whatsappchannel.FieldStatus:
  43151. return m.Status()
  43152. case whatsappchannel.FieldDeletedAt:
  43153. return m.DeletedAt()
  43154. case whatsappchannel.FieldAk:
  43155. return m.Ak()
  43156. case whatsappchannel.FieldSk:
  43157. return m.Sk()
  43158. case whatsappchannel.FieldWaID:
  43159. return m.WaID()
  43160. case whatsappchannel.FieldWaName:
  43161. return m.WaName()
  43162. case whatsappchannel.FieldWabaID:
  43163. return m.WabaID()
  43164. case whatsappchannel.FieldBusinessID:
  43165. return m.BusinessID()
  43166. case whatsappchannel.FieldOrganizationID:
  43167. return m.OrganizationID()
  43168. case whatsappchannel.FieldVerifyAccount:
  43169. return m.VerifyAccount()
  43170. }
  43171. return nil, false
  43172. }
  43173. // OldField returns the old value of the field from the database. An error is
  43174. // returned if the mutation operation is not UpdateOne, or the query to the
  43175. // database failed.
  43176. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43177. switch name {
  43178. case whatsappchannel.FieldCreatedAt:
  43179. return m.OldCreatedAt(ctx)
  43180. case whatsappchannel.FieldUpdatedAt:
  43181. return m.OldUpdatedAt(ctx)
  43182. case whatsappchannel.FieldStatus:
  43183. return m.OldStatus(ctx)
  43184. case whatsappchannel.FieldDeletedAt:
  43185. return m.OldDeletedAt(ctx)
  43186. case whatsappchannel.FieldAk:
  43187. return m.OldAk(ctx)
  43188. case whatsappchannel.FieldSk:
  43189. return m.OldSk(ctx)
  43190. case whatsappchannel.FieldWaID:
  43191. return m.OldWaID(ctx)
  43192. case whatsappchannel.FieldWaName:
  43193. return m.OldWaName(ctx)
  43194. case whatsappchannel.FieldWabaID:
  43195. return m.OldWabaID(ctx)
  43196. case whatsappchannel.FieldBusinessID:
  43197. return m.OldBusinessID(ctx)
  43198. case whatsappchannel.FieldOrganizationID:
  43199. return m.OldOrganizationID(ctx)
  43200. case whatsappchannel.FieldVerifyAccount:
  43201. return m.OldVerifyAccount(ctx)
  43202. }
  43203. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  43204. }
  43205. // SetField sets the value of a field with the given name. It returns an error if
  43206. // the field is not defined in the schema, or if the type mismatched the field
  43207. // type.
  43208. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  43209. switch name {
  43210. case whatsappchannel.FieldCreatedAt:
  43211. v, ok := value.(time.Time)
  43212. if !ok {
  43213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43214. }
  43215. m.SetCreatedAt(v)
  43216. return nil
  43217. case whatsappchannel.FieldUpdatedAt:
  43218. v, ok := value.(time.Time)
  43219. if !ok {
  43220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43221. }
  43222. m.SetUpdatedAt(v)
  43223. return nil
  43224. case whatsappchannel.FieldStatus:
  43225. v, ok := value.(uint8)
  43226. if !ok {
  43227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43228. }
  43229. m.SetStatus(v)
  43230. return nil
  43231. case whatsappchannel.FieldDeletedAt:
  43232. v, ok := value.(time.Time)
  43233. if !ok {
  43234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43235. }
  43236. m.SetDeletedAt(v)
  43237. return nil
  43238. case whatsappchannel.FieldAk:
  43239. v, ok := value.(string)
  43240. if !ok {
  43241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43242. }
  43243. m.SetAk(v)
  43244. return nil
  43245. case whatsappchannel.FieldSk:
  43246. v, ok := value.(string)
  43247. if !ok {
  43248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43249. }
  43250. m.SetSk(v)
  43251. return nil
  43252. case whatsappchannel.FieldWaID:
  43253. v, ok := value.(string)
  43254. if !ok {
  43255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43256. }
  43257. m.SetWaID(v)
  43258. return nil
  43259. case whatsappchannel.FieldWaName:
  43260. v, ok := value.(string)
  43261. if !ok {
  43262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43263. }
  43264. m.SetWaName(v)
  43265. return nil
  43266. case whatsappchannel.FieldWabaID:
  43267. v, ok := value.(uint64)
  43268. if !ok {
  43269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43270. }
  43271. m.SetWabaID(v)
  43272. return nil
  43273. case whatsappchannel.FieldBusinessID:
  43274. v, ok := value.(uint64)
  43275. if !ok {
  43276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43277. }
  43278. m.SetBusinessID(v)
  43279. return nil
  43280. case whatsappchannel.FieldOrganizationID:
  43281. v, ok := value.(uint64)
  43282. if !ok {
  43283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43284. }
  43285. m.SetOrganizationID(v)
  43286. return nil
  43287. case whatsappchannel.FieldVerifyAccount:
  43288. v, ok := value.(string)
  43289. if !ok {
  43290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43291. }
  43292. m.SetVerifyAccount(v)
  43293. return nil
  43294. }
  43295. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  43296. }
  43297. // AddedFields returns all numeric fields that were incremented/decremented during
  43298. // this mutation.
  43299. func (m *WhatsappChannelMutation) AddedFields() []string {
  43300. var fields []string
  43301. if m.addstatus != nil {
  43302. fields = append(fields, whatsappchannel.FieldStatus)
  43303. }
  43304. if m.addwaba_id != nil {
  43305. fields = append(fields, whatsappchannel.FieldWabaID)
  43306. }
  43307. if m.addbusiness_id != nil {
  43308. fields = append(fields, whatsappchannel.FieldBusinessID)
  43309. }
  43310. if m.addorganization_id != nil {
  43311. fields = append(fields, whatsappchannel.FieldOrganizationID)
  43312. }
  43313. return fields
  43314. }
  43315. // AddedField returns the numeric value that was incremented/decremented on a field
  43316. // with the given name. The second boolean return value indicates that this field
  43317. // was not set, or was not defined in the schema.
  43318. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  43319. switch name {
  43320. case whatsappchannel.FieldStatus:
  43321. return m.AddedStatus()
  43322. case whatsappchannel.FieldWabaID:
  43323. return m.AddedWabaID()
  43324. case whatsappchannel.FieldBusinessID:
  43325. return m.AddedBusinessID()
  43326. case whatsappchannel.FieldOrganizationID:
  43327. return m.AddedOrganizationID()
  43328. }
  43329. return nil, false
  43330. }
  43331. // AddField adds the value to the field with the given name. It returns an error if
  43332. // the field is not defined in the schema, or if the type mismatched the field
  43333. // type.
  43334. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  43335. switch name {
  43336. case whatsappchannel.FieldStatus:
  43337. v, ok := value.(int8)
  43338. if !ok {
  43339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43340. }
  43341. m.AddStatus(v)
  43342. return nil
  43343. case whatsappchannel.FieldWabaID:
  43344. v, ok := value.(int64)
  43345. if !ok {
  43346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43347. }
  43348. m.AddWabaID(v)
  43349. return nil
  43350. case whatsappchannel.FieldBusinessID:
  43351. v, ok := value.(int64)
  43352. if !ok {
  43353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43354. }
  43355. m.AddBusinessID(v)
  43356. return nil
  43357. case whatsappchannel.FieldOrganizationID:
  43358. v, ok := value.(int64)
  43359. if !ok {
  43360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43361. }
  43362. m.AddOrganizationID(v)
  43363. return nil
  43364. }
  43365. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  43366. }
  43367. // ClearedFields returns all nullable fields that were cleared during this
  43368. // mutation.
  43369. func (m *WhatsappChannelMutation) ClearedFields() []string {
  43370. var fields []string
  43371. if m.FieldCleared(whatsappchannel.FieldStatus) {
  43372. fields = append(fields, whatsappchannel.FieldStatus)
  43373. }
  43374. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  43375. fields = append(fields, whatsappchannel.FieldDeletedAt)
  43376. }
  43377. if m.FieldCleared(whatsappchannel.FieldAk) {
  43378. fields = append(fields, whatsappchannel.FieldAk)
  43379. }
  43380. if m.FieldCleared(whatsappchannel.FieldWaID) {
  43381. fields = append(fields, whatsappchannel.FieldWaID)
  43382. }
  43383. if m.FieldCleared(whatsappchannel.FieldWaName) {
  43384. fields = append(fields, whatsappchannel.FieldWaName)
  43385. }
  43386. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  43387. fields = append(fields, whatsappchannel.FieldOrganizationID)
  43388. }
  43389. return fields
  43390. }
  43391. // FieldCleared returns a boolean indicating if a field with the given name was
  43392. // cleared in this mutation.
  43393. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  43394. _, ok := m.clearedFields[name]
  43395. return ok
  43396. }
  43397. // ClearField clears the value of the field with the given name. It returns an
  43398. // error if the field is not defined in the schema.
  43399. func (m *WhatsappChannelMutation) ClearField(name string) error {
  43400. switch name {
  43401. case whatsappchannel.FieldStatus:
  43402. m.ClearStatus()
  43403. return nil
  43404. case whatsappchannel.FieldDeletedAt:
  43405. m.ClearDeletedAt()
  43406. return nil
  43407. case whatsappchannel.FieldAk:
  43408. m.ClearAk()
  43409. return nil
  43410. case whatsappchannel.FieldWaID:
  43411. m.ClearWaID()
  43412. return nil
  43413. case whatsappchannel.FieldWaName:
  43414. m.ClearWaName()
  43415. return nil
  43416. case whatsappchannel.FieldOrganizationID:
  43417. m.ClearOrganizationID()
  43418. return nil
  43419. }
  43420. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  43421. }
  43422. // ResetField resets all changes in the mutation for the field with the given name.
  43423. // It returns an error if the field is not defined in the schema.
  43424. func (m *WhatsappChannelMutation) ResetField(name string) error {
  43425. switch name {
  43426. case whatsappchannel.FieldCreatedAt:
  43427. m.ResetCreatedAt()
  43428. return nil
  43429. case whatsappchannel.FieldUpdatedAt:
  43430. m.ResetUpdatedAt()
  43431. return nil
  43432. case whatsappchannel.FieldStatus:
  43433. m.ResetStatus()
  43434. return nil
  43435. case whatsappchannel.FieldDeletedAt:
  43436. m.ResetDeletedAt()
  43437. return nil
  43438. case whatsappchannel.FieldAk:
  43439. m.ResetAk()
  43440. return nil
  43441. case whatsappchannel.FieldSk:
  43442. m.ResetSk()
  43443. return nil
  43444. case whatsappchannel.FieldWaID:
  43445. m.ResetWaID()
  43446. return nil
  43447. case whatsappchannel.FieldWaName:
  43448. m.ResetWaName()
  43449. return nil
  43450. case whatsappchannel.FieldWabaID:
  43451. m.ResetWabaID()
  43452. return nil
  43453. case whatsappchannel.FieldBusinessID:
  43454. m.ResetBusinessID()
  43455. return nil
  43456. case whatsappchannel.FieldOrganizationID:
  43457. m.ResetOrganizationID()
  43458. return nil
  43459. case whatsappchannel.FieldVerifyAccount:
  43460. m.ResetVerifyAccount()
  43461. return nil
  43462. }
  43463. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  43464. }
  43465. // AddedEdges returns all edge names that were set/added in this mutation.
  43466. func (m *WhatsappChannelMutation) AddedEdges() []string {
  43467. edges := make([]string, 0, 0)
  43468. return edges
  43469. }
  43470. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43471. // name in this mutation.
  43472. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  43473. return nil
  43474. }
  43475. // RemovedEdges returns all edge names that were removed in this mutation.
  43476. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  43477. edges := make([]string, 0, 0)
  43478. return edges
  43479. }
  43480. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43481. // the given name in this mutation.
  43482. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  43483. return nil
  43484. }
  43485. // ClearedEdges returns all edge names that were cleared in this mutation.
  43486. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  43487. edges := make([]string, 0, 0)
  43488. return edges
  43489. }
  43490. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43491. // was cleared in this mutation.
  43492. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  43493. return false
  43494. }
  43495. // ClearEdge clears the value of the edge with the given name. It returns an error
  43496. // if that edge is not defined in the schema.
  43497. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  43498. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  43499. }
  43500. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43501. // It returns an error if the edge is not defined in the schema.
  43502. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  43503. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  43504. }
  43505. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  43506. type WorkExperienceMutation struct {
  43507. config
  43508. op Op
  43509. typ string
  43510. id *uint64
  43511. created_at *time.Time
  43512. updated_at *time.Time
  43513. deleted_at *time.Time
  43514. start_date *time.Time
  43515. end_date *time.Time
  43516. company *string
  43517. experience *string
  43518. organization_id *uint64
  43519. addorganization_id *int64
  43520. clearedFields map[string]struct{}
  43521. employee *uint64
  43522. clearedemployee bool
  43523. done bool
  43524. oldValue func(context.Context) (*WorkExperience, error)
  43525. predicates []predicate.WorkExperience
  43526. }
  43527. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  43528. // workexperienceOption allows management of the mutation configuration using functional options.
  43529. type workexperienceOption func(*WorkExperienceMutation)
  43530. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  43531. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  43532. m := &WorkExperienceMutation{
  43533. config: c,
  43534. op: op,
  43535. typ: TypeWorkExperience,
  43536. clearedFields: make(map[string]struct{}),
  43537. }
  43538. for _, opt := range opts {
  43539. opt(m)
  43540. }
  43541. return m
  43542. }
  43543. // withWorkExperienceID sets the ID field of the mutation.
  43544. func withWorkExperienceID(id uint64) workexperienceOption {
  43545. return func(m *WorkExperienceMutation) {
  43546. var (
  43547. err error
  43548. once sync.Once
  43549. value *WorkExperience
  43550. )
  43551. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  43552. once.Do(func() {
  43553. if m.done {
  43554. err = errors.New("querying old values post mutation is not allowed")
  43555. } else {
  43556. value, err = m.Client().WorkExperience.Get(ctx, id)
  43557. }
  43558. })
  43559. return value, err
  43560. }
  43561. m.id = &id
  43562. }
  43563. }
  43564. // withWorkExperience sets the old WorkExperience of the mutation.
  43565. func withWorkExperience(node *WorkExperience) workexperienceOption {
  43566. return func(m *WorkExperienceMutation) {
  43567. m.oldValue = func(context.Context) (*WorkExperience, error) {
  43568. return node, nil
  43569. }
  43570. m.id = &node.ID
  43571. }
  43572. }
  43573. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43574. // executed in a transaction (ent.Tx), a transactional client is returned.
  43575. func (m WorkExperienceMutation) Client() *Client {
  43576. client := &Client{config: m.config}
  43577. client.init()
  43578. return client
  43579. }
  43580. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43581. // it returns an error otherwise.
  43582. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  43583. if _, ok := m.driver.(*txDriver); !ok {
  43584. return nil, errors.New("ent: mutation is not running in a transaction")
  43585. }
  43586. tx := &Tx{config: m.config}
  43587. tx.init()
  43588. return tx, nil
  43589. }
  43590. // SetID sets the value of the id field. Note that this
  43591. // operation is only accepted on creation of WorkExperience entities.
  43592. func (m *WorkExperienceMutation) SetID(id uint64) {
  43593. m.id = &id
  43594. }
  43595. // ID returns the ID value in the mutation. Note that the ID is only available
  43596. // if it was provided to the builder or after it was returned from the database.
  43597. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  43598. if m.id == nil {
  43599. return
  43600. }
  43601. return *m.id, true
  43602. }
  43603. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43604. // That means, if the mutation is applied within a transaction with an isolation level such
  43605. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43606. // or updated by the mutation.
  43607. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  43608. switch {
  43609. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43610. id, exists := m.ID()
  43611. if exists {
  43612. return []uint64{id}, nil
  43613. }
  43614. fallthrough
  43615. case m.op.Is(OpUpdate | OpDelete):
  43616. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  43617. default:
  43618. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43619. }
  43620. }
  43621. // SetCreatedAt sets the "created_at" field.
  43622. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  43623. m.created_at = &t
  43624. }
  43625. // CreatedAt returns the value of the "created_at" field in the mutation.
  43626. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  43627. v := m.created_at
  43628. if v == nil {
  43629. return
  43630. }
  43631. return *v, true
  43632. }
  43633. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  43634. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43636. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43637. if !m.op.Is(OpUpdateOne) {
  43638. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43639. }
  43640. if m.id == nil || m.oldValue == nil {
  43641. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43642. }
  43643. oldValue, err := m.oldValue(ctx)
  43644. if err != nil {
  43645. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43646. }
  43647. return oldValue.CreatedAt, nil
  43648. }
  43649. // ResetCreatedAt resets all changes to the "created_at" field.
  43650. func (m *WorkExperienceMutation) ResetCreatedAt() {
  43651. m.created_at = nil
  43652. }
  43653. // SetUpdatedAt sets the "updated_at" field.
  43654. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  43655. m.updated_at = &t
  43656. }
  43657. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43658. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  43659. v := m.updated_at
  43660. if v == nil {
  43661. return
  43662. }
  43663. return *v, true
  43664. }
  43665. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  43666. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43668. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43669. if !m.op.Is(OpUpdateOne) {
  43670. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43671. }
  43672. if m.id == nil || m.oldValue == nil {
  43673. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43674. }
  43675. oldValue, err := m.oldValue(ctx)
  43676. if err != nil {
  43677. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43678. }
  43679. return oldValue.UpdatedAt, nil
  43680. }
  43681. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43682. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  43683. m.updated_at = nil
  43684. }
  43685. // SetDeletedAt sets the "deleted_at" field.
  43686. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  43687. m.deleted_at = &t
  43688. }
  43689. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43690. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  43691. v := m.deleted_at
  43692. if v == nil {
  43693. return
  43694. }
  43695. return *v, true
  43696. }
  43697. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  43698. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43700. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43701. if !m.op.Is(OpUpdateOne) {
  43702. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43703. }
  43704. if m.id == nil || m.oldValue == nil {
  43705. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43706. }
  43707. oldValue, err := m.oldValue(ctx)
  43708. if err != nil {
  43709. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43710. }
  43711. return oldValue.DeletedAt, nil
  43712. }
  43713. // ClearDeletedAt clears the value of the "deleted_at" field.
  43714. func (m *WorkExperienceMutation) ClearDeletedAt() {
  43715. m.deleted_at = nil
  43716. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  43717. }
  43718. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43719. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  43720. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  43721. return ok
  43722. }
  43723. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43724. func (m *WorkExperienceMutation) ResetDeletedAt() {
  43725. m.deleted_at = nil
  43726. delete(m.clearedFields, workexperience.FieldDeletedAt)
  43727. }
  43728. // SetEmployeeID sets the "employee_id" field.
  43729. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  43730. m.employee = &u
  43731. }
  43732. // EmployeeID returns the value of the "employee_id" field in the mutation.
  43733. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  43734. v := m.employee
  43735. if v == nil {
  43736. return
  43737. }
  43738. return *v, true
  43739. }
  43740. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  43741. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43743. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  43744. if !m.op.Is(OpUpdateOne) {
  43745. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  43746. }
  43747. if m.id == nil || m.oldValue == nil {
  43748. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  43749. }
  43750. oldValue, err := m.oldValue(ctx)
  43751. if err != nil {
  43752. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  43753. }
  43754. return oldValue.EmployeeID, nil
  43755. }
  43756. // ResetEmployeeID resets all changes to the "employee_id" field.
  43757. func (m *WorkExperienceMutation) ResetEmployeeID() {
  43758. m.employee = nil
  43759. }
  43760. // SetStartDate sets the "start_date" field.
  43761. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  43762. m.start_date = &t
  43763. }
  43764. // StartDate returns the value of the "start_date" field in the mutation.
  43765. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  43766. v := m.start_date
  43767. if v == nil {
  43768. return
  43769. }
  43770. return *v, true
  43771. }
  43772. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  43773. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43775. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  43776. if !m.op.Is(OpUpdateOne) {
  43777. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  43778. }
  43779. if m.id == nil || m.oldValue == nil {
  43780. return v, errors.New("OldStartDate requires an ID field in the mutation")
  43781. }
  43782. oldValue, err := m.oldValue(ctx)
  43783. if err != nil {
  43784. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  43785. }
  43786. return oldValue.StartDate, nil
  43787. }
  43788. // ResetStartDate resets all changes to the "start_date" field.
  43789. func (m *WorkExperienceMutation) ResetStartDate() {
  43790. m.start_date = nil
  43791. }
  43792. // SetEndDate sets the "end_date" field.
  43793. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  43794. m.end_date = &t
  43795. }
  43796. // EndDate returns the value of the "end_date" field in the mutation.
  43797. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  43798. v := m.end_date
  43799. if v == nil {
  43800. return
  43801. }
  43802. return *v, true
  43803. }
  43804. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  43805. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43807. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  43808. if !m.op.Is(OpUpdateOne) {
  43809. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  43810. }
  43811. if m.id == nil || m.oldValue == nil {
  43812. return v, errors.New("OldEndDate requires an ID field in the mutation")
  43813. }
  43814. oldValue, err := m.oldValue(ctx)
  43815. if err != nil {
  43816. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  43817. }
  43818. return oldValue.EndDate, nil
  43819. }
  43820. // ResetEndDate resets all changes to the "end_date" field.
  43821. func (m *WorkExperienceMutation) ResetEndDate() {
  43822. m.end_date = nil
  43823. }
  43824. // SetCompany sets the "company" field.
  43825. func (m *WorkExperienceMutation) SetCompany(s string) {
  43826. m.company = &s
  43827. }
  43828. // Company returns the value of the "company" field in the mutation.
  43829. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  43830. v := m.company
  43831. if v == nil {
  43832. return
  43833. }
  43834. return *v, true
  43835. }
  43836. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  43837. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43839. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  43840. if !m.op.Is(OpUpdateOne) {
  43841. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  43842. }
  43843. if m.id == nil || m.oldValue == nil {
  43844. return v, errors.New("OldCompany requires an ID field in the mutation")
  43845. }
  43846. oldValue, err := m.oldValue(ctx)
  43847. if err != nil {
  43848. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  43849. }
  43850. return oldValue.Company, nil
  43851. }
  43852. // ResetCompany resets all changes to the "company" field.
  43853. func (m *WorkExperienceMutation) ResetCompany() {
  43854. m.company = nil
  43855. }
  43856. // SetExperience sets the "experience" field.
  43857. func (m *WorkExperienceMutation) SetExperience(s string) {
  43858. m.experience = &s
  43859. }
  43860. // Experience returns the value of the "experience" field in the mutation.
  43861. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  43862. v := m.experience
  43863. if v == nil {
  43864. return
  43865. }
  43866. return *v, true
  43867. }
  43868. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  43869. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43871. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  43872. if !m.op.Is(OpUpdateOne) {
  43873. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  43874. }
  43875. if m.id == nil || m.oldValue == nil {
  43876. return v, errors.New("OldExperience requires an ID field in the mutation")
  43877. }
  43878. oldValue, err := m.oldValue(ctx)
  43879. if err != nil {
  43880. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  43881. }
  43882. return oldValue.Experience, nil
  43883. }
  43884. // ResetExperience resets all changes to the "experience" field.
  43885. func (m *WorkExperienceMutation) ResetExperience() {
  43886. m.experience = nil
  43887. }
  43888. // SetOrganizationID sets the "organization_id" field.
  43889. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  43890. m.organization_id = &u
  43891. m.addorganization_id = nil
  43892. }
  43893. // OrganizationID returns the value of the "organization_id" field in the mutation.
  43894. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  43895. v := m.organization_id
  43896. if v == nil {
  43897. return
  43898. }
  43899. return *v, true
  43900. }
  43901. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  43902. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  43903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43904. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  43905. if !m.op.Is(OpUpdateOne) {
  43906. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  43907. }
  43908. if m.id == nil || m.oldValue == nil {
  43909. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  43910. }
  43911. oldValue, err := m.oldValue(ctx)
  43912. if err != nil {
  43913. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  43914. }
  43915. return oldValue.OrganizationID, nil
  43916. }
  43917. // AddOrganizationID adds u to the "organization_id" field.
  43918. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  43919. if m.addorganization_id != nil {
  43920. *m.addorganization_id += u
  43921. } else {
  43922. m.addorganization_id = &u
  43923. }
  43924. }
  43925. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  43926. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  43927. v := m.addorganization_id
  43928. if v == nil {
  43929. return
  43930. }
  43931. return *v, true
  43932. }
  43933. // ResetOrganizationID resets all changes to the "organization_id" field.
  43934. func (m *WorkExperienceMutation) ResetOrganizationID() {
  43935. m.organization_id = nil
  43936. m.addorganization_id = nil
  43937. }
  43938. // ClearEmployee clears the "employee" edge to the Employee entity.
  43939. func (m *WorkExperienceMutation) ClearEmployee() {
  43940. m.clearedemployee = true
  43941. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  43942. }
  43943. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  43944. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  43945. return m.clearedemployee
  43946. }
  43947. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  43948. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43949. // EmployeeID instead. It exists only for internal usage by the builders.
  43950. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  43951. if id := m.employee; id != nil {
  43952. ids = append(ids, *id)
  43953. }
  43954. return
  43955. }
  43956. // ResetEmployee resets all changes to the "employee" edge.
  43957. func (m *WorkExperienceMutation) ResetEmployee() {
  43958. m.employee = nil
  43959. m.clearedemployee = false
  43960. }
  43961. // Where appends a list predicates to the WorkExperienceMutation builder.
  43962. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  43963. m.predicates = append(m.predicates, ps...)
  43964. }
  43965. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  43966. // users can use type-assertion to append predicates that do not depend on any generated package.
  43967. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  43968. p := make([]predicate.WorkExperience, len(ps))
  43969. for i := range ps {
  43970. p[i] = ps[i]
  43971. }
  43972. m.Where(p...)
  43973. }
  43974. // Op returns the operation name.
  43975. func (m *WorkExperienceMutation) Op() Op {
  43976. return m.op
  43977. }
  43978. // SetOp allows setting the mutation operation.
  43979. func (m *WorkExperienceMutation) SetOp(op Op) {
  43980. m.op = op
  43981. }
  43982. // Type returns the node type of this mutation (WorkExperience).
  43983. func (m *WorkExperienceMutation) Type() string {
  43984. return m.typ
  43985. }
  43986. // Fields returns all fields that were changed during this mutation. Note that in
  43987. // order to get all numeric fields that were incremented/decremented, call
  43988. // AddedFields().
  43989. func (m *WorkExperienceMutation) Fields() []string {
  43990. fields := make([]string, 0, 9)
  43991. if m.created_at != nil {
  43992. fields = append(fields, workexperience.FieldCreatedAt)
  43993. }
  43994. if m.updated_at != nil {
  43995. fields = append(fields, workexperience.FieldUpdatedAt)
  43996. }
  43997. if m.deleted_at != nil {
  43998. fields = append(fields, workexperience.FieldDeletedAt)
  43999. }
  44000. if m.employee != nil {
  44001. fields = append(fields, workexperience.FieldEmployeeID)
  44002. }
  44003. if m.start_date != nil {
  44004. fields = append(fields, workexperience.FieldStartDate)
  44005. }
  44006. if m.end_date != nil {
  44007. fields = append(fields, workexperience.FieldEndDate)
  44008. }
  44009. if m.company != nil {
  44010. fields = append(fields, workexperience.FieldCompany)
  44011. }
  44012. if m.experience != nil {
  44013. fields = append(fields, workexperience.FieldExperience)
  44014. }
  44015. if m.organization_id != nil {
  44016. fields = append(fields, workexperience.FieldOrganizationID)
  44017. }
  44018. return fields
  44019. }
  44020. // Field returns the value of a field with the given name. The second boolean
  44021. // return value indicates that this field was not set, or was not defined in the
  44022. // schema.
  44023. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  44024. switch name {
  44025. case workexperience.FieldCreatedAt:
  44026. return m.CreatedAt()
  44027. case workexperience.FieldUpdatedAt:
  44028. return m.UpdatedAt()
  44029. case workexperience.FieldDeletedAt:
  44030. return m.DeletedAt()
  44031. case workexperience.FieldEmployeeID:
  44032. return m.EmployeeID()
  44033. case workexperience.FieldStartDate:
  44034. return m.StartDate()
  44035. case workexperience.FieldEndDate:
  44036. return m.EndDate()
  44037. case workexperience.FieldCompany:
  44038. return m.Company()
  44039. case workexperience.FieldExperience:
  44040. return m.Experience()
  44041. case workexperience.FieldOrganizationID:
  44042. return m.OrganizationID()
  44043. }
  44044. return nil, false
  44045. }
  44046. // OldField returns the old value of the field from the database. An error is
  44047. // returned if the mutation operation is not UpdateOne, or the query to the
  44048. // database failed.
  44049. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44050. switch name {
  44051. case workexperience.FieldCreatedAt:
  44052. return m.OldCreatedAt(ctx)
  44053. case workexperience.FieldUpdatedAt:
  44054. return m.OldUpdatedAt(ctx)
  44055. case workexperience.FieldDeletedAt:
  44056. return m.OldDeletedAt(ctx)
  44057. case workexperience.FieldEmployeeID:
  44058. return m.OldEmployeeID(ctx)
  44059. case workexperience.FieldStartDate:
  44060. return m.OldStartDate(ctx)
  44061. case workexperience.FieldEndDate:
  44062. return m.OldEndDate(ctx)
  44063. case workexperience.FieldCompany:
  44064. return m.OldCompany(ctx)
  44065. case workexperience.FieldExperience:
  44066. return m.OldExperience(ctx)
  44067. case workexperience.FieldOrganizationID:
  44068. return m.OldOrganizationID(ctx)
  44069. }
  44070. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  44071. }
  44072. // SetField sets the value of a field with the given name. It returns an error if
  44073. // the field is not defined in the schema, or if the type mismatched the field
  44074. // type.
  44075. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  44076. switch name {
  44077. case workexperience.FieldCreatedAt:
  44078. v, ok := value.(time.Time)
  44079. if !ok {
  44080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44081. }
  44082. m.SetCreatedAt(v)
  44083. return nil
  44084. case workexperience.FieldUpdatedAt:
  44085. v, ok := value.(time.Time)
  44086. if !ok {
  44087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44088. }
  44089. m.SetUpdatedAt(v)
  44090. return nil
  44091. case workexperience.FieldDeletedAt:
  44092. v, ok := value.(time.Time)
  44093. if !ok {
  44094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44095. }
  44096. m.SetDeletedAt(v)
  44097. return nil
  44098. case workexperience.FieldEmployeeID:
  44099. v, ok := value.(uint64)
  44100. if !ok {
  44101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44102. }
  44103. m.SetEmployeeID(v)
  44104. return nil
  44105. case workexperience.FieldStartDate:
  44106. v, ok := value.(time.Time)
  44107. if !ok {
  44108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44109. }
  44110. m.SetStartDate(v)
  44111. return nil
  44112. case workexperience.FieldEndDate:
  44113. v, ok := value.(time.Time)
  44114. if !ok {
  44115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44116. }
  44117. m.SetEndDate(v)
  44118. return nil
  44119. case workexperience.FieldCompany:
  44120. v, ok := value.(string)
  44121. if !ok {
  44122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44123. }
  44124. m.SetCompany(v)
  44125. return nil
  44126. case workexperience.FieldExperience:
  44127. v, ok := value.(string)
  44128. if !ok {
  44129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44130. }
  44131. m.SetExperience(v)
  44132. return nil
  44133. case workexperience.FieldOrganizationID:
  44134. v, ok := value.(uint64)
  44135. if !ok {
  44136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44137. }
  44138. m.SetOrganizationID(v)
  44139. return nil
  44140. }
  44141. return fmt.Errorf("unknown WorkExperience field %s", name)
  44142. }
  44143. // AddedFields returns all numeric fields that were incremented/decremented during
  44144. // this mutation.
  44145. func (m *WorkExperienceMutation) AddedFields() []string {
  44146. var fields []string
  44147. if m.addorganization_id != nil {
  44148. fields = append(fields, workexperience.FieldOrganizationID)
  44149. }
  44150. return fields
  44151. }
  44152. // AddedField returns the numeric value that was incremented/decremented on a field
  44153. // with the given name. The second boolean return value indicates that this field
  44154. // was not set, or was not defined in the schema.
  44155. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  44156. switch name {
  44157. case workexperience.FieldOrganizationID:
  44158. return m.AddedOrganizationID()
  44159. }
  44160. return nil, false
  44161. }
  44162. // AddField adds the value to the field with the given name. It returns an error if
  44163. // the field is not defined in the schema, or if the type mismatched the field
  44164. // type.
  44165. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  44166. switch name {
  44167. case workexperience.FieldOrganizationID:
  44168. v, ok := value.(int64)
  44169. if !ok {
  44170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44171. }
  44172. m.AddOrganizationID(v)
  44173. return nil
  44174. }
  44175. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  44176. }
  44177. // ClearedFields returns all nullable fields that were cleared during this
  44178. // mutation.
  44179. func (m *WorkExperienceMutation) ClearedFields() []string {
  44180. var fields []string
  44181. if m.FieldCleared(workexperience.FieldDeletedAt) {
  44182. fields = append(fields, workexperience.FieldDeletedAt)
  44183. }
  44184. return fields
  44185. }
  44186. // FieldCleared returns a boolean indicating if a field with the given name was
  44187. // cleared in this mutation.
  44188. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  44189. _, ok := m.clearedFields[name]
  44190. return ok
  44191. }
  44192. // ClearField clears the value of the field with the given name. It returns an
  44193. // error if the field is not defined in the schema.
  44194. func (m *WorkExperienceMutation) ClearField(name string) error {
  44195. switch name {
  44196. case workexperience.FieldDeletedAt:
  44197. m.ClearDeletedAt()
  44198. return nil
  44199. }
  44200. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  44201. }
  44202. // ResetField resets all changes in the mutation for the field with the given name.
  44203. // It returns an error if the field is not defined in the schema.
  44204. func (m *WorkExperienceMutation) ResetField(name string) error {
  44205. switch name {
  44206. case workexperience.FieldCreatedAt:
  44207. m.ResetCreatedAt()
  44208. return nil
  44209. case workexperience.FieldUpdatedAt:
  44210. m.ResetUpdatedAt()
  44211. return nil
  44212. case workexperience.FieldDeletedAt:
  44213. m.ResetDeletedAt()
  44214. return nil
  44215. case workexperience.FieldEmployeeID:
  44216. m.ResetEmployeeID()
  44217. return nil
  44218. case workexperience.FieldStartDate:
  44219. m.ResetStartDate()
  44220. return nil
  44221. case workexperience.FieldEndDate:
  44222. m.ResetEndDate()
  44223. return nil
  44224. case workexperience.FieldCompany:
  44225. m.ResetCompany()
  44226. return nil
  44227. case workexperience.FieldExperience:
  44228. m.ResetExperience()
  44229. return nil
  44230. case workexperience.FieldOrganizationID:
  44231. m.ResetOrganizationID()
  44232. return nil
  44233. }
  44234. return fmt.Errorf("unknown WorkExperience field %s", name)
  44235. }
  44236. // AddedEdges returns all edge names that were set/added in this mutation.
  44237. func (m *WorkExperienceMutation) AddedEdges() []string {
  44238. edges := make([]string, 0, 1)
  44239. if m.employee != nil {
  44240. edges = append(edges, workexperience.EdgeEmployee)
  44241. }
  44242. return edges
  44243. }
  44244. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44245. // name in this mutation.
  44246. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  44247. switch name {
  44248. case workexperience.EdgeEmployee:
  44249. if id := m.employee; id != nil {
  44250. return []ent.Value{*id}
  44251. }
  44252. }
  44253. return nil
  44254. }
  44255. // RemovedEdges returns all edge names that were removed in this mutation.
  44256. func (m *WorkExperienceMutation) RemovedEdges() []string {
  44257. edges := make([]string, 0, 1)
  44258. return edges
  44259. }
  44260. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44261. // the given name in this mutation.
  44262. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  44263. return nil
  44264. }
  44265. // ClearedEdges returns all edge names that were cleared in this mutation.
  44266. func (m *WorkExperienceMutation) ClearedEdges() []string {
  44267. edges := make([]string, 0, 1)
  44268. if m.clearedemployee {
  44269. edges = append(edges, workexperience.EdgeEmployee)
  44270. }
  44271. return edges
  44272. }
  44273. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44274. // was cleared in this mutation.
  44275. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  44276. switch name {
  44277. case workexperience.EdgeEmployee:
  44278. return m.clearedemployee
  44279. }
  44280. return false
  44281. }
  44282. // ClearEdge clears the value of the edge with the given name. It returns an error
  44283. // if that edge is not defined in the schema.
  44284. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  44285. switch name {
  44286. case workexperience.EdgeEmployee:
  44287. m.ClearEmployee()
  44288. return nil
  44289. }
  44290. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  44291. }
  44292. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44293. // It returns an error if the edge is not defined in the schema.
  44294. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  44295. switch name {
  44296. case workexperience.EdgeEmployee:
  44297. m.ResetEmployee()
  44298. return nil
  44299. }
  44300. return fmt.Errorf("unknown WorkExperience edge %s", name)
  44301. }
  44302. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  44303. type WpChatroomMutation struct {
  44304. config
  44305. op Op
  44306. typ string
  44307. id *uint64
  44308. created_at *time.Time
  44309. updated_at *time.Time
  44310. status *uint8
  44311. addstatus *int8
  44312. wx_wxid *string
  44313. chatroom_id *string
  44314. nickname *string
  44315. owner *string
  44316. avatar *string
  44317. member_list *[]string
  44318. appendmember_list []string
  44319. clearedFields map[string]struct{}
  44320. done bool
  44321. oldValue func(context.Context) (*WpChatroom, error)
  44322. predicates []predicate.WpChatroom
  44323. }
  44324. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  44325. // wpchatroomOption allows management of the mutation configuration using functional options.
  44326. type wpchatroomOption func(*WpChatroomMutation)
  44327. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  44328. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  44329. m := &WpChatroomMutation{
  44330. config: c,
  44331. op: op,
  44332. typ: TypeWpChatroom,
  44333. clearedFields: make(map[string]struct{}),
  44334. }
  44335. for _, opt := range opts {
  44336. opt(m)
  44337. }
  44338. return m
  44339. }
  44340. // withWpChatroomID sets the ID field of the mutation.
  44341. func withWpChatroomID(id uint64) wpchatroomOption {
  44342. return func(m *WpChatroomMutation) {
  44343. var (
  44344. err error
  44345. once sync.Once
  44346. value *WpChatroom
  44347. )
  44348. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  44349. once.Do(func() {
  44350. if m.done {
  44351. err = errors.New("querying old values post mutation is not allowed")
  44352. } else {
  44353. value, err = m.Client().WpChatroom.Get(ctx, id)
  44354. }
  44355. })
  44356. return value, err
  44357. }
  44358. m.id = &id
  44359. }
  44360. }
  44361. // withWpChatroom sets the old WpChatroom of the mutation.
  44362. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  44363. return func(m *WpChatroomMutation) {
  44364. m.oldValue = func(context.Context) (*WpChatroom, error) {
  44365. return node, nil
  44366. }
  44367. m.id = &node.ID
  44368. }
  44369. }
  44370. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44371. // executed in a transaction (ent.Tx), a transactional client is returned.
  44372. func (m WpChatroomMutation) Client() *Client {
  44373. client := &Client{config: m.config}
  44374. client.init()
  44375. return client
  44376. }
  44377. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44378. // it returns an error otherwise.
  44379. func (m WpChatroomMutation) Tx() (*Tx, error) {
  44380. if _, ok := m.driver.(*txDriver); !ok {
  44381. return nil, errors.New("ent: mutation is not running in a transaction")
  44382. }
  44383. tx := &Tx{config: m.config}
  44384. tx.init()
  44385. return tx, nil
  44386. }
  44387. // SetID sets the value of the id field. Note that this
  44388. // operation is only accepted on creation of WpChatroom entities.
  44389. func (m *WpChatroomMutation) SetID(id uint64) {
  44390. m.id = &id
  44391. }
  44392. // ID returns the ID value in the mutation. Note that the ID is only available
  44393. // if it was provided to the builder or after it was returned from the database.
  44394. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  44395. if m.id == nil {
  44396. return
  44397. }
  44398. return *m.id, true
  44399. }
  44400. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44401. // That means, if the mutation is applied within a transaction with an isolation level such
  44402. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44403. // or updated by the mutation.
  44404. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  44405. switch {
  44406. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44407. id, exists := m.ID()
  44408. if exists {
  44409. return []uint64{id}, nil
  44410. }
  44411. fallthrough
  44412. case m.op.Is(OpUpdate | OpDelete):
  44413. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  44414. default:
  44415. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44416. }
  44417. }
  44418. // SetCreatedAt sets the "created_at" field.
  44419. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  44420. m.created_at = &t
  44421. }
  44422. // CreatedAt returns the value of the "created_at" field in the mutation.
  44423. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  44424. v := m.created_at
  44425. if v == nil {
  44426. return
  44427. }
  44428. return *v, true
  44429. }
  44430. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  44431. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44433. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44434. if !m.op.Is(OpUpdateOne) {
  44435. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44436. }
  44437. if m.id == nil || m.oldValue == nil {
  44438. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44439. }
  44440. oldValue, err := m.oldValue(ctx)
  44441. if err != nil {
  44442. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44443. }
  44444. return oldValue.CreatedAt, nil
  44445. }
  44446. // ResetCreatedAt resets all changes to the "created_at" field.
  44447. func (m *WpChatroomMutation) ResetCreatedAt() {
  44448. m.created_at = nil
  44449. }
  44450. // SetUpdatedAt sets the "updated_at" field.
  44451. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  44452. m.updated_at = &t
  44453. }
  44454. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44455. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  44456. v := m.updated_at
  44457. if v == nil {
  44458. return
  44459. }
  44460. return *v, true
  44461. }
  44462. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  44463. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44465. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44466. if !m.op.Is(OpUpdateOne) {
  44467. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44468. }
  44469. if m.id == nil || m.oldValue == nil {
  44470. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44471. }
  44472. oldValue, err := m.oldValue(ctx)
  44473. if err != nil {
  44474. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44475. }
  44476. return oldValue.UpdatedAt, nil
  44477. }
  44478. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44479. func (m *WpChatroomMutation) ResetUpdatedAt() {
  44480. m.updated_at = nil
  44481. }
  44482. // SetStatus sets the "status" field.
  44483. func (m *WpChatroomMutation) SetStatus(u uint8) {
  44484. m.status = &u
  44485. m.addstatus = nil
  44486. }
  44487. // Status returns the value of the "status" field in the mutation.
  44488. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  44489. v := m.status
  44490. if v == nil {
  44491. return
  44492. }
  44493. return *v, true
  44494. }
  44495. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  44496. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44498. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  44499. if !m.op.Is(OpUpdateOne) {
  44500. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  44501. }
  44502. if m.id == nil || m.oldValue == nil {
  44503. return v, errors.New("OldStatus requires an ID field in the mutation")
  44504. }
  44505. oldValue, err := m.oldValue(ctx)
  44506. if err != nil {
  44507. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  44508. }
  44509. return oldValue.Status, nil
  44510. }
  44511. // AddStatus adds u to the "status" field.
  44512. func (m *WpChatroomMutation) AddStatus(u int8) {
  44513. if m.addstatus != nil {
  44514. *m.addstatus += u
  44515. } else {
  44516. m.addstatus = &u
  44517. }
  44518. }
  44519. // AddedStatus returns the value that was added to the "status" field in this mutation.
  44520. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  44521. v := m.addstatus
  44522. if v == nil {
  44523. return
  44524. }
  44525. return *v, true
  44526. }
  44527. // ClearStatus clears the value of the "status" field.
  44528. func (m *WpChatroomMutation) ClearStatus() {
  44529. m.status = nil
  44530. m.addstatus = nil
  44531. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  44532. }
  44533. // StatusCleared returns if the "status" field was cleared in this mutation.
  44534. func (m *WpChatroomMutation) StatusCleared() bool {
  44535. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  44536. return ok
  44537. }
  44538. // ResetStatus resets all changes to the "status" field.
  44539. func (m *WpChatroomMutation) ResetStatus() {
  44540. m.status = nil
  44541. m.addstatus = nil
  44542. delete(m.clearedFields, wpchatroom.FieldStatus)
  44543. }
  44544. // SetWxWxid sets the "wx_wxid" field.
  44545. func (m *WpChatroomMutation) SetWxWxid(s string) {
  44546. m.wx_wxid = &s
  44547. }
  44548. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  44549. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  44550. v := m.wx_wxid
  44551. if v == nil {
  44552. return
  44553. }
  44554. return *v, true
  44555. }
  44556. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  44557. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44559. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  44560. if !m.op.Is(OpUpdateOne) {
  44561. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  44562. }
  44563. if m.id == nil || m.oldValue == nil {
  44564. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  44565. }
  44566. oldValue, err := m.oldValue(ctx)
  44567. if err != nil {
  44568. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  44569. }
  44570. return oldValue.WxWxid, nil
  44571. }
  44572. // ResetWxWxid resets all changes to the "wx_wxid" field.
  44573. func (m *WpChatroomMutation) ResetWxWxid() {
  44574. m.wx_wxid = nil
  44575. }
  44576. // SetChatroomID sets the "chatroom_id" field.
  44577. func (m *WpChatroomMutation) SetChatroomID(s string) {
  44578. m.chatroom_id = &s
  44579. }
  44580. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  44581. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  44582. v := m.chatroom_id
  44583. if v == nil {
  44584. return
  44585. }
  44586. return *v, true
  44587. }
  44588. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  44589. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44591. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  44592. if !m.op.Is(OpUpdateOne) {
  44593. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  44594. }
  44595. if m.id == nil || m.oldValue == nil {
  44596. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  44597. }
  44598. oldValue, err := m.oldValue(ctx)
  44599. if err != nil {
  44600. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  44601. }
  44602. return oldValue.ChatroomID, nil
  44603. }
  44604. // ResetChatroomID resets all changes to the "chatroom_id" field.
  44605. func (m *WpChatroomMutation) ResetChatroomID() {
  44606. m.chatroom_id = nil
  44607. }
  44608. // SetNickname sets the "nickname" field.
  44609. func (m *WpChatroomMutation) SetNickname(s string) {
  44610. m.nickname = &s
  44611. }
  44612. // Nickname returns the value of the "nickname" field in the mutation.
  44613. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  44614. v := m.nickname
  44615. if v == nil {
  44616. return
  44617. }
  44618. return *v, true
  44619. }
  44620. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  44621. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44623. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  44624. if !m.op.Is(OpUpdateOne) {
  44625. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44626. }
  44627. if m.id == nil || m.oldValue == nil {
  44628. return v, errors.New("OldNickname requires an ID field in the mutation")
  44629. }
  44630. oldValue, err := m.oldValue(ctx)
  44631. if err != nil {
  44632. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  44633. }
  44634. return oldValue.Nickname, nil
  44635. }
  44636. // ResetNickname resets all changes to the "nickname" field.
  44637. func (m *WpChatroomMutation) ResetNickname() {
  44638. m.nickname = nil
  44639. }
  44640. // SetOwner sets the "owner" field.
  44641. func (m *WpChatroomMutation) SetOwner(s string) {
  44642. m.owner = &s
  44643. }
  44644. // Owner returns the value of the "owner" field in the mutation.
  44645. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  44646. v := m.owner
  44647. if v == nil {
  44648. return
  44649. }
  44650. return *v, true
  44651. }
  44652. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  44653. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44655. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  44656. if !m.op.Is(OpUpdateOne) {
  44657. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  44658. }
  44659. if m.id == nil || m.oldValue == nil {
  44660. return v, errors.New("OldOwner requires an ID field in the mutation")
  44661. }
  44662. oldValue, err := m.oldValue(ctx)
  44663. if err != nil {
  44664. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  44665. }
  44666. return oldValue.Owner, nil
  44667. }
  44668. // ResetOwner resets all changes to the "owner" field.
  44669. func (m *WpChatroomMutation) ResetOwner() {
  44670. m.owner = nil
  44671. }
  44672. // SetAvatar sets the "avatar" field.
  44673. func (m *WpChatroomMutation) SetAvatar(s string) {
  44674. m.avatar = &s
  44675. }
  44676. // Avatar returns the value of the "avatar" field in the mutation.
  44677. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  44678. v := m.avatar
  44679. if v == nil {
  44680. return
  44681. }
  44682. return *v, true
  44683. }
  44684. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  44685. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44687. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44688. if !m.op.Is(OpUpdateOne) {
  44689. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44690. }
  44691. if m.id == nil || m.oldValue == nil {
  44692. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44693. }
  44694. oldValue, err := m.oldValue(ctx)
  44695. if err != nil {
  44696. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44697. }
  44698. return oldValue.Avatar, nil
  44699. }
  44700. // ResetAvatar resets all changes to the "avatar" field.
  44701. func (m *WpChatroomMutation) ResetAvatar() {
  44702. m.avatar = nil
  44703. }
  44704. // SetMemberList sets the "member_list" field.
  44705. func (m *WpChatroomMutation) SetMemberList(s []string) {
  44706. m.member_list = &s
  44707. m.appendmember_list = nil
  44708. }
  44709. // MemberList returns the value of the "member_list" field in the mutation.
  44710. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  44711. v := m.member_list
  44712. if v == nil {
  44713. return
  44714. }
  44715. return *v, true
  44716. }
  44717. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  44718. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  44719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44720. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  44721. if !m.op.Is(OpUpdateOne) {
  44722. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  44723. }
  44724. if m.id == nil || m.oldValue == nil {
  44725. return v, errors.New("OldMemberList requires an ID field in the mutation")
  44726. }
  44727. oldValue, err := m.oldValue(ctx)
  44728. if err != nil {
  44729. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  44730. }
  44731. return oldValue.MemberList, nil
  44732. }
  44733. // AppendMemberList adds s to the "member_list" field.
  44734. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  44735. m.appendmember_list = append(m.appendmember_list, s...)
  44736. }
  44737. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  44738. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  44739. if len(m.appendmember_list) == 0 {
  44740. return nil, false
  44741. }
  44742. return m.appendmember_list, true
  44743. }
  44744. // ResetMemberList resets all changes to the "member_list" field.
  44745. func (m *WpChatroomMutation) ResetMemberList() {
  44746. m.member_list = nil
  44747. m.appendmember_list = nil
  44748. }
  44749. // Where appends a list predicates to the WpChatroomMutation builder.
  44750. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  44751. m.predicates = append(m.predicates, ps...)
  44752. }
  44753. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  44754. // users can use type-assertion to append predicates that do not depend on any generated package.
  44755. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  44756. p := make([]predicate.WpChatroom, len(ps))
  44757. for i := range ps {
  44758. p[i] = ps[i]
  44759. }
  44760. m.Where(p...)
  44761. }
  44762. // Op returns the operation name.
  44763. func (m *WpChatroomMutation) Op() Op {
  44764. return m.op
  44765. }
  44766. // SetOp allows setting the mutation operation.
  44767. func (m *WpChatroomMutation) SetOp(op Op) {
  44768. m.op = op
  44769. }
  44770. // Type returns the node type of this mutation (WpChatroom).
  44771. func (m *WpChatroomMutation) Type() string {
  44772. return m.typ
  44773. }
  44774. // Fields returns all fields that were changed during this mutation. Note that in
  44775. // order to get all numeric fields that were incremented/decremented, call
  44776. // AddedFields().
  44777. func (m *WpChatroomMutation) Fields() []string {
  44778. fields := make([]string, 0, 9)
  44779. if m.created_at != nil {
  44780. fields = append(fields, wpchatroom.FieldCreatedAt)
  44781. }
  44782. if m.updated_at != nil {
  44783. fields = append(fields, wpchatroom.FieldUpdatedAt)
  44784. }
  44785. if m.status != nil {
  44786. fields = append(fields, wpchatroom.FieldStatus)
  44787. }
  44788. if m.wx_wxid != nil {
  44789. fields = append(fields, wpchatroom.FieldWxWxid)
  44790. }
  44791. if m.chatroom_id != nil {
  44792. fields = append(fields, wpchatroom.FieldChatroomID)
  44793. }
  44794. if m.nickname != nil {
  44795. fields = append(fields, wpchatroom.FieldNickname)
  44796. }
  44797. if m.owner != nil {
  44798. fields = append(fields, wpchatroom.FieldOwner)
  44799. }
  44800. if m.avatar != nil {
  44801. fields = append(fields, wpchatroom.FieldAvatar)
  44802. }
  44803. if m.member_list != nil {
  44804. fields = append(fields, wpchatroom.FieldMemberList)
  44805. }
  44806. return fields
  44807. }
  44808. // Field returns the value of a field with the given name. The second boolean
  44809. // return value indicates that this field was not set, or was not defined in the
  44810. // schema.
  44811. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  44812. switch name {
  44813. case wpchatroom.FieldCreatedAt:
  44814. return m.CreatedAt()
  44815. case wpchatroom.FieldUpdatedAt:
  44816. return m.UpdatedAt()
  44817. case wpchatroom.FieldStatus:
  44818. return m.Status()
  44819. case wpchatroom.FieldWxWxid:
  44820. return m.WxWxid()
  44821. case wpchatroom.FieldChatroomID:
  44822. return m.ChatroomID()
  44823. case wpchatroom.FieldNickname:
  44824. return m.Nickname()
  44825. case wpchatroom.FieldOwner:
  44826. return m.Owner()
  44827. case wpchatroom.FieldAvatar:
  44828. return m.Avatar()
  44829. case wpchatroom.FieldMemberList:
  44830. return m.MemberList()
  44831. }
  44832. return nil, false
  44833. }
  44834. // OldField returns the old value of the field from the database. An error is
  44835. // returned if the mutation operation is not UpdateOne, or the query to the
  44836. // database failed.
  44837. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44838. switch name {
  44839. case wpchatroom.FieldCreatedAt:
  44840. return m.OldCreatedAt(ctx)
  44841. case wpchatroom.FieldUpdatedAt:
  44842. return m.OldUpdatedAt(ctx)
  44843. case wpchatroom.FieldStatus:
  44844. return m.OldStatus(ctx)
  44845. case wpchatroom.FieldWxWxid:
  44846. return m.OldWxWxid(ctx)
  44847. case wpchatroom.FieldChatroomID:
  44848. return m.OldChatroomID(ctx)
  44849. case wpchatroom.FieldNickname:
  44850. return m.OldNickname(ctx)
  44851. case wpchatroom.FieldOwner:
  44852. return m.OldOwner(ctx)
  44853. case wpchatroom.FieldAvatar:
  44854. return m.OldAvatar(ctx)
  44855. case wpchatroom.FieldMemberList:
  44856. return m.OldMemberList(ctx)
  44857. }
  44858. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  44859. }
  44860. // SetField sets the value of a field with the given name. It returns an error if
  44861. // the field is not defined in the schema, or if the type mismatched the field
  44862. // type.
  44863. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  44864. switch name {
  44865. case wpchatroom.FieldCreatedAt:
  44866. v, ok := value.(time.Time)
  44867. if !ok {
  44868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44869. }
  44870. m.SetCreatedAt(v)
  44871. return nil
  44872. case wpchatroom.FieldUpdatedAt:
  44873. v, ok := value.(time.Time)
  44874. if !ok {
  44875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44876. }
  44877. m.SetUpdatedAt(v)
  44878. return nil
  44879. case wpchatroom.FieldStatus:
  44880. v, ok := value.(uint8)
  44881. if !ok {
  44882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44883. }
  44884. m.SetStatus(v)
  44885. return nil
  44886. case wpchatroom.FieldWxWxid:
  44887. v, ok := value.(string)
  44888. if !ok {
  44889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44890. }
  44891. m.SetWxWxid(v)
  44892. return nil
  44893. case wpchatroom.FieldChatroomID:
  44894. v, ok := value.(string)
  44895. if !ok {
  44896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44897. }
  44898. m.SetChatroomID(v)
  44899. return nil
  44900. case wpchatroom.FieldNickname:
  44901. v, ok := value.(string)
  44902. if !ok {
  44903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44904. }
  44905. m.SetNickname(v)
  44906. return nil
  44907. case wpchatroom.FieldOwner:
  44908. v, ok := value.(string)
  44909. if !ok {
  44910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44911. }
  44912. m.SetOwner(v)
  44913. return nil
  44914. case wpchatroom.FieldAvatar:
  44915. v, ok := value.(string)
  44916. if !ok {
  44917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44918. }
  44919. m.SetAvatar(v)
  44920. return nil
  44921. case wpchatroom.FieldMemberList:
  44922. v, ok := value.([]string)
  44923. if !ok {
  44924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44925. }
  44926. m.SetMemberList(v)
  44927. return nil
  44928. }
  44929. return fmt.Errorf("unknown WpChatroom field %s", name)
  44930. }
  44931. // AddedFields returns all numeric fields that were incremented/decremented during
  44932. // this mutation.
  44933. func (m *WpChatroomMutation) AddedFields() []string {
  44934. var fields []string
  44935. if m.addstatus != nil {
  44936. fields = append(fields, wpchatroom.FieldStatus)
  44937. }
  44938. return fields
  44939. }
  44940. // AddedField returns the numeric value that was incremented/decremented on a field
  44941. // with the given name. The second boolean return value indicates that this field
  44942. // was not set, or was not defined in the schema.
  44943. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  44944. switch name {
  44945. case wpchatroom.FieldStatus:
  44946. return m.AddedStatus()
  44947. }
  44948. return nil, false
  44949. }
  44950. // AddField adds the value to the field with the given name. It returns an error if
  44951. // the field is not defined in the schema, or if the type mismatched the field
  44952. // type.
  44953. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  44954. switch name {
  44955. case wpchatroom.FieldStatus:
  44956. v, ok := value.(int8)
  44957. if !ok {
  44958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44959. }
  44960. m.AddStatus(v)
  44961. return nil
  44962. }
  44963. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  44964. }
  44965. // ClearedFields returns all nullable fields that were cleared during this
  44966. // mutation.
  44967. func (m *WpChatroomMutation) ClearedFields() []string {
  44968. var fields []string
  44969. if m.FieldCleared(wpchatroom.FieldStatus) {
  44970. fields = append(fields, wpchatroom.FieldStatus)
  44971. }
  44972. return fields
  44973. }
  44974. // FieldCleared returns a boolean indicating if a field with the given name was
  44975. // cleared in this mutation.
  44976. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  44977. _, ok := m.clearedFields[name]
  44978. return ok
  44979. }
  44980. // ClearField clears the value of the field with the given name. It returns an
  44981. // error if the field is not defined in the schema.
  44982. func (m *WpChatroomMutation) ClearField(name string) error {
  44983. switch name {
  44984. case wpchatroom.FieldStatus:
  44985. m.ClearStatus()
  44986. return nil
  44987. }
  44988. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  44989. }
  44990. // ResetField resets all changes in the mutation for the field with the given name.
  44991. // It returns an error if the field is not defined in the schema.
  44992. func (m *WpChatroomMutation) ResetField(name string) error {
  44993. switch name {
  44994. case wpchatroom.FieldCreatedAt:
  44995. m.ResetCreatedAt()
  44996. return nil
  44997. case wpchatroom.FieldUpdatedAt:
  44998. m.ResetUpdatedAt()
  44999. return nil
  45000. case wpchatroom.FieldStatus:
  45001. m.ResetStatus()
  45002. return nil
  45003. case wpchatroom.FieldWxWxid:
  45004. m.ResetWxWxid()
  45005. return nil
  45006. case wpchatroom.FieldChatroomID:
  45007. m.ResetChatroomID()
  45008. return nil
  45009. case wpchatroom.FieldNickname:
  45010. m.ResetNickname()
  45011. return nil
  45012. case wpchatroom.FieldOwner:
  45013. m.ResetOwner()
  45014. return nil
  45015. case wpchatroom.FieldAvatar:
  45016. m.ResetAvatar()
  45017. return nil
  45018. case wpchatroom.FieldMemberList:
  45019. m.ResetMemberList()
  45020. return nil
  45021. }
  45022. return fmt.Errorf("unknown WpChatroom field %s", name)
  45023. }
  45024. // AddedEdges returns all edge names that were set/added in this mutation.
  45025. func (m *WpChatroomMutation) AddedEdges() []string {
  45026. edges := make([]string, 0, 0)
  45027. return edges
  45028. }
  45029. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45030. // name in this mutation.
  45031. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  45032. return nil
  45033. }
  45034. // RemovedEdges returns all edge names that were removed in this mutation.
  45035. func (m *WpChatroomMutation) RemovedEdges() []string {
  45036. edges := make([]string, 0, 0)
  45037. return edges
  45038. }
  45039. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45040. // the given name in this mutation.
  45041. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  45042. return nil
  45043. }
  45044. // ClearedEdges returns all edge names that were cleared in this mutation.
  45045. func (m *WpChatroomMutation) ClearedEdges() []string {
  45046. edges := make([]string, 0, 0)
  45047. return edges
  45048. }
  45049. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45050. // was cleared in this mutation.
  45051. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  45052. return false
  45053. }
  45054. // ClearEdge clears the value of the edge with the given name. It returns an error
  45055. // if that edge is not defined in the schema.
  45056. func (m *WpChatroomMutation) ClearEdge(name string) error {
  45057. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  45058. }
  45059. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45060. // It returns an error if the edge is not defined in the schema.
  45061. func (m *WpChatroomMutation) ResetEdge(name string) error {
  45062. return fmt.Errorf("unknown WpChatroom edge %s", name)
  45063. }
  45064. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  45065. type WpChatroomMemberMutation struct {
  45066. config
  45067. op Op
  45068. typ string
  45069. id *uint64
  45070. created_at *time.Time
  45071. updated_at *time.Time
  45072. status *uint8
  45073. addstatus *int8
  45074. wx_wxid *string
  45075. wxid *string
  45076. nickname *string
  45077. avatar *string
  45078. clearedFields map[string]struct{}
  45079. done bool
  45080. oldValue func(context.Context) (*WpChatroomMember, error)
  45081. predicates []predicate.WpChatroomMember
  45082. }
  45083. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  45084. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  45085. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  45086. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  45087. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  45088. m := &WpChatroomMemberMutation{
  45089. config: c,
  45090. op: op,
  45091. typ: TypeWpChatroomMember,
  45092. clearedFields: make(map[string]struct{}),
  45093. }
  45094. for _, opt := range opts {
  45095. opt(m)
  45096. }
  45097. return m
  45098. }
  45099. // withWpChatroomMemberID sets the ID field of the mutation.
  45100. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  45101. return func(m *WpChatroomMemberMutation) {
  45102. var (
  45103. err error
  45104. once sync.Once
  45105. value *WpChatroomMember
  45106. )
  45107. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  45108. once.Do(func() {
  45109. if m.done {
  45110. err = errors.New("querying old values post mutation is not allowed")
  45111. } else {
  45112. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  45113. }
  45114. })
  45115. return value, err
  45116. }
  45117. m.id = &id
  45118. }
  45119. }
  45120. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  45121. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  45122. return func(m *WpChatroomMemberMutation) {
  45123. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  45124. return node, nil
  45125. }
  45126. m.id = &node.ID
  45127. }
  45128. }
  45129. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45130. // executed in a transaction (ent.Tx), a transactional client is returned.
  45131. func (m WpChatroomMemberMutation) Client() *Client {
  45132. client := &Client{config: m.config}
  45133. client.init()
  45134. return client
  45135. }
  45136. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45137. // it returns an error otherwise.
  45138. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  45139. if _, ok := m.driver.(*txDriver); !ok {
  45140. return nil, errors.New("ent: mutation is not running in a transaction")
  45141. }
  45142. tx := &Tx{config: m.config}
  45143. tx.init()
  45144. return tx, nil
  45145. }
  45146. // SetID sets the value of the id field. Note that this
  45147. // operation is only accepted on creation of WpChatroomMember entities.
  45148. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  45149. m.id = &id
  45150. }
  45151. // ID returns the ID value in the mutation. Note that the ID is only available
  45152. // if it was provided to the builder or after it was returned from the database.
  45153. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  45154. if m.id == nil {
  45155. return
  45156. }
  45157. return *m.id, true
  45158. }
  45159. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45160. // That means, if the mutation is applied within a transaction with an isolation level such
  45161. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45162. // or updated by the mutation.
  45163. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  45164. switch {
  45165. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45166. id, exists := m.ID()
  45167. if exists {
  45168. return []uint64{id}, nil
  45169. }
  45170. fallthrough
  45171. case m.op.Is(OpUpdate | OpDelete):
  45172. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  45173. default:
  45174. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45175. }
  45176. }
  45177. // SetCreatedAt sets the "created_at" field.
  45178. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  45179. m.created_at = &t
  45180. }
  45181. // CreatedAt returns the value of the "created_at" field in the mutation.
  45182. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  45183. v := m.created_at
  45184. if v == nil {
  45185. return
  45186. }
  45187. return *v, true
  45188. }
  45189. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  45190. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45192. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45193. if !m.op.Is(OpUpdateOne) {
  45194. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45195. }
  45196. if m.id == nil || m.oldValue == nil {
  45197. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45198. }
  45199. oldValue, err := m.oldValue(ctx)
  45200. if err != nil {
  45201. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45202. }
  45203. return oldValue.CreatedAt, nil
  45204. }
  45205. // ResetCreatedAt resets all changes to the "created_at" field.
  45206. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  45207. m.created_at = nil
  45208. }
  45209. // SetUpdatedAt sets the "updated_at" field.
  45210. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  45211. m.updated_at = &t
  45212. }
  45213. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45214. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  45215. v := m.updated_at
  45216. if v == nil {
  45217. return
  45218. }
  45219. return *v, true
  45220. }
  45221. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  45222. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45224. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45225. if !m.op.Is(OpUpdateOne) {
  45226. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45227. }
  45228. if m.id == nil || m.oldValue == nil {
  45229. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45230. }
  45231. oldValue, err := m.oldValue(ctx)
  45232. if err != nil {
  45233. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45234. }
  45235. return oldValue.UpdatedAt, nil
  45236. }
  45237. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45238. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  45239. m.updated_at = nil
  45240. }
  45241. // SetStatus sets the "status" field.
  45242. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  45243. m.status = &u
  45244. m.addstatus = nil
  45245. }
  45246. // Status returns the value of the "status" field in the mutation.
  45247. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  45248. v := m.status
  45249. if v == nil {
  45250. return
  45251. }
  45252. return *v, true
  45253. }
  45254. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  45255. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45257. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45258. if !m.op.Is(OpUpdateOne) {
  45259. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45260. }
  45261. if m.id == nil || m.oldValue == nil {
  45262. return v, errors.New("OldStatus requires an ID field in the mutation")
  45263. }
  45264. oldValue, err := m.oldValue(ctx)
  45265. if err != nil {
  45266. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45267. }
  45268. return oldValue.Status, nil
  45269. }
  45270. // AddStatus adds u to the "status" field.
  45271. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  45272. if m.addstatus != nil {
  45273. *m.addstatus += u
  45274. } else {
  45275. m.addstatus = &u
  45276. }
  45277. }
  45278. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45279. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  45280. v := m.addstatus
  45281. if v == nil {
  45282. return
  45283. }
  45284. return *v, true
  45285. }
  45286. // ClearStatus clears the value of the "status" field.
  45287. func (m *WpChatroomMemberMutation) ClearStatus() {
  45288. m.status = nil
  45289. m.addstatus = nil
  45290. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  45291. }
  45292. // StatusCleared returns if the "status" field was cleared in this mutation.
  45293. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  45294. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  45295. return ok
  45296. }
  45297. // ResetStatus resets all changes to the "status" field.
  45298. func (m *WpChatroomMemberMutation) ResetStatus() {
  45299. m.status = nil
  45300. m.addstatus = nil
  45301. delete(m.clearedFields, wpchatroommember.FieldStatus)
  45302. }
  45303. // SetWxWxid sets the "wx_wxid" field.
  45304. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  45305. m.wx_wxid = &s
  45306. }
  45307. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  45308. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  45309. v := m.wx_wxid
  45310. if v == nil {
  45311. return
  45312. }
  45313. return *v, true
  45314. }
  45315. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  45316. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45318. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  45319. if !m.op.Is(OpUpdateOne) {
  45320. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  45321. }
  45322. if m.id == nil || m.oldValue == nil {
  45323. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  45324. }
  45325. oldValue, err := m.oldValue(ctx)
  45326. if err != nil {
  45327. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  45328. }
  45329. return oldValue.WxWxid, nil
  45330. }
  45331. // ResetWxWxid resets all changes to the "wx_wxid" field.
  45332. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  45333. m.wx_wxid = nil
  45334. }
  45335. // SetWxid sets the "wxid" field.
  45336. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  45337. m.wxid = &s
  45338. }
  45339. // Wxid returns the value of the "wxid" field in the mutation.
  45340. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  45341. v := m.wxid
  45342. if v == nil {
  45343. return
  45344. }
  45345. return *v, true
  45346. }
  45347. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  45348. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45350. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  45351. if !m.op.Is(OpUpdateOne) {
  45352. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  45353. }
  45354. if m.id == nil || m.oldValue == nil {
  45355. return v, errors.New("OldWxid requires an ID field in the mutation")
  45356. }
  45357. oldValue, err := m.oldValue(ctx)
  45358. if err != nil {
  45359. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  45360. }
  45361. return oldValue.Wxid, nil
  45362. }
  45363. // ResetWxid resets all changes to the "wxid" field.
  45364. func (m *WpChatroomMemberMutation) ResetWxid() {
  45365. m.wxid = nil
  45366. }
  45367. // SetNickname sets the "nickname" field.
  45368. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  45369. m.nickname = &s
  45370. }
  45371. // Nickname returns the value of the "nickname" field in the mutation.
  45372. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  45373. v := m.nickname
  45374. if v == nil {
  45375. return
  45376. }
  45377. return *v, true
  45378. }
  45379. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  45380. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45382. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  45383. if !m.op.Is(OpUpdateOne) {
  45384. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45385. }
  45386. if m.id == nil || m.oldValue == nil {
  45387. return v, errors.New("OldNickname requires an ID field in the mutation")
  45388. }
  45389. oldValue, err := m.oldValue(ctx)
  45390. if err != nil {
  45391. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45392. }
  45393. return oldValue.Nickname, nil
  45394. }
  45395. // ResetNickname resets all changes to the "nickname" field.
  45396. func (m *WpChatroomMemberMutation) ResetNickname() {
  45397. m.nickname = nil
  45398. }
  45399. // SetAvatar sets the "avatar" field.
  45400. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  45401. m.avatar = &s
  45402. }
  45403. // Avatar returns the value of the "avatar" field in the mutation.
  45404. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  45405. v := m.avatar
  45406. if v == nil {
  45407. return
  45408. }
  45409. return *v, true
  45410. }
  45411. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  45412. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  45413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45414. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  45415. if !m.op.Is(OpUpdateOne) {
  45416. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  45417. }
  45418. if m.id == nil || m.oldValue == nil {
  45419. return v, errors.New("OldAvatar requires an ID field in the mutation")
  45420. }
  45421. oldValue, err := m.oldValue(ctx)
  45422. if err != nil {
  45423. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  45424. }
  45425. return oldValue.Avatar, nil
  45426. }
  45427. // ResetAvatar resets all changes to the "avatar" field.
  45428. func (m *WpChatroomMemberMutation) ResetAvatar() {
  45429. m.avatar = nil
  45430. }
  45431. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  45432. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  45433. m.predicates = append(m.predicates, ps...)
  45434. }
  45435. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  45436. // users can use type-assertion to append predicates that do not depend on any generated package.
  45437. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  45438. p := make([]predicate.WpChatroomMember, len(ps))
  45439. for i := range ps {
  45440. p[i] = ps[i]
  45441. }
  45442. m.Where(p...)
  45443. }
  45444. // Op returns the operation name.
  45445. func (m *WpChatroomMemberMutation) Op() Op {
  45446. return m.op
  45447. }
  45448. // SetOp allows setting the mutation operation.
  45449. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  45450. m.op = op
  45451. }
  45452. // Type returns the node type of this mutation (WpChatroomMember).
  45453. func (m *WpChatroomMemberMutation) Type() string {
  45454. return m.typ
  45455. }
  45456. // Fields returns all fields that were changed during this mutation. Note that in
  45457. // order to get all numeric fields that were incremented/decremented, call
  45458. // AddedFields().
  45459. func (m *WpChatroomMemberMutation) Fields() []string {
  45460. fields := make([]string, 0, 7)
  45461. if m.created_at != nil {
  45462. fields = append(fields, wpchatroommember.FieldCreatedAt)
  45463. }
  45464. if m.updated_at != nil {
  45465. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  45466. }
  45467. if m.status != nil {
  45468. fields = append(fields, wpchatroommember.FieldStatus)
  45469. }
  45470. if m.wx_wxid != nil {
  45471. fields = append(fields, wpchatroommember.FieldWxWxid)
  45472. }
  45473. if m.wxid != nil {
  45474. fields = append(fields, wpchatroommember.FieldWxid)
  45475. }
  45476. if m.nickname != nil {
  45477. fields = append(fields, wpchatroommember.FieldNickname)
  45478. }
  45479. if m.avatar != nil {
  45480. fields = append(fields, wpchatroommember.FieldAvatar)
  45481. }
  45482. return fields
  45483. }
  45484. // Field returns the value of a field with the given name. The second boolean
  45485. // return value indicates that this field was not set, or was not defined in the
  45486. // schema.
  45487. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  45488. switch name {
  45489. case wpchatroommember.FieldCreatedAt:
  45490. return m.CreatedAt()
  45491. case wpchatroommember.FieldUpdatedAt:
  45492. return m.UpdatedAt()
  45493. case wpchatroommember.FieldStatus:
  45494. return m.Status()
  45495. case wpchatroommember.FieldWxWxid:
  45496. return m.WxWxid()
  45497. case wpchatroommember.FieldWxid:
  45498. return m.Wxid()
  45499. case wpchatroommember.FieldNickname:
  45500. return m.Nickname()
  45501. case wpchatroommember.FieldAvatar:
  45502. return m.Avatar()
  45503. }
  45504. return nil, false
  45505. }
  45506. // OldField returns the old value of the field from the database. An error is
  45507. // returned if the mutation operation is not UpdateOne, or the query to the
  45508. // database failed.
  45509. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45510. switch name {
  45511. case wpchatroommember.FieldCreatedAt:
  45512. return m.OldCreatedAt(ctx)
  45513. case wpchatroommember.FieldUpdatedAt:
  45514. return m.OldUpdatedAt(ctx)
  45515. case wpchatroommember.FieldStatus:
  45516. return m.OldStatus(ctx)
  45517. case wpchatroommember.FieldWxWxid:
  45518. return m.OldWxWxid(ctx)
  45519. case wpchatroommember.FieldWxid:
  45520. return m.OldWxid(ctx)
  45521. case wpchatroommember.FieldNickname:
  45522. return m.OldNickname(ctx)
  45523. case wpchatroommember.FieldAvatar:
  45524. return m.OldAvatar(ctx)
  45525. }
  45526. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  45527. }
  45528. // SetField sets the value of a field with the given name. It returns an error if
  45529. // the field is not defined in the schema, or if the type mismatched the field
  45530. // type.
  45531. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  45532. switch name {
  45533. case wpchatroommember.FieldCreatedAt:
  45534. v, ok := value.(time.Time)
  45535. if !ok {
  45536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45537. }
  45538. m.SetCreatedAt(v)
  45539. return nil
  45540. case wpchatroommember.FieldUpdatedAt:
  45541. v, ok := value.(time.Time)
  45542. if !ok {
  45543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45544. }
  45545. m.SetUpdatedAt(v)
  45546. return nil
  45547. case wpchatroommember.FieldStatus:
  45548. v, ok := value.(uint8)
  45549. if !ok {
  45550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45551. }
  45552. m.SetStatus(v)
  45553. return nil
  45554. case wpchatroommember.FieldWxWxid:
  45555. v, ok := value.(string)
  45556. if !ok {
  45557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45558. }
  45559. m.SetWxWxid(v)
  45560. return nil
  45561. case wpchatroommember.FieldWxid:
  45562. v, ok := value.(string)
  45563. if !ok {
  45564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45565. }
  45566. m.SetWxid(v)
  45567. return nil
  45568. case wpchatroommember.FieldNickname:
  45569. v, ok := value.(string)
  45570. if !ok {
  45571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45572. }
  45573. m.SetNickname(v)
  45574. return nil
  45575. case wpchatroommember.FieldAvatar:
  45576. v, ok := value.(string)
  45577. if !ok {
  45578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45579. }
  45580. m.SetAvatar(v)
  45581. return nil
  45582. }
  45583. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  45584. }
  45585. // AddedFields returns all numeric fields that were incremented/decremented during
  45586. // this mutation.
  45587. func (m *WpChatroomMemberMutation) AddedFields() []string {
  45588. var fields []string
  45589. if m.addstatus != nil {
  45590. fields = append(fields, wpchatroommember.FieldStatus)
  45591. }
  45592. return fields
  45593. }
  45594. // AddedField returns the numeric value that was incremented/decremented on a field
  45595. // with the given name. The second boolean return value indicates that this field
  45596. // was not set, or was not defined in the schema.
  45597. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  45598. switch name {
  45599. case wpchatroommember.FieldStatus:
  45600. return m.AddedStatus()
  45601. }
  45602. return nil, false
  45603. }
  45604. // AddField adds the value to the field with the given name. It returns an error if
  45605. // the field is not defined in the schema, or if the type mismatched the field
  45606. // type.
  45607. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  45608. switch name {
  45609. case wpchatroommember.FieldStatus:
  45610. v, ok := value.(int8)
  45611. if !ok {
  45612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45613. }
  45614. m.AddStatus(v)
  45615. return nil
  45616. }
  45617. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  45618. }
  45619. // ClearedFields returns all nullable fields that were cleared during this
  45620. // mutation.
  45621. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  45622. var fields []string
  45623. if m.FieldCleared(wpchatroommember.FieldStatus) {
  45624. fields = append(fields, wpchatroommember.FieldStatus)
  45625. }
  45626. return fields
  45627. }
  45628. // FieldCleared returns a boolean indicating if a field with the given name was
  45629. // cleared in this mutation.
  45630. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  45631. _, ok := m.clearedFields[name]
  45632. return ok
  45633. }
  45634. // ClearField clears the value of the field with the given name. It returns an
  45635. // error if the field is not defined in the schema.
  45636. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  45637. switch name {
  45638. case wpchatroommember.FieldStatus:
  45639. m.ClearStatus()
  45640. return nil
  45641. }
  45642. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  45643. }
  45644. // ResetField resets all changes in the mutation for the field with the given name.
  45645. // It returns an error if the field is not defined in the schema.
  45646. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  45647. switch name {
  45648. case wpchatroommember.FieldCreatedAt:
  45649. m.ResetCreatedAt()
  45650. return nil
  45651. case wpchatroommember.FieldUpdatedAt:
  45652. m.ResetUpdatedAt()
  45653. return nil
  45654. case wpchatroommember.FieldStatus:
  45655. m.ResetStatus()
  45656. return nil
  45657. case wpchatroommember.FieldWxWxid:
  45658. m.ResetWxWxid()
  45659. return nil
  45660. case wpchatroommember.FieldWxid:
  45661. m.ResetWxid()
  45662. return nil
  45663. case wpchatroommember.FieldNickname:
  45664. m.ResetNickname()
  45665. return nil
  45666. case wpchatroommember.FieldAvatar:
  45667. m.ResetAvatar()
  45668. return nil
  45669. }
  45670. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  45671. }
  45672. // AddedEdges returns all edge names that were set/added in this mutation.
  45673. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  45674. edges := make([]string, 0, 0)
  45675. return edges
  45676. }
  45677. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45678. // name in this mutation.
  45679. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  45680. return nil
  45681. }
  45682. // RemovedEdges returns all edge names that were removed in this mutation.
  45683. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  45684. edges := make([]string, 0, 0)
  45685. return edges
  45686. }
  45687. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45688. // the given name in this mutation.
  45689. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  45690. return nil
  45691. }
  45692. // ClearedEdges returns all edge names that were cleared in this mutation.
  45693. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  45694. edges := make([]string, 0, 0)
  45695. return edges
  45696. }
  45697. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45698. // was cleared in this mutation.
  45699. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  45700. return false
  45701. }
  45702. // ClearEdge clears the value of the edge with the given name. It returns an error
  45703. // if that edge is not defined in the schema.
  45704. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  45705. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  45706. }
  45707. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45708. // It returns an error if the edge is not defined in the schema.
  45709. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  45710. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  45711. }
  45712. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  45713. type WxMutation struct {
  45714. config
  45715. op Op
  45716. typ string
  45717. id *uint64
  45718. created_at *time.Time
  45719. updated_at *time.Time
  45720. status *uint8
  45721. addstatus *int8
  45722. deleted_at *time.Time
  45723. port *string
  45724. process_id *string
  45725. callback *string
  45726. wxid *string
  45727. account *string
  45728. nickname *string
  45729. tel *string
  45730. head_big *string
  45731. organization_id *uint64
  45732. addorganization_id *int64
  45733. api_base *string
  45734. api_key *string
  45735. allow_list *[]string
  45736. appendallow_list []string
  45737. group_allow_list *[]string
  45738. appendgroup_allow_list []string
  45739. block_list *[]string
  45740. appendblock_list []string
  45741. group_block_list *[]string
  45742. appendgroup_block_list []string
  45743. ctype *uint64
  45744. addctype *int64
  45745. clearedFields map[string]struct{}
  45746. server *uint64
  45747. clearedserver bool
  45748. agent *uint64
  45749. clearedagent bool
  45750. done bool
  45751. oldValue func(context.Context) (*Wx, error)
  45752. predicates []predicate.Wx
  45753. }
  45754. var _ ent.Mutation = (*WxMutation)(nil)
  45755. // wxOption allows management of the mutation configuration using functional options.
  45756. type wxOption func(*WxMutation)
  45757. // newWxMutation creates new mutation for the Wx entity.
  45758. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  45759. m := &WxMutation{
  45760. config: c,
  45761. op: op,
  45762. typ: TypeWx,
  45763. clearedFields: make(map[string]struct{}),
  45764. }
  45765. for _, opt := range opts {
  45766. opt(m)
  45767. }
  45768. return m
  45769. }
  45770. // withWxID sets the ID field of the mutation.
  45771. func withWxID(id uint64) wxOption {
  45772. return func(m *WxMutation) {
  45773. var (
  45774. err error
  45775. once sync.Once
  45776. value *Wx
  45777. )
  45778. m.oldValue = func(ctx context.Context) (*Wx, error) {
  45779. once.Do(func() {
  45780. if m.done {
  45781. err = errors.New("querying old values post mutation is not allowed")
  45782. } else {
  45783. value, err = m.Client().Wx.Get(ctx, id)
  45784. }
  45785. })
  45786. return value, err
  45787. }
  45788. m.id = &id
  45789. }
  45790. }
  45791. // withWx sets the old Wx of the mutation.
  45792. func withWx(node *Wx) wxOption {
  45793. return func(m *WxMutation) {
  45794. m.oldValue = func(context.Context) (*Wx, error) {
  45795. return node, nil
  45796. }
  45797. m.id = &node.ID
  45798. }
  45799. }
  45800. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45801. // executed in a transaction (ent.Tx), a transactional client is returned.
  45802. func (m WxMutation) Client() *Client {
  45803. client := &Client{config: m.config}
  45804. client.init()
  45805. return client
  45806. }
  45807. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45808. // it returns an error otherwise.
  45809. func (m WxMutation) Tx() (*Tx, error) {
  45810. if _, ok := m.driver.(*txDriver); !ok {
  45811. return nil, errors.New("ent: mutation is not running in a transaction")
  45812. }
  45813. tx := &Tx{config: m.config}
  45814. tx.init()
  45815. return tx, nil
  45816. }
  45817. // SetID sets the value of the id field. Note that this
  45818. // operation is only accepted on creation of Wx entities.
  45819. func (m *WxMutation) SetID(id uint64) {
  45820. m.id = &id
  45821. }
  45822. // ID returns the ID value in the mutation. Note that the ID is only available
  45823. // if it was provided to the builder or after it was returned from the database.
  45824. func (m *WxMutation) ID() (id uint64, exists bool) {
  45825. if m.id == nil {
  45826. return
  45827. }
  45828. return *m.id, true
  45829. }
  45830. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45831. // That means, if the mutation is applied within a transaction with an isolation level such
  45832. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45833. // or updated by the mutation.
  45834. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  45835. switch {
  45836. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45837. id, exists := m.ID()
  45838. if exists {
  45839. return []uint64{id}, nil
  45840. }
  45841. fallthrough
  45842. case m.op.Is(OpUpdate | OpDelete):
  45843. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  45844. default:
  45845. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45846. }
  45847. }
  45848. // SetCreatedAt sets the "created_at" field.
  45849. func (m *WxMutation) SetCreatedAt(t time.Time) {
  45850. m.created_at = &t
  45851. }
  45852. // CreatedAt returns the value of the "created_at" field in the mutation.
  45853. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  45854. v := m.created_at
  45855. if v == nil {
  45856. return
  45857. }
  45858. return *v, true
  45859. }
  45860. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  45861. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45863. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45864. if !m.op.Is(OpUpdateOne) {
  45865. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45866. }
  45867. if m.id == nil || m.oldValue == nil {
  45868. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45869. }
  45870. oldValue, err := m.oldValue(ctx)
  45871. if err != nil {
  45872. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45873. }
  45874. return oldValue.CreatedAt, nil
  45875. }
  45876. // ResetCreatedAt resets all changes to the "created_at" field.
  45877. func (m *WxMutation) ResetCreatedAt() {
  45878. m.created_at = nil
  45879. }
  45880. // SetUpdatedAt sets the "updated_at" field.
  45881. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  45882. m.updated_at = &t
  45883. }
  45884. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45885. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  45886. v := m.updated_at
  45887. if v == nil {
  45888. return
  45889. }
  45890. return *v, true
  45891. }
  45892. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  45893. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45895. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45896. if !m.op.Is(OpUpdateOne) {
  45897. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45898. }
  45899. if m.id == nil || m.oldValue == nil {
  45900. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45901. }
  45902. oldValue, err := m.oldValue(ctx)
  45903. if err != nil {
  45904. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45905. }
  45906. return oldValue.UpdatedAt, nil
  45907. }
  45908. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45909. func (m *WxMutation) ResetUpdatedAt() {
  45910. m.updated_at = nil
  45911. }
  45912. // SetStatus sets the "status" field.
  45913. func (m *WxMutation) SetStatus(u uint8) {
  45914. m.status = &u
  45915. m.addstatus = nil
  45916. }
  45917. // Status returns the value of the "status" field in the mutation.
  45918. func (m *WxMutation) Status() (r uint8, exists bool) {
  45919. v := m.status
  45920. if v == nil {
  45921. return
  45922. }
  45923. return *v, true
  45924. }
  45925. // OldStatus returns the old "status" field's value of the Wx entity.
  45926. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45928. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45929. if !m.op.Is(OpUpdateOne) {
  45930. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45931. }
  45932. if m.id == nil || m.oldValue == nil {
  45933. return v, errors.New("OldStatus requires an ID field in the mutation")
  45934. }
  45935. oldValue, err := m.oldValue(ctx)
  45936. if err != nil {
  45937. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45938. }
  45939. return oldValue.Status, nil
  45940. }
  45941. // AddStatus adds u to the "status" field.
  45942. func (m *WxMutation) AddStatus(u int8) {
  45943. if m.addstatus != nil {
  45944. *m.addstatus += u
  45945. } else {
  45946. m.addstatus = &u
  45947. }
  45948. }
  45949. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45950. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  45951. v := m.addstatus
  45952. if v == nil {
  45953. return
  45954. }
  45955. return *v, true
  45956. }
  45957. // ClearStatus clears the value of the "status" field.
  45958. func (m *WxMutation) ClearStatus() {
  45959. m.status = nil
  45960. m.addstatus = nil
  45961. m.clearedFields[wx.FieldStatus] = struct{}{}
  45962. }
  45963. // StatusCleared returns if the "status" field was cleared in this mutation.
  45964. func (m *WxMutation) StatusCleared() bool {
  45965. _, ok := m.clearedFields[wx.FieldStatus]
  45966. return ok
  45967. }
  45968. // ResetStatus resets all changes to the "status" field.
  45969. func (m *WxMutation) ResetStatus() {
  45970. m.status = nil
  45971. m.addstatus = nil
  45972. delete(m.clearedFields, wx.FieldStatus)
  45973. }
  45974. // SetDeletedAt sets the "deleted_at" field.
  45975. func (m *WxMutation) SetDeletedAt(t time.Time) {
  45976. m.deleted_at = &t
  45977. }
  45978. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45979. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  45980. v := m.deleted_at
  45981. if v == nil {
  45982. return
  45983. }
  45984. return *v, true
  45985. }
  45986. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  45987. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45989. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45990. if !m.op.Is(OpUpdateOne) {
  45991. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45992. }
  45993. if m.id == nil || m.oldValue == nil {
  45994. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45995. }
  45996. oldValue, err := m.oldValue(ctx)
  45997. if err != nil {
  45998. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45999. }
  46000. return oldValue.DeletedAt, nil
  46001. }
  46002. // ClearDeletedAt clears the value of the "deleted_at" field.
  46003. func (m *WxMutation) ClearDeletedAt() {
  46004. m.deleted_at = nil
  46005. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  46006. }
  46007. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46008. func (m *WxMutation) DeletedAtCleared() bool {
  46009. _, ok := m.clearedFields[wx.FieldDeletedAt]
  46010. return ok
  46011. }
  46012. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46013. func (m *WxMutation) ResetDeletedAt() {
  46014. m.deleted_at = nil
  46015. delete(m.clearedFields, wx.FieldDeletedAt)
  46016. }
  46017. // SetServerID sets the "server_id" field.
  46018. func (m *WxMutation) SetServerID(u uint64) {
  46019. m.server = &u
  46020. }
  46021. // ServerID returns the value of the "server_id" field in the mutation.
  46022. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  46023. v := m.server
  46024. if v == nil {
  46025. return
  46026. }
  46027. return *v, true
  46028. }
  46029. // OldServerID returns the old "server_id" field's value of the Wx entity.
  46030. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46032. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  46033. if !m.op.Is(OpUpdateOne) {
  46034. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  46035. }
  46036. if m.id == nil || m.oldValue == nil {
  46037. return v, errors.New("OldServerID requires an ID field in the mutation")
  46038. }
  46039. oldValue, err := m.oldValue(ctx)
  46040. if err != nil {
  46041. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  46042. }
  46043. return oldValue.ServerID, nil
  46044. }
  46045. // ClearServerID clears the value of the "server_id" field.
  46046. func (m *WxMutation) ClearServerID() {
  46047. m.server = nil
  46048. m.clearedFields[wx.FieldServerID] = struct{}{}
  46049. }
  46050. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  46051. func (m *WxMutation) ServerIDCleared() bool {
  46052. _, ok := m.clearedFields[wx.FieldServerID]
  46053. return ok
  46054. }
  46055. // ResetServerID resets all changes to the "server_id" field.
  46056. func (m *WxMutation) ResetServerID() {
  46057. m.server = nil
  46058. delete(m.clearedFields, wx.FieldServerID)
  46059. }
  46060. // SetPort sets the "port" field.
  46061. func (m *WxMutation) SetPort(s string) {
  46062. m.port = &s
  46063. }
  46064. // Port returns the value of the "port" field in the mutation.
  46065. func (m *WxMutation) Port() (r string, exists bool) {
  46066. v := m.port
  46067. if v == nil {
  46068. return
  46069. }
  46070. return *v, true
  46071. }
  46072. // OldPort returns the old "port" field's value of the Wx entity.
  46073. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46075. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  46076. if !m.op.Is(OpUpdateOne) {
  46077. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  46078. }
  46079. if m.id == nil || m.oldValue == nil {
  46080. return v, errors.New("OldPort requires an ID field in the mutation")
  46081. }
  46082. oldValue, err := m.oldValue(ctx)
  46083. if err != nil {
  46084. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  46085. }
  46086. return oldValue.Port, nil
  46087. }
  46088. // ResetPort resets all changes to the "port" field.
  46089. func (m *WxMutation) ResetPort() {
  46090. m.port = nil
  46091. }
  46092. // SetProcessID sets the "process_id" field.
  46093. func (m *WxMutation) SetProcessID(s string) {
  46094. m.process_id = &s
  46095. }
  46096. // ProcessID returns the value of the "process_id" field in the mutation.
  46097. func (m *WxMutation) ProcessID() (r string, exists bool) {
  46098. v := m.process_id
  46099. if v == nil {
  46100. return
  46101. }
  46102. return *v, true
  46103. }
  46104. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  46105. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46107. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  46108. if !m.op.Is(OpUpdateOne) {
  46109. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  46110. }
  46111. if m.id == nil || m.oldValue == nil {
  46112. return v, errors.New("OldProcessID requires an ID field in the mutation")
  46113. }
  46114. oldValue, err := m.oldValue(ctx)
  46115. if err != nil {
  46116. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  46117. }
  46118. return oldValue.ProcessID, nil
  46119. }
  46120. // ResetProcessID resets all changes to the "process_id" field.
  46121. func (m *WxMutation) ResetProcessID() {
  46122. m.process_id = nil
  46123. }
  46124. // SetCallback sets the "callback" field.
  46125. func (m *WxMutation) SetCallback(s string) {
  46126. m.callback = &s
  46127. }
  46128. // Callback returns the value of the "callback" field in the mutation.
  46129. func (m *WxMutation) Callback() (r string, exists bool) {
  46130. v := m.callback
  46131. if v == nil {
  46132. return
  46133. }
  46134. return *v, true
  46135. }
  46136. // OldCallback returns the old "callback" field's value of the Wx entity.
  46137. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46139. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  46140. if !m.op.Is(OpUpdateOne) {
  46141. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  46142. }
  46143. if m.id == nil || m.oldValue == nil {
  46144. return v, errors.New("OldCallback requires an ID field in the mutation")
  46145. }
  46146. oldValue, err := m.oldValue(ctx)
  46147. if err != nil {
  46148. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  46149. }
  46150. return oldValue.Callback, nil
  46151. }
  46152. // ResetCallback resets all changes to the "callback" field.
  46153. func (m *WxMutation) ResetCallback() {
  46154. m.callback = nil
  46155. }
  46156. // SetWxid sets the "wxid" field.
  46157. func (m *WxMutation) SetWxid(s string) {
  46158. m.wxid = &s
  46159. }
  46160. // Wxid returns the value of the "wxid" field in the mutation.
  46161. func (m *WxMutation) Wxid() (r string, exists bool) {
  46162. v := m.wxid
  46163. if v == nil {
  46164. return
  46165. }
  46166. return *v, true
  46167. }
  46168. // OldWxid returns the old "wxid" field's value of the Wx entity.
  46169. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46171. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  46172. if !m.op.Is(OpUpdateOne) {
  46173. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46174. }
  46175. if m.id == nil || m.oldValue == nil {
  46176. return v, errors.New("OldWxid requires an ID field in the mutation")
  46177. }
  46178. oldValue, err := m.oldValue(ctx)
  46179. if err != nil {
  46180. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46181. }
  46182. return oldValue.Wxid, nil
  46183. }
  46184. // ResetWxid resets all changes to the "wxid" field.
  46185. func (m *WxMutation) ResetWxid() {
  46186. m.wxid = nil
  46187. }
  46188. // SetAccount sets the "account" field.
  46189. func (m *WxMutation) SetAccount(s string) {
  46190. m.account = &s
  46191. }
  46192. // Account returns the value of the "account" field in the mutation.
  46193. func (m *WxMutation) Account() (r string, exists bool) {
  46194. v := m.account
  46195. if v == nil {
  46196. return
  46197. }
  46198. return *v, true
  46199. }
  46200. // OldAccount returns the old "account" field's value of the Wx entity.
  46201. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46203. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  46204. if !m.op.Is(OpUpdateOne) {
  46205. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  46206. }
  46207. if m.id == nil || m.oldValue == nil {
  46208. return v, errors.New("OldAccount requires an ID field in the mutation")
  46209. }
  46210. oldValue, err := m.oldValue(ctx)
  46211. if err != nil {
  46212. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  46213. }
  46214. return oldValue.Account, nil
  46215. }
  46216. // ResetAccount resets all changes to the "account" field.
  46217. func (m *WxMutation) ResetAccount() {
  46218. m.account = nil
  46219. }
  46220. // SetNickname sets the "nickname" field.
  46221. func (m *WxMutation) SetNickname(s string) {
  46222. m.nickname = &s
  46223. }
  46224. // Nickname returns the value of the "nickname" field in the mutation.
  46225. func (m *WxMutation) Nickname() (r string, exists bool) {
  46226. v := m.nickname
  46227. if v == nil {
  46228. return
  46229. }
  46230. return *v, true
  46231. }
  46232. // OldNickname returns the old "nickname" field's value of the Wx entity.
  46233. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46235. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  46236. if !m.op.Is(OpUpdateOne) {
  46237. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  46238. }
  46239. if m.id == nil || m.oldValue == nil {
  46240. return v, errors.New("OldNickname requires an ID field in the mutation")
  46241. }
  46242. oldValue, err := m.oldValue(ctx)
  46243. if err != nil {
  46244. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  46245. }
  46246. return oldValue.Nickname, nil
  46247. }
  46248. // ResetNickname resets all changes to the "nickname" field.
  46249. func (m *WxMutation) ResetNickname() {
  46250. m.nickname = nil
  46251. }
  46252. // SetTel sets the "tel" field.
  46253. func (m *WxMutation) SetTel(s string) {
  46254. m.tel = &s
  46255. }
  46256. // Tel returns the value of the "tel" field in the mutation.
  46257. func (m *WxMutation) Tel() (r string, exists bool) {
  46258. v := m.tel
  46259. if v == nil {
  46260. return
  46261. }
  46262. return *v, true
  46263. }
  46264. // OldTel returns the old "tel" field's value of the Wx entity.
  46265. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46267. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  46268. if !m.op.Is(OpUpdateOne) {
  46269. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  46270. }
  46271. if m.id == nil || m.oldValue == nil {
  46272. return v, errors.New("OldTel requires an ID field in the mutation")
  46273. }
  46274. oldValue, err := m.oldValue(ctx)
  46275. if err != nil {
  46276. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  46277. }
  46278. return oldValue.Tel, nil
  46279. }
  46280. // ResetTel resets all changes to the "tel" field.
  46281. func (m *WxMutation) ResetTel() {
  46282. m.tel = nil
  46283. }
  46284. // SetHeadBig sets the "head_big" field.
  46285. func (m *WxMutation) SetHeadBig(s string) {
  46286. m.head_big = &s
  46287. }
  46288. // HeadBig returns the value of the "head_big" field in the mutation.
  46289. func (m *WxMutation) HeadBig() (r string, exists bool) {
  46290. v := m.head_big
  46291. if v == nil {
  46292. return
  46293. }
  46294. return *v, true
  46295. }
  46296. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  46297. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46299. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  46300. if !m.op.Is(OpUpdateOne) {
  46301. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  46302. }
  46303. if m.id == nil || m.oldValue == nil {
  46304. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  46305. }
  46306. oldValue, err := m.oldValue(ctx)
  46307. if err != nil {
  46308. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  46309. }
  46310. return oldValue.HeadBig, nil
  46311. }
  46312. // ResetHeadBig resets all changes to the "head_big" field.
  46313. func (m *WxMutation) ResetHeadBig() {
  46314. m.head_big = nil
  46315. }
  46316. // SetOrganizationID sets the "organization_id" field.
  46317. func (m *WxMutation) SetOrganizationID(u uint64) {
  46318. m.organization_id = &u
  46319. m.addorganization_id = nil
  46320. }
  46321. // OrganizationID returns the value of the "organization_id" field in the mutation.
  46322. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  46323. v := m.organization_id
  46324. if v == nil {
  46325. return
  46326. }
  46327. return *v, true
  46328. }
  46329. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  46330. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46332. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  46333. if !m.op.Is(OpUpdateOne) {
  46334. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  46335. }
  46336. if m.id == nil || m.oldValue == nil {
  46337. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  46338. }
  46339. oldValue, err := m.oldValue(ctx)
  46340. if err != nil {
  46341. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  46342. }
  46343. return oldValue.OrganizationID, nil
  46344. }
  46345. // AddOrganizationID adds u to the "organization_id" field.
  46346. func (m *WxMutation) AddOrganizationID(u int64) {
  46347. if m.addorganization_id != nil {
  46348. *m.addorganization_id += u
  46349. } else {
  46350. m.addorganization_id = &u
  46351. }
  46352. }
  46353. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  46354. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  46355. v := m.addorganization_id
  46356. if v == nil {
  46357. return
  46358. }
  46359. return *v, true
  46360. }
  46361. // ClearOrganizationID clears the value of the "organization_id" field.
  46362. func (m *WxMutation) ClearOrganizationID() {
  46363. m.organization_id = nil
  46364. m.addorganization_id = nil
  46365. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  46366. }
  46367. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  46368. func (m *WxMutation) OrganizationIDCleared() bool {
  46369. _, ok := m.clearedFields[wx.FieldOrganizationID]
  46370. return ok
  46371. }
  46372. // ResetOrganizationID resets all changes to the "organization_id" field.
  46373. func (m *WxMutation) ResetOrganizationID() {
  46374. m.organization_id = nil
  46375. m.addorganization_id = nil
  46376. delete(m.clearedFields, wx.FieldOrganizationID)
  46377. }
  46378. // SetAgentID sets the "agent_id" field.
  46379. func (m *WxMutation) SetAgentID(u uint64) {
  46380. m.agent = &u
  46381. }
  46382. // AgentID returns the value of the "agent_id" field in the mutation.
  46383. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  46384. v := m.agent
  46385. if v == nil {
  46386. return
  46387. }
  46388. return *v, true
  46389. }
  46390. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  46391. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46393. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  46394. if !m.op.Is(OpUpdateOne) {
  46395. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  46396. }
  46397. if m.id == nil || m.oldValue == nil {
  46398. return v, errors.New("OldAgentID requires an ID field in the mutation")
  46399. }
  46400. oldValue, err := m.oldValue(ctx)
  46401. if err != nil {
  46402. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  46403. }
  46404. return oldValue.AgentID, nil
  46405. }
  46406. // ResetAgentID resets all changes to the "agent_id" field.
  46407. func (m *WxMutation) ResetAgentID() {
  46408. m.agent = nil
  46409. }
  46410. // SetAPIBase sets the "api_base" field.
  46411. func (m *WxMutation) SetAPIBase(s string) {
  46412. m.api_base = &s
  46413. }
  46414. // APIBase returns the value of the "api_base" field in the mutation.
  46415. func (m *WxMutation) APIBase() (r string, exists bool) {
  46416. v := m.api_base
  46417. if v == nil {
  46418. return
  46419. }
  46420. return *v, true
  46421. }
  46422. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  46423. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46425. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  46426. if !m.op.Is(OpUpdateOne) {
  46427. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  46428. }
  46429. if m.id == nil || m.oldValue == nil {
  46430. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  46431. }
  46432. oldValue, err := m.oldValue(ctx)
  46433. if err != nil {
  46434. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  46435. }
  46436. return oldValue.APIBase, nil
  46437. }
  46438. // ClearAPIBase clears the value of the "api_base" field.
  46439. func (m *WxMutation) ClearAPIBase() {
  46440. m.api_base = nil
  46441. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  46442. }
  46443. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  46444. func (m *WxMutation) APIBaseCleared() bool {
  46445. _, ok := m.clearedFields[wx.FieldAPIBase]
  46446. return ok
  46447. }
  46448. // ResetAPIBase resets all changes to the "api_base" field.
  46449. func (m *WxMutation) ResetAPIBase() {
  46450. m.api_base = nil
  46451. delete(m.clearedFields, wx.FieldAPIBase)
  46452. }
  46453. // SetAPIKey sets the "api_key" field.
  46454. func (m *WxMutation) SetAPIKey(s string) {
  46455. m.api_key = &s
  46456. }
  46457. // APIKey returns the value of the "api_key" field in the mutation.
  46458. func (m *WxMutation) APIKey() (r string, exists bool) {
  46459. v := m.api_key
  46460. if v == nil {
  46461. return
  46462. }
  46463. return *v, true
  46464. }
  46465. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  46466. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46468. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  46469. if !m.op.Is(OpUpdateOne) {
  46470. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  46471. }
  46472. if m.id == nil || m.oldValue == nil {
  46473. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  46474. }
  46475. oldValue, err := m.oldValue(ctx)
  46476. if err != nil {
  46477. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  46478. }
  46479. return oldValue.APIKey, nil
  46480. }
  46481. // ClearAPIKey clears the value of the "api_key" field.
  46482. func (m *WxMutation) ClearAPIKey() {
  46483. m.api_key = nil
  46484. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  46485. }
  46486. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  46487. func (m *WxMutation) APIKeyCleared() bool {
  46488. _, ok := m.clearedFields[wx.FieldAPIKey]
  46489. return ok
  46490. }
  46491. // ResetAPIKey resets all changes to the "api_key" field.
  46492. func (m *WxMutation) ResetAPIKey() {
  46493. m.api_key = nil
  46494. delete(m.clearedFields, wx.FieldAPIKey)
  46495. }
  46496. // SetAllowList sets the "allow_list" field.
  46497. func (m *WxMutation) SetAllowList(s []string) {
  46498. m.allow_list = &s
  46499. m.appendallow_list = nil
  46500. }
  46501. // AllowList returns the value of the "allow_list" field in the mutation.
  46502. func (m *WxMutation) AllowList() (r []string, exists bool) {
  46503. v := m.allow_list
  46504. if v == nil {
  46505. return
  46506. }
  46507. return *v, true
  46508. }
  46509. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  46510. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46512. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  46513. if !m.op.Is(OpUpdateOne) {
  46514. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  46515. }
  46516. if m.id == nil || m.oldValue == nil {
  46517. return v, errors.New("OldAllowList requires an ID field in the mutation")
  46518. }
  46519. oldValue, err := m.oldValue(ctx)
  46520. if err != nil {
  46521. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  46522. }
  46523. return oldValue.AllowList, nil
  46524. }
  46525. // AppendAllowList adds s to the "allow_list" field.
  46526. func (m *WxMutation) AppendAllowList(s []string) {
  46527. m.appendallow_list = append(m.appendallow_list, s...)
  46528. }
  46529. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  46530. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  46531. if len(m.appendallow_list) == 0 {
  46532. return nil, false
  46533. }
  46534. return m.appendallow_list, true
  46535. }
  46536. // ResetAllowList resets all changes to the "allow_list" field.
  46537. func (m *WxMutation) ResetAllowList() {
  46538. m.allow_list = nil
  46539. m.appendallow_list = nil
  46540. }
  46541. // SetGroupAllowList sets the "group_allow_list" field.
  46542. func (m *WxMutation) SetGroupAllowList(s []string) {
  46543. m.group_allow_list = &s
  46544. m.appendgroup_allow_list = nil
  46545. }
  46546. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  46547. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  46548. v := m.group_allow_list
  46549. if v == nil {
  46550. return
  46551. }
  46552. return *v, true
  46553. }
  46554. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  46555. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46557. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  46558. if !m.op.Is(OpUpdateOne) {
  46559. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  46560. }
  46561. if m.id == nil || m.oldValue == nil {
  46562. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  46563. }
  46564. oldValue, err := m.oldValue(ctx)
  46565. if err != nil {
  46566. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  46567. }
  46568. return oldValue.GroupAllowList, nil
  46569. }
  46570. // AppendGroupAllowList adds s to the "group_allow_list" field.
  46571. func (m *WxMutation) AppendGroupAllowList(s []string) {
  46572. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  46573. }
  46574. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  46575. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  46576. if len(m.appendgroup_allow_list) == 0 {
  46577. return nil, false
  46578. }
  46579. return m.appendgroup_allow_list, true
  46580. }
  46581. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  46582. func (m *WxMutation) ResetGroupAllowList() {
  46583. m.group_allow_list = nil
  46584. m.appendgroup_allow_list = nil
  46585. }
  46586. // SetBlockList sets the "block_list" field.
  46587. func (m *WxMutation) SetBlockList(s []string) {
  46588. m.block_list = &s
  46589. m.appendblock_list = nil
  46590. }
  46591. // BlockList returns the value of the "block_list" field in the mutation.
  46592. func (m *WxMutation) BlockList() (r []string, exists bool) {
  46593. v := m.block_list
  46594. if v == nil {
  46595. return
  46596. }
  46597. return *v, true
  46598. }
  46599. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  46600. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46602. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  46603. if !m.op.Is(OpUpdateOne) {
  46604. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  46605. }
  46606. if m.id == nil || m.oldValue == nil {
  46607. return v, errors.New("OldBlockList requires an ID field in the mutation")
  46608. }
  46609. oldValue, err := m.oldValue(ctx)
  46610. if err != nil {
  46611. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  46612. }
  46613. return oldValue.BlockList, nil
  46614. }
  46615. // AppendBlockList adds s to the "block_list" field.
  46616. func (m *WxMutation) AppendBlockList(s []string) {
  46617. m.appendblock_list = append(m.appendblock_list, s...)
  46618. }
  46619. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  46620. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  46621. if len(m.appendblock_list) == 0 {
  46622. return nil, false
  46623. }
  46624. return m.appendblock_list, true
  46625. }
  46626. // ResetBlockList resets all changes to the "block_list" field.
  46627. func (m *WxMutation) ResetBlockList() {
  46628. m.block_list = nil
  46629. m.appendblock_list = nil
  46630. }
  46631. // SetGroupBlockList sets the "group_block_list" field.
  46632. func (m *WxMutation) SetGroupBlockList(s []string) {
  46633. m.group_block_list = &s
  46634. m.appendgroup_block_list = nil
  46635. }
  46636. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  46637. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  46638. v := m.group_block_list
  46639. if v == nil {
  46640. return
  46641. }
  46642. return *v, true
  46643. }
  46644. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  46645. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46647. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  46648. if !m.op.Is(OpUpdateOne) {
  46649. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  46650. }
  46651. if m.id == nil || m.oldValue == nil {
  46652. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  46653. }
  46654. oldValue, err := m.oldValue(ctx)
  46655. if err != nil {
  46656. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  46657. }
  46658. return oldValue.GroupBlockList, nil
  46659. }
  46660. // AppendGroupBlockList adds s to the "group_block_list" field.
  46661. func (m *WxMutation) AppendGroupBlockList(s []string) {
  46662. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  46663. }
  46664. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  46665. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  46666. if len(m.appendgroup_block_list) == 0 {
  46667. return nil, false
  46668. }
  46669. return m.appendgroup_block_list, true
  46670. }
  46671. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  46672. func (m *WxMutation) ResetGroupBlockList() {
  46673. m.group_block_list = nil
  46674. m.appendgroup_block_list = nil
  46675. }
  46676. // SetCtype sets the "ctype" field.
  46677. func (m *WxMutation) SetCtype(u uint64) {
  46678. m.ctype = &u
  46679. m.addctype = nil
  46680. }
  46681. // Ctype returns the value of the "ctype" field in the mutation.
  46682. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  46683. v := m.ctype
  46684. if v == nil {
  46685. return
  46686. }
  46687. return *v, true
  46688. }
  46689. // OldCtype returns the old "ctype" field's value of the Wx entity.
  46690. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46692. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  46693. if !m.op.Is(OpUpdateOne) {
  46694. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  46695. }
  46696. if m.id == nil || m.oldValue == nil {
  46697. return v, errors.New("OldCtype requires an ID field in the mutation")
  46698. }
  46699. oldValue, err := m.oldValue(ctx)
  46700. if err != nil {
  46701. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  46702. }
  46703. return oldValue.Ctype, nil
  46704. }
  46705. // AddCtype adds u to the "ctype" field.
  46706. func (m *WxMutation) AddCtype(u int64) {
  46707. if m.addctype != nil {
  46708. *m.addctype += u
  46709. } else {
  46710. m.addctype = &u
  46711. }
  46712. }
  46713. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  46714. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  46715. v := m.addctype
  46716. if v == nil {
  46717. return
  46718. }
  46719. return *v, true
  46720. }
  46721. // ClearCtype clears the value of the "ctype" field.
  46722. func (m *WxMutation) ClearCtype() {
  46723. m.ctype = nil
  46724. m.addctype = nil
  46725. m.clearedFields[wx.FieldCtype] = struct{}{}
  46726. }
  46727. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  46728. func (m *WxMutation) CtypeCleared() bool {
  46729. _, ok := m.clearedFields[wx.FieldCtype]
  46730. return ok
  46731. }
  46732. // ResetCtype resets all changes to the "ctype" field.
  46733. func (m *WxMutation) ResetCtype() {
  46734. m.ctype = nil
  46735. m.addctype = nil
  46736. delete(m.clearedFields, wx.FieldCtype)
  46737. }
  46738. // ClearServer clears the "server" edge to the Server entity.
  46739. func (m *WxMutation) ClearServer() {
  46740. m.clearedserver = true
  46741. m.clearedFields[wx.FieldServerID] = struct{}{}
  46742. }
  46743. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  46744. func (m *WxMutation) ServerCleared() bool {
  46745. return m.ServerIDCleared() || m.clearedserver
  46746. }
  46747. // ServerIDs returns the "server" edge IDs in the mutation.
  46748. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  46749. // ServerID instead. It exists only for internal usage by the builders.
  46750. func (m *WxMutation) ServerIDs() (ids []uint64) {
  46751. if id := m.server; id != nil {
  46752. ids = append(ids, *id)
  46753. }
  46754. return
  46755. }
  46756. // ResetServer resets all changes to the "server" edge.
  46757. func (m *WxMutation) ResetServer() {
  46758. m.server = nil
  46759. m.clearedserver = false
  46760. }
  46761. // ClearAgent clears the "agent" edge to the Agent entity.
  46762. func (m *WxMutation) ClearAgent() {
  46763. m.clearedagent = true
  46764. m.clearedFields[wx.FieldAgentID] = struct{}{}
  46765. }
  46766. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  46767. func (m *WxMutation) AgentCleared() bool {
  46768. return m.clearedagent
  46769. }
  46770. // AgentIDs returns the "agent" edge IDs in the mutation.
  46771. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  46772. // AgentID instead. It exists only for internal usage by the builders.
  46773. func (m *WxMutation) AgentIDs() (ids []uint64) {
  46774. if id := m.agent; id != nil {
  46775. ids = append(ids, *id)
  46776. }
  46777. return
  46778. }
  46779. // ResetAgent resets all changes to the "agent" edge.
  46780. func (m *WxMutation) ResetAgent() {
  46781. m.agent = nil
  46782. m.clearedagent = false
  46783. }
  46784. // Where appends a list predicates to the WxMutation builder.
  46785. func (m *WxMutation) Where(ps ...predicate.Wx) {
  46786. m.predicates = append(m.predicates, ps...)
  46787. }
  46788. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  46789. // users can use type-assertion to append predicates that do not depend on any generated package.
  46790. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  46791. p := make([]predicate.Wx, len(ps))
  46792. for i := range ps {
  46793. p[i] = ps[i]
  46794. }
  46795. m.Where(p...)
  46796. }
  46797. // Op returns the operation name.
  46798. func (m *WxMutation) Op() Op {
  46799. return m.op
  46800. }
  46801. // SetOp allows setting the mutation operation.
  46802. func (m *WxMutation) SetOp(op Op) {
  46803. m.op = op
  46804. }
  46805. // Type returns the node type of this mutation (Wx).
  46806. func (m *WxMutation) Type() string {
  46807. return m.typ
  46808. }
  46809. // Fields returns all fields that were changed during this mutation. Note that in
  46810. // order to get all numeric fields that were incremented/decremented, call
  46811. // AddedFields().
  46812. func (m *WxMutation) Fields() []string {
  46813. fields := make([]string, 0, 22)
  46814. if m.created_at != nil {
  46815. fields = append(fields, wx.FieldCreatedAt)
  46816. }
  46817. if m.updated_at != nil {
  46818. fields = append(fields, wx.FieldUpdatedAt)
  46819. }
  46820. if m.status != nil {
  46821. fields = append(fields, wx.FieldStatus)
  46822. }
  46823. if m.deleted_at != nil {
  46824. fields = append(fields, wx.FieldDeletedAt)
  46825. }
  46826. if m.server != nil {
  46827. fields = append(fields, wx.FieldServerID)
  46828. }
  46829. if m.port != nil {
  46830. fields = append(fields, wx.FieldPort)
  46831. }
  46832. if m.process_id != nil {
  46833. fields = append(fields, wx.FieldProcessID)
  46834. }
  46835. if m.callback != nil {
  46836. fields = append(fields, wx.FieldCallback)
  46837. }
  46838. if m.wxid != nil {
  46839. fields = append(fields, wx.FieldWxid)
  46840. }
  46841. if m.account != nil {
  46842. fields = append(fields, wx.FieldAccount)
  46843. }
  46844. if m.nickname != nil {
  46845. fields = append(fields, wx.FieldNickname)
  46846. }
  46847. if m.tel != nil {
  46848. fields = append(fields, wx.FieldTel)
  46849. }
  46850. if m.head_big != nil {
  46851. fields = append(fields, wx.FieldHeadBig)
  46852. }
  46853. if m.organization_id != nil {
  46854. fields = append(fields, wx.FieldOrganizationID)
  46855. }
  46856. if m.agent != nil {
  46857. fields = append(fields, wx.FieldAgentID)
  46858. }
  46859. if m.api_base != nil {
  46860. fields = append(fields, wx.FieldAPIBase)
  46861. }
  46862. if m.api_key != nil {
  46863. fields = append(fields, wx.FieldAPIKey)
  46864. }
  46865. if m.allow_list != nil {
  46866. fields = append(fields, wx.FieldAllowList)
  46867. }
  46868. if m.group_allow_list != nil {
  46869. fields = append(fields, wx.FieldGroupAllowList)
  46870. }
  46871. if m.block_list != nil {
  46872. fields = append(fields, wx.FieldBlockList)
  46873. }
  46874. if m.group_block_list != nil {
  46875. fields = append(fields, wx.FieldGroupBlockList)
  46876. }
  46877. if m.ctype != nil {
  46878. fields = append(fields, wx.FieldCtype)
  46879. }
  46880. return fields
  46881. }
  46882. // Field returns the value of a field with the given name. The second boolean
  46883. // return value indicates that this field was not set, or was not defined in the
  46884. // schema.
  46885. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  46886. switch name {
  46887. case wx.FieldCreatedAt:
  46888. return m.CreatedAt()
  46889. case wx.FieldUpdatedAt:
  46890. return m.UpdatedAt()
  46891. case wx.FieldStatus:
  46892. return m.Status()
  46893. case wx.FieldDeletedAt:
  46894. return m.DeletedAt()
  46895. case wx.FieldServerID:
  46896. return m.ServerID()
  46897. case wx.FieldPort:
  46898. return m.Port()
  46899. case wx.FieldProcessID:
  46900. return m.ProcessID()
  46901. case wx.FieldCallback:
  46902. return m.Callback()
  46903. case wx.FieldWxid:
  46904. return m.Wxid()
  46905. case wx.FieldAccount:
  46906. return m.Account()
  46907. case wx.FieldNickname:
  46908. return m.Nickname()
  46909. case wx.FieldTel:
  46910. return m.Tel()
  46911. case wx.FieldHeadBig:
  46912. return m.HeadBig()
  46913. case wx.FieldOrganizationID:
  46914. return m.OrganizationID()
  46915. case wx.FieldAgentID:
  46916. return m.AgentID()
  46917. case wx.FieldAPIBase:
  46918. return m.APIBase()
  46919. case wx.FieldAPIKey:
  46920. return m.APIKey()
  46921. case wx.FieldAllowList:
  46922. return m.AllowList()
  46923. case wx.FieldGroupAllowList:
  46924. return m.GroupAllowList()
  46925. case wx.FieldBlockList:
  46926. return m.BlockList()
  46927. case wx.FieldGroupBlockList:
  46928. return m.GroupBlockList()
  46929. case wx.FieldCtype:
  46930. return m.Ctype()
  46931. }
  46932. return nil, false
  46933. }
  46934. // OldField returns the old value of the field from the database. An error is
  46935. // returned if the mutation operation is not UpdateOne, or the query to the
  46936. // database failed.
  46937. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46938. switch name {
  46939. case wx.FieldCreatedAt:
  46940. return m.OldCreatedAt(ctx)
  46941. case wx.FieldUpdatedAt:
  46942. return m.OldUpdatedAt(ctx)
  46943. case wx.FieldStatus:
  46944. return m.OldStatus(ctx)
  46945. case wx.FieldDeletedAt:
  46946. return m.OldDeletedAt(ctx)
  46947. case wx.FieldServerID:
  46948. return m.OldServerID(ctx)
  46949. case wx.FieldPort:
  46950. return m.OldPort(ctx)
  46951. case wx.FieldProcessID:
  46952. return m.OldProcessID(ctx)
  46953. case wx.FieldCallback:
  46954. return m.OldCallback(ctx)
  46955. case wx.FieldWxid:
  46956. return m.OldWxid(ctx)
  46957. case wx.FieldAccount:
  46958. return m.OldAccount(ctx)
  46959. case wx.FieldNickname:
  46960. return m.OldNickname(ctx)
  46961. case wx.FieldTel:
  46962. return m.OldTel(ctx)
  46963. case wx.FieldHeadBig:
  46964. return m.OldHeadBig(ctx)
  46965. case wx.FieldOrganizationID:
  46966. return m.OldOrganizationID(ctx)
  46967. case wx.FieldAgentID:
  46968. return m.OldAgentID(ctx)
  46969. case wx.FieldAPIBase:
  46970. return m.OldAPIBase(ctx)
  46971. case wx.FieldAPIKey:
  46972. return m.OldAPIKey(ctx)
  46973. case wx.FieldAllowList:
  46974. return m.OldAllowList(ctx)
  46975. case wx.FieldGroupAllowList:
  46976. return m.OldGroupAllowList(ctx)
  46977. case wx.FieldBlockList:
  46978. return m.OldBlockList(ctx)
  46979. case wx.FieldGroupBlockList:
  46980. return m.OldGroupBlockList(ctx)
  46981. case wx.FieldCtype:
  46982. return m.OldCtype(ctx)
  46983. }
  46984. return nil, fmt.Errorf("unknown Wx field %s", name)
  46985. }
  46986. // SetField sets the value of a field with the given name. It returns an error if
  46987. // the field is not defined in the schema, or if the type mismatched the field
  46988. // type.
  46989. func (m *WxMutation) SetField(name string, value ent.Value) error {
  46990. switch name {
  46991. case wx.FieldCreatedAt:
  46992. v, ok := value.(time.Time)
  46993. if !ok {
  46994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46995. }
  46996. m.SetCreatedAt(v)
  46997. return nil
  46998. case wx.FieldUpdatedAt:
  46999. v, ok := value.(time.Time)
  47000. if !ok {
  47001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47002. }
  47003. m.SetUpdatedAt(v)
  47004. return nil
  47005. case wx.FieldStatus:
  47006. v, ok := value.(uint8)
  47007. if !ok {
  47008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47009. }
  47010. m.SetStatus(v)
  47011. return nil
  47012. case wx.FieldDeletedAt:
  47013. v, ok := value.(time.Time)
  47014. if !ok {
  47015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47016. }
  47017. m.SetDeletedAt(v)
  47018. return nil
  47019. case wx.FieldServerID:
  47020. v, ok := value.(uint64)
  47021. if !ok {
  47022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47023. }
  47024. m.SetServerID(v)
  47025. return nil
  47026. case wx.FieldPort:
  47027. v, ok := value.(string)
  47028. if !ok {
  47029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47030. }
  47031. m.SetPort(v)
  47032. return nil
  47033. case wx.FieldProcessID:
  47034. v, ok := value.(string)
  47035. if !ok {
  47036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47037. }
  47038. m.SetProcessID(v)
  47039. return nil
  47040. case wx.FieldCallback:
  47041. v, ok := value.(string)
  47042. if !ok {
  47043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47044. }
  47045. m.SetCallback(v)
  47046. return nil
  47047. case wx.FieldWxid:
  47048. v, ok := value.(string)
  47049. if !ok {
  47050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47051. }
  47052. m.SetWxid(v)
  47053. return nil
  47054. case wx.FieldAccount:
  47055. v, ok := value.(string)
  47056. if !ok {
  47057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47058. }
  47059. m.SetAccount(v)
  47060. return nil
  47061. case wx.FieldNickname:
  47062. v, ok := value.(string)
  47063. if !ok {
  47064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47065. }
  47066. m.SetNickname(v)
  47067. return nil
  47068. case wx.FieldTel:
  47069. v, ok := value.(string)
  47070. if !ok {
  47071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47072. }
  47073. m.SetTel(v)
  47074. return nil
  47075. case wx.FieldHeadBig:
  47076. v, ok := value.(string)
  47077. if !ok {
  47078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47079. }
  47080. m.SetHeadBig(v)
  47081. return nil
  47082. case wx.FieldOrganizationID:
  47083. v, ok := value.(uint64)
  47084. if !ok {
  47085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47086. }
  47087. m.SetOrganizationID(v)
  47088. return nil
  47089. case wx.FieldAgentID:
  47090. v, ok := value.(uint64)
  47091. if !ok {
  47092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47093. }
  47094. m.SetAgentID(v)
  47095. return nil
  47096. case wx.FieldAPIBase:
  47097. v, ok := value.(string)
  47098. if !ok {
  47099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47100. }
  47101. m.SetAPIBase(v)
  47102. return nil
  47103. case wx.FieldAPIKey:
  47104. v, ok := value.(string)
  47105. if !ok {
  47106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47107. }
  47108. m.SetAPIKey(v)
  47109. return nil
  47110. case wx.FieldAllowList:
  47111. v, ok := value.([]string)
  47112. if !ok {
  47113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47114. }
  47115. m.SetAllowList(v)
  47116. return nil
  47117. case wx.FieldGroupAllowList:
  47118. v, ok := value.([]string)
  47119. if !ok {
  47120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47121. }
  47122. m.SetGroupAllowList(v)
  47123. return nil
  47124. case wx.FieldBlockList:
  47125. v, ok := value.([]string)
  47126. if !ok {
  47127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47128. }
  47129. m.SetBlockList(v)
  47130. return nil
  47131. case wx.FieldGroupBlockList:
  47132. v, ok := value.([]string)
  47133. if !ok {
  47134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47135. }
  47136. m.SetGroupBlockList(v)
  47137. return nil
  47138. case wx.FieldCtype:
  47139. v, ok := value.(uint64)
  47140. if !ok {
  47141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47142. }
  47143. m.SetCtype(v)
  47144. return nil
  47145. }
  47146. return fmt.Errorf("unknown Wx field %s", name)
  47147. }
  47148. // AddedFields returns all numeric fields that were incremented/decremented during
  47149. // this mutation.
  47150. func (m *WxMutation) AddedFields() []string {
  47151. var fields []string
  47152. if m.addstatus != nil {
  47153. fields = append(fields, wx.FieldStatus)
  47154. }
  47155. if m.addorganization_id != nil {
  47156. fields = append(fields, wx.FieldOrganizationID)
  47157. }
  47158. if m.addctype != nil {
  47159. fields = append(fields, wx.FieldCtype)
  47160. }
  47161. return fields
  47162. }
  47163. // AddedField returns the numeric value that was incremented/decremented on a field
  47164. // with the given name. The second boolean return value indicates that this field
  47165. // was not set, or was not defined in the schema.
  47166. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  47167. switch name {
  47168. case wx.FieldStatus:
  47169. return m.AddedStatus()
  47170. case wx.FieldOrganizationID:
  47171. return m.AddedOrganizationID()
  47172. case wx.FieldCtype:
  47173. return m.AddedCtype()
  47174. }
  47175. return nil, false
  47176. }
  47177. // AddField adds the value to the field with the given name. It returns an error if
  47178. // the field is not defined in the schema, or if the type mismatched the field
  47179. // type.
  47180. func (m *WxMutation) AddField(name string, value ent.Value) error {
  47181. switch name {
  47182. case wx.FieldStatus:
  47183. v, ok := value.(int8)
  47184. if !ok {
  47185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47186. }
  47187. m.AddStatus(v)
  47188. return nil
  47189. case wx.FieldOrganizationID:
  47190. v, ok := value.(int64)
  47191. if !ok {
  47192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47193. }
  47194. m.AddOrganizationID(v)
  47195. return nil
  47196. case wx.FieldCtype:
  47197. v, ok := value.(int64)
  47198. if !ok {
  47199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47200. }
  47201. m.AddCtype(v)
  47202. return nil
  47203. }
  47204. return fmt.Errorf("unknown Wx numeric field %s", name)
  47205. }
  47206. // ClearedFields returns all nullable fields that were cleared during this
  47207. // mutation.
  47208. func (m *WxMutation) ClearedFields() []string {
  47209. var fields []string
  47210. if m.FieldCleared(wx.FieldStatus) {
  47211. fields = append(fields, wx.FieldStatus)
  47212. }
  47213. if m.FieldCleared(wx.FieldDeletedAt) {
  47214. fields = append(fields, wx.FieldDeletedAt)
  47215. }
  47216. if m.FieldCleared(wx.FieldServerID) {
  47217. fields = append(fields, wx.FieldServerID)
  47218. }
  47219. if m.FieldCleared(wx.FieldOrganizationID) {
  47220. fields = append(fields, wx.FieldOrganizationID)
  47221. }
  47222. if m.FieldCleared(wx.FieldAPIBase) {
  47223. fields = append(fields, wx.FieldAPIBase)
  47224. }
  47225. if m.FieldCleared(wx.FieldAPIKey) {
  47226. fields = append(fields, wx.FieldAPIKey)
  47227. }
  47228. if m.FieldCleared(wx.FieldCtype) {
  47229. fields = append(fields, wx.FieldCtype)
  47230. }
  47231. return fields
  47232. }
  47233. // FieldCleared returns a boolean indicating if a field with the given name was
  47234. // cleared in this mutation.
  47235. func (m *WxMutation) FieldCleared(name string) bool {
  47236. _, ok := m.clearedFields[name]
  47237. return ok
  47238. }
  47239. // ClearField clears the value of the field with the given name. It returns an
  47240. // error if the field is not defined in the schema.
  47241. func (m *WxMutation) ClearField(name string) error {
  47242. switch name {
  47243. case wx.FieldStatus:
  47244. m.ClearStatus()
  47245. return nil
  47246. case wx.FieldDeletedAt:
  47247. m.ClearDeletedAt()
  47248. return nil
  47249. case wx.FieldServerID:
  47250. m.ClearServerID()
  47251. return nil
  47252. case wx.FieldOrganizationID:
  47253. m.ClearOrganizationID()
  47254. return nil
  47255. case wx.FieldAPIBase:
  47256. m.ClearAPIBase()
  47257. return nil
  47258. case wx.FieldAPIKey:
  47259. m.ClearAPIKey()
  47260. return nil
  47261. case wx.FieldCtype:
  47262. m.ClearCtype()
  47263. return nil
  47264. }
  47265. return fmt.Errorf("unknown Wx nullable field %s", name)
  47266. }
  47267. // ResetField resets all changes in the mutation for the field with the given name.
  47268. // It returns an error if the field is not defined in the schema.
  47269. func (m *WxMutation) ResetField(name string) error {
  47270. switch name {
  47271. case wx.FieldCreatedAt:
  47272. m.ResetCreatedAt()
  47273. return nil
  47274. case wx.FieldUpdatedAt:
  47275. m.ResetUpdatedAt()
  47276. return nil
  47277. case wx.FieldStatus:
  47278. m.ResetStatus()
  47279. return nil
  47280. case wx.FieldDeletedAt:
  47281. m.ResetDeletedAt()
  47282. return nil
  47283. case wx.FieldServerID:
  47284. m.ResetServerID()
  47285. return nil
  47286. case wx.FieldPort:
  47287. m.ResetPort()
  47288. return nil
  47289. case wx.FieldProcessID:
  47290. m.ResetProcessID()
  47291. return nil
  47292. case wx.FieldCallback:
  47293. m.ResetCallback()
  47294. return nil
  47295. case wx.FieldWxid:
  47296. m.ResetWxid()
  47297. return nil
  47298. case wx.FieldAccount:
  47299. m.ResetAccount()
  47300. return nil
  47301. case wx.FieldNickname:
  47302. m.ResetNickname()
  47303. return nil
  47304. case wx.FieldTel:
  47305. m.ResetTel()
  47306. return nil
  47307. case wx.FieldHeadBig:
  47308. m.ResetHeadBig()
  47309. return nil
  47310. case wx.FieldOrganizationID:
  47311. m.ResetOrganizationID()
  47312. return nil
  47313. case wx.FieldAgentID:
  47314. m.ResetAgentID()
  47315. return nil
  47316. case wx.FieldAPIBase:
  47317. m.ResetAPIBase()
  47318. return nil
  47319. case wx.FieldAPIKey:
  47320. m.ResetAPIKey()
  47321. return nil
  47322. case wx.FieldAllowList:
  47323. m.ResetAllowList()
  47324. return nil
  47325. case wx.FieldGroupAllowList:
  47326. m.ResetGroupAllowList()
  47327. return nil
  47328. case wx.FieldBlockList:
  47329. m.ResetBlockList()
  47330. return nil
  47331. case wx.FieldGroupBlockList:
  47332. m.ResetGroupBlockList()
  47333. return nil
  47334. case wx.FieldCtype:
  47335. m.ResetCtype()
  47336. return nil
  47337. }
  47338. return fmt.Errorf("unknown Wx field %s", name)
  47339. }
  47340. // AddedEdges returns all edge names that were set/added in this mutation.
  47341. func (m *WxMutation) AddedEdges() []string {
  47342. edges := make([]string, 0, 2)
  47343. if m.server != nil {
  47344. edges = append(edges, wx.EdgeServer)
  47345. }
  47346. if m.agent != nil {
  47347. edges = append(edges, wx.EdgeAgent)
  47348. }
  47349. return edges
  47350. }
  47351. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47352. // name in this mutation.
  47353. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  47354. switch name {
  47355. case wx.EdgeServer:
  47356. if id := m.server; id != nil {
  47357. return []ent.Value{*id}
  47358. }
  47359. case wx.EdgeAgent:
  47360. if id := m.agent; id != nil {
  47361. return []ent.Value{*id}
  47362. }
  47363. }
  47364. return nil
  47365. }
  47366. // RemovedEdges returns all edge names that were removed in this mutation.
  47367. func (m *WxMutation) RemovedEdges() []string {
  47368. edges := make([]string, 0, 2)
  47369. return edges
  47370. }
  47371. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47372. // the given name in this mutation.
  47373. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  47374. return nil
  47375. }
  47376. // ClearedEdges returns all edge names that were cleared in this mutation.
  47377. func (m *WxMutation) ClearedEdges() []string {
  47378. edges := make([]string, 0, 2)
  47379. if m.clearedserver {
  47380. edges = append(edges, wx.EdgeServer)
  47381. }
  47382. if m.clearedagent {
  47383. edges = append(edges, wx.EdgeAgent)
  47384. }
  47385. return edges
  47386. }
  47387. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47388. // was cleared in this mutation.
  47389. func (m *WxMutation) EdgeCleared(name string) bool {
  47390. switch name {
  47391. case wx.EdgeServer:
  47392. return m.clearedserver
  47393. case wx.EdgeAgent:
  47394. return m.clearedagent
  47395. }
  47396. return false
  47397. }
  47398. // ClearEdge clears the value of the edge with the given name. It returns an error
  47399. // if that edge is not defined in the schema.
  47400. func (m *WxMutation) ClearEdge(name string) error {
  47401. switch name {
  47402. case wx.EdgeServer:
  47403. m.ClearServer()
  47404. return nil
  47405. case wx.EdgeAgent:
  47406. m.ClearAgent()
  47407. return nil
  47408. }
  47409. return fmt.Errorf("unknown Wx unique edge %s", name)
  47410. }
  47411. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47412. // It returns an error if the edge is not defined in the schema.
  47413. func (m *WxMutation) ResetEdge(name string) error {
  47414. switch name {
  47415. case wx.EdgeServer:
  47416. m.ResetServer()
  47417. return nil
  47418. case wx.EdgeAgent:
  47419. m.ResetAgent()
  47420. return nil
  47421. }
  47422. return fmt.Errorf("unknown Wx edge %s", name)
  47423. }
  47424. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  47425. type WxCardMutation struct {
  47426. config
  47427. op Op
  47428. typ string
  47429. id *uint64
  47430. created_at *time.Time
  47431. updated_at *time.Time
  47432. deleted_at *time.Time
  47433. user_id *uint64
  47434. adduser_id *int64
  47435. wx_user_id *uint64
  47436. addwx_user_id *int64
  47437. avatar *string
  47438. logo *string
  47439. name *string
  47440. company *string
  47441. address *string
  47442. phone *string
  47443. official_account *string
  47444. wechat_account *string
  47445. email *string
  47446. api_base *string
  47447. api_key *string
  47448. ai_info *string
  47449. intro *string
  47450. clearedFields map[string]struct{}
  47451. done bool
  47452. oldValue func(context.Context) (*WxCard, error)
  47453. predicates []predicate.WxCard
  47454. }
  47455. var _ ent.Mutation = (*WxCardMutation)(nil)
  47456. // wxcardOption allows management of the mutation configuration using functional options.
  47457. type wxcardOption func(*WxCardMutation)
  47458. // newWxCardMutation creates new mutation for the WxCard entity.
  47459. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  47460. m := &WxCardMutation{
  47461. config: c,
  47462. op: op,
  47463. typ: TypeWxCard,
  47464. clearedFields: make(map[string]struct{}),
  47465. }
  47466. for _, opt := range opts {
  47467. opt(m)
  47468. }
  47469. return m
  47470. }
  47471. // withWxCardID sets the ID field of the mutation.
  47472. func withWxCardID(id uint64) wxcardOption {
  47473. return func(m *WxCardMutation) {
  47474. var (
  47475. err error
  47476. once sync.Once
  47477. value *WxCard
  47478. )
  47479. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  47480. once.Do(func() {
  47481. if m.done {
  47482. err = errors.New("querying old values post mutation is not allowed")
  47483. } else {
  47484. value, err = m.Client().WxCard.Get(ctx, id)
  47485. }
  47486. })
  47487. return value, err
  47488. }
  47489. m.id = &id
  47490. }
  47491. }
  47492. // withWxCard sets the old WxCard of the mutation.
  47493. func withWxCard(node *WxCard) wxcardOption {
  47494. return func(m *WxCardMutation) {
  47495. m.oldValue = func(context.Context) (*WxCard, error) {
  47496. return node, nil
  47497. }
  47498. m.id = &node.ID
  47499. }
  47500. }
  47501. // Client returns a new `ent.Client` from the mutation. If the mutation was
  47502. // executed in a transaction (ent.Tx), a transactional client is returned.
  47503. func (m WxCardMutation) Client() *Client {
  47504. client := &Client{config: m.config}
  47505. client.init()
  47506. return client
  47507. }
  47508. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  47509. // it returns an error otherwise.
  47510. func (m WxCardMutation) Tx() (*Tx, error) {
  47511. if _, ok := m.driver.(*txDriver); !ok {
  47512. return nil, errors.New("ent: mutation is not running in a transaction")
  47513. }
  47514. tx := &Tx{config: m.config}
  47515. tx.init()
  47516. return tx, nil
  47517. }
  47518. // SetID sets the value of the id field. Note that this
  47519. // operation is only accepted on creation of WxCard entities.
  47520. func (m *WxCardMutation) SetID(id uint64) {
  47521. m.id = &id
  47522. }
  47523. // ID returns the ID value in the mutation. Note that the ID is only available
  47524. // if it was provided to the builder or after it was returned from the database.
  47525. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  47526. if m.id == nil {
  47527. return
  47528. }
  47529. return *m.id, true
  47530. }
  47531. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  47532. // That means, if the mutation is applied within a transaction with an isolation level such
  47533. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  47534. // or updated by the mutation.
  47535. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  47536. switch {
  47537. case m.op.Is(OpUpdateOne | OpDeleteOne):
  47538. id, exists := m.ID()
  47539. if exists {
  47540. return []uint64{id}, nil
  47541. }
  47542. fallthrough
  47543. case m.op.Is(OpUpdate | OpDelete):
  47544. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  47545. default:
  47546. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47547. }
  47548. }
  47549. // SetCreatedAt sets the "created_at" field.
  47550. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  47551. m.created_at = &t
  47552. }
  47553. // CreatedAt returns the value of the "created_at" field in the mutation.
  47554. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  47555. v := m.created_at
  47556. if v == nil {
  47557. return
  47558. }
  47559. return *v, true
  47560. }
  47561. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  47562. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47564. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47565. if !m.op.Is(OpUpdateOne) {
  47566. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47567. }
  47568. if m.id == nil || m.oldValue == nil {
  47569. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  47570. }
  47571. oldValue, err := m.oldValue(ctx)
  47572. if err != nil {
  47573. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  47574. }
  47575. return oldValue.CreatedAt, nil
  47576. }
  47577. // ResetCreatedAt resets all changes to the "created_at" field.
  47578. func (m *WxCardMutation) ResetCreatedAt() {
  47579. m.created_at = nil
  47580. }
  47581. // SetUpdatedAt sets the "updated_at" field.
  47582. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  47583. m.updated_at = &t
  47584. }
  47585. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47586. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  47587. v := m.updated_at
  47588. if v == nil {
  47589. return
  47590. }
  47591. return *v, true
  47592. }
  47593. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  47594. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47596. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47597. if !m.op.Is(OpUpdateOne) {
  47598. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47599. }
  47600. if m.id == nil || m.oldValue == nil {
  47601. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  47602. }
  47603. oldValue, err := m.oldValue(ctx)
  47604. if err != nil {
  47605. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  47606. }
  47607. return oldValue.UpdatedAt, nil
  47608. }
  47609. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47610. func (m *WxCardMutation) ResetUpdatedAt() {
  47611. m.updated_at = nil
  47612. }
  47613. // SetDeletedAt sets the "deleted_at" field.
  47614. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  47615. m.deleted_at = &t
  47616. }
  47617. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47618. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  47619. v := m.deleted_at
  47620. if v == nil {
  47621. return
  47622. }
  47623. return *v, true
  47624. }
  47625. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  47626. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47628. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47629. if !m.op.Is(OpUpdateOne) {
  47630. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47631. }
  47632. if m.id == nil || m.oldValue == nil {
  47633. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47634. }
  47635. oldValue, err := m.oldValue(ctx)
  47636. if err != nil {
  47637. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47638. }
  47639. return oldValue.DeletedAt, nil
  47640. }
  47641. // ClearDeletedAt clears the value of the "deleted_at" field.
  47642. func (m *WxCardMutation) ClearDeletedAt() {
  47643. m.deleted_at = nil
  47644. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  47645. }
  47646. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47647. func (m *WxCardMutation) DeletedAtCleared() bool {
  47648. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  47649. return ok
  47650. }
  47651. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47652. func (m *WxCardMutation) ResetDeletedAt() {
  47653. m.deleted_at = nil
  47654. delete(m.clearedFields, wxcard.FieldDeletedAt)
  47655. }
  47656. // SetUserID sets the "user_id" field.
  47657. func (m *WxCardMutation) SetUserID(u uint64) {
  47658. m.user_id = &u
  47659. m.adduser_id = nil
  47660. }
  47661. // UserID returns the value of the "user_id" field in the mutation.
  47662. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  47663. v := m.user_id
  47664. if v == nil {
  47665. return
  47666. }
  47667. return *v, true
  47668. }
  47669. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  47670. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47672. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  47673. if !m.op.Is(OpUpdateOne) {
  47674. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  47675. }
  47676. if m.id == nil || m.oldValue == nil {
  47677. return v, errors.New("OldUserID requires an ID field in the mutation")
  47678. }
  47679. oldValue, err := m.oldValue(ctx)
  47680. if err != nil {
  47681. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  47682. }
  47683. return oldValue.UserID, nil
  47684. }
  47685. // AddUserID adds u to the "user_id" field.
  47686. func (m *WxCardMutation) AddUserID(u int64) {
  47687. if m.adduser_id != nil {
  47688. *m.adduser_id += u
  47689. } else {
  47690. m.adduser_id = &u
  47691. }
  47692. }
  47693. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  47694. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  47695. v := m.adduser_id
  47696. if v == nil {
  47697. return
  47698. }
  47699. return *v, true
  47700. }
  47701. // ClearUserID clears the value of the "user_id" field.
  47702. func (m *WxCardMutation) ClearUserID() {
  47703. m.user_id = nil
  47704. m.adduser_id = nil
  47705. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  47706. }
  47707. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  47708. func (m *WxCardMutation) UserIDCleared() bool {
  47709. _, ok := m.clearedFields[wxcard.FieldUserID]
  47710. return ok
  47711. }
  47712. // ResetUserID resets all changes to the "user_id" field.
  47713. func (m *WxCardMutation) ResetUserID() {
  47714. m.user_id = nil
  47715. m.adduser_id = nil
  47716. delete(m.clearedFields, wxcard.FieldUserID)
  47717. }
  47718. // SetWxUserID sets the "wx_user_id" field.
  47719. func (m *WxCardMutation) SetWxUserID(u uint64) {
  47720. m.wx_user_id = &u
  47721. m.addwx_user_id = nil
  47722. }
  47723. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  47724. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  47725. v := m.wx_user_id
  47726. if v == nil {
  47727. return
  47728. }
  47729. return *v, true
  47730. }
  47731. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  47732. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47734. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  47735. if !m.op.Is(OpUpdateOne) {
  47736. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  47737. }
  47738. if m.id == nil || m.oldValue == nil {
  47739. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  47740. }
  47741. oldValue, err := m.oldValue(ctx)
  47742. if err != nil {
  47743. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  47744. }
  47745. return oldValue.WxUserID, nil
  47746. }
  47747. // AddWxUserID adds u to the "wx_user_id" field.
  47748. func (m *WxCardMutation) AddWxUserID(u int64) {
  47749. if m.addwx_user_id != nil {
  47750. *m.addwx_user_id += u
  47751. } else {
  47752. m.addwx_user_id = &u
  47753. }
  47754. }
  47755. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  47756. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  47757. v := m.addwx_user_id
  47758. if v == nil {
  47759. return
  47760. }
  47761. return *v, true
  47762. }
  47763. // ClearWxUserID clears the value of the "wx_user_id" field.
  47764. func (m *WxCardMutation) ClearWxUserID() {
  47765. m.wx_user_id = nil
  47766. m.addwx_user_id = nil
  47767. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  47768. }
  47769. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  47770. func (m *WxCardMutation) WxUserIDCleared() bool {
  47771. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  47772. return ok
  47773. }
  47774. // ResetWxUserID resets all changes to the "wx_user_id" field.
  47775. func (m *WxCardMutation) ResetWxUserID() {
  47776. m.wx_user_id = nil
  47777. m.addwx_user_id = nil
  47778. delete(m.clearedFields, wxcard.FieldWxUserID)
  47779. }
  47780. // SetAvatar sets the "avatar" field.
  47781. func (m *WxCardMutation) SetAvatar(s string) {
  47782. m.avatar = &s
  47783. }
  47784. // Avatar returns the value of the "avatar" field in the mutation.
  47785. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  47786. v := m.avatar
  47787. if v == nil {
  47788. return
  47789. }
  47790. return *v, true
  47791. }
  47792. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  47793. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47795. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  47796. if !m.op.Is(OpUpdateOne) {
  47797. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  47798. }
  47799. if m.id == nil || m.oldValue == nil {
  47800. return v, errors.New("OldAvatar requires an ID field in the mutation")
  47801. }
  47802. oldValue, err := m.oldValue(ctx)
  47803. if err != nil {
  47804. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  47805. }
  47806. return oldValue.Avatar, nil
  47807. }
  47808. // ResetAvatar resets all changes to the "avatar" field.
  47809. func (m *WxCardMutation) ResetAvatar() {
  47810. m.avatar = nil
  47811. }
  47812. // SetLogo sets the "logo" field.
  47813. func (m *WxCardMutation) SetLogo(s string) {
  47814. m.logo = &s
  47815. }
  47816. // Logo returns the value of the "logo" field in the mutation.
  47817. func (m *WxCardMutation) Logo() (r string, exists bool) {
  47818. v := m.logo
  47819. if v == nil {
  47820. return
  47821. }
  47822. return *v, true
  47823. }
  47824. // OldLogo returns the old "logo" field's value of the WxCard entity.
  47825. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47827. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  47828. if !m.op.Is(OpUpdateOne) {
  47829. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  47830. }
  47831. if m.id == nil || m.oldValue == nil {
  47832. return v, errors.New("OldLogo requires an ID field in the mutation")
  47833. }
  47834. oldValue, err := m.oldValue(ctx)
  47835. if err != nil {
  47836. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  47837. }
  47838. return oldValue.Logo, nil
  47839. }
  47840. // ResetLogo resets all changes to the "logo" field.
  47841. func (m *WxCardMutation) ResetLogo() {
  47842. m.logo = nil
  47843. }
  47844. // SetName sets the "name" field.
  47845. func (m *WxCardMutation) SetName(s string) {
  47846. m.name = &s
  47847. }
  47848. // Name returns the value of the "name" field in the mutation.
  47849. func (m *WxCardMutation) Name() (r string, exists bool) {
  47850. v := m.name
  47851. if v == nil {
  47852. return
  47853. }
  47854. return *v, true
  47855. }
  47856. // OldName returns the old "name" field's value of the WxCard entity.
  47857. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47859. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  47860. if !m.op.Is(OpUpdateOne) {
  47861. return v, errors.New("OldName is only allowed on UpdateOne operations")
  47862. }
  47863. if m.id == nil || m.oldValue == nil {
  47864. return v, errors.New("OldName requires an ID field in the mutation")
  47865. }
  47866. oldValue, err := m.oldValue(ctx)
  47867. if err != nil {
  47868. return v, fmt.Errorf("querying old value for OldName: %w", err)
  47869. }
  47870. return oldValue.Name, nil
  47871. }
  47872. // ResetName resets all changes to the "name" field.
  47873. func (m *WxCardMutation) ResetName() {
  47874. m.name = nil
  47875. }
  47876. // SetCompany sets the "company" field.
  47877. func (m *WxCardMutation) SetCompany(s string) {
  47878. m.company = &s
  47879. }
  47880. // Company returns the value of the "company" field in the mutation.
  47881. func (m *WxCardMutation) Company() (r string, exists bool) {
  47882. v := m.company
  47883. if v == nil {
  47884. return
  47885. }
  47886. return *v, true
  47887. }
  47888. // OldCompany returns the old "company" field's value of the WxCard entity.
  47889. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47891. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  47892. if !m.op.Is(OpUpdateOne) {
  47893. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  47894. }
  47895. if m.id == nil || m.oldValue == nil {
  47896. return v, errors.New("OldCompany requires an ID field in the mutation")
  47897. }
  47898. oldValue, err := m.oldValue(ctx)
  47899. if err != nil {
  47900. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  47901. }
  47902. return oldValue.Company, nil
  47903. }
  47904. // ResetCompany resets all changes to the "company" field.
  47905. func (m *WxCardMutation) ResetCompany() {
  47906. m.company = nil
  47907. }
  47908. // SetAddress sets the "address" field.
  47909. func (m *WxCardMutation) SetAddress(s string) {
  47910. m.address = &s
  47911. }
  47912. // Address returns the value of the "address" field in the mutation.
  47913. func (m *WxCardMutation) Address() (r string, exists bool) {
  47914. v := m.address
  47915. if v == nil {
  47916. return
  47917. }
  47918. return *v, true
  47919. }
  47920. // OldAddress returns the old "address" field's value of the WxCard entity.
  47921. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47923. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  47924. if !m.op.Is(OpUpdateOne) {
  47925. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  47926. }
  47927. if m.id == nil || m.oldValue == nil {
  47928. return v, errors.New("OldAddress requires an ID field in the mutation")
  47929. }
  47930. oldValue, err := m.oldValue(ctx)
  47931. if err != nil {
  47932. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  47933. }
  47934. return oldValue.Address, nil
  47935. }
  47936. // ResetAddress resets all changes to the "address" field.
  47937. func (m *WxCardMutation) ResetAddress() {
  47938. m.address = nil
  47939. }
  47940. // SetPhone sets the "phone" field.
  47941. func (m *WxCardMutation) SetPhone(s string) {
  47942. m.phone = &s
  47943. }
  47944. // Phone returns the value of the "phone" field in the mutation.
  47945. func (m *WxCardMutation) Phone() (r string, exists bool) {
  47946. v := m.phone
  47947. if v == nil {
  47948. return
  47949. }
  47950. return *v, true
  47951. }
  47952. // OldPhone returns the old "phone" field's value of the WxCard entity.
  47953. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47955. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  47956. if !m.op.Is(OpUpdateOne) {
  47957. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  47958. }
  47959. if m.id == nil || m.oldValue == nil {
  47960. return v, errors.New("OldPhone requires an ID field in the mutation")
  47961. }
  47962. oldValue, err := m.oldValue(ctx)
  47963. if err != nil {
  47964. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  47965. }
  47966. return oldValue.Phone, nil
  47967. }
  47968. // ResetPhone resets all changes to the "phone" field.
  47969. func (m *WxCardMutation) ResetPhone() {
  47970. m.phone = nil
  47971. }
  47972. // SetOfficialAccount sets the "official_account" field.
  47973. func (m *WxCardMutation) SetOfficialAccount(s string) {
  47974. m.official_account = &s
  47975. }
  47976. // OfficialAccount returns the value of the "official_account" field in the mutation.
  47977. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  47978. v := m.official_account
  47979. if v == nil {
  47980. return
  47981. }
  47982. return *v, true
  47983. }
  47984. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  47985. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47987. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  47988. if !m.op.Is(OpUpdateOne) {
  47989. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  47990. }
  47991. if m.id == nil || m.oldValue == nil {
  47992. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  47993. }
  47994. oldValue, err := m.oldValue(ctx)
  47995. if err != nil {
  47996. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  47997. }
  47998. return oldValue.OfficialAccount, nil
  47999. }
  48000. // ResetOfficialAccount resets all changes to the "official_account" field.
  48001. func (m *WxCardMutation) ResetOfficialAccount() {
  48002. m.official_account = nil
  48003. }
  48004. // SetWechatAccount sets the "wechat_account" field.
  48005. func (m *WxCardMutation) SetWechatAccount(s string) {
  48006. m.wechat_account = &s
  48007. }
  48008. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  48009. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  48010. v := m.wechat_account
  48011. if v == nil {
  48012. return
  48013. }
  48014. return *v, true
  48015. }
  48016. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  48017. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48019. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  48020. if !m.op.Is(OpUpdateOne) {
  48021. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  48022. }
  48023. if m.id == nil || m.oldValue == nil {
  48024. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  48025. }
  48026. oldValue, err := m.oldValue(ctx)
  48027. if err != nil {
  48028. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  48029. }
  48030. return oldValue.WechatAccount, nil
  48031. }
  48032. // ResetWechatAccount resets all changes to the "wechat_account" field.
  48033. func (m *WxCardMutation) ResetWechatAccount() {
  48034. m.wechat_account = nil
  48035. }
  48036. // SetEmail sets the "email" field.
  48037. func (m *WxCardMutation) SetEmail(s string) {
  48038. m.email = &s
  48039. }
  48040. // Email returns the value of the "email" field in the mutation.
  48041. func (m *WxCardMutation) Email() (r string, exists bool) {
  48042. v := m.email
  48043. if v == nil {
  48044. return
  48045. }
  48046. return *v, true
  48047. }
  48048. // OldEmail returns the old "email" field's value of the WxCard entity.
  48049. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48051. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  48052. if !m.op.Is(OpUpdateOne) {
  48053. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  48054. }
  48055. if m.id == nil || m.oldValue == nil {
  48056. return v, errors.New("OldEmail requires an ID field in the mutation")
  48057. }
  48058. oldValue, err := m.oldValue(ctx)
  48059. if err != nil {
  48060. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  48061. }
  48062. return oldValue.Email, nil
  48063. }
  48064. // ClearEmail clears the value of the "email" field.
  48065. func (m *WxCardMutation) ClearEmail() {
  48066. m.email = nil
  48067. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  48068. }
  48069. // EmailCleared returns if the "email" field was cleared in this mutation.
  48070. func (m *WxCardMutation) EmailCleared() bool {
  48071. _, ok := m.clearedFields[wxcard.FieldEmail]
  48072. return ok
  48073. }
  48074. // ResetEmail resets all changes to the "email" field.
  48075. func (m *WxCardMutation) ResetEmail() {
  48076. m.email = nil
  48077. delete(m.clearedFields, wxcard.FieldEmail)
  48078. }
  48079. // SetAPIBase sets the "api_base" field.
  48080. func (m *WxCardMutation) SetAPIBase(s string) {
  48081. m.api_base = &s
  48082. }
  48083. // APIBase returns the value of the "api_base" field in the mutation.
  48084. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  48085. v := m.api_base
  48086. if v == nil {
  48087. return
  48088. }
  48089. return *v, true
  48090. }
  48091. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  48092. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48094. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  48095. if !m.op.Is(OpUpdateOne) {
  48096. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  48097. }
  48098. if m.id == nil || m.oldValue == nil {
  48099. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  48100. }
  48101. oldValue, err := m.oldValue(ctx)
  48102. if err != nil {
  48103. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  48104. }
  48105. return oldValue.APIBase, nil
  48106. }
  48107. // ClearAPIBase clears the value of the "api_base" field.
  48108. func (m *WxCardMutation) ClearAPIBase() {
  48109. m.api_base = nil
  48110. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  48111. }
  48112. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  48113. func (m *WxCardMutation) APIBaseCleared() bool {
  48114. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  48115. return ok
  48116. }
  48117. // ResetAPIBase resets all changes to the "api_base" field.
  48118. func (m *WxCardMutation) ResetAPIBase() {
  48119. m.api_base = nil
  48120. delete(m.clearedFields, wxcard.FieldAPIBase)
  48121. }
  48122. // SetAPIKey sets the "api_key" field.
  48123. func (m *WxCardMutation) SetAPIKey(s string) {
  48124. m.api_key = &s
  48125. }
  48126. // APIKey returns the value of the "api_key" field in the mutation.
  48127. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  48128. v := m.api_key
  48129. if v == nil {
  48130. return
  48131. }
  48132. return *v, true
  48133. }
  48134. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  48135. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48137. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  48138. if !m.op.Is(OpUpdateOne) {
  48139. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  48140. }
  48141. if m.id == nil || m.oldValue == nil {
  48142. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  48143. }
  48144. oldValue, err := m.oldValue(ctx)
  48145. if err != nil {
  48146. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  48147. }
  48148. return oldValue.APIKey, nil
  48149. }
  48150. // ClearAPIKey clears the value of the "api_key" field.
  48151. func (m *WxCardMutation) ClearAPIKey() {
  48152. m.api_key = nil
  48153. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  48154. }
  48155. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  48156. func (m *WxCardMutation) APIKeyCleared() bool {
  48157. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  48158. return ok
  48159. }
  48160. // ResetAPIKey resets all changes to the "api_key" field.
  48161. func (m *WxCardMutation) ResetAPIKey() {
  48162. m.api_key = nil
  48163. delete(m.clearedFields, wxcard.FieldAPIKey)
  48164. }
  48165. // SetAiInfo sets the "ai_info" field.
  48166. func (m *WxCardMutation) SetAiInfo(s string) {
  48167. m.ai_info = &s
  48168. }
  48169. // AiInfo returns the value of the "ai_info" field in the mutation.
  48170. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  48171. v := m.ai_info
  48172. if v == nil {
  48173. return
  48174. }
  48175. return *v, true
  48176. }
  48177. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  48178. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48180. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  48181. if !m.op.Is(OpUpdateOne) {
  48182. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  48183. }
  48184. if m.id == nil || m.oldValue == nil {
  48185. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  48186. }
  48187. oldValue, err := m.oldValue(ctx)
  48188. if err != nil {
  48189. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  48190. }
  48191. return oldValue.AiInfo, nil
  48192. }
  48193. // ClearAiInfo clears the value of the "ai_info" field.
  48194. func (m *WxCardMutation) ClearAiInfo() {
  48195. m.ai_info = nil
  48196. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  48197. }
  48198. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  48199. func (m *WxCardMutation) AiInfoCleared() bool {
  48200. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  48201. return ok
  48202. }
  48203. // ResetAiInfo resets all changes to the "ai_info" field.
  48204. func (m *WxCardMutation) ResetAiInfo() {
  48205. m.ai_info = nil
  48206. delete(m.clearedFields, wxcard.FieldAiInfo)
  48207. }
  48208. // SetIntro sets the "intro" field.
  48209. func (m *WxCardMutation) SetIntro(s string) {
  48210. m.intro = &s
  48211. }
  48212. // Intro returns the value of the "intro" field in the mutation.
  48213. func (m *WxCardMutation) Intro() (r string, exists bool) {
  48214. v := m.intro
  48215. if v == nil {
  48216. return
  48217. }
  48218. return *v, true
  48219. }
  48220. // OldIntro returns the old "intro" field's value of the WxCard entity.
  48221. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48223. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  48224. if !m.op.Is(OpUpdateOne) {
  48225. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  48226. }
  48227. if m.id == nil || m.oldValue == nil {
  48228. return v, errors.New("OldIntro requires an ID field in the mutation")
  48229. }
  48230. oldValue, err := m.oldValue(ctx)
  48231. if err != nil {
  48232. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  48233. }
  48234. return oldValue.Intro, nil
  48235. }
  48236. // ClearIntro clears the value of the "intro" field.
  48237. func (m *WxCardMutation) ClearIntro() {
  48238. m.intro = nil
  48239. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  48240. }
  48241. // IntroCleared returns if the "intro" field was cleared in this mutation.
  48242. func (m *WxCardMutation) IntroCleared() bool {
  48243. _, ok := m.clearedFields[wxcard.FieldIntro]
  48244. return ok
  48245. }
  48246. // ResetIntro resets all changes to the "intro" field.
  48247. func (m *WxCardMutation) ResetIntro() {
  48248. m.intro = nil
  48249. delete(m.clearedFields, wxcard.FieldIntro)
  48250. }
  48251. // Where appends a list predicates to the WxCardMutation builder.
  48252. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  48253. m.predicates = append(m.predicates, ps...)
  48254. }
  48255. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  48256. // users can use type-assertion to append predicates that do not depend on any generated package.
  48257. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  48258. p := make([]predicate.WxCard, len(ps))
  48259. for i := range ps {
  48260. p[i] = ps[i]
  48261. }
  48262. m.Where(p...)
  48263. }
  48264. // Op returns the operation name.
  48265. func (m *WxCardMutation) Op() Op {
  48266. return m.op
  48267. }
  48268. // SetOp allows setting the mutation operation.
  48269. func (m *WxCardMutation) SetOp(op Op) {
  48270. m.op = op
  48271. }
  48272. // Type returns the node type of this mutation (WxCard).
  48273. func (m *WxCardMutation) Type() string {
  48274. return m.typ
  48275. }
  48276. // Fields returns all fields that were changed during this mutation. Note that in
  48277. // order to get all numeric fields that were incremented/decremented, call
  48278. // AddedFields().
  48279. func (m *WxCardMutation) Fields() []string {
  48280. fields := make([]string, 0, 18)
  48281. if m.created_at != nil {
  48282. fields = append(fields, wxcard.FieldCreatedAt)
  48283. }
  48284. if m.updated_at != nil {
  48285. fields = append(fields, wxcard.FieldUpdatedAt)
  48286. }
  48287. if m.deleted_at != nil {
  48288. fields = append(fields, wxcard.FieldDeletedAt)
  48289. }
  48290. if m.user_id != nil {
  48291. fields = append(fields, wxcard.FieldUserID)
  48292. }
  48293. if m.wx_user_id != nil {
  48294. fields = append(fields, wxcard.FieldWxUserID)
  48295. }
  48296. if m.avatar != nil {
  48297. fields = append(fields, wxcard.FieldAvatar)
  48298. }
  48299. if m.logo != nil {
  48300. fields = append(fields, wxcard.FieldLogo)
  48301. }
  48302. if m.name != nil {
  48303. fields = append(fields, wxcard.FieldName)
  48304. }
  48305. if m.company != nil {
  48306. fields = append(fields, wxcard.FieldCompany)
  48307. }
  48308. if m.address != nil {
  48309. fields = append(fields, wxcard.FieldAddress)
  48310. }
  48311. if m.phone != nil {
  48312. fields = append(fields, wxcard.FieldPhone)
  48313. }
  48314. if m.official_account != nil {
  48315. fields = append(fields, wxcard.FieldOfficialAccount)
  48316. }
  48317. if m.wechat_account != nil {
  48318. fields = append(fields, wxcard.FieldWechatAccount)
  48319. }
  48320. if m.email != nil {
  48321. fields = append(fields, wxcard.FieldEmail)
  48322. }
  48323. if m.api_base != nil {
  48324. fields = append(fields, wxcard.FieldAPIBase)
  48325. }
  48326. if m.api_key != nil {
  48327. fields = append(fields, wxcard.FieldAPIKey)
  48328. }
  48329. if m.ai_info != nil {
  48330. fields = append(fields, wxcard.FieldAiInfo)
  48331. }
  48332. if m.intro != nil {
  48333. fields = append(fields, wxcard.FieldIntro)
  48334. }
  48335. return fields
  48336. }
  48337. // Field returns the value of a field with the given name. The second boolean
  48338. // return value indicates that this field was not set, or was not defined in the
  48339. // schema.
  48340. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  48341. switch name {
  48342. case wxcard.FieldCreatedAt:
  48343. return m.CreatedAt()
  48344. case wxcard.FieldUpdatedAt:
  48345. return m.UpdatedAt()
  48346. case wxcard.FieldDeletedAt:
  48347. return m.DeletedAt()
  48348. case wxcard.FieldUserID:
  48349. return m.UserID()
  48350. case wxcard.FieldWxUserID:
  48351. return m.WxUserID()
  48352. case wxcard.FieldAvatar:
  48353. return m.Avatar()
  48354. case wxcard.FieldLogo:
  48355. return m.Logo()
  48356. case wxcard.FieldName:
  48357. return m.Name()
  48358. case wxcard.FieldCompany:
  48359. return m.Company()
  48360. case wxcard.FieldAddress:
  48361. return m.Address()
  48362. case wxcard.FieldPhone:
  48363. return m.Phone()
  48364. case wxcard.FieldOfficialAccount:
  48365. return m.OfficialAccount()
  48366. case wxcard.FieldWechatAccount:
  48367. return m.WechatAccount()
  48368. case wxcard.FieldEmail:
  48369. return m.Email()
  48370. case wxcard.FieldAPIBase:
  48371. return m.APIBase()
  48372. case wxcard.FieldAPIKey:
  48373. return m.APIKey()
  48374. case wxcard.FieldAiInfo:
  48375. return m.AiInfo()
  48376. case wxcard.FieldIntro:
  48377. return m.Intro()
  48378. }
  48379. return nil, false
  48380. }
  48381. // OldField returns the old value of the field from the database. An error is
  48382. // returned if the mutation operation is not UpdateOne, or the query to the
  48383. // database failed.
  48384. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48385. switch name {
  48386. case wxcard.FieldCreatedAt:
  48387. return m.OldCreatedAt(ctx)
  48388. case wxcard.FieldUpdatedAt:
  48389. return m.OldUpdatedAt(ctx)
  48390. case wxcard.FieldDeletedAt:
  48391. return m.OldDeletedAt(ctx)
  48392. case wxcard.FieldUserID:
  48393. return m.OldUserID(ctx)
  48394. case wxcard.FieldWxUserID:
  48395. return m.OldWxUserID(ctx)
  48396. case wxcard.FieldAvatar:
  48397. return m.OldAvatar(ctx)
  48398. case wxcard.FieldLogo:
  48399. return m.OldLogo(ctx)
  48400. case wxcard.FieldName:
  48401. return m.OldName(ctx)
  48402. case wxcard.FieldCompany:
  48403. return m.OldCompany(ctx)
  48404. case wxcard.FieldAddress:
  48405. return m.OldAddress(ctx)
  48406. case wxcard.FieldPhone:
  48407. return m.OldPhone(ctx)
  48408. case wxcard.FieldOfficialAccount:
  48409. return m.OldOfficialAccount(ctx)
  48410. case wxcard.FieldWechatAccount:
  48411. return m.OldWechatAccount(ctx)
  48412. case wxcard.FieldEmail:
  48413. return m.OldEmail(ctx)
  48414. case wxcard.FieldAPIBase:
  48415. return m.OldAPIBase(ctx)
  48416. case wxcard.FieldAPIKey:
  48417. return m.OldAPIKey(ctx)
  48418. case wxcard.FieldAiInfo:
  48419. return m.OldAiInfo(ctx)
  48420. case wxcard.FieldIntro:
  48421. return m.OldIntro(ctx)
  48422. }
  48423. return nil, fmt.Errorf("unknown WxCard field %s", name)
  48424. }
  48425. // SetField sets the value of a field with the given name. It returns an error if
  48426. // the field is not defined in the schema, or if the type mismatched the field
  48427. // type.
  48428. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  48429. switch name {
  48430. case wxcard.FieldCreatedAt:
  48431. v, ok := value.(time.Time)
  48432. if !ok {
  48433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48434. }
  48435. m.SetCreatedAt(v)
  48436. return nil
  48437. case wxcard.FieldUpdatedAt:
  48438. v, ok := value.(time.Time)
  48439. if !ok {
  48440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48441. }
  48442. m.SetUpdatedAt(v)
  48443. return nil
  48444. case wxcard.FieldDeletedAt:
  48445. v, ok := value.(time.Time)
  48446. if !ok {
  48447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48448. }
  48449. m.SetDeletedAt(v)
  48450. return nil
  48451. case wxcard.FieldUserID:
  48452. v, ok := value.(uint64)
  48453. if !ok {
  48454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48455. }
  48456. m.SetUserID(v)
  48457. return nil
  48458. case wxcard.FieldWxUserID:
  48459. v, ok := value.(uint64)
  48460. if !ok {
  48461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48462. }
  48463. m.SetWxUserID(v)
  48464. return nil
  48465. case wxcard.FieldAvatar:
  48466. v, ok := value.(string)
  48467. if !ok {
  48468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48469. }
  48470. m.SetAvatar(v)
  48471. return nil
  48472. case wxcard.FieldLogo:
  48473. v, ok := value.(string)
  48474. if !ok {
  48475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48476. }
  48477. m.SetLogo(v)
  48478. return nil
  48479. case wxcard.FieldName:
  48480. v, ok := value.(string)
  48481. if !ok {
  48482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48483. }
  48484. m.SetName(v)
  48485. return nil
  48486. case wxcard.FieldCompany:
  48487. v, ok := value.(string)
  48488. if !ok {
  48489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48490. }
  48491. m.SetCompany(v)
  48492. return nil
  48493. case wxcard.FieldAddress:
  48494. v, ok := value.(string)
  48495. if !ok {
  48496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48497. }
  48498. m.SetAddress(v)
  48499. return nil
  48500. case wxcard.FieldPhone:
  48501. v, ok := value.(string)
  48502. if !ok {
  48503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48504. }
  48505. m.SetPhone(v)
  48506. return nil
  48507. case wxcard.FieldOfficialAccount:
  48508. v, ok := value.(string)
  48509. if !ok {
  48510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48511. }
  48512. m.SetOfficialAccount(v)
  48513. return nil
  48514. case wxcard.FieldWechatAccount:
  48515. v, ok := value.(string)
  48516. if !ok {
  48517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48518. }
  48519. m.SetWechatAccount(v)
  48520. return nil
  48521. case wxcard.FieldEmail:
  48522. v, ok := value.(string)
  48523. if !ok {
  48524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48525. }
  48526. m.SetEmail(v)
  48527. return nil
  48528. case wxcard.FieldAPIBase:
  48529. v, ok := value.(string)
  48530. if !ok {
  48531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48532. }
  48533. m.SetAPIBase(v)
  48534. return nil
  48535. case wxcard.FieldAPIKey:
  48536. v, ok := value.(string)
  48537. if !ok {
  48538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48539. }
  48540. m.SetAPIKey(v)
  48541. return nil
  48542. case wxcard.FieldAiInfo:
  48543. v, ok := value.(string)
  48544. if !ok {
  48545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48546. }
  48547. m.SetAiInfo(v)
  48548. return nil
  48549. case wxcard.FieldIntro:
  48550. v, ok := value.(string)
  48551. if !ok {
  48552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48553. }
  48554. m.SetIntro(v)
  48555. return nil
  48556. }
  48557. return fmt.Errorf("unknown WxCard field %s", name)
  48558. }
  48559. // AddedFields returns all numeric fields that were incremented/decremented during
  48560. // this mutation.
  48561. func (m *WxCardMutation) AddedFields() []string {
  48562. var fields []string
  48563. if m.adduser_id != nil {
  48564. fields = append(fields, wxcard.FieldUserID)
  48565. }
  48566. if m.addwx_user_id != nil {
  48567. fields = append(fields, wxcard.FieldWxUserID)
  48568. }
  48569. return fields
  48570. }
  48571. // AddedField returns the numeric value that was incremented/decremented on a field
  48572. // with the given name. The second boolean return value indicates that this field
  48573. // was not set, or was not defined in the schema.
  48574. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  48575. switch name {
  48576. case wxcard.FieldUserID:
  48577. return m.AddedUserID()
  48578. case wxcard.FieldWxUserID:
  48579. return m.AddedWxUserID()
  48580. }
  48581. return nil, false
  48582. }
  48583. // AddField adds the value to the field with the given name. It returns an error if
  48584. // the field is not defined in the schema, or if the type mismatched the field
  48585. // type.
  48586. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  48587. switch name {
  48588. case wxcard.FieldUserID:
  48589. v, ok := value.(int64)
  48590. if !ok {
  48591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48592. }
  48593. m.AddUserID(v)
  48594. return nil
  48595. case wxcard.FieldWxUserID:
  48596. v, ok := value.(int64)
  48597. if !ok {
  48598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48599. }
  48600. m.AddWxUserID(v)
  48601. return nil
  48602. }
  48603. return fmt.Errorf("unknown WxCard numeric field %s", name)
  48604. }
  48605. // ClearedFields returns all nullable fields that were cleared during this
  48606. // mutation.
  48607. func (m *WxCardMutation) ClearedFields() []string {
  48608. var fields []string
  48609. if m.FieldCleared(wxcard.FieldDeletedAt) {
  48610. fields = append(fields, wxcard.FieldDeletedAt)
  48611. }
  48612. if m.FieldCleared(wxcard.FieldUserID) {
  48613. fields = append(fields, wxcard.FieldUserID)
  48614. }
  48615. if m.FieldCleared(wxcard.FieldWxUserID) {
  48616. fields = append(fields, wxcard.FieldWxUserID)
  48617. }
  48618. if m.FieldCleared(wxcard.FieldEmail) {
  48619. fields = append(fields, wxcard.FieldEmail)
  48620. }
  48621. if m.FieldCleared(wxcard.FieldAPIBase) {
  48622. fields = append(fields, wxcard.FieldAPIBase)
  48623. }
  48624. if m.FieldCleared(wxcard.FieldAPIKey) {
  48625. fields = append(fields, wxcard.FieldAPIKey)
  48626. }
  48627. if m.FieldCleared(wxcard.FieldAiInfo) {
  48628. fields = append(fields, wxcard.FieldAiInfo)
  48629. }
  48630. if m.FieldCleared(wxcard.FieldIntro) {
  48631. fields = append(fields, wxcard.FieldIntro)
  48632. }
  48633. return fields
  48634. }
  48635. // FieldCleared returns a boolean indicating if a field with the given name was
  48636. // cleared in this mutation.
  48637. func (m *WxCardMutation) FieldCleared(name string) bool {
  48638. _, ok := m.clearedFields[name]
  48639. return ok
  48640. }
  48641. // ClearField clears the value of the field with the given name. It returns an
  48642. // error if the field is not defined in the schema.
  48643. func (m *WxCardMutation) ClearField(name string) error {
  48644. switch name {
  48645. case wxcard.FieldDeletedAt:
  48646. m.ClearDeletedAt()
  48647. return nil
  48648. case wxcard.FieldUserID:
  48649. m.ClearUserID()
  48650. return nil
  48651. case wxcard.FieldWxUserID:
  48652. m.ClearWxUserID()
  48653. return nil
  48654. case wxcard.FieldEmail:
  48655. m.ClearEmail()
  48656. return nil
  48657. case wxcard.FieldAPIBase:
  48658. m.ClearAPIBase()
  48659. return nil
  48660. case wxcard.FieldAPIKey:
  48661. m.ClearAPIKey()
  48662. return nil
  48663. case wxcard.FieldAiInfo:
  48664. m.ClearAiInfo()
  48665. return nil
  48666. case wxcard.FieldIntro:
  48667. m.ClearIntro()
  48668. return nil
  48669. }
  48670. return fmt.Errorf("unknown WxCard nullable field %s", name)
  48671. }
  48672. // ResetField resets all changes in the mutation for the field with the given name.
  48673. // It returns an error if the field is not defined in the schema.
  48674. func (m *WxCardMutation) ResetField(name string) error {
  48675. switch name {
  48676. case wxcard.FieldCreatedAt:
  48677. m.ResetCreatedAt()
  48678. return nil
  48679. case wxcard.FieldUpdatedAt:
  48680. m.ResetUpdatedAt()
  48681. return nil
  48682. case wxcard.FieldDeletedAt:
  48683. m.ResetDeletedAt()
  48684. return nil
  48685. case wxcard.FieldUserID:
  48686. m.ResetUserID()
  48687. return nil
  48688. case wxcard.FieldWxUserID:
  48689. m.ResetWxUserID()
  48690. return nil
  48691. case wxcard.FieldAvatar:
  48692. m.ResetAvatar()
  48693. return nil
  48694. case wxcard.FieldLogo:
  48695. m.ResetLogo()
  48696. return nil
  48697. case wxcard.FieldName:
  48698. m.ResetName()
  48699. return nil
  48700. case wxcard.FieldCompany:
  48701. m.ResetCompany()
  48702. return nil
  48703. case wxcard.FieldAddress:
  48704. m.ResetAddress()
  48705. return nil
  48706. case wxcard.FieldPhone:
  48707. m.ResetPhone()
  48708. return nil
  48709. case wxcard.FieldOfficialAccount:
  48710. m.ResetOfficialAccount()
  48711. return nil
  48712. case wxcard.FieldWechatAccount:
  48713. m.ResetWechatAccount()
  48714. return nil
  48715. case wxcard.FieldEmail:
  48716. m.ResetEmail()
  48717. return nil
  48718. case wxcard.FieldAPIBase:
  48719. m.ResetAPIBase()
  48720. return nil
  48721. case wxcard.FieldAPIKey:
  48722. m.ResetAPIKey()
  48723. return nil
  48724. case wxcard.FieldAiInfo:
  48725. m.ResetAiInfo()
  48726. return nil
  48727. case wxcard.FieldIntro:
  48728. m.ResetIntro()
  48729. return nil
  48730. }
  48731. return fmt.Errorf("unknown WxCard field %s", name)
  48732. }
  48733. // AddedEdges returns all edge names that were set/added in this mutation.
  48734. func (m *WxCardMutation) AddedEdges() []string {
  48735. edges := make([]string, 0, 0)
  48736. return edges
  48737. }
  48738. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48739. // name in this mutation.
  48740. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  48741. return nil
  48742. }
  48743. // RemovedEdges returns all edge names that were removed in this mutation.
  48744. func (m *WxCardMutation) RemovedEdges() []string {
  48745. edges := make([]string, 0, 0)
  48746. return edges
  48747. }
  48748. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48749. // the given name in this mutation.
  48750. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  48751. return nil
  48752. }
  48753. // ClearedEdges returns all edge names that were cleared in this mutation.
  48754. func (m *WxCardMutation) ClearedEdges() []string {
  48755. edges := make([]string, 0, 0)
  48756. return edges
  48757. }
  48758. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48759. // was cleared in this mutation.
  48760. func (m *WxCardMutation) EdgeCleared(name string) bool {
  48761. return false
  48762. }
  48763. // ClearEdge clears the value of the edge with the given name. It returns an error
  48764. // if that edge is not defined in the schema.
  48765. func (m *WxCardMutation) ClearEdge(name string) error {
  48766. return fmt.Errorf("unknown WxCard unique edge %s", name)
  48767. }
  48768. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48769. // It returns an error if the edge is not defined in the schema.
  48770. func (m *WxCardMutation) ResetEdge(name string) error {
  48771. return fmt.Errorf("unknown WxCard edge %s", name)
  48772. }
  48773. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  48774. type WxCardUserMutation struct {
  48775. config
  48776. op Op
  48777. typ string
  48778. id *uint64
  48779. created_at *time.Time
  48780. updated_at *time.Time
  48781. deleted_at *time.Time
  48782. wxid *string
  48783. account *string
  48784. avatar *string
  48785. nickname *string
  48786. remark *string
  48787. phone *string
  48788. open_id *string
  48789. union_id *string
  48790. session_key *string
  48791. is_vip *int
  48792. addis_vip *int
  48793. clearedFields map[string]struct{}
  48794. done bool
  48795. oldValue func(context.Context) (*WxCardUser, error)
  48796. predicates []predicate.WxCardUser
  48797. }
  48798. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  48799. // wxcarduserOption allows management of the mutation configuration using functional options.
  48800. type wxcarduserOption func(*WxCardUserMutation)
  48801. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  48802. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  48803. m := &WxCardUserMutation{
  48804. config: c,
  48805. op: op,
  48806. typ: TypeWxCardUser,
  48807. clearedFields: make(map[string]struct{}),
  48808. }
  48809. for _, opt := range opts {
  48810. opt(m)
  48811. }
  48812. return m
  48813. }
  48814. // withWxCardUserID sets the ID field of the mutation.
  48815. func withWxCardUserID(id uint64) wxcarduserOption {
  48816. return func(m *WxCardUserMutation) {
  48817. var (
  48818. err error
  48819. once sync.Once
  48820. value *WxCardUser
  48821. )
  48822. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  48823. once.Do(func() {
  48824. if m.done {
  48825. err = errors.New("querying old values post mutation is not allowed")
  48826. } else {
  48827. value, err = m.Client().WxCardUser.Get(ctx, id)
  48828. }
  48829. })
  48830. return value, err
  48831. }
  48832. m.id = &id
  48833. }
  48834. }
  48835. // withWxCardUser sets the old WxCardUser of the mutation.
  48836. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  48837. return func(m *WxCardUserMutation) {
  48838. m.oldValue = func(context.Context) (*WxCardUser, error) {
  48839. return node, nil
  48840. }
  48841. m.id = &node.ID
  48842. }
  48843. }
  48844. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48845. // executed in a transaction (ent.Tx), a transactional client is returned.
  48846. func (m WxCardUserMutation) Client() *Client {
  48847. client := &Client{config: m.config}
  48848. client.init()
  48849. return client
  48850. }
  48851. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48852. // it returns an error otherwise.
  48853. func (m WxCardUserMutation) Tx() (*Tx, error) {
  48854. if _, ok := m.driver.(*txDriver); !ok {
  48855. return nil, errors.New("ent: mutation is not running in a transaction")
  48856. }
  48857. tx := &Tx{config: m.config}
  48858. tx.init()
  48859. return tx, nil
  48860. }
  48861. // SetID sets the value of the id field. Note that this
  48862. // operation is only accepted on creation of WxCardUser entities.
  48863. func (m *WxCardUserMutation) SetID(id uint64) {
  48864. m.id = &id
  48865. }
  48866. // ID returns the ID value in the mutation. Note that the ID is only available
  48867. // if it was provided to the builder or after it was returned from the database.
  48868. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  48869. if m.id == nil {
  48870. return
  48871. }
  48872. return *m.id, true
  48873. }
  48874. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48875. // That means, if the mutation is applied within a transaction with an isolation level such
  48876. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48877. // or updated by the mutation.
  48878. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  48879. switch {
  48880. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48881. id, exists := m.ID()
  48882. if exists {
  48883. return []uint64{id}, nil
  48884. }
  48885. fallthrough
  48886. case m.op.Is(OpUpdate | OpDelete):
  48887. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  48888. default:
  48889. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48890. }
  48891. }
  48892. // SetCreatedAt sets the "created_at" field.
  48893. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  48894. m.created_at = &t
  48895. }
  48896. // CreatedAt returns the value of the "created_at" field in the mutation.
  48897. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  48898. v := m.created_at
  48899. if v == nil {
  48900. return
  48901. }
  48902. return *v, true
  48903. }
  48904. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  48905. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48907. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48908. if !m.op.Is(OpUpdateOne) {
  48909. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48910. }
  48911. if m.id == nil || m.oldValue == nil {
  48912. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48913. }
  48914. oldValue, err := m.oldValue(ctx)
  48915. if err != nil {
  48916. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48917. }
  48918. return oldValue.CreatedAt, nil
  48919. }
  48920. // ResetCreatedAt resets all changes to the "created_at" field.
  48921. func (m *WxCardUserMutation) ResetCreatedAt() {
  48922. m.created_at = nil
  48923. }
  48924. // SetUpdatedAt sets the "updated_at" field.
  48925. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  48926. m.updated_at = &t
  48927. }
  48928. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48929. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  48930. v := m.updated_at
  48931. if v == nil {
  48932. return
  48933. }
  48934. return *v, true
  48935. }
  48936. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  48937. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48939. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48940. if !m.op.Is(OpUpdateOne) {
  48941. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48942. }
  48943. if m.id == nil || m.oldValue == nil {
  48944. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48945. }
  48946. oldValue, err := m.oldValue(ctx)
  48947. if err != nil {
  48948. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48949. }
  48950. return oldValue.UpdatedAt, nil
  48951. }
  48952. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48953. func (m *WxCardUserMutation) ResetUpdatedAt() {
  48954. m.updated_at = nil
  48955. }
  48956. // SetDeletedAt sets the "deleted_at" field.
  48957. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  48958. m.deleted_at = &t
  48959. }
  48960. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48961. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  48962. v := m.deleted_at
  48963. if v == nil {
  48964. return
  48965. }
  48966. return *v, true
  48967. }
  48968. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  48969. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48971. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48972. if !m.op.Is(OpUpdateOne) {
  48973. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48974. }
  48975. if m.id == nil || m.oldValue == nil {
  48976. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48977. }
  48978. oldValue, err := m.oldValue(ctx)
  48979. if err != nil {
  48980. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48981. }
  48982. return oldValue.DeletedAt, nil
  48983. }
  48984. // ClearDeletedAt clears the value of the "deleted_at" field.
  48985. func (m *WxCardUserMutation) ClearDeletedAt() {
  48986. m.deleted_at = nil
  48987. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  48988. }
  48989. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48990. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  48991. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  48992. return ok
  48993. }
  48994. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48995. func (m *WxCardUserMutation) ResetDeletedAt() {
  48996. m.deleted_at = nil
  48997. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  48998. }
  48999. // SetWxid sets the "wxid" field.
  49000. func (m *WxCardUserMutation) SetWxid(s string) {
  49001. m.wxid = &s
  49002. }
  49003. // Wxid returns the value of the "wxid" field in the mutation.
  49004. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  49005. v := m.wxid
  49006. if v == nil {
  49007. return
  49008. }
  49009. return *v, true
  49010. }
  49011. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  49012. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49014. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  49015. if !m.op.Is(OpUpdateOne) {
  49016. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  49017. }
  49018. if m.id == nil || m.oldValue == nil {
  49019. return v, errors.New("OldWxid requires an ID field in the mutation")
  49020. }
  49021. oldValue, err := m.oldValue(ctx)
  49022. if err != nil {
  49023. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  49024. }
  49025. return oldValue.Wxid, nil
  49026. }
  49027. // ResetWxid resets all changes to the "wxid" field.
  49028. func (m *WxCardUserMutation) ResetWxid() {
  49029. m.wxid = nil
  49030. }
  49031. // SetAccount sets the "account" field.
  49032. func (m *WxCardUserMutation) SetAccount(s string) {
  49033. m.account = &s
  49034. }
  49035. // Account returns the value of the "account" field in the mutation.
  49036. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  49037. v := m.account
  49038. if v == nil {
  49039. return
  49040. }
  49041. return *v, true
  49042. }
  49043. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  49044. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49046. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  49047. if !m.op.Is(OpUpdateOne) {
  49048. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  49049. }
  49050. if m.id == nil || m.oldValue == nil {
  49051. return v, errors.New("OldAccount requires an ID field in the mutation")
  49052. }
  49053. oldValue, err := m.oldValue(ctx)
  49054. if err != nil {
  49055. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  49056. }
  49057. return oldValue.Account, nil
  49058. }
  49059. // ResetAccount resets all changes to the "account" field.
  49060. func (m *WxCardUserMutation) ResetAccount() {
  49061. m.account = nil
  49062. }
  49063. // SetAvatar sets the "avatar" field.
  49064. func (m *WxCardUserMutation) SetAvatar(s string) {
  49065. m.avatar = &s
  49066. }
  49067. // Avatar returns the value of the "avatar" field in the mutation.
  49068. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  49069. v := m.avatar
  49070. if v == nil {
  49071. return
  49072. }
  49073. return *v, true
  49074. }
  49075. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  49076. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49078. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  49079. if !m.op.Is(OpUpdateOne) {
  49080. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  49081. }
  49082. if m.id == nil || m.oldValue == nil {
  49083. return v, errors.New("OldAvatar requires an ID field in the mutation")
  49084. }
  49085. oldValue, err := m.oldValue(ctx)
  49086. if err != nil {
  49087. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  49088. }
  49089. return oldValue.Avatar, nil
  49090. }
  49091. // ResetAvatar resets all changes to the "avatar" field.
  49092. func (m *WxCardUserMutation) ResetAvatar() {
  49093. m.avatar = nil
  49094. }
  49095. // SetNickname sets the "nickname" field.
  49096. func (m *WxCardUserMutation) SetNickname(s string) {
  49097. m.nickname = &s
  49098. }
  49099. // Nickname returns the value of the "nickname" field in the mutation.
  49100. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  49101. v := m.nickname
  49102. if v == nil {
  49103. return
  49104. }
  49105. return *v, true
  49106. }
  49107. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  49108. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49110. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  49111. if !m.op.Is(OpUpdateOne) {
  49112. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  49113. }
  49114. if m.id == nil || m.oldValue == nil {
  49115. return v, errors.New("OldNickname requires an ID field in the mutation")
  49116. }
  49117. oldValue, err := m.oldValue(ctx)
  49118. if err != nil {
  49119. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  49120. }
  49121. return oldValue.Nickname, nil
  49122. }
  49123. // ResetNickname resets all changes to the "nickname" field.
  49124. func (m *WxCardUserMutation) ResetNickname() {
  49125. m.nickname = nil
  49126. }
  49127. // SetRemark sets the "remark" field.
  49128. func (m *WxCardUserMutation) SetRemark(s string) {
  49129. m.remark = &s
  49130. }
  49131. // Remark returns the value of the "remark" field in the mutation.
  49132. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  49133. v := m.remark
  49134. if v == nil {
  49135. return
  49136. }
  49137. return *v, true
  49138. }
  49139. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  49140. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49142. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  49143. if !m.op.Is(OpUpdateOne) {
  49144. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  49145. }
  49146. if m.id == nil || m.oldValue == nil {
  49147. return v, errors.New("OldRemark requires an ID field in the mutation")
  49148. }
  49149. oldValue, err := m.oldValue(ctx)
  49150. if err != nil {
  49151. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  49152. }
  49153. return oldValue.Remark, nil
  49154. }
  49155. // ResetRemark resets all changes to the "remark" field.
  49156. func (m *WxCardUserMutation) ResetRemark() {
  49157. m.remark = nil
  49158. }
  49159. // SetPhone sets the "phone" field.
  49160. func (m *WxCardUserMutation) SetPhone(s string) {
  49161. m.phone = &s
  49162. }
  49163. // Phone returns the value of the "phone" field in the mutation.
  49164. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  49165. v := m.phone
  49166. if v == nil {
  49167. return
  49168. }
  49169. return *v, true
  49170. }
  49171. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  49172. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49174. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  49175. if !m.op.Is(OpUpdateOne) {
  49176. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  49177. }
  49178. if m.id == nil || m.oldValue == nil {
  49179. return v, errors.New("OldPhone requires an ID field in the mutation")
  49180. }
  49181. oldValue, err := m.oldValue(ctx)
  49182. if err != nil {
  49183. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  49184. }
  49185. return oldValue.Phone, nil
  49186. }
  49187. // ResetPhone resets all changes to the "phone" field.
  49188. func (m *WxCardUserMutation) ResetPhone() {
  49189. m.phone = nil
  49190. }
  49191. // SetOpenID sets the "open_id" field.
  49192. func (m *WxCardUserMutation) SetOpenID(s string) {
  49193. m.open_id = &s
  49194. }
  49195. // OpenID returns the value of the "open_id" field in the mutation.
  49196. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  49197. v := m.open_id
  49198. if v == nil {
  49199. return
  49200. }
  49201. return *v, true
  49202. }
  49203. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  49204. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49206. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  49207. if !m.op.Is(OpUpdateOne) {
  49208. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  49209. }
  49210. if m.id == nil || m.oldValue == nil {
  49211. return v, errors.New("OldOpenID requires an ID field in the mutation")
  49212. }
  49213. oldValue, err := m.oldValue(ctx)
  49214. if err != nil {
  49215. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  49216. }
  49217. return oldValue.OpenID, nil
  49218. }
  49219. // ResetOpenID resets all changes to the "open_id" field.
  49220. func (m *WxCardUserMutation) ResetOpenID() {
  49221. m.open_id = nil
  49222. }
  49223. // SetUnionID sets the "union_id" field.
  49224. func (m *WxCardUserMutation) SetUnionID(s string) {
  49225. m.union_id = &s
  49226. }
  49227. // UnionID returns the value of the "union_id" field in the mutation.
  49228. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  49229. v := m.union_id
  49230. if v == nil {
  49231. return
  49232. }
  49233. return *v, true
  49234. }
  49235. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  49236. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49238. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  49239. if !m.op.Is(OpUpdateOne) {
  49240. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  49241. }
  49242. if m.id == nil || m.oldValue == nil {
  49243. return v, errors.New("OldUnionID requires an ID field in the mutation")
  49244. }
  49245. oldValue, err := m.oldValue(ctx)
  49246. if err != nil {
  49247. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  49248. }
  49249. return oldValue.UnionID, nil
  49250. }
  49251. // ResetUnionID resets all changes to the "union_id" field.
  49252. func (m *WxCardUserMutation) ResetUnionID() {
  49253. m.union_id = nil
  49254. }
  49255. // SetSessionKey sets the "session_key" field.
  49256. func (m *WxCardUserMutation) SetSessionKey(s string) {
  49257. m.session_key = &s
  49258. }
  49259. // SessionKey returns the value of the "session_key" field in the mutation.
  49260. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  49261. v := m.session_key
  49262. if v == nil {
  49263. return
  49264. }
  49265. return *v, true
  49266. }
  49267. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  49268. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49270. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  49271. if !m.op.Is(OpUpdateOne) {
  49272. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  49273. }
  49274. if m.id == nil || m.oldValue == nil {
  49275. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  49276. }
  49277. oldValue, err := m.oldValue(ctx)
  49278. if err != nil {
  49279. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  49280. }
  49281. return oldValue.SessionKey, nil
  49282. }
  49283. // ResetSessionKey resets all changes to the "session_key" field.
  49284. func (m *WxCardUserMutation) ResetSessionKey() {
  49285. m.session_key = nil
  49286. }
  49287. // SetIsVip sets the "is_vip" field.
  49288. func (m *WxCardUserMutation) SetIsVip(i int) {
  49289. m.is_vip = &i
  49290. m.addis_vip = nil
  49291. }
  49292. // IsVip returns the value of the "is_vip" field in the mutation.
  49293. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  49294. v := m.is_vip
  49295. if v == nil {
  49296. return
  49297. }
  49298. return *v, true
  49299. }
  49300. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  49301. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49303. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  49304. if !m.op.Is(OpUpdateOne) {
  49305. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  49306. }
  49307. if m.id == nil || m.oldValue == nil {
  49308. return v, errors.New("OldIsVip requires an ID field in the mutation")
  49309. }
  49310. oldValue, err := m.oldValue(ctx)
  49311. if err != nil {
  49312. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  49313. }
  49314. return oldValue.IsVip, nil
  49315. }
  49316. // AddIsVip adds i to the "is_vip" field.
  49317. func (m *WxCardUserMutation) AddIsVip(i int) {
  49318. if m.addis_vip != nil {
  49319. *m.addis_vip += i
  49320. } else {
  49321. m.addis_vip = &i
  49322. }
  49323. }
  49324. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  49325. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  49326. v := m.addis_vip
  49327. if v == nil {
  49328. return
  49329. }
  49330. return *v, true
  49331. }
  49332. // ResetIsVip resets all changes to the "is_vip" field.
  49333. func (m *WxCardUserMutation) ResetIsVip() {
  49334. m.is_vip = nil
  49335. m.addis_vip = nil
  49336. }
  49337. // Where appends a list predicates to the WxCardUserMutation builder.
  49338. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  49339. m.predicates = append(m.predicates, ps...)
  49340. }
  49341. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  49342. // users can use type-assertion to append predicates that do not depend on any generated package.
  49343. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  49344. p := make([]predicate.WxCardUser, len(ps))
  49345. for i := range ps {
  49346. p[i] = ps[i]
  49347. }
  49348. m.Where(p...)
  49349. }
  49350. // Op returns the operation name.
  49351. func (m *WxCardUserMutation) Op() Op {
  49352. return m.op
  49353. }
  49354. // SetOp allows setting the mutation operation.
  49355. func (m *WxCardUserMutation) SetOp(op Op) {
  49356. m.op = op
  49357. }
  49358. // Type returns the node type of this mutation (WxCardUser).
  49359. func (m *WxCardUserMutation) Type() string {
  49360. return m.typ
  49361. }
  49362. // Fields returns all fields that were changed during this mutation. Note that in
  49363. // order to get all numeric fields that were incremented/decremented, call
  49364. // AddedFields().
  49365. func (m *WxCardUserMutation) Fields() []string {
  49366. fields := make([]string, 0, 13)
  49367. if m.created_at != nil {
  49368. fields = append(fields, wxcarduser.FieldCreatedAt)
  49369. }
  49370. if m.updated_at != nil {
  49371. fields = append(fields, wxcarduser.FieldUpdatedAt)
  49372. }
  49373. if m.deleted_at != nil {
  49374. fields = append(fields, wxcarduser.FieldDeletedAt)
  49375. }
  49376. if m.wxid != nil {
  49377. fields = append(fields, wxcarduser.FieldWxid)
  49378. }
  49379. if m.account != nil {
  49380. fields = append(fields, wxcarduser.FieldAccount)
  49381. }
  49382. if m.avatar != nil {
  49383. fields = append(fields, wxcarduser.FieldAvatar)
  49384. }
  49385. if m.nickname != nil {
  49386. fields = append(fields, wxcarduser.FieldNickname)
  49387. }
  49388. if m.remark != nil {
  49389. fields = append(fields, wxcarduser.FieldRemark)
  49390. }
  49391. if m.phone != nil {
  49392. fields = append(fields, wxcarduser.FieldPhone)
  49393. }
  49394. if m.open_id != nil {
  49395. fields = append(fields, wxcarduser.FieldOpenID)
  49396. }
  49397. if m.union_id != nil {
  49398. fields = append(fields, wxcarduser.FieldUnionID)
  49399. }
  49400. if m.session_key != nil {
  49401. fields = append(fields, wxcarduser.FieldSessionKey)
  49402. }
  49403. if m.is_vip != nil {
  49404. fields = append(fields, wxcarduser.FieldIsVip)
  49405. }
  49406. return fields
  49407. }
  49408. // Field returns the value of a field with the given name. The second boolean
  49409. // return value indicates that this field was not set, or was not defined in the
  49410. // schema.
  49411. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  49412. switch name {
  49413. case wxcarduser.FieldCreatedAt:
  49414. return m.CreatedAt()
  49415. case wxcarduser.FieldUpdatedAt:
  49416. return m.UpdatedAt()
  49417. case wxcarduser.FieldDeletedAt:
  49418. return m.DeletedAt()
  49419. case wxcarduser.FieldWxid:
  49420. return m.Wxid()
  49421. case wxcarduser.FieldAccount:
  49422. return m.Account()
  49423. case wxcarduser.FieldAvatar:
  49424. return m.Avatar()
  49425. case wxcarduser.FieldNickname:
  49426. return m.Nickname()
  49427. case wxcarduser.FieldRemark:
  49428. return m.Remark()
  49429. case wxcarduser.FieldPhone:
  49430. return m.Phone()
  49431. case wxcarduser.FieldOpenID:
  49432. return m.OpenID()
  49433. case wxcarduser.FieldUnionID:
  49434. return m.UnionID()
  49435. case wxcarduser.FieldSessionKey:
  49436. return m.SessionKey()
  49437. case wxcarduser.FieldIsVip:
  49438. return m.IsVip()
  49439. }
  49440. return nil, false
  49441. }
  49442. // OldField returns the old value of the field from the database. An error is
  49443. // returned if the mutation operation is not UpdateOne, or the query to the
  49444. // database failed.
  49445. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49446. switch name {
  49447. case wxcarduser.FieldCreatedAt:
  49448. return m.OldCreatedAt(ctx)
  49449. case wxcarduser.FieldUpdatedAt:
  49450. return m.OldUpdatedAt(ctx)
  49451. case wxcarduser.FieldDeletedAt:
  49452. return m.OldDeletedAt(ctx)
  49453. case wxcarduser.FieldWxid:
  49454. return m.OldWxid(ctx)
  49455. case wxcarduser.FieldAccount:
  49456. return m.OldAccount(ctx)
  49457. case wxcarduser.FieldAvatar:
  49458. return m.OldAvatar(ctx)
  49459. case wxcarduser.FieldNickname:
  49460. return m.OldNickname(ctx)
  49461. case wxcarduser.FieldRemark:
  49462. return m.OldRemark(ctx)
  49463. case wxcarduser.FieldPhone:
  49464. return m.OldPhone(ctx)
  49465. case wxcarduser.FieldOpenID:
  49466. return m.OldOpenID(ctx)
  49467. case wxcarduser.FieldUnionID:
  49468. return m.OldUnionID(ctx)
  49469. case wxcarduser.FieldSessionKey:
  49470. return m.OldSessionKey(ctx)
  49471. case wxcarduser.FieldIsVip:
  49472. return m.OldIsVip(ctx)
  49473. }
  49474. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  49475. }
  49476. // SetField sets the value of a field with the given name. It returns an error if
  49477. // the field is not defined in the schema, or if the type mismatched the field
  49478. // type.
  49479. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  49480. switch name {
  49481. case wxcarduser.FieldCreatedAt:
  49482. v, ok := value.(time.Time)
  49483. if !ok {
  49484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49485. }
  49486. m.SetCreatedAt(v)
  49487. return nil
  49488. case wxcarduser.FieldUpdatedAt:
  49489. v, ok := value.(time.Time)
  49490. if !ok {
  49491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49492. }
  49493. m.SetUpdatedAt(v)
  49494. return nil
  49495. case wxcarduser.FieldDeletedAt:
  49496. v, ok := value.(time.Time)
  49497. if !ok {
  49498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49499. }
  49500. m.SetDeletedAt(v)
  49501. return nil
  49502. case wxcarduser.FieldWxid:
  49503. v, ok := value.(string)
  49504. if !ok {
  49505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49506. }
  49507. m.SetWxid(v)
  49508. return nil
  49509. case wxcarduser.FieldAccount:
  49510. v, ok := value.(string)
  49511. if !ok {
  49512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49513. }
  49514. m.SetAccount(v)
  49515. return nil
  49516. case wxcarduser.FieldAvatar:
  49517. v, ok := value.(string)
  49518. if !ok {
  49519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49520. }
  49521. m.SetAvatar(v)
  49522. return nil
  49523. case wxcarduser.FieldNickname:
  49524. v, ok := value.(string)
  49525. if !ok {
  49526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49527. }
  49528. m.SetNickname(v)
  49529. return nil
  49530. case wxcarduser.FieldRemark:
  49531. v, ok := value.(string)
  49532. if !ok {
  49533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49534. }
  49535. m.SetRemark(v)
  49536. return nil
  49537. case wxcarduser.FieldPhone:
  49538. v, ok := value.(string)
  49539. if !ok {
  49540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49541. }
  49542. m.SetPhone(v)
  49543. return nil
  49544. case wxcarduser.FieldOpenID:
  49545. v, ok := value.(string)
  49546. if !ok {
  49547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49548. }
  49549. m.SetOpenID(v)
  49550. return nil
  49551. case wxcarduser.FieldUnionID:
  49552. v, ok := value.(string)
  49553. if !ok {
  49554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49555. }
  49556. m.SetUnionID(v)
  49557. return nil
  49558. case wxcarduser.FieldSessionKey:
  49559. v, ok := value.(string)
  49560. if !ok {
  49561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49562. }
  49563. m.SetSessionKey(v)
  49564. return nil
  49565. case wxcarduser.FieldIsVip:
  49566. v, ok := value.(int)
  49567. if !ok {
  49568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49569. }
  49570. m.SetIsVip(v)
  49571. return nil
  49572. }
  49573. return fmt.Errorf("unknown WxCardUser field %s", name)
  49574. }
  49575. // AddedFields returns all numeric fields that were incremented/decremented during
  49576. // this mutation.
  49577. func (m *WxCardUserMutation) AddedFields() []string {
  49578. var fields []string
  49579. if m.addis_vip != nil {
  49580. fields = append(fields, wxcarduser.FieldIsVip)
  49581. }
  49582. return fields
  49583. }
  49584. // AddedField returns the numeric value that was incremented/decremented on a field
  49585. // with the given name. The second boolean return value indicates that this field
  49586. // was not set, or was not defined in the schema.
  49587. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  49588. switch name {
  49589. case wxcarduser.FieldIsVip:
  49590. return m.AddedIsVip()
  49591. }
  49592. return nil, false
  49593. }
  49594. // AddField adds the value to the field with the given name. It returns an error if
  49595. // the field is not defined in the schema, or if the type mismatched the field
  49596. // type.
  49597. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  49598. switch name {
  49599. case wxcarduser.FieldIsVip:
  49600. v, ok := value.(int)
  49601. if !ok {
  49602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49603. }
  49604. m.AddIsVip(v)
  49605. return nil
  49606. }
  49607. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  49608. }
  49609. // ClearedFields returns all nullable fields that were cleared during this
  49610. // mutation.
  49611. func (m *WxCardUserMutation) ClearedFields() []string {
  49612. var fields []string
  49613. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  49614. fields = append(fields, wxcarduser.FieldDeletedAt)
  49615. }
  49616. return fields
  49617. }
  49618. // FieldCleared returns a boolean indicating if a field with the given name was
  49619. // cleared in this mutation.
  49620. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  49621. _, ok := m.clearedFields[name]
  49622. return ok
  49623. }
  49624. // ClearField clears the value of the field with the given name. It returns an
  49625. // error if the field is not defined in the schema.
  49626. func (m *WxCardUserMutation) ClearField(name string) error {
  49627. switch name {
  49628. case wxcarduser.FieldDeletedAt:
  49629. m.ClearDeletedAt()
  49630. return nil
  49631. }
  49632. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  49633. }
  49634. // ResetField resets all changes in the mutation for the field with the given name.
  49635. // It returns an error if the field is not defined in the schema.
  49636. func (m *WxCardUserMutation) ResetField(name string) error {
  49637. switch name {
  49638. case wxcarduser.FieldCreatedAt:
  49639. m.ResetCreatedAt()
  49640. return nil
  49641. case wxcarduser.FieldUpdatedAt:
  49642. m.ResetUpdatedAt()
  49643. return nil
  49644. case wxcarduser.FieldDeletedAt:
  49645. m.ResetDeletedAt()
  49646. return nil
  49647. case wxcarduser.FieldWxid:
  49648. m.ResetWxid()
  49649. return nil
  49650. case wxcarduser.FieldAccount:
  49651. m.ResetAccount()
  49652. return nil
  49653. case wxcarduser.FieldAvatar:
  49654. m.ResetAvatar()
  49655. return nil
  49656. case wxcarduser.FieldNickname:
  49657. m.ResetNickname()
  49658. return nil
  49659. case wxcarduser.FieldRemark:
  49660. m.ResetRemark()
  49661. return nil
  49662. case wxcarduser.FieldPhone:
  49663. m.ResetPhone()
  49664. return nil
  49665. case wxcarduser.FieldOpenID:
  49666. m.ResetOpenID()
  49667. return nil
  49668. case wxcarduser.FieldUnionID:
  49669. m.ResetUnionID()
  49670. return nil
  49671. case wxcarduser.FieldSessionKey:
  49672. m.ResetSessionKey()
  49673. return nil
  49674. case wxcarduser.FieldIsVip:
  49675. m.ResetIsVip()
  49676. return nil
  49677. }
  49678. return fmt.Errorf("unknown WxCardUser field %s", name)
  49679. }
  49680. // AddedEdges returns all edge names that were set/added in this mutation.
  49681. func (m *WxCardUserMutation) AddedEdges() []string {
  49682. edges := make([]string, 0, 0)
  49683. return edges
  49684. }
  49685. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49686. // name in this mutation.
  49687. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  49688. return nil
  49689. }
  49690. // RemovedEdges returns all edge names that were removed in this mutation.
  49691. func (m *WxCardUserMutation) RemovedEdges() []string {
  49692. edges := make([]string, 0, 0)
  49693. return edges
  49694. }
  49695. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49696. // the given name in this mutation.
  49697. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  49698. return nil
  49699. }
  49700. // ClearedEdges returns all edge names that were cleared in this mutation.
  49701. func (m *WxCardUserMutation) ClearedEdges() []string {
  49702. edges := make([]string, 0, 0)
  49703. return edges
  49704. }
  49705. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49706. // was cleared in this mutation.
  49707. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  49708. return false
  49709. }
  49710. // ClearEdge clears the value of the edge with the given name. It returns an error
  49711. // if that edge is not defined in the schema.
  49712. func (m *WxCardUserMutation) ClearEdge(name string) error {
  49713. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  49714. }
  49715. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49716. // It returns an error if the edge is not defined in the schema.
  49717. func (m *WxCardUserMutation) ResetEdge(name string) error {
  49718. return fmt.Errorf("unknown WxCardUser edge %s", name)
  49719. }
  49720. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  49721. type WxCardVisitMutation struct {
  49722. config
  49723. op Op
  49724. typ string
  49725. id *uint64
  49726. created_at *time.Time
  49727. updated_at *time.Time
  49728. deleted_at *time.Time
  49729. user_id *uint64
  49730. adduser_id *int64
  49731. bot_id *uint64
  49732. addbot_id *int64
  49733. bot_type *uint8
  49734. addbot_type *int8
  49735. clearedFields map[string]struct{}
  49736. done bool
  49737. oldValue func(context.Context) (*WxCardVisit, error)
  49738. predicates []predicate.WxCardVisit
  49739. }
  49740. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  49741. // wxcardvisitOption allows management of the mutation configuration using functional options.
  49742. type wxcardvisitOption func(*WxCardVisitMutation)
  49743. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  49744. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  49745. m := &WxCardVisitMutation{
  49746. config: c,
  49747. op: op,
  49748. typ: TypeWxCardVisit,
  49749. clearedFields: make(map[string]struct{}),
  49750. }
  49751. for _, opt := range opts {
  49752. opt(m)
  49753. }
  49754. return m
  49755. }
  49756. // withWxCardVisitID sets the ID field of the mutation.
  49757. func withWxCardVisitID(id uint64) wxcardvisitOption {
  49758. return func(m *WxCardVisitMutation) {
  49759. var (
  49760. err error
  49761. once sync.Once
  49762. value *WxCardVisit
  49763. )
  49764. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  49765. once.Do(func() {
  49766. if m.done {
  49767. err = errors.New("querying old values post mutation is not allowed")
  49768. } else {
  49769. value, err = m.Client().WxCardVisit.Get(ctx, id)
  49770. }
  49771. })
  49772. return value, err
  49773. }
  49774. m.id = &id
  49775. }
  49776. }
  49777. // withWxCardVisit sets the old WxCardVisit of the mutation.
  49778. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  49779. return func(m *WxCardVisitMutation) {
  49780. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  49781. return node, nil
  49782. }
  49783. m.id = &node.ID
  49784. }
  49785. }
  49786. // Client returns a new `ent.Client` from the mutation. If the mutation was
  49787. // executed in a transaction (ent.Tx), a transactional client is returned.
  49788. func (m WxCardVisitMutation) Client() *Client {
  49789. client := &Client{config: m.config}
  49790. client.init()
  49791. return client
  49792. }
  49793. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  49794. // it returns an error otherwise.
  49795. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  49796. if _, ok := m.driver.(*txDriver); !ok {
  49797. return nil, errors.New("ent: mutation is not running in a transaction")
  49798. }
  49799. tx := &Tx{config: m.config}
  49800. tx.init()
  49801. return tx, nil
  49802. }
  49803. // SetID sets the value of the id field. Note that this
  49804. // operation is only accepted on creation of WxCardVisit entities.
  49805. func (m *WxCardVisitMutation) SetID(id uint64) {
  49806. m.id = &id
  49807. }
  49808. // ID returns the ID value in the mutation. Note that the ID is only available
  49809. // if it was provided to the builder or after it was returned from the database.
  49810. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  49811. if m.id == nil {
  49812. return
  49813. }
  49814. return *m.id, true
  49815. }
  49816. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  49817. // That means, if the mutation is applied within a transaction with an isolation level such
  49818. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  49819. // or updated by the mutation.
  49820. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  49821. switch {
  49822. case m.op.Is(OpUpdateOne | OpDeleteOne):
  49823. id, exists := m.ID()
  49824. if exists {
  49825. return []uint64{id}, nil
  49826. }
  49827. fallthrough
  49828. case m.op.Is(OpUpdate | OpDelete):
  49829. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  49830. default:
  49831. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  49832. }
  49833. }
  49834. // SetCreatedAt sets the "created_at" field.
  49835. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  49836. m.created_at = &t
  49837. }
  49838. // CreatedAt returns the value of the "created_at" field in the mutation.
  49839. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  49840. v := m.created_at
  49841. if v == nil {
  49842. return
  49843. }
  49844. return *v, true
  49845. }
  49846. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  49847. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49849. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  49850. if !m.op.Is(OpUpdateOne) {
  49851. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  49852. }
  49853. if m.id == nil || m.oldValue == nil {
  49854. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  49855. }
  49856. oldValue, err := m.oldValue(ctx)
  49857. if err != nil {
  49858. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  49859. }
  49860. return oldValue.CreatedAt, nil
  49861. }
  49862. // ResetCreatedAt resets all changes to the "created_at" field.
  49863. func (m *WxCardVisitMutation) ResetCreatedAt() {
  49864. m.created_at = nil
  49865. }
  49866. // SetUpdatedAt sets the "updated_at" field.
  49867. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  49868. m.updated_at = &t
  49869. }
  49870. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  49871. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  49872. v := m.updated_at
  49873. if v == nil {
  49874. return
  49875. }
  49876. return *v, true
  49877. }
  49878. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  49879. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49881. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  49882. if !m.op.Is(OpUpdateOne) {
  49883. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  49884. }
  49885. if m.id == nil || m.oldValue == nil {
  49886. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  49887. }
  49888. oldValue, err := m.oldValue(ctx)
  49889. if err != nil {
  49890. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  49891. }
  49892. return oldValue.UpdatedAt, nil
  49893. }
  49894. // ResetUpdatedAt resets all changes to the "updated_at" field.
  49895. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  49896. m.updated_at = nil
  49897. }
  49898. // SetDeletedAt sets the "deleted_at" field.
  49899. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  49900. m.deleted_at = &t
  49901. }
  49902. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  49903. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  49904. v := m.deleted_at
  49905. if v == nil {
  49906. return
  49907. }
  49908. return *v, true
  49909. }
  49910. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  49911. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49913. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  49914. if !m.op.Is(OpUpdateOne) {
  49915. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  49916. }
  49917. if m.id == nil || m.oldValue == nil {
  49918. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  49919. }
  49920. oldValue, err := m.oldValue(ctx)
  49921. if err != nil {
  49922. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  49923. }
  49924. return oldValue.DeletedAt, nil
  49925. }
  49926. // ClearDeletedAt clears the value of the "deleted_at" field.
  49927. func (m *WxCardVisitMutation) ClearDeletedAt() {
  49928. m.deleted_at = nil
  49929. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  49930. }
  49931. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  49932. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  49933. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  49934. return ok
  49935. }
  49936. // ResetDeletedAt resets all changes to the "deleted_at" field.
  49937. func (m *WxCardVisitMutation) ResetDeletedAt() {
  49938. m.deleted_at = nil
  49939. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  49940. }
  49941. // SetUserID sets the "user_id" field.
  49942. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  49943. m.user_id = &u
  49944. m.adduser_id = nil
  49945. }
  49946. // UserID returns the value of the "user_id" field in the mutation.
  49947. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  49948. v := m.user_id
  49949. if v == nil {
  49950. return
  49951. }
  49952. return *v, true
  49953. }
  49954. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  49955. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49957. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  49958. if !m.op.Is(OpUpdateOne) {
  49959. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  49960. }
  49961. if m.id == nil || m.oldValue == nil {
  49962. return v, errors.New("OldUserID requires an ID field in the mutation")
  49963. }
  49964. oldValue, err := m.oldValue(ctx)
  49965. if err != nil {
  49966. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  49967. }
  49968. return oldValue.UserID, nil
  49969. }
  49970. // AddUserID adds u to the "user_id" field.
  49971. func (m *WxCardVisitMutation) AddUserID(u int64) {
  49972. if m.adduser_id != nil {
  49973. *m.adduser_id += u
  49974. } else {
  49975. m.adduser_id = &u
  49976. }
  49977. }
  49978. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  49979. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  49980. v := m.adduser_id
  49981. if v == nil {
  49982. return
  49983. }
  49984. return *v, true
  49985. }
  49986. // ClearUserID clears the value of the "user_id" field.
  49987. func (m *WxCardVisitMutation) ClearUserID() {
  49988. m.user_id = nil
  49989. m.adduser_id = nil
  49990. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  49991. }
  49992. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  49993. func (m *WxCardVisitMutation) UserIDCleared() bool {
  49994. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  49995. return ok
  49996. }
  49997. // ResetUserID resets all changes to the "user_id" field.
  49998. func (m *WxCardVisitMutation) ResetUserID() {
  49999. m.user_id = nil
  50000. m.adduser_id = nil
  50001. delete(m.clearedFields, wxcardvisit.FieldUserID)
  50002. }
  50003. // SetBotID sets the "bot_id" field.
  50004. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  50005. m.bot_id = &u
  50006. m.addbot_id = nil
  50007. }
  50008. // BotID returns the value of the "bot_id" field in the mutation.
  50009. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  50010. v := m.bot_id
  50011. if v == nil {
  50012. return
  50013. }
  50014. return *v, true
  50015. }
  50016. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  50017. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50019. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  50020. if !m.op.Is(OpUpdateOne) {
  50021. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  50022. }
  50023. if m.id == nil || m.oldValue == nil {
  50024. return v, errors.New("OldBotID requires an ID field in the mutation")
  50025. }
  50026. oldValue, err := m.oldValue(ctx)
  50027. if err != nil {
  50028. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  50029. }
  50030. return oldValue.BotID, nil
  50031. }
  50032. // AddBotID adds u to the "bot_id" field.
  50033. func (m *WxCardVisitMutation) AddBotID(u int64) {
  50034. if m.addbot_id != nil {
  50035. *m.addbot_id += u
  50036. } else {
  50037. m.addbot_id = &u
  50038. }
  50039. }
  50040. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  50041. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  50042. v := m.addbot_id
  50043. if v == nil {
  50044. return
  50045. }
  50046. return *v, true
  50047. }
  50048. // ResetBotID resets all changes to the "bot_id" field.
  50049. func (m *WxCardVisitMutation) ResetBotID() {
  50050. m.bot_id = nil
  50051. m.addbot_id = nil
  50052. }
  50053. // SetBotType sets the "bot_type" field.
  50054. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  50055. m.bot_type = &u
  50056. m.addbot_type = nil
  50057. }
  50058. // BotType returns the value of the "bot_type" field in the mutation.
  50059. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  50060. v := m.bot_type
  50061. if v == nil {
  50062. return
  50063. }
  50064. return *v, true
  50065. }
  50066. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  50067. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50069. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  50070. if !m.op.Is(OpUpdateOne) {
  50071. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  50072. }
  50073. if m.id == nil || m.oldValue == nil {
  50074. return v, errors.New("OldBotType requires an ID field in the mutation")
  50075. }
  50076. oldValue, err := m.oldValue(ctx)
  50077. if err != nil {
  50078. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  50079. }
  50080. return oldValue.BotType, nil
  50081. }
  50082. // AddBotType adds u to the "bot_type" field.
  50083. func (m *WxCardVisitMutation) AddBotType(u int8) {
  50084. if m.addbot_type != nil {
  50085. *m.addbot_type += u
  50086. } else {
  50087. m.addbot_type = &u
  50088. }
  50089. }
  50090. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  50091. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  50092. v := m.addbot_type
  50093. if v == nil {
  50094. return
  50095. }
  50096. return *v, true
  50097. }
  50098. // ResetBotType resets all changes to the "bot_type" field.
  50099. func (m *WxCardVisitMutation) ResetBotType() {
  50100. m.bot_type = nil
  50101. m.addbot_type = nil
  50102. }
  50103. // Where appends a list predicates to the WxCardVisitMutation builder.
  50104. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  50105. m.predicates = append(m.predicates, ps...)
  50106. }
  50107. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  50108. // users can use type-assertion to append predicates that do not depend on any generated package.
  50109. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  50110. p := make([]predicate.WxCardVisit, len(ps))
  50111. for i := range ps {
  50112. p[i] = ps[i]
  50113. }
  50114. m.Where(p...)
  50115. }
  50116. // Op returns the operation name.
  50117. func (m *WxCardVisitMutation) Op() Op {
  50118. return m.op
  50119. }
  50120. // SetOp allows setting the mutation operation.
  50121. func (m *WxCardVisitMutation) SetOp(op Op) {
  50122. m.op = op
  50123. }
  50124. // Type returns the node type of this mutation (WxCardVisit).
  50125. func (m *WxCardVisitMutation) Type() string {
  50126. return m.typ
  50127. }
  50128. // Fields returns all fields that were changed during this mutation. Note that in
  50129. // order to get all numeric fields that were incremented/decremented, call
  50130. // AddedFields().
  50131. func (m *WxCardVisitMutation) Fields() []string {
  50132. fields := make([]string, 0, 6)
  50133. if m.created_at != nil {
  50134. fields = append(fields, wxcardvisit.FieldCreatedAt)
  50135. }
  50136. if m.updated_at != nil {
  50137. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  50138. }
  50139. if m.deleted_at != nil {
  50140. fields = append(fields, wxcardvisit.FieldDeletedAt)
  50141. }
  50142. if m.user_id != nil {
  50143. fields = append(fields, wxcardvisit.FieldUserID)
  50144. }
  50145. if m.bot_id != nil {
  50146. fields = append(fields, wxcardvisit.FieldBotID)
  50147. }
  50148. if m.bot_type != nil {
  50149. fields = append(fields, wxcardvisit.FieldBotType)
  50150. }
  50151. return fields
  50152. }
  50153. // Field returns the value of a field with the given name. The second boolean
  50154. // return value indicates that this field was not set, or was not defined in the
  50155. // schema.
  50156. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  50157. switch name {
  50158. case wxcardvisit.FieldCreatedAt:
  50159. return m.CreatedAt()
  50160. case wxcardvisit.FieldUpdatedAt:
  50161. return m.UpdatedAt()
  50162. case wxcardvisit.FieldDeletedAt:
  50163. return m.DeletedAt()
  50164. case wxcardvisit.FieldUserID:
  50165. return m.UserID()
  50166. case wxcardvisit.FieldBotID:
  50167. return m.BotID()
  50168. case wxcardvisit.FieldBotType:
  50169. return m.BotType()
  50170. }
  50171. return nil, false
  50172. }
  50173. // OldField returns the old value of the field from the database. An error is
  50174. // returned if the mutation operation is not UpdateOne, or the query to the
  50175. // database failed.
  50176. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  50177. switch name {
  50178. case wxcardvisit.FieldCreatedAt:
  50179. return m.OldCreatedAt(ctx)
  50180. case wxcardvisit.FieldUpdatedAt:
  50181. return m.OldUpdatedAt(ctx)
  50182. case wxcardvisit.FieldDeletedAt:
  50183. return m.OldDeletedAt(ctx)
  50184. case wxcardvisit.FieldUserID:
  50185. return m.OldUserID(ctx)
  50186. case wxcardvisit.FieldBotID:
  50187. return m.OldBotID(ctx)
  50188. case wxcardvisit.FieldBotType:
  50189. return m.OldBotType(ctx)
  50190. }
  50191. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  50192. }
  50193. // SetField sets the value of a field with the given name. It returns an error if
  50194. // the field is not defined in the schema, or if the type mismatched the field
  50195. // type.
  50196. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  50197. switch name {
  50198. case wxcardvisit.FieldCreatedAt:
  50199. v, ok := value.(time.Time)
  50200. if !ok {
  50201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50202. }
  50203. m.SetCreatedAt(v)
  50204. return nil
  50205. case wxcardvisit.FieldUpdatedAt:
  50206. v, ok := value.(time.Time)
  50207. if !ok {
  50208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50209. }
  50210. m.SetUpdatedAt(v)
  50211. return nil
  50212. case wxcardvisit.FieldDeletedAt:
  50213. v, ok := value.(time.Time)
  50214. if !ok {
  50215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50216. }
  50217. m.SetDeletedAt(v)
  50218. return nil
  50219. case wxcardvisit.FieldUserID:
  50220. v, ok := value.(uint64)
  50221. if !ok {
  50222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50223. }
  50224. m.SetUserID(v)
  50225. return nil
  50226. case wxcardvisit.FieldBotID:
  50227. v, ok := value.(uint64)
  50228. if !ok {
  50229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50230. }
  50231. m.SetBotID(v)
  50232. return nil
  50233. case wxcardvisit.FieldBotType:
  50234. v, ok := value.(uint8)
  50235. if !ok {
  50236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50237. }
  50238. m.SetBotType(v)
  50239. return nil
  50240. }
  50241. return fmt.Errorf("unknown WxCardVisit field %s", name)
  50242. }
  50243. // AddedFields returns all numeric fields that were incremented/decremented during
  50244. // this mutation.
  50245. func (m *WxCardVisitMutation) AddedFields() []string {
  50246. var fields []string
  50247. if m.adduser_id != nil {
  50248. fields = append(fields, wxcardvisit.FieldUserID)
  50249. }
  50250. if m.addbot_id != nil {
  50251. fields = append(fields, wxcardvisit.FieldBotID)
  50252. }
  50253. if m.addbot_type != nil {
  50254. fields = append(fields, wxcardvisit.FieldBotType)
  50255. }
  50256. return fields
  50257. }
  50258. // AddedField returns the numeric value that was incremented/decremented on a field
  50259. // with the given name. The second boolean return value indicates that this field
  50260. // was not set, or was not defined in the schema.
  50261. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  50262. switch name {
  50263. case wxcardvisit.FieldUserID:
  50264. return m.AddedUserID()
  50265. case wxcardvisit.FieldBotID:
  50266. return m.AddedBotID()
  50267. case wxcardvisit.FieldBotType:
  50268. return m.AddedBotType()
  50269. }
  50270. return nil, false
  50271. }
  50272. // AddField adds the value to the field with the given name. It returns an error if
  50273. // the field is not defined in the schema, or if the type mismatched the field
  50274. // type.
  50275. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  50276. switch name {
  50277. case wxcardvisit.FieldUserID:
  50278. v, ok := value.(int64)
  50279. if !ok {
  50280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50281. }
  50282. m.AddUserID(v)
  50283. return nil
  50284. case wxcardvisit.FieldBotID:
  50285. v, ok := value.(int64)
  50286. if !ok {
  50287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50288. }
  50289. m.AddBotID(v)
  50290. return nil
  50291. case wxcardvisit.FieldBotType:
  50292. v, ok := value.(int8)
  50293. if !ok {
  50294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50295. }
  50296. m.AddBotType(v)
  50297. return nil
  50298. }
  50299. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  50300. }
  50301. // ClearedFields returns all nullable fields that were cleared during this
  50302. // mutation.
  50303. func (m *WxCardVisitMutation) ClearedFields() []string {
  50304. var fields []string
  50305. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  50306. fields = append(fields, wxcardvisit.FieldDeletedAt)
  50307. }
  50308. if m.FieldCleared(wxcardvisit.FieldUserID) {
  50309. fields = append(fields, wxcardvisit.FieldUserID)
  50310. }
  50311. return fields
  50312. }
  50313. // FieldCleared returns a boolean indicating if a field with the given name was
  50314. // cleared in this mutation.
  50315. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  50316. _, ok := m.clearedFields[name]
  50317. return ok
  50318. }
  50319. // ClearField clears the value of the field with the given name. It returns an
  50320. // error if the field is not defined in the schema.
  50321. func (m *WxCardVisitMutation) ClearField(name string) error {
  50322. switch name {
  50323. case wxcardvisit.FieldDeletedAt:
  50324. m.ClearDeletedAt()
  50325. return nil
  50326. case wxcardvisit.FieldUserID:
  50327. m.ClearUserID()
  50328. return nil
  50329. }
  50330. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  50331. }
  50332. // ResetField resets all changes in the mutation for the field with the given name.
  50333. // It returns an error if the field is not defined in the schema.
  50334. func (m *WxCardVisitMutation) ResetField(name string) error {
  50335. switch name {
  50336. case wxcardvisit.FieldCreatedAt:
  50337. m.ResetCreatedAt()
  50338. return nil
  50339. case wxcardvisit.FieldUpdatedAt:
  50340. m.ResetUpdatedAt()
  50341. return nil
  50342. case wxcardvisit.FieldDeletedAt:
  50343. m.ResetDeletedAt()
  50344. return nil
  50345. case wxcardvisit.FieldUserID:
  50346. m.ResetUserID()
  50347. return nil
  50348. case wxcardvisit.FieldBotID:
  50349. m.ResetBotID()
  50350. return nil
  50351. case wxcardvisit.FieldBotType:
  50352. m.ResetBotType()
  50353. return nil
  50354. }
  50355. return fmt.Errorf("unknown WxCardVisit field %s", name)
  50356. }
  50357. // AddedEdges returns all edge names that were set/added in this mutation.
  50358. func (m *WxCardVisitMutation) AddedEdges() []string {
  50359. edges := make([]string, 0, 0)
  50360. return edges
  50361. }
  50362. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  50363. // name in this mutation.
  50364. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  50365. return nil
  50366. }
  50367. // RemovedEdges returns all edge names that were removed in this mutation.
  50368. func (m *WxCardVisitMutation) RemovedEdges() []string {
  50369. edges := make([]string, 0, 0)
  50370. return edges
  50371. }
  50372. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  50373. // the given name in this mutation.
  50374. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  50375. return nil
  50376. }
  50377. // ClearedEdges returns all edge names that were cleared in this mutation.
  50378. func (m *WxCardVisitMutation) ClearedEdges() []string {
  50379. edges := make([]string, 0, 0)
  50380. return edges
  50381. }
  50382. // EdgeCleared returns a boolean which indicates if the edge with the given name
  50383. // was cleared in this mutation.
  50384. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  50385. return false
  50386. }
  50387. // ClearEdge clears the value of the edge with the given name. It returns an error
  50388. // if that edge is not defined in the schema.
  50389. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  50390. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  50391. }
  50392. // ResetEdge resets all changes to the edge with the given name in this mutation.
  50393. // It returns an error if the edge is not defined in the schema.
  50394. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  50395. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  50396. }
  50397. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  50398. type XunjiMutation struct {
  50399. config
  50400. op Op
  50401. typ string
  50402. id *uint64
  50403. created_at *time.Time
  50404. updated_at *time.Time
  50405. status *uint8
  50406. addstatus *int8
  50407. deleted_at *time.Time
  50408. app_key *string
  50409. app_secret *string
  50410. token *string
  50411. encoding_key *string
  50412. organization_id *uint64
  50413. addorganization_id *int64
  50414. clearedFields map[string]struct{}
  50415. done bool
  50416. oldValue func(context.Context) (*Xunji, error)
  50417. predicates []predicate.Xunji
  50418. }
  50419. var _ ent.Mutation = (*XunjiMutation)(nil)
  50420. // xunjiOption allows management of the mutation configuration using functional options.
  50421. type xunjiOption func(*XunjiMutation)
  50422. // newXunjiMutation creates new mutation for the Xunji entity.
  50423. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  50424. m := &XunjiMutation{
  50425. config: c,
  50426. op: op,
  50427. typ: TypeXunji,
  50428. clearedFields: make(map[string]struct{}),
  50429. }
  50430. for _, opt := range opts {
  50431. opt(m)
  50432. }
  50433. return m
  50434. }
  50435. // withXunjiID sets the ID field of the mutation.
  50436. func withXunjiID(id uint64) xunjiOption {
  50437. return func(m *XunjiMutation) {
  50438. var (
  50439. err error
  50440. once sync.Once
  50441. value *Xunji
  50442. )
  50443. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  50444. once.Do(func() {
  50445. if m.done {
  50446. err = errors.New("querying old values post mutation is not allowed")
  50447. } else {
  50448. value, err = m.Client().Xunji.Get(ctx, id)
  50449. }
  50450. })
  50451. return value, err
  50452. }
  50453. m.id = &id
  50454. }
  50455. }
  50456. // withXunji sets the old Xunji of the mutation.
  50457. func withXunji(node *Xunji) xunjiOption {
  50458. return func(m *XunjiMutation) {
  50459. m.oldValue = func(context.Context) (*Xunji, error) {
  50460. return node, nil
  50461. }
  50462. m.id = &node.ID
  50463. }
  50464. }
  50465. // Client returns a new `ent.Client` from the mutation. If the mutation was
  50466. // executed in a transaction (ent.Tx), a transactional client is returned.
  50467. func (m XunjiMutation) Client() *Client {
  50468. client := &Client{config: m.config}
  50469. client.init()
  50470. return client
  50471. }
  50472. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  50473. // it returns an error otherwise.
  50474. func (m XunjiMutation) Tx() (*Tx, error) {
  50475. if _, ok := m.driver.(*txDriver); !ok {
  50476. return nil, errors.New("ent: mutation is not running in a transaction")
  50477. }
  50478. tx := &Tx{config: m.config}
  50479. tx.init()
  50480. return tx, nil
  50481. }
  50482. // SetID sets the value of the id field. Note that this
  50483. // operation is only accepted on creation of Xunji entities.
  50484. func (m *XunjiMutation) SetID(id uint64) {
  50485. m.id = &id
  50486. }
  50487. // ID returns the ID value in the mutation. Note that the ID is only available
  50488. // if it was provided to the builder or after it was returned from the database.
  50489. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  50490. if m.id == nil {
  50491. return
  50492. }
  50493. return *m.id, true
  50494. }
  50495. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  50496. // That means, if the mutation is applied within a transaction with an isolation level such
  50497. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  50498. // or updated by the mutation.
  50499. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  50500. switch {
  50501. case m.op.Is(OpUpdateOne | OpDeleteOne):
  50502. id, exists := m.ID()
  50503. if exists {
  50504. return []uint64{id}, nil
  50505. }
  50506. fallthrough
  50507. case m.op.Is(OpUpdate | OpDelete):
  50508. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  50509. default:
  50510. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  50511. }
  50512. }
  50513. // SetCreatedAt sets the "created_at" field.
  50514. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  50515. m.created_at = &t
  50516. }
  50517. // CreatedAt returns the value of the "created_at" field in the mutation.
  50518. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  50519. v := m.created_at
  50520. if v == nil {
  50521. return
  50522. }
  50523. return *v, true
  50524. }
  50525. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  50526. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50528. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  50529. if !m.op.Is(OpUpdateOne) {
  50530. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  50531. }
  50532. if m.id == nil || m.oldValue == nil {
  50533. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  50534. }
  50535. oldValue, err := m.oldValue(ctx)
  50536. if err != nil {
  50537. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  50538. }
  50539. return oldValue.CreatedAt, nil
  50540. }
  50541. // ResetCreatedAt resets all changes to the "created_at" field.
  50542. func (m *XunjiMutation) ResetCreatedAt() {
  50543. m.created_at = nil
  50544. }
  50545. // SetUpdatedAt sets the "updated_at" field.
  50546. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  50547. m.updated_at = &t
  50548. }
  50549. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  50550. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  50551. v := m.updated_at
  50552. if v == nil {
  50553. return
  50554. }
  50555. return *v, true
  50556. }
  50557. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  50558. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50560. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  50561. if !m.op.Is(OpUpdateOne) {
  50562. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  50563. }
  50564. if m.id == nil || m.oldValue == nil {
  50565. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  50566. }
  50567. oldValue, err := m.oldValue(ctx)
  50568. if err != nil {
  50569. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  50570. }
  50571. return oldValue.UpdatedAt, nil
  50572. }
  50573. // ResetUpdatedAt resets all changes to the "updated_at" field.
  50574. func (m *XunjiMutation) ResetUpdatedAt() {
  50575. m.updated_at = nil
  50576. }
  50577. // SetStatus sets the "status" field.
  50578. func (m *XunjiMutation) SetStatus(u uint8) {
  50579. m.status = &u
  50580. m.addstatus = nil
  50581. }
  50582. // Status returns the value of the "status" field in the mutation.
  50583. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  50584. v := m.status
  50585. if v == nil {
  50586. return
  50587. }
  50588. return *v, true
  50589. }
  50590. // OldStatus returns the old "status" field's value of the Xunji entity.
  50591. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50593. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  50594. if !m.op.Is(OpUpdateOne) {
  50595. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  50596. }
  50597. if m.id == nil || m.oldValue == nil {
  50598. return v, errors.New("OldStatus requires an ID field in the mutation")
  50599. }
  50600. oldValue, err := m.oldValue(ctx)
  50601. if err != nil {
  50602. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  50603. }
  50604. return oldValue.Status, nil
  50605. }
  50606. // AddStatus adds u to the "status" field.
  50607. func (m *XunjiMutation) AddStatus(u int8) {
  50608. if m.addstatus != nil {
  50609. *m.addstatus += u
  50610. } else {
  50611. m.addstatus = &u
  50612. }
  50613. }
  50614. // AddedStatus returns the value that was added to the "status" field in this mutation.
  50615. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  50616. v := m.addstatus
  50617. if v == nil {
  50618. return
  50619. }
  50620. return *v, true
  50621. }
  50622. // ClearStatus clears the value of the "status" field.
  50623. func (m *XunjiMutation) ClearStatus() {
  50624. m.status = nil
  50625. m.addstatus = nil
  50626. m.clearedFields[xunji.FieldStatus] = struct{}{}
  50627. }
  50628. // StatusCleared returns if the "status" field was cleared in this mutation.
  50629. func (m *XunjiMutation) StatusCleared() bool {
  50630. _, ok := m.clearedFields[xunji.FieldStatus]
  50631. return ok
  50632. }
  50633. // ResetStatus resets all changes to the "status" field.
  50634. func (m *XunjiMutation) ResetStatus() {
  50635. m.status = nil
  50636. m.addstatus = nil
  50637. delete(m.clearedFields, xunji.FieldStatus)
  50638. }
  50639. // SetDeletedAt sets the "deleted_at" field.
  50640. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  50641. m.deleted_at = &t
  50642. }
  50643. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  50644. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  50645. v := m.deleted_at
  50646. if v == nil {
  50647. return
  50648. }
  50649. return *v, true
  50650. }
  50651. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  50652. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50654. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  50655. if !m.op.Is(OpUpdateOne) {
  50656. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  50657. }
  50658. if m.id == nil || m.oldValue == nil {
  50659. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  50660. }
  50661. oldValue, err := m.oldValue(ctx)
  50662. if err != nil {
  50663. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  50664. }
  50665. return oldValue.DeletedAt, nil
  50666. }
  50667. // ClearDeletedAt clears the value of the "deleted_at" field.
  50668. func (m *XunjiMutation) ClearDeletedAt() {
  50669. m.deleted_at = nil
  50670. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  50671. }
  50672. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  50673. func (m *XunjiMutation) DeletedAtCleared() bool {
  50674. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  50675. return ok
  50676. }
  50677. // ResetDeletedAt resets all changes to the "deleted_at" field.
  50678. func (m *XunjiMutation) ResetDeletedAt() {
  50679. m.deleted_at = nil
  50680. delete(m.clearedFields, xunji.FieldDeletedAt)
  50681. }
  50682. // SetAppKey sets the "app_key" field.
  50683. func (m *XunjiMutation) SetAppKey(s string) {
  50684. m.app_key = &s
  50685. }
  50686. // AppKey returns the value of the "app_key" field in the mutation.
  50687. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  50688. v := m.app_key
  50689. if v == nil {
  50690. return
  50691. }
  50692. return *v, true
  50693. }
  50694. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  50695. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50697. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  50698. if !m.op.Is(OpUpdateOne) {
  50699. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  50700. }
  50701. if m.id == nil || m.oldValue == nil {
  50702. return v, errors.New("OldAppKey requires an ID field in the mutation")
  50703. }
  50704. oldValue, err := m.oldValue(ctx)
  50705. if err != nil {
  50706. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  50707. }
  50708. return oldValue.AppKey, nil
  50709. }
  50710. // ClearAppKey clears the value of the "app_key" field.
  50711. func (m *XunjiMutation) ClearAppKey() {
  50712. m.app_key = nil
  50713. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  50714. }
  50715. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  50716. func (m *XunjiMutation) AppKeyCleared() bool {
  50717. _, ok := m.clearedFields[xunji.FieldAppKey]
  50718. return ok
  50719. }
  50720. // ResetAppKey resets all changes to the "app_key" field.
  50721. func (m *XunjiMutation) ResetAppKey() {
  50722. m.app_key = nil
  50723. delete(m.clearedFields, xunji.FieldAppKey)
  50724. }
  50725. // SetAppSecret sets the "app_secret" field.
  50726. func (m *XunjiMutation) SetAppSecret(s string) {
  50727. m.app_secret = &s
  50728. }
  50729. // AppSecret returns the value of the "app_secret" field in the mutation.
  50730. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  50731. v := m.app_secret
  50732. if v == nil {
  50733. return
  50734. }
  50735. return *v, true
  50736. }
  50737. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  50738. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50740. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  50741. if !m.op.Is(OpUpdateOne) {
  50742. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  50743. }
  50744. if m.id == nil || m.oldValue == nil {
  50745. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  50746. }
  50747. oldValue, err := m.oldValue(ctx)
  50748. if err != nil {
  50749. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  50750. }
  50751. return oldValue.AppSecret, nil
  50752. }
  50753. // ClearAppSecret clears the value of the "app_secret" field.
  50754. func (m *XunjiMutation) ClearAppSecret() {
  50755. m.app_secret = nil
  50756. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  50757. }
  50758. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  50759. func (m *XunjiMutation) AppSecretCleared() bool {
  50760. _, ok := m.clearedFields[xunji.FieldAppSecret]
  50761. return ok
  50762. }
  50763. // ResetAppSecret resets all changes to the "app_secret" field.
  50764. func (m *XunjiMutation) ResetAppSecret() {
  50765. m.app_secret = nil
  50766. delete(m.clearedFields, xunji.FieldAppSecret)
  50767. }
  50768. // SetToken sets the "token" field.
  50769. func (m *XunjiMutation) SetToken(s string) {
  50770. m.token = &s
  50771. }
  50772. // Token returns the value of the "token" field in the mutation.
  50773. func (m *XunjiMutation) Token() (r string, exists bool) {
  50774. v := m.token
  50775. if v == nil {
  50776. return
  50777. }
  50778. return *v, true
  50779. }
  50780. // OldToken returns the old "token" field's value of the Xunji entity.
  50781. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50783. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  50784. if !m.op.Is(OpUpdateOne) {
  50785. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  50786. }
  50787. if m.id == nil || m.oldValue == nil {
  50788. return v, errors.New("OldToken requires an ID field in the mutation")
  50789. }
  50790. oldValue, err := m.oldValue(ctx)
  50791. if err != nil {
  50792. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  50793. }
  50794. return oldValue.Token, nil
  50795. }
  50796. // ClearToken clears the value of the "token" field.
  50797. func (m *XunjiMutation) ClearToken() {
  50798. m.token = nil
  50799. m.clearedFields[xunji.FieldToken] = struct{}{}
  50800. }
  50801. // TokenCleared returns if the "token" field was cleared in this mutation.
  50802. func (m *XunjiMutation) TokenCleared() bool {
  50803. _, ok := m.clearedFields[xunji.FieldToken]
  50804. return ok
  50805. }
  50806. // ResetToken resets all changes to the "token" field.
  50807. func (m *XunjiMutation) ResetToken() {
  50808. m.token = nil
  50809. delete(m.clearedFields, xunji.FieldToken)
  50810. }
  50811. // SetEncodingKey sets the "encoding_key" field.
  50812. func (m *XunjiMutation) SetEncodingKey(s string) {
  50813. m.encoding_key = &s
  50814. }
  50815. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  50816. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  50817. v := m.encoding_key
  50818. if v == nil {
  50819. return
  50820. }
  50821. return *v, true
  50822. }
  50823. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  50824. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50826. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  50827. if !m.op.Is(OpUpdateOne) {
  50828. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  50829. }
  50830. if m.id == nil || m.oldValue == nil {
  50831. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  50832. }
  50833. oldValue, err := m.oldValue(ctx)
  50834. if err != nil {
  50835. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  50836. }
  50837. return oldValue.EncodingKey, nil
  50838. }
  50839. // ClearEncodingKey clears the value of the "encoding_key" field.
  50840. func (m *XunjiMutation) ClearEncodingKey() {
  50841. m.encoding_key = nil
  50842. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  50843. }
  50844. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  50845. func (m *XunjiMutation) EncodingKeyCleared() bool {
  50846. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  50847. return ok
  50848. }
  50849. // ResetEncodingKey resets all changes to the "encoding_key" field.
  50850. func (m *XunjiMutation) ResetEncodingKey() {
  50851. m.encoding_key = nil
  50852. delete(m.clearedFields, xunji.FieldEncodingKey)
  50853. }
  50854. // SetOrganizationID sets the "organization_id" field.
  50855. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  50856. m.organization_id = &u
  50857. m.addorganization_id = nil
  50858. }
  50859. // OrganizationID returns the value of the "organization_id" field in the mutation.
  50860. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  50861. v := m.organization_id
  50862. if v == nil {
  50863. return
  50864. }
  50865. return *v, true
  50866. }
  50867. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  50868. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  50869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50870. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  50871. if !m.op.Is(OpUpdateOne) {
  50872. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  50873. }
  50874. if m.id == nil || m.oldValue == nil {
  50875. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  50876. }
  50877. oldValue, err := m.oldValue(ctx)
  50878. if err != nil {
  50879. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  50880. }
  50881. return oldValue.OrganizationID, nil
  50882. }
  50883. // AddOrganizationID adds u to the "organization_id" field.
  50884. func (m *XunjiMutation) AddOrganizationID(u int64) {
  50885. if m.addorganization_id != nil {
  50886. *m.addorganization_id += u
  50887. } else {
  50888. m.addorganization_id = &u
  50889. }
  50890. }
  50891. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  50892. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  50893. v := m.addorganization_id
  50894. if v == nil {
  50895. return
  50896. }
  50897. return *v, true
  50898. }
  50899. // ResetOrganizationID resets all changes to the "organization_id" field.
  50900. func (m *XunjiMutation) ResetOrganizationID() {
  50901. m.organization_id = nil
  50902. m.addorganization_id = nil
  50903. }
  50904. // Where appends a list predicates to the XunjiMutation builder.
  50905. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  50906. m.predicates = append(m.predicates, ps...)
  50907. }
  50908. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  50909. // users can use type-assertion to append predicates that do not depend on any generated package.
  50910. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  50911. p := make([]predicate.Xunji, len(ps))
  50912. for i := range ps {
  50913. p[i] = ps[i]
  50914. }
  50915. m.Where(p...)
  50916. }
  50917. // Op returns the operation name.
  50918. func (m *XunjiMutation) Op() Op {
  50919. return m.op
  50920. }
  50921. // SetOp allows setting the mutation operation.
  50922. func (m *XunjiMutation) SetOp(op Op) {
  50923. m.op = op
  50924. }
  50925. // Type returns the node type of this mutation (Xunji).
  50926. func (m *XunjiMutation) Type() string {
  50927. return m.typ
  50928. }
  50929. // Fields returns all fields that were changed during this mutation. Note that in
  50930. // order to get all numeric fields that were incremented/decremented, call
  50931. // AddedFields().
  50932. func (m *XunjiMutation) Fields() []string {
  50933. fields := make([]string, 0, 9)
  50934. if m.created_at != nil {
  50935. fields = append(fields, xunji.FieldCreatedAt)
  50936. }
  50937. if m.updated_at != nil {
  50938. fields = append(fields, xunji.FieldUpdatedAt)
  50939. }
  50940. if m.status != nil {
  50941. fields = append(fields, xunji.FieldStatus)
  50942. }
  50943. if m.deleted_at != nil {
  50944. fields = append(fields, xunji.FieldDeletedAt)
  50945. }
  50946. if m.app_key != nil {
  50947. fields = append(fields, xunji.FieldAppKey)
  50948. }
  50949. if m.app_secret != nil {
  50950. fields = append(fields, xunji.FieldAppSecret)
  50951. }
  50952. if m.token != nil {
  50953. fields = append(fields, xunji.FieldToken)
  50954. }
  50955. if m.encoding_key != nil {
  50956. fields = append(fields, xunji.FieldEncodingKey)
  50957. }
  50958. if m.organization_id != nil {
  50959. fields = append(fields, xunji.FieldOrganizationID)
  50960. }
  50961. return fields
  50962. }
  50963. // Field returns the value of a field with the given name. The second boolean
  50964. // return value indicates that this field was not set, or was not defined in the
  50965. // schema.
  50966. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  50967. switch name {
  50968. case xunji.FieldCreatedAt:
  50969. return m.CreatedAt()
  50970. case xunji.FieldUpdatedAt:
  50971. return m.UpdatedAt()
  50972. case xunji.FieldStatus:
  50973. return m.Status()
  50974. case xunji.FieldDeletedAt:
  50975. return m.DeletedAt()
  50976. case xunji.FieldAppKey:
  50977. return m.AppKey()
  50978. case xunji.FieldAppSecret:
  50979. return m.AppSecret()
  50980. case xunji.FieldToken:
  50981. return m.Token()
  50982. case xunji.FieldEncodingKey:
  50983. return m.EncodingKey()
  50984. case xunji.FieldOrganizationID:
  50985. return m.OrganizationID()
  50986. }
  50987. return nil, false
  50988. }
  50989. // OldField returns the old value of the field from the database. An error is
  50990. // returned if the mutation operation is not UpdateOne, or the query to the
  50991. // database failed.
  50992. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  50993. switch name {
  50994. case xunji.FieldCreatedAt:
  50995. return m.OldCreatedAt(ctx)
  50996. case xunji.FieldUpdatedAt:
  50997. return m.OldUpdatedAt(ctx)
  50998. case xunji.FieldStatus:
  50999. return m.OldStatus(ctx)
  51000. case xunji.FieldDeletedAt:
  51001. return m.OldDeletedAt(ctx)
  51002. case xunji.FieldAppKey:
  51003. return m.OldAppKey(ctx)
  51004. case xunji.FieldAppSecret:
  51005. return m.OldAppSecret(ctx)
  51006. case xunji.FieldToken:
  51007. return m.OldToken(ctx)
  51008. case xunji.FieldEncodingKey:
  51009. return m.OldEncodingKey(ctx)
  51010. case xunji.FieldOrganizationID:
  51011. return m.OldOrganizationID(ctx)
  51012. }
  51013. return nil, fmt.Errorf("unknown Xunji field %s", name)
  51014. }
  51015. // SetField sets the value of a field with the given name. It returns an error if
  51016. // the field is not defined in the schema, or if the type mismatched the field
  51017. // type.
  51018. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  51019. switch name {
  51020. case xunji.FieldCreatedAt:
  51021. v, ok := value.(time.Time)
  51022. if !ok {
  51023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51024. }
  51025. m.SetCreatedAt(v)
  51026. return nil
  51027. case xunji.FieldUpdatedAt:
  51028. v, ok := value.(time.Time)
  51029. if !ok {
  51030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51031. }
  51032. m.SetUpdatedAt(v)
  51033. return nil
  51034. case xunji.FieldStatus:
  51035. v, ok := value.(uint8)
  51036. if !ok {
  51037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51038. }
  51039. m.SetStatus(v)
  51040. return nil
  51041. case xunji.FieldDeletedAt:
  51042. v, ok := value.(time.Time)
  51043. if !ok {
  51044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51045. }
  51046. m.SetDeletedAt(v)
  51047. return nil
  51048. case xunji.FieldAppKey:
  51049. v, ok := value.(string)
  51050. if !ok {
  51051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51052. }
  51053. m.SetAppKey(v)
  51054. return nil
  51055. case xunji.FieldAppSecret:
  51056. v, ok := value.(string)
  51057. if !ok {
  51058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51059. }
  51060. m.SetAppSecret(v)
  51061. return nil
  51062. case xunji.FieldToken:
  51063. v, ok := value.(string)
  51064. if !ok {
  51065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51066. }
  51067. m.SetToken(v)
  51068. return nil
  51069. case xunji.FieldEncodingKey:
  51070. v, ok := value.(string)
  51071. if !ok {
  51072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51073. }
  51074. m.SetEncodingKey(v)
  51075. return nil
  51076. case xunji.FieldOrganizationID:
  51077. v, ok := value.(uint64)
  51078. if !ok {
  51079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51080. }
  51081. m.SetOrganizationID(v)
  51082. return nil
  51083. }
  51084. return fmt.Errorf("unknown Xunji field %s", name)
  51085. }
  51086. // AddedFields returns all numeric fields that were incremented/decremented during
  51087. // this mutation.
  51088. func (m *XunjiMutation) AddedFields() []string {
  51089. var fields []string
  51090. if m.addstatus != nil {
  51091. fields = append(fields, xunji.FieldStatus)
  51092. }
  51093. if m.addorganization_id != nil {
  51094. fields = append(fields, xunji.FieldOrganizationID)
  51095. }
  51096. return fields
  51097. }
  51098. // AddedField returns the numeric value that was incremented/decremented on a field
  51099. // with the given name. The second boolean return value indicates that this field
  51100. // was not set, or was not defined in the schema.
  51101. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  51102. switch name {
  51103. case xunji.FieldStatus:
  51104. return m.AddedStatus()
  51105. case xunji.FieldOrganizationID:
  51106. return m.AddedOrganizationID()
  51107. }
  51108. return nil, false
  51109. }
  51110. // AddField adds the value to the field with the given name. It returns an error if
  51111. // the field is not defined in the schema, or if the type mismatched the field
  51112. // type.
  51113. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  51114. switch name {
  51115. case xunji.FieldStatus:
  51116. v, ok := value.(int8)
  51117. if !ok {
  51118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51119. }
  51120. m.AddStatus(v)
  51121. return nil
  51122. case xunji.FieldOrganizationID:
  51123. v, ok := value.(int64)
  51124. if !ok {
  51125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51126. }
  51127. m.AddOrganizationID(v)
  51128. return nil
  51129. }
  51130. return fmt.Errorf("unknown Xunji numeric field %s", name)
  51131. }
  51132. // ClearedFields returns all nullable fields that were cleared during this
  51133. // mutation.
  51134. func (m *XunjiMutation) ClearedFields() []string {
  51135. var fields []string
  51136. if m.FieldCleared(xunji.FieldStatus) {
  51137. fields = append(fields, xunji.FieldStatus)
  51138. }
  51139. if m.FieldCleared(xunji.FieldDeletedAt) {
  51140. fields = append(fields, xunji.FieldDeletedAt)
  51141. }
  51142. if m.FieldCleared(xunji.FieldAppKey) {
  51143. fields = append(fields, xunji.FieldAppKey)
  51144. }
  51145. if m.FieldCleared(xunji.FieldAppSecret) {
  51146. fields = append(fields, xunji.FieldAppSecret)
  51147. }
  51148. if m.FieldCleared(xunji.FieldToken) {
  51149. fields = append(fields, xunji.FieldToken)
  51150. }
  51151. if m.FieldCleared(xunji.FieldEncodingKey) {
  51152. fields = append(fields, xunji.FieldEncodingKey)
  51153. }
  51154. return fields
  51155. }
  51156. // FieldCleared returns a boolean indicating if a field with the given name was
  51157. // cleared in this mutation.
  51158. func (m *XunjiMutation) FieldCleared(name string) bool {
  51159. _, ok := m.clearedFields[name]
  51160. return ok
  51161. }
  51162. // ClearField clears the value of the field with the given name. It returns an
  51163. // error if the field is not defined in the schema.
  51164. func (m *XunjiMutation) ClearField(name string) error {
  51165. switch name {
  51166. case xunji.FieldStatus:
  51167. m.ClearStatus()
  51168. return nil
  51169. case xunji.FieldDeletedAt:
  51170. m.ClearDeletedAt()
  51171. return nil
  51172. case xunji.FieldAppKey:
  51173. m.ClearAppKey()
  51174. return nil
  51175. case xunji.FieldAppSecret:
  51176. m.ClearAppSecret()
  51177. return nil
  51178. case xunji.FieldToken:
  51179. m.ClearToken()
  51180. return nil
  51181. case xunji.FieldEncodingKey:
  51182. m.ClearEncodingKey()
  51183. return nil
  51184. }
  51185. return fmt.Errorf("unknown Xunji nullable field %s", name)
  51186. }
  51187. // ResetField resets all changes in the mutation for the field with the given name.
  51188. // It returns an error if the field is not defined in the schema.
  51189. func (m *XunjiMutation) ResetField(name string) error {
  51190. switch name {
  51191. case xunji.FieldCreatedAt:
  51192. m.ResetCreatedAt()
  51193. return nil
  51194. case xunji.FieldUpdatedAt:
  51195. m.ResetUpdatedAt()
  51196. return nil
  51197. case xunji.FieldStatus:
  51198. m.ResetStatus()
  51199. return nil
  51200. case xunji.FieldDeletedAt:
  51201. m.ResetDeletedAt()
  51202. return nil
  51203. case xunji.FieldAppKey:
  51204. m.ResetAppKey()
  51205. return nil
  51206. case xunji.FieldAppSecret:
  51207. m.ResetAppSecret()
  51208. return nil
  51209. case xunji.FieldToken:
  51210. m.ResetToken()
  51211. return nil
  51212. case xunji.FieldEncodingKey:
  51213. m.ResetEncodingKey()
  51214. return nil
  51215. case xunji.FieldOrganizationID:
  51216. m.ResetOrganizationID()
  51217. return nil
  51218. }
  51219. return fmt.Errorf("unknown Xunji field %s", name)
  51220. }
  51221. // AddedEdges returns all edge names that were set/added in this mutation.
  51222. func (m *XunjiMutation) AddedEdges() []string {
  51223. edges := make([]string, 0, 0)
  51224. return edges
  51225. }
  51226. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  51227. // name in this mutation.
  51228. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  51229. return nil
  51230. }
  51231. // RemovedEdges returns all edge names that were removed in this mutation.
  51232. func (m *XunjiMutation) RemovedEdges() []string {
  51233. edges := make([]string, 0, 0)
  51234. return edges
  51235. }
  51236. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  51237. // the given name in this mutation.
  51238. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  51239. return nil
  51240. }
  51241. // ClearedEdges returns all edge names that were cleared in this mutation.
  51242. func (m *XunjiMutation) ClearedEdges() []string {
  51243. edges := make([]string, 0, 0)
  51244. return edges
  51245. }
  51246. // EdgeCleared returns a boolean which indicates if the edge with the given name
  51247. // was cleared in this mutation.
  51248. func (m *XunjiMutation) EdgeCleared(name string) bool {
  51249. return false
  51250. }
  51251. // ClearEdge clears the value of the edge with the given name. It returns an error
  51252. // if that edge is not defined in the schema.
  51253. func (m *XunjiMutation) ClearEdge(name string) error {
  51254. return fmt.Errorf("unknown Xunji unique edge %s", name)
  51255. }
  51256. // ResetEdge resets all changes to the edge with the given name in this mutation.
  51257. // It returns an error if the edge is not defined in the schema.
  51258. func (m *XunjiMutation) ResetEdge(name string) error {
  51259. return fmt.Errorf("unknown Xunji edge %s", name)
  51260. }
  51261. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  51262. type XunjiServiceMutation struct {
  51263. config
  51264. op Op
  51265. typ string
  51266. id *uint64
  51267. created_at *time.Time
  51268. updated_at *time.Time
  51269. status *uint8
  51270. addstatus *int8
  51271. deleted_at *time.Time
  51272. xunji_id *uint64
  51273. addxunji_id *int64
  51274. organization_id *uint64
  51275. addorganization_id *int64
  51276. wxid *string
  51277. api_base *string
  51278. api_key *string
  51279. clearedFields map[string]struct{}
  51280. agent *uint64
  51281. clearedagent bool
  51282. done bool
  51283. oldValue func(context.Context) (*XunjiService, error)
  51284. predicates []predicate.XunjiService
  51285. }
  51286. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  51287. // xunjiserviceOption allows management of the mutation configuration using functional options.
  51288. type xunjiserviceOption func(*XunjiServiceMutation)
  51289. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  51290. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  51291. m := &XunjiServiceMutation{
  51292. config: c,
  51293. op: op,
  51294. typ: TypeXunjiService,
  51295. clearedFields: make(map[string]struct{}),
  51296. }
  51297. for _, opt := range opts {
  51298. opt(m)
  51299. }
  51300. return m
  51301. }
  51302. // withXunjiServiceID sets the ID field of the mutation.
  51303. func withXunjiServiceID(id uint64) xunjiserviceOption {
  51304. return func(m *XunjiServiceMutation) {
  51305. var (
  51306. err error
  51307. once sync.Once
  51308. value *XunjiService
  51309. )
  51310. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  51311. once.Do(func() {
  51312. if m.done {
  51313. err = errors.New("querying old values post mutation is not allowed")
  51314. } else {
  51315. value, err = m.Client().XunjiService.Get(ctx, id)
  51316. }
  51317. })
  51318. return value, err
  51319. }
  51320. m.id = &id
  51321. }
  51322. }
  51323. // withXunjiService sets the old XunjiService of the mutation.
  51324. func withXunjiService(node *XunjiService) xunjiserviceOption {
  51325. return func(m *XunjiServiceMutation) {
  51326. m.oldValue = func(context.Context) (*XunjiService, error) {
  51327. return node, nil
  51328. }
  51329. m.id = &node.ID
  51330. }
  51331. }
  51332. // Client returns a new `ent.Client` from the mutation. If the mutation was
  51333. // executed in a transaction (ent.Tx), a transactional client is returned.
  51334. func (m XunjiServiceMutation) Client() *Client {
  51335. client := &Client{config: m.config}
  51336. client.init()
  51337. return client
  51338. }
  51339. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  51340. // it returns an error otherwise.
  51341. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  51342. if _, ok := m.driver.(*txDriver); !ok {
  51343. return nil, errors.New("ent: mutation is not running in a transaction")
  51344. }
  51345. tx := &Tx{config: m.config}
  51346. tx.init()
  51347. return tx, nil
  51348. }
  51349. // SetID sets the value of the id field. Note that this
  51350. // operation is only accepted on creation of XunjiService entities.
  51351. func (m *XunjiServiceMutation) SetID(id uint64) {
  51352. m.id = &id
  51353. }
  51354. // ID returns the ID value in the mutation. Note that the ID is only available
  51355. // if it was provided to the builder or after it was returned from the database.
  51356. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  51357. if m.id == nil {
  51358. return
  51359. }
  51360. return *m.id, true
  51361. }
  51362. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  51363. // That means, if the mutation is applied within a transaction with an isolation level such
  51364. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  51365. // or updated by the mutation.
  51366. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  51367. switch {
  51368. case m.op.Is(OpUpdateOne | OpDeleteOne):
  51369. id, exists := m.ID()
  51370. if exists {
  51371. return []uint64{id}, nil
  51372. }
  51373. fallthrough
  51374. case m.op.Is(OpUpdate | OpDelete):
  51375. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  51376. default:
  51377. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  51378. }
  51379. }
  51380. // SetCreatedAt sets the "created_at" field.
  51381. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  51382. m.created_at = &t
  51383. }
  51384. // CreatedAt returns the value of the "created_at" field in the mutation.
  51385. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  51386. v := m.created_at
  51387. if v == nil {
  51388. return
  51389. }
  51390. return *v, true
  51391. }
  51392. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  51393. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51395. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  51396. if !m.op.Is(OpUpdateOne) {
  51397. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  51398. }
  51399. if m.id == nil || m.oldValue == nil {
  51400. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  51401. }
  51402. oldValue, err := m.oldValue(ctx)
  51403. if err != nil {
  51404. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  51405. }
  51406. return oldValue.CreatedAt, nil
  51407. }
  51408. // ResetCreatedAt resets all changes to the "created_at" field.
  51409. func (m *XunjiServiceMutation) ResetCreatedAt() {
  51410. m.created_at = nil
  51411. }
  51412. // SetUpdatedAt sets the "updated_at" field.
  51413. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  51414. m.updated_at = &t
  51415. }
  51416. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  51417. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  51418. v := m.updated_at
  51419. if v == nil {
  51420. return
  51421. }
  51422. return *v, true
  51423. }
  51424. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  51425. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51427. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  51428. if !m.op.Is(OpUpdateOne) {
  51429. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  51430. }
  51431. if m.id == nil || m.oldValue == nil {
  51432. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  51433. }
  51434. oldValue, err := m.oldValue(ctx)
  51435. if err != nil {
  51436. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  51437. }
  51438. return oldValue.UpdatedAt, nil
  51439. }
  51440. // ResetUpdatedAt resets all changes to the "updated_at" field.
  51441. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  51442. m.updated_at = nil
  51443. }
  51444. // SetStatus sets the "status" field.
  51445. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  51446. m.status = &u
  51447. m.addstatus = nil
  51448. }
  51449. // Status returns the value of the "status" field in the mutation.
  51450. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  51451. v := m.status
  51452. if v == nil {
  51453. return
  51454. }
  51455. return *v, true
  51456. }
  51457. // OldStatus returns the old "status" field's value of the XunjiService entity.
  51458. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51460. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  51461. if !m.op.Is(OpUpdateOne) {
  51462. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  51463. }
  51464. if m.id == nil || m.oldValue == nil {
  51465. return v, errors.New("OldStatus requires an ID field in the mutation")
  51466. }
  51467. oldValue, err := m.oldValue(ctx)
  51468. if err != nil {
  51469. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  51470. }
  51471. return oldValue.Status, nil
  51472. }
  51473. // AddStatus adds u to the "status" field.
  51474. func (m *XunjiServiceMutation) AddStatus(u int8) {
  51475. if m.addstatus != nil {
  51476. *m.addstatus += u
  51477. } else {
  51478. m.addstatus = &u
  51479. }
  51480. }
  51481. // AddedStatus returns the value that was added to the "status" field in this mutation.
  51482. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  51483. v := m.addstatus
  51484. if v == nil {
  51485. return
  51486. }
  51487. return *v, true
  51488. }
  51489. // ClearStatus clears the value of the "status" field.
  51490. func (m *XunjiServiceMutation) ClearStatus() {
  51491. m.status = nil
  51492. m.addstatus = nil
  51493. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  51494. }
  51495. // StatusCleared returns if the "status" field was cleared in this mutation.
  51496. func (m *XunjiServiceMutation) StatusCleared() bool {
  51497. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  51498. return ok
  51499. }
  51500. // ResetStatus resets all changes to the "status" field.
  51501. func (m *XunjiServiceMutation) ResetStatus() {
  51502. m.status = nil
  51503. m.addstatus = nil
  51504. delete(m.clearedFields, xunjiservice.FieldStatus)
  51505. }
  51506. // SetDeletedAt sets the "deleted_at" field.
  51507. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  51508. m.deleted_at = &t
  51509. }
  51510. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  51511. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  51512. v := m.deleted_at
  51513. if v == nil {
  51514. return
  51515. }
  51516. return *v, true
  51517. }
  51518. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  51519. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51521. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  51522. if !m.op.Is(OpUpdateOne) {
  51523. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  51524. }
  51525. if m.id == nil || m.oldValue == nil {
  51526. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  51527. }
  51528. oldValue, err := m.oldValue(ctx)
  51529. if err != nil {
  51530. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  51531. }
  51532. return oldValue.DeletedAt, nil
  51533. }
  51534. // ClearDeletedAt clears the value of the "deleted_at" field.
  51535. func (m *XunjiServiceMutation) ClearDeletedAt() {
  51536. m.deleted_at = nil
  51537. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  51538. }
  51539. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  51540. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  51541. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  51542. return ok
  51543. }
  51544. // ResetDeletedAt resets all changes to the "deleted_at" field.
  51545. func (m *XunjiServiceMutation) ResetDeletedAt() {
  51546. m.deleted_at = nil
  51547. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  51548. }
  51549. // SetXunjiID sets the "xunji_id" field.
  51550. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  51551. m.xunji_id = &u
  51552. m.addxunji_id = nil
  51553. }
  51554. // XunjiID returns the value of the "xunji_id" field in the mutation.
  51555. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  51556. v := m.xunji_id
  51557. if v == nil {
  51558. return
  51559. }
  51560. return *v, true
  51561. }
  51562. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  51563. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51565. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  51566. if !m.op.Is(OpUpdateOne) {
  51567. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  51568. }
  51569. if m.id == nil || m.oldValue == nil {
  51570. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  51571. }
  51572. oldValue, err := m.oldValue(ctx)
  51573. if err != nil {
  51574. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  51575. }
  51576. return oldValue.XunjiID, nil
  51577. }
  51578. // AddXunjiID adds u to the "xunji_id" field.
  51579. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  51580. if m.addxunji_id != nil {
  51581. *m.addxunji_id += u
  51582. } else {
  51583. m.addxunji_id = &u
  51584. }
  51585. }
  51586. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  51587. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  51588. v := m.addxunji_id
  51589. if v == nil {
  51590. return
  51591. }
  51592. return *v, true
  51593. }
  51594. // ResetXunjiID resets all changes to the "xunji_id" field.
  51595. func (m *XunjiServiceMutation) ResetXunjiID() {
  51596. m.xunji_id = nil
  51597. m.addxunji_id = nil
  51598. }
  51599. // SetAgentID sets the "agent_id" field.
  51600. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  51601. m.agent = &u
  51602. }
  51603. // AgentID returns the value of the "agent_id" field in the mutation.
  51604. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  51605. v := m.agent
  51606. if v == nil {
  51607. return
  51608. }
  51609. return *v, true
  51610. }
  51611. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  51612. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51614. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  51615. if !m.op.Is(OpUpdateOne) {
  51616. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  51617. }
  51618. if m.id == nil || m.oldValue == nil {
  51619. return v, errors.New("OldAgentID requires an ID field in the mutation")
  51620. }
  51621. oldValue, err := m.oldValue(ctx)
  51622. if err != nil {
  51623. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  51624. }
  51625. return oldValue.AgentID, nil
  51626. }
  51627. // ResetAgentID resets all changes to the "agent_id" field.
  51628. func (m *XunjiServiceMutation) ResetAgentID() {
  51629. m.agent = nil
  51630. }
  51631. // SetOrganizationID sets the "organization_id" field.
  51632. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  51633. m.organization_id = &u
  51634. m.addorganization_id = nil
  51635. }
  51636. // OrganizationID returns the value of the "organization_id" field in the mutation.
  51637. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  51638. v := m.organization_id
  51639. if v == nil {
  51640. return
  51641. }
  51642. return *v, true
  51643. }
  51644. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  51645. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51647. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  51648. if !m.op.Is(OpUpdateOne) {
  51649. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  51650. }
  51651. if m.id == nil || m.oldValue == nil {
  51652. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  51653. }
  51654. oldValue, err := m.oldValue(ctx)
  51655. if err != nil {
  51656. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  51657. }
  51658. return oldValue.OrganizationID, nil
  51659. }
  51660. // AddOrganizationID adds u to the "organization_id" field.
  51661. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  51662. if m.addorganization_id != nil {
  51663. *m.addorganization_id += u
  51664. } else {
  51665. m.addorganization_id = &u
  51666. }
  51667. }
  51668. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  51669. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  51670. v := m.addorganization_id
  51671. if v == nil {
  51672. return
  51673. }
  51674. return *v, true
  51675. }
  51676. // ResetOrganizationID resets all changes to the "organization_id" field.
  51677. func (m *XunjiServiceMutation) ResetOrganizationID() {
  51678. m.organization_id = nil
  51679. m.addorganization_id = nil
  51680. }
  51681. // SetWxid sets the "wxid" field.
  51682. func (m *XunjiServiceMutation) SetWxid(s string) {
  51683. m.wxid = &s
  51684. }
  51685. // Wxid returns the value of the "wxid" field in the mutation.
  51686. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  51687. v := m.wxid
  51688. if v == nil {
  51689. return
  51690. }
  51691. return *v, true
  51692. }
  51693. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  51694. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51696. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  51697. if !m.op.Is(OpUpdateOne) {
  51698. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  51699. }
  51700. if m.id == nil || m.oldValue == nil {
  51701. return v, errors.New("OldWxid requires an ID field in the mutation")
  51702. }
  51703. oldValue, err := m.oldValue(ctx)
  51704. if err != nil {
  51705. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  51706. }
  51707. return oldValue.Wxid, nil
  51708. }
  51709. // ResetWxid resets all changes to the "wxid" field.
  51710. func (m *XunjiServiceMutation) ResetWxid() {
  51711. m.wxid = nil
  51712. }
  51713. // SetAPIBase sets the "api_base" field.
  51714. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  51715. m.api_base = &s
  51716. }
  51717. // APIBase returns the value of the "api_base" field in the mutation.
  51718. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  51719. v := m.api_base
  51720. if v == nil {
  51721. return
  51722. }
  51723. return *v, true
  51724. }
  51725. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  51726. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51728. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  51729. if !m.op.Is(OpUpdateOne) {
  51730. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  51731. }
  51732. if m.id == nil || m.oldValue == nil {
  51733. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  51734. }
  51735. oldValue, err := m.oldValue(ctx)
  51736. if err != nil {
  51737. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  51738. }
  51739. return oldValue.APIBase, nil
  51740. }
  51741. // ClearAPIBase clears the value of the "api_base" field.
  51742. func (m *XunjiServiceMutation) ClearAPIBase() {
  51743. m.api_base = nil
  51744. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  51745. }
  51746. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  51747. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  51748. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  51749. return ok
  51750. }
  51751. // ResetAPIBase resets all changes to the "api_base" field.
  51752. func (m *XunjiServiceMutation) ResetAPIBase() {
  51753. m.api_base = nil
  51754. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  51755. }
  51756. // SetAPIKey sets the "api_key" field.
  51757. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  51758. m.api_key = &s
  51759. }
  51760. // APIKey returns the value of the "api_key" field in the mutation.
  51761. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  51762. v := m.api_key
  51763. if v == nil {
  51764. return
  51765. }
  51766. return *v, true
  51767. }
  51768. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  51769. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  51770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51771. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  51772. if !m.op.Is(OpUpdateOne) {
  51773. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  51774. }
  51775. if m.id == nil || m.oldValue == nil {
  51776. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  51777. }
  51778. oldValue, err := m.oldValue(ctx)
  51779. if err != nil {
  51780. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  51781. }
  51782. return oldValue.APIKey, nil
  51783. }
  51784. // ClearAPIKey clears the value of the "api_key" field.
  51785. func (m *XunjiServiceMutation) ClearAPIKey() {
  51786. m.api_key = nil
  51787. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  51788. }
  51789. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  51790. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  51791. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  51792. return ok
  51793. }
  51794. // ResetAPIKey resets all changes to the "api_key" field.
  51795. func (m *XunjiServiceMutation) ResetAPIKey() {
  51796. m.api_key = nil
  51797. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  51798. }
  51799. // ClearAgent clears the "agent" edge to the Agent entity.
  51800. func (m *XunjiServiceMutation) ClearAgent() {
  51801. m.clearedagent = true
  51802. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  51803. }
  51804. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  51805. func (m *XunjiServiceMutation) AgentCleared() bool {
  51806. return m.clearedagent
  51807. }
  51808. // AgentIDs returns the "agent" edge IDs in the mutation.
  51809. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  51810. // AgentID instead. It exists only for internal usage by the builders.
  51811. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  51812. if id := m.agent; id != nil {
  51813. ids = append(ids, *id)
  51814. }
  51815. return
  51816. }
  51817. // ResetAgent resets all changes to the "agent" edge.
  51818. func (m *XunjiServiceMutation) ResetAgent() {
  51819. m.agent = nil
  51820. m.clearedagent = false
  51821. }
  51822. // Where appends a list predicates to the XunjiServiceMutation builder.
  51823. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  51824. m.predicates = append(m.predicates, ps...)
  51825. }
  51826. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  51827. // users can use type-assertion to append predicates that do not depend on any generated package.
  51828. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  51829. p := make([]predicate.XunjiService, len(ps))
  51830. for i := range ps {
  51831. p[i] = ps[i]
  51832. }
  51833. m.Where(p...)
  51834. }
  51835. // Op returns the operation name.
  51836. func (m *XunjiServiceMutation) Op() Op {
  51837. return m.op
  51838. }
  51839. // SetOp allows setting the mutation operation.
  51840. func (m *XunjiServiceMutation) SetOp(op Op) {
  51841. m.op = op
  51842. }
  51843. // Type returns the node type of this mutation (XunjiService).
  51844. func (m *XunjiServiceMutation) Type() string {
  51845. return m.typ
  51846. }
  51847. // Fields returns all fields that were changed during this mutation. Note that in
  51848. // order to get all numeric fields that were incremented/decremented, call
  51849. // AddedFields().
  51850. func (m *XunjiServiceMutation) Fields() []string {
  51851. fields := make([]string, 0, 10)
  51852. if m.created_at != nil {
  51853. fields = append(fields, xunjiservice.FieldCreatedAt)
  51854. }
  51855. if m.updated_at != nil {
  51856. fields = append(fields, xunjiservice.FieldUpdatedAt)
  51857. }
  51858. if m.status != nil {
  51859. fields = append(fields, xunjiservice.FieldStatus)
  51860. }
  51861. if m.deleted_at != nil {
  51862. fields = append(fields, xunjiservice.FieldDeletedAt)
  51863. }
  51864. if m.xunji_id != nil {
  51865. fields = append(fields, xunjiservice.FieldXunjiID)
  51866. }
  51867. if m.agent != nil {
  51868. fields = append(fields, xunjiservice.FieldAgentID)
  51869. }
  51870. if m.organization_id != nil {
  51871. fields = append(fields, xunjiservice.FieldOrganizationID)
  51872. }
  51873. if m.wxid != nil {
  51874. fields = append(fields, xunjiservice.FieldWxid)
  51875. }
  51876. if m.api_base != nil {
  51877. fields = append(fields, xunjiservice.FieldAPIBase)
  51878. }
  51879. if m.api_key != nil {
  51880. fields = append(fields, xunjiservice.FieldAPIKey)
  51881. }
  51882. return fields
  51883. }
  51884. // Field returns the value of a field with the given name. The second boolean
  51885. // return value indicates that this field was not set, or was not defined in the
  51886. // schema.
  51887. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  51888. switch name {
  51889. case xunjiservice.FieldCreatedAt:
  51890. return m.CreatedAt()
  51891. case xunjiservice.FieldUpdatedAt:
  51892. return m.UpdatedAt()
  51893. case xunjiservice.FieldStatus:
  51894. return m.Status()
  51895. case xunjiservice.FieldDeletedAt:
  51896. return m.DeletedAt()
  51897. case xunjiservice.FieldXunjiID:
  51898. return m.XunjiID()
  51899. case xunjiservice.FieldAgentID:
  51900. return m.AgentID()
  51901. case xunjiservice.FieldOrganizationID:
  51902. return m.OrganizationID()
  51903. case xunjiservice.FieldWxid:
  51904. return m.Wxid()
  51905. case xunjiservice.FieldAPIBase:
  51906. return m.APIBase()
  51907. case xunjiservice.FieldAPIKey:
  51908. return m.APIKey()
  51909. }
  51910. return nil, false
  51911. }
  51912. // OldField returns the old value of the field from the database. An error is
  51913. // returned if the mutation operation is not UpdateOne, or the query to the
  51914. // database failed.
  51915. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  51916. switch name {
  51917. case xunjiservice.FieldCreatedAt:
  51918. return m.OldCreatedAt(ctx)
  51919. case xunjiservice.FieldUpdatedAt:
  51920. return m.OldUpdatedAt(ctx)
  51921. case xunjiservice.FieldStatus:
  51922. return m.OldStatus(ctx)
  51923. case xunjiservice.FieldDeletedAt:
  51924. return m.OldDeletedAt(ctx)
  51925. case xunjiservice.FieldXunjiID:
  51926. return m.OldXunjiID(ctx)
  51927. case xunjiservice.FieldAgentID:
  51928. return m.OldAgentID(ctx)
  51929. case xunjiservice.FieldOrganizationID:
  51930. return m.OldOrganizationID(ctx)
  51931. case xunjiservice.FieldWxid:
  51932. return m.OldWxid(ctx)
  51933. case xunjiservice.FieldAPIBase:
  51934. return m.OldAPIBase(ctx)
  51935. case xunjiservice.FieldAPIKey:
  51936. return m.OldAPIKey(ctx)
  51937. }
  51938. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  51939. }
  51940. // SetField sets the value of a field with the given name. It returns an error if
  51941. // the field is not defined in the schema, or if the type mismatched the field
  51942. // type.
  51943. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  51944. switch name {
  51945. case xunjiservice.FieldCreatedAt:
  51946. v, ok := value.(time.Time)
  51947. if !ok {
  51948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51949. }
  51950. m.SetCreatedAt(v)
  51951. return nil
  51952. case xunjiservice.FieldUpdatedAt:
  51953. v, ok := value.(time.Time)
  51954. if !ok {
  51955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51956. }
  51957. m.SetUpdatedAt(v)
  51958. return nil
  51959. case xunjiservice.FieldStatus:
  51960. v, ok := value.(uint8)
  51961. if !ok {
  51962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51963. }
  51964. m.SetStatus(v)
  51965. return nil
  51966. case xunjiservice.FieldDeletedAt:
  51967. v, ok := value.(time.Time)
  51968. if !ok {
  51969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51970. }
  51971. m.SetDeletedAt(v)
  51972. return nil
  51973. case xunjiservice.FieldXunjiID:
  51974. v, ok := value.(uint64)
  51975. if !ok {
  51976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51977. }
  51978. m.SetXunjiID(v)
  51979. return nil
  51980. case xunjiservice.FieldAgentID:
  51981. v, ok := value.(uint64)
  51982. if !ok {
  51983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51984. }
  51985. m.SetAgentID(v)
  51986. return nil
  51987. case xunjiservice.FieldOrganizationID:
  51988. v, ok := value.(uint64)
  51989. if !ok {
  51990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51991. }
  51992. m.SetOrganizationID(v)
  51993. return nil
  51994. case xunjiservice.FieldWxid:
  51995. v, ok := value.(string)
  51996. if !ok {
  51997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51998. }
  51999. m.SetWxid(v)
  52000. return nil
  52001. case xunjiservice.FieldAPIBase:
  52002. v, ok := value.(string)
  52003. if !ok {
  52004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52005. }
  52006. m.SetAPIBase(v)
  52007. return nil
  52008. case xunjiservice.FieldAPIKey:
  52009. v, ok := value.(string)
  52010. if !ok {
  52011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52012. }
  52013. m.SetAPIKey(v)
  52014. return nil
  52015. }
  52016. return fmt.Errorf("unknown XunjiService field %s", name)
  52017. }
  52018. // AddedFields returns all numeric fields that were incremented/decremented during
  52019. // this mutation.
  52020. func (m *XunjiServiceMutation) AddedFields() []string {
  52021. var fields []string
  52022. if m.addstatus != nil {
  52023. fields = append(fields, xunjiservice.FieldStatus)
  52024. }
  52025. if m.addxunji_id != nil {
  52026. fields = append(fields, xunjiservice.FieldXunjiID)
  52027. }
  52028. if m.addorganization_id != nil {
  52029. fields = append(fields, xunjiservice.FieldOrganizationID)
  52030. }
  52031. return fields
  52032. }
  52033. // AddedField returns the numeric value that was incremented/decremented on a field
  52034. // with the given name. The second boolean return value indicates that this field
  52035. // was not set, or was not defined in the schema.
  52036. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  52037. switch name {
  52038. case xunjiservice.FieldStatus:
  52039. return m.AddedStatus()
  52040. case xunjiservice.FieldXunjiID:
  52041. return m.AddedXunjiID()
  52042. case xunjiservice.FieldOrganizationID:
  52043. return m.AddedOrganizationID()
  52044. }
  52045. return nil, false
  52046. }
  52047. // AddField adds the value to the field with the given name. It returns an error if
  52048. // the field is not defined in the schema, or if the type mismatched the field
  52049. // type.
  52050. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  52051. switch name {
  52052. case xunjiservice.FieldStatus:
  52053. v, ok := value.(int8)
  52054. if !ok {
  52055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52056. }
  52057. m.AddStatus(v)
  52058. return nil
  52059. case xunjiservice.FieldXunjiID:
  52060. v, ok := value.(int64)
  52061. if !ok {
  52062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52063. }
  52064. m.AddXunjiID(v)
  52065. return nil
  52066. case xunjiservice.FieldOrganizationID:
  52067. v, ok := value.(int64)
  52068. if !ok {
  52069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52070. }
  52071. m.AddOrganizationID(v)
  52072. return nil
  52073. }
  52074. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  52075. }
  52076. // ClearedFields returns all nullable fields that were cleared during this
  52077. // mutation.
  52078. func (m *XunjiServiceMutation) ClearedFields() []string {
  52079. var fields []string
  52080. if m.FieldCleared(xunjiservice.FieldStatus) {
  52081. fields = append(fields, xunjiservice.FieldStatus)
  52082. }
  52083. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  52084. fields = append(fields, xunjiservice.FieldDeletedAt)
  52085. }
  52086. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  52087. fields = append(fields, xunjiservice.FieldAPIBase)
  52088. }
  52089. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  52090. fields = append(fields, xunjiservice.FieldAPIKey)
  52091. }
  52092. return fields
  52093. }
  52094. // FieldCleared returns a boolean indicating if a field with the given name was
  52095. // cleared in this mutation.
  52096. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  52097. _, ok := m.clearedFields[name]
  52098. return ok
  52099. }
  52100. // ClearField clears the value of the field with the given name. It returns an
  52101. // error if the field is not defined in the schema.
  52102. func (m *XunjiServiceMutation) ClearField(name string) error {
  52103. switch name {
  52104. case xunjiservice.FieldStatus:
  52105. m.ClearStatus()
  52106. return nil
  52107. case xunjiservice.FieldDeletedAt:
  52108. m.ClearDeletedAt()
  52109. return nil
  52110. case xunjiservice.FieldAPIBase:
  52111. m.ClearAPIBase()
  52112. return nil
  52113. case xunjiservice.FieldAPIKey:
  52114. m.ClearAPIKey()
  52115. return nil
  52116. }
  52117. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  52118. }
  52119. // ResetField resets all changes in the mutation for the field with the given name.
  52120. // It returns an error if the field is not defined in the schema.
  52121. func (m *XunjiServiceMutation) ResetField(name string) error {
  52122. switch name {
  52123. case xunjiservice.FieldCreatedAt:
  52124. m.ResetCreatedAt()
  52125. return nil
  52126. case xunjiservice.FieldUpdatedAt:
  52127. m.ResetUpdatedAt()
  52128. return nil
  52129. case xunjiservice.FieldStatus:
  52130. m.ResetStatus()
  52131. return nil
  52132. case xunjiservice.FieldDeletedAt:
  52133. m.ResetDeletedAt()
  52134. return nil
  52135. case xunjiservice.FieldXunjiID:
  52136. m.ResetXunjiID()
  52137. return nil
  52138. case xunjiservice.FieldAgentID:
  52139. m.ResetAgentID()
  52140. return nil
  52141. case xunjiservice.FieldOrganizationID:
  52142. m.ResetOrganizationID()
  52143. return nil
  52144. case xunjiservice.FieldWxid:
  52145. m.ResetWxid()
  52146. return nil
  52147. case xunjiservice.FieldAPIBase:
  52148. m.ResetAPIBase()
  52149. return nil
  52150. case xunjiservice.FieldAPIKey:
  52151. m.ResetAPIKey()
  52152. return nil
  52153. }
  52154. return fmt.Errorf("unknown XunjiService field %s", name)
  52155. }
  52156. // AddedEdges returns all edge names that were set/added in this mutation.
  52157. func (m *XunjiServiceMutation) AddedEdges() []string {
  52158. edges := make([]string, 0, 1)
  52159. if m.agent != nil {
  52160. edges = append(edges, xunjiservice.EdgeAgent)
  52161. }
  52162. return edges
  52163. }
  52164. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  52165. // name in this mutation.
  52166. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  52167. switch name {
  52168. case xunjiservice.EdgeAgent:
  52169. if id := m.agent; id != nil {
  52170. return []ent.Value{*id}
  52171. }
  52172. }
  52173. return nil
  52174. }
  52175. // RemovedEdges returns all edge names that were removed in this mutation.
  52176. func (m *XunjiServiceMutation) RemovedEdges() []string {
  52177. edges := make([]string, 0, 1)
  52178. return edges
  52179. }
  52180. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  52181. // the given name in this mutation.
  52182. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  52183. return nil
  52184. }
  52185. // ClearedEdges returns all edge names that were cleared in this mutation.
  52186. func (m *XunjiServiceMutation) ClearedEdges() []string {
  52187. edges := make([]string, 0, 1)
  52188. if m.clearedagent {
  52189. edges = append(edges, xunjiservice.EdgeAgent)
  52190. }
  52191. return edges
  52192. }
  52193. // EdgeCleared returns a boolean which indicates if the edge with the given name
  52194. // was cleared in this mutation.
  52195. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  52196. switch name {
  52197. case xunjiservice.EdgeAgent:
  52198. return m.clearedagent
  52199. }
  52200. return false
  52201. }
  52202. // ClearEdge clears the value of the edge with the given name. It returns an error
  52203. // if that edge is not defined in the schema.
  52204. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  52205. switch name {
  52206. case xunjiservice.EdgeAgent:
  52207. m.ClearAgent()
  52208. return nil
  52209. }
  52210. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  52211. }
  52212. // ResetEdge resets all changes to the edge with the given name in this mutation.
  52213. // It returns an error if the edge is not defined in the schema.
  52214. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  52215. switch name {
  52216. case xunjiservice.EdgeAgent:
  52217. m.ResetAgent()
  52218. return nil
  52219. }
  52220. return fmt.Errorf("unknown XunjiService edge %s", name)
  52221. }