mutation.go 1.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290
  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/batchmsg"
  14. "wechat-api/ent/category"
  15. "wechat-api/ent/chatrecords"
  16. "wechat-api/ent/chatsession"
  17. "wechat-api/ent/contact"
  18. "wechat-api/ent/custom_types"
  19. "wechat-api/ent/employee"
  20. "wechat-api/ent/employeeconfig"
  21. "wechat-api/ent/label"
  22. "wechat-api/ent/labelrelationship"
  23. "wechat-api/ent/message"
  24. "wechat-api/ent/messagerecords"
  25. "wechat-api/ent/msg"
  26. "wechat-api/ent/predicate"
  27. "wechat-api/ent/server"
  28. "wechat-api/ent/sopnode"
  29. "wechat-api/ent/sopstage"
  30. "wechat-api/ent/soptask"
  31. "wechat-api/ent/token"
  32. "wechat-api/ent/tutorial"
  33. "wechat-api/ent/usagedetail"
  34. "wechat-api/ent/usagetotal"
  35. "wechat-api/ent/workexperience"
  36. "wechat-api/ent/wpchatroom"
  37. "wechat-api/ent/wpchatroommember"
  38. "wechat-api/ent/wx"
  39. "wechat-api/ent/wxcard"
  40. "wechat-api/ent/wxcarduser"
  41. "wechat-api/ent/wxcardvisit"
  42. "entgo.io/ent"
  43. "entgo.io/ent/dialect/sql"
  44. )
  45. const (
  46. // Operation types.
  47. OpCreate = ent.OpCreate
  48. OpDelete = ent.OpDelete
  49. OpDeleteOne = ent.OpDeleteOne
  50. OpUpdate = ent.OpUpdate
  51. OpUpdateOne = ent.OpUpdateOne
  52. // Node types.
  53. TypeAgent = "Agent"
  54. TypeAgentBase = "AgentBase"
  55. TypeAliyunAvatar = "AliyunAvatar"
  56. TypeAllocAgent = "AllocAgent"
  57. TypeBatchMsg = "BatchMsg"
  58. TypeCategory = "Category"
  59. TypeChatRecords = "ChatRecords"
  60. TypeChatSession = "ChatSession"
  61. TypeContact = "Contact"
  62. TypeEmployee = "Employee"
  63. TypeEmployeeConfig = "EmployeeConfig"
  64. TypeLabel = "Label"
  65. TypeLabelRelationship = "LabelRelationship"
  66. TypeMessage = "Message"
  67. TypeMessageRecords = "MessageRecords"
  68. TypeMsg = "Msg"
  69. TypeServer = "Server"
  70. TypeSopNode = "SopNode"
  71. TypeSopStage = "SopStage"
  72. TypeSopTask = "SopTask"
  73. TypeToken = "Token"
  74. TypeTutorial = "Tutorial"
  75. TypeUsageDetail = "UsageDetail"
  76. TypeUsageTotal = "UsageTotal"
  77. TypeWorkExperience = "WorkExperience"
  78. TypeWpChatroom = "WpChatroom"
  79. TypeWpChatroomMember = "WpChatroomMember"
  80. TypeWx = "Wx"
  81. TypeWxCard = "WxCard"
  82. TypeWxCardUser = "WxCardUser"
  83. TypeWxCardVisit = "WxCardVisit"
  84. )
  85. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  86. type AgentMutation struct {
  87. config
  88. op Op
  89. typ string
  90. id *uint64
  91. created_at *time.Time
  92. updated_at *time.Time
  93. deleted_at *time.Time
  94. name *string
  95. role *string
  96. status *int
  97. addstatus *int
  98. background *string
  99. examples *string
  100. organization_id *uint64
  101. addorganization_id *int64
  102. dataset_id *string
  103. collection_id *string
  104. clearedFields map[string]struct{}
  105. wx_agent map[uint64]struct{}
  106. removedwx_agent map[uint64]struct{}
  107. clearedwx_agent bool
  108. token_agent map[uint64]struct{}
  109. removedtoken_agent map[uint64]struct{}
  110. clearedtoken_agent bool
  111. done bool
  112. oldValue func(context.Context) (*Agent, error)
  113. predicates []predicate.Agent
  114. }
  115. var _ ent.Mutation = (*AgentMutation)(nil)
  116. // agentOption allows management of the mutation configuration using functional options.
  117. type agentOption func(*AgentMutation)
  118. // newAgentMutation creates new mutation for the Agent entity.
  119. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  120. m := &AgentMutation{
  121. config: c,
  122. op: op,
  123. typ: TypeAgent,
  124. clearedFields: make(map[string]struct{}),
  125. }
  126. for _, opt := range opts {
  127. opt(m)
  128. }
  129. return m
  130. }
  131. // withAgentID sets the ID field of the mutation.
  132. func withAgentID(id uint64) agentOption {
  133. return func(m *AgentMutation) {
  134. var (
  135. err error
  136. once sync.Once
  137. value *Agent
  138. )
  139. m.oldValue = func(ctx context.Context) (*Agent, error) {
  140. once.Do(func() {
  141. if m.done {
  142. err = errors.New("querying old values post mutation is not allowed")
  143. } else {
  144. value, err = m.Client().Agent.Get(ctx, id)
  145. }
  146. })
  147. return value, err
  148. }
  149. m.id = &id
  150. }
  151. }
  152. // withAgent sets the old Agent of the mutation.
  153. func withAgent(node *Agent) agentOption {
  154. return func(m *AgentMutation) {
  155. m.oldValue = func(context.Context) (*Agent, error) {
  156. return node, nil
  157. }
  158. m.id = &node.ID
  159. }
  160. }
  161. // Client returns a new `ent.Client` from the mutation. If the mutation was
  162. // executed in a transaction (ent.Tx), a transactional client is returned.
  163. func (m AgentMutation) Client() *Client {
  164. client := &Client{config: m.config}
  165. client.init()
  166. return client
  167. }
  168. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  169. // it returns an error otherwise.
  170. func (m AgentMutation) Tx() (*Tx, error) {
  171. if _, ok := m.driver.(*txDriver); !ok {
  172. return nil, errors.New("ent: mutation is not running in a transaction")
  173. }
  174. tx := &Tx{config: m.config}
  175. tx.init()
  176. return tx, nil
  177. }
  178. // SetID sets the value of the id field. Note that this
  179. // operation is only accepted on creation of Agent entities.
  180. func (m *AgentMutation) SetID(id uint64) {
  181. m.id = &id
  182. }
  183. // ID returns the ID value in the mutation. Note that the ID is only available
  184. // if it was provided to the builder or after it was returned from the database.
  185. func (m *AgentMutation) ID() (id uint64, exists bool) {
  186. if m.id == nil {
  187. return
  188. }
  189. return *m.id, true
  190. }
  191. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  192. // That means, if the mutation is applied within a transaction with an isolation level such
  193. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  194. // or updated by the mutation.
  195. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  196. switch {
  197. case m.op.Is(OpUpdateOne | OpDeleteOne):
  198. id, exists := m.ID()
  199. if exists {
  200. return []uint64{id}, nil
  201. }
  202. fallthrough
  203. case m.op.Is(OpUpdate | OpDelete):
  204. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  205. default:
  206. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  207. }
  208. }
  209. // SetCreatedAt sets the "created_at" field.
  210. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  211. m.created_at = &t
  212. }
  213. // CreatedAt returns the value of the "created_at" field in the mutation.
  214. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  215. v := m.created_at
  216. if v == nil {
  217. return
  218. }
  219. return *v, true
  220. }
  221. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  222. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  224. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  225. if !m.op.Is(OpUpdateOne) {
  226. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  227. }
  228. if m.id == nil || m.oldValue == nil {
  229. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  230. }
  231. oldValue, err := m.oldValue(ctx)
  232. if err != nil {
  233. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  234. }
  235. return oldValue.CreatedAt, nil
  236. }
  237. // ResetCreatedAt resets all changes to the "created_at" field.
  238. func (m *AgentMutation) ResetCreatedAt() {
  239. m.created_at = nil
  240. }
  241. // SetUpdatedAt sets the "updated_at" field.
  242. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  243. m.updated_at = &t
  244. }
  245. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  246. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  247. v := m.updated_at
  248. if v == nil {
  249. return
  250. }
  251. return *v, true
  252. }
  253. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  254. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  256. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  257. if !m.op.Is(OpUpdateOne) {
  258. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  259. }
  260. if m.id == nil || m.oldValue == nil {
  261. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  262. }
  263. oldValue, err := m.oldValue(ctx)
  264. if err != nil {
  265. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  266. }
  267. return oldValue.UpdatedAt, nil
  268. }
  269. // ResetUpdatedAt resets all changes to the "updated_at" field.
  270. func (m *AgentMutation) ResetUpdatedAt() {
  271. m.updated_at = nil
  272. }
  273. // SetDeletedAt sets the "deleted_at" field.
  274. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  275. m.deleted_at = &t
  276. }
  277. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  278. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  279. v := m.deleted_at
  280. if v == nil {
  281. return
  282. }
  283. return *v, true
  284. }
  285. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  286. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  288. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  289. if !m.op.Is(OpUpdateOne) {
  290. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  291. }
  292. if m.id == nil || m.oldValue == nil {
  293. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  294. }
  295. oldValue, err := m.oldValue(ctx)
  296. if err != nil {
  297. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  298. }
  299. return oldValue.DeletedAt, nil
  300. }
  301. // ClearDeletedAt clears the value of the "deleted_at" field.
  302. func (m *AgentMutation) ClearDeletedAt() {
  303. m.deleted_at = nil
  304. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  305. }
  306. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  307. func (m *AgentMutation) DeletedAtCleared() bool {
  308. _, ok := m.clearedFields[agent.FieldDeletedAt]
  309. return ok
  310. }
  311. // ResetDeletedAt resets all changes to the "deleted_at" field.
  312. func (m *AgentMutation) ResetDeletedAt() {
  313. m.deleted_at = nil
  314. delete(m.clearedFields, agent.FieldDeletedAt)
  315. }
  316. // SetName sets the "name" field.
  317. func (m *AgentMutation) SetName(s string) {
  318. m.name = &s
  319. }
  320. // Name returns the value of the "name" field in the mutation.
  321. func (m *AgentMutation) Name() (r string, exists bool) {
  322. v := m.name
  323. if v == nil {
  324. return
  325. }
  326. return *v, true
  327. }
  328. // OldName returns the old "name" field's value of the Agent entity.
  329. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  331. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  332. if !m.op.Is(OpUpdateOne) {
  333. return v, errors.New("OldName is only allowed on UpdateOne operations")
  334. }
  335. if m.id == nil || m.oldValue == nil {
  336. return v, errors.New("OldName requires an ID field in the mutation")
  337. }
  338. oldValue, err := m.oldValue(ctx)
  339. if err != nil {
  340. return v, fmt.Errorf("querying old value for OldName: %w", err)
  341. }
  342. return oldValue.Name, nil
  343. }
  344. // ResetName resets all changes to the "name" field.
  345. func (m *AgentMutation) ResetName() {
  346. m.name = nil
  347. }
  348. // SetRole sets the "role" field.
  349. func (m *AgentMutation) SetRole(s string) {
  350. m.role = &s
  351. }
  352. // Role returns the value of the "role" field in the mutation.
  353. func (m *AgentMutation) Role() (r string, exists bool) {
  354. v := m.role
  355. if v == nil {
  356. return
  357. }
  358. return *v, true
  359. }
  360. // OldRole returns the old "role" field's value of the Agent entity.
  361. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  363. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  364. if !m.op.Is(OpUpdateOne) {
  365. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  366. }
  367. if m.id == nil || m.oldValue == nil {
  368. return v, errors.New("OldRole requires an ID field in the mutation")
  369. }
  370. oldValue, err := m.oldValue(ctx)
  371. if err != nil {
  372. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  373. }
  374. return oldValue.Role, nil
  375. }
  376. // ResetRole resets all changes to the "role" field.
  377. func (m *AgentMutation) ResetRole() {
  378. m.role = nil
  379. }
  380. // SetStatus sets the "status" field.
  381. func (m *AgentMutation) SetStatus(i int) {
  382. m.status = &i
  383. m.addstatus = nil
  384. }
  385. // Status returns the value of the "status" field in the mutation.
  386. func (m *AgentMutation) Status() (r int, exists bool) {
  387. v := m.status
  388. if v == nil {
  389. return
  390. }
  391. return *v, true
  392. }
  393. // OldStatus returns the old "status" field's value of the Agent entity.
  394. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  396. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  397. if !m.op.Is(OpUpdateOne) {
  398. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  399. }
  400. if m.id == nil || m.oldValue == nil {
  401. return v, errors.New("OldStatus requires an ID field in the mutation")
  402. }
  403. oldValue, err := m.oldValue(ctx)
  404. if err != nil {
  405. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  406. }
  407. return oldValue.Status, nil
  408. }
  409. // AddStatus adds i to the "status" field.
  410. func (m *AgentMutation) AddStatus(i int) {
  411. if m.addstatus != nil {
  412. *m.addstatus += i
  413. } else {
  414. m.addstatus = &i
  415. }
  416. }
  417. // AddedStatus returns the value that was added to the "status" field in this mutation.
  418. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  419. v := m.addstatus
  420. if v == nil {
  421. return
  422. }
  423. return *v, true
  424. }
  425. // ClearStatus clears the value of the "status" field.
  426. func (m *AgentMutation) ClearStatus() {
  427. m.status = nil
  428. m.addstatus = nil
  429. m.clearedFields[agent.FieldStatus] = struct{}{}
  430. }
  431. // StatusCleared returns if the "status" field was cleared in this mutation.
  432. func (m *AgentMutation) StatusCleared() bool {
  433. _, ok := m.clearedFields[agent.FieldStatus]
  434. return ok
  435. }
  436. // ResetStatus resets all changes to the "status" field.
  437. func (m *AgentMutation) ResetStatus() {
  438. m.status = nil
  439. m.addstatus = nil
  440. delete(m.clearedFields, agent.FieldStatus)
  441. }
  442. // SetBackground sets the "background" field.
  443. func (m *AgentMutation) SetBackground(s string) {
  444. m.background = &s
  445. }
  446. // Background returns the value of the "background" field in the mutation.
  447. func (m *AgentMutation) Background() (r string, exists bool) {
  448. v := m.background
  449. if v == nil {
  450. return
  451. }
  452. return *v, true
  453. }
  454. // OldBackground returns the old "background" field's value of the Agent entity.
  455. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  457. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  458. if !m.op.Is(OpUpdateOne) {
  459. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  460. }
  461. if m.id == nil || m.oldValue == nil {
  462. return v, errors.New("OldBackground requires an ID field in the mutation")
  463. }
  464. oldValue, err := m.oldValue(ctx)
  465. if err != nil {
  466. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  467. }
  468. return oldValue.Background, nil
  469. }
  470. // ClearBackground clears the value of the "background" field.
  471. func (m *AgentMutation) ClearBackground() {
  472. m.background = nil
  473. m.clearedFields[agent.FieldBackground] = struct{}{}
  474. }
  475. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  476. func (m *AgentMutation) BackgroundCleared() bool {
  477. _, ok := m.clearedFields[agent.FieldBackground]
  478. return ok
  479. }
  480. // ResetBackground resets all changes to the "background" field.
  481. func (m *AgentMutation) ResetBackground() {
  482. m.background = nil
  483. delete(m.clearedFields, agent.FieldBackground)
  484. }
  485. // SetExamples sets the "examples" field.
  486. func (m *AgentMutation) SetExamples(s string) {
  487. m.examples = &s
  488. }
  489. // Examples returns the value of the "examples" field in the mutation.
  490. func (m *AgentMutation) Examples() (r string, exists bool) {
  491. v := m.examples
  492. if v == nil {
  493. return
  494. }
  495. return *v, true
  496. }
  497. // OldExamples returns the old "examples" field's value of the Agent entity.
  498. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  500. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  501. if !m.op.Is(OpUpdateOne) {
  502. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  503. }
  504. if m.id == nil || m.oldValue == nil {
  505. return v, errors.New("OldExamples requires an ID field in the mutation")
  506. }
  507. oldValue, err := m.oldValue(ctx)
  508. if err != nil {
  509. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  510. }
  511. return oldValue.Examples, nil
  512. }
  513. // ClearExamples clears the value of the "examples" field.
  514. func (m *AgentMutation) ClearExamples() {
  515. m.examples = nil
  516. m.clearedFields[agent.FieldExamples] = struct{}{}
  517. }
  518. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  519. func (m *AgentMutation) ExamplesCleared() bool {
  520. _, ok := m.clearedFields[agent.FieldExamples]
  521. return ok
  522. }
  523. // ResetExamples resets all changes to the "examples" field.
  524. func (m *AgentMutation) ResetExamples() {
  525. m.examples = nil
  526. delete(m.clearedFields, agent.FieldExamples)
  527. }
  528. // SetOrganizationID sets the "organization_id" field.
  529. func (m *AgentMutation) SetOrganizationID(u uint64) {
  530. m.organization_id = &u
  531. m.addorganization_id = nil
  532. }
  533. // OrganizationID returns the value of the "organization_id" field in the mutation.
  534. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  535. v := m.organization_id
  536. if v == nil {
  537. return
  538. }
  539. return *v, true
  540. }
  541. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  542. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  544. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  545. if !m.op.Is(OpUpdateOne) {
  546. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  547. }
  548. if m.id == nil || m.oldValue == nil {
  549. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  550. }
  551. oldValue, err := m.oldValue(ctx)
  552. if err != nil {
  553. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  554. }
  555. return oldValue.OrganizationID, nil
  556. }
  557. // AddOrganizationID adds u to the "organization_id" field.
  558. func (m *AgentMutation) AddOrganizationID(u int64) {
  559. if m.addorganization_id != nil {
  560. *m.addorganization_id += u
  561. } else {
  562. m.addorganization_id = &u
  563. }
  564. }
  565. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  566. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  567. v := m.addorganization_id
  568. if v == nil {
  569. return
  570. }
  571. return *v, true
  572. }
  573. // ResetOrganizationID resets all changes to the "organization_id" field.
  574. func (m *AgentMutation) ResetOrganizationID() {
  575. m.organization_id = nil
  576. m.addorganization_id = nil
  577. }
  578. // SetDatasetID sets the "dataset_id" field.
  579. func (m *AgentMutation) SetDatasetID(s string) {
  580. m.dataset_id = &s
  581. }
  582. // DatasetID returns the value of the "dataset_id" field in the mutation.
  583. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  584. v := m.dataset_id
  585. if v == nil {
  586. return
  587. }
  588. return *v, true
  589. }
  590. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  591. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  593. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  594. if !m.op.Is(OpUpdateOne) {
  595. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  596. }
  597. if m.id == nil || m.oldValue == nil {
  598. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  599. }
  600. oldValue, err := m.oldValue(ctx)
  601. if err != nil {
  602. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  603. }
  604. return oldValue.DatasetID, nil
  605. }
  606. // ResetDatasetID resets all changes to the "dataset_id" field.
  607. func (m *AgentMutation) ResetDatasetID() {
  608. m.dataset_id = nil
  609. }
  610. // SetCollectionID sets the "collection_id" field.
  611. func (m *AgentMutation) SetCollectionID(s string) {
  612. m.collection_id = &s
  613. }
  614. // CollectionID returns the value of the "collection_id" field in the mutation.
  615. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  616. v := m.collection_id
  617. if v == nil {
  618. return
  619. }
  620. return *v, true
  621. }
  622. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  623. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  625. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  626. if !m.op.Is(OpUpdateOne) {
  627. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  628. }
  629. if m.id == nil || m.oldValue == nil {
  630. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  631. }
  632. oldValue, err := m.oldValue(ctx)
  633. if err != nil {
  634. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  635. }
  636. return oldValue.CollectionID, nil
  637. }
  638. // ResetCollectionID resets all changes to the "collection_id" field.
  639. func (m *AgentMutation) ResetCollectionID() {
  640. m.collection_id = nil
  641. }
  642. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  643. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  644. if m.wx_agent == nil {
  645. m.wx_agent = make(map[uint64]struct{})
  646. }
  647. for i := range ids {
  648. m.wx_agent[ids[i]] = struct{}{}
  649. }
  650. }
  651. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  652. func (m *AgentMutation) ClearWxAgent() {
  653. m.clearedwx_agent = true
  654. }
  655. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  656. func (m *AgentMutation) WxAgentCleared() bool {
  657. return m.clearedwx_agent
  658. }
  659. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  660. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  661. if m.removedwx_agent == nil {
  662. m.removedwx_agent = make(map[uint64]struct{})
  663. }
  664. for i := range ids {
  665. delete(m.wx_agent, ids[i])
  666. m.removedwx_agent[ids[i]] = struct{}{}
  667. }
  668. }
  669. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  670. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  671. for id := range m.removedwx_agent {
  672. ids = append(ids, id)
  673. }
  674. return
  675. }
  676. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  677. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  678. for id := range m.wx_agent {
  679. ids = append(ids, id)
  680. }
  681. return
  682. }
  683. // ResetWxAgent resets all changes to the "wx_agent" edge.
  684. func (m *AgentMutation) ResetWxAgent() {
  685. m.wx_agent = nil
  686. m.clearedwx_agent = false
  687. m.removedwx_agent = nil
  688. }
  689. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  690. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  691. if m.token_agent == nil {
  692. m.token_agent = make(map[uint64]struct{})
  693. }
  694. for i := range ids {
  695. m.token_agent[ids[i]] = struct{}{}
  696. }
  697. }
  698. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  699. func (m *AgentMutation) ClearTokenAgent() {
  700. m.clearedtoken_agent = true
  701. }
  702. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  703. func (m *AgentMutation) TokenAgentCleared() bool {
  704. return m.clearedtoken_agent
  705. }
  706. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  707. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  708. if m.removedtoken_agent == nil {
  709. m.removedtoken_agent = make(map[uint64]struct{})
  710. }
  711. for i := range ids {
  712. delete(m.token_agent, ids[i])
  713. m.removedtoken_agent[ids[i]] = struct{}{}
  714. }
  715. }
  716. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  717. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  718. for id := range m.removedtoken_agent {
  719. ids = append(ids, id)
  720. }
  721. return
  722. }
  723. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  724. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  725. for id := range m.token_agent {
  726. ids = append(ids, id)
  727. }
  728. return
  729. }
  730. // ResetTokenAgent resets all changes to the "token_agent" edge.
  731. func (m *AgentMutation) ResetTokenAgent() {
  732. m.token_agent = nil
  733. m.clearedtoken_agent = false
  734. m.removedtoken_agent = nil
  735. }
  736. // Where appends a list predicates to the AgentMutation builder.
  737. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  738. m.predicates = append(m.predicates, ps...)
  739. }
  740. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  741. // users can use type-assertion to append predicates that do not depend on any generated package.
  742. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  743. p := make([]predicate.Agent, len(ps))
  744. for i := range ps {
  745. p[i] = ps[i]
  746. }
  747. m.Where(p...)
  748. }
  749. // Op returns the operation name.
  750. func (m *AgentMutation) Op() Op {
  751. return m.op
  752. }
  753. // SetOp allows setting the mutation operation.
  754. func (m *AgentMutation) SetOp(op Op) {
  755. m.op = op
  756. }
  757. // Type returns the node type of this mutation (Agent).
  758. func (m *AgentMutation) Type() string {
  759. return m.typ
  760. }
  761. // Fields returns all fields that were changed during this mutation. Note that in
  762. // order to get all numeric fields that were incremented/decremented, call
  763. // AddedFields().
  764. func (m *AgentMutation) Fields() []string {
  765. fields := make([]string, 0, 11)
  766. if m.created_at != nil {
  767. fields = append(fields, agent.FieldCreatedAt)
  768. }
  769. if m.updated_at != nil {
  770. fields = append(fields, agent.FieldUpdatedAt)
  771. }
  772. if m.deleted_at != nil {
  773. fields = append(fields, agent.FieldDeletedAt)
  774. }
  775. if m.name != nil {
  776. fields = append(fields, agent.FieldName)
  777. }
  778. if m.role != nil {
  779. fields = append(fields, agent.FieldRole)
  780. }
  781. if m.status != nil {
  782. fields = append(fields, agent.FieldStatus)
  783. }
  784. if m.background != nil {
  785. fields = append(fields, agent.FieldBackground)
  786. }
  787. if m.examples != nil {
  788. fields = append(fields, agent.FieldExamples)
  789. }
  790. if m.organization_id != nil {
  791. fields = append(fields, agent.FieldOrganizationID)
  792. }
  793. if m.dataset_id != nil {
  794. fields = append(fields, agent.FieldDatasetID)
  795. }
  796. if m.collection_id != nil {
  797. fields = append(fields, agent.FieldCollectionID)
  798. }
  799. return fields
  800. }
  801. // Field returns the value of a field with the given name. The second boolean
  802. // return value indicates that this field was not set, or was not defined in the
  803. // schema.
  804. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  805. switch name {
  806. case agent.FieldCreatedAt:
  807. return m.CreatedAt()
  808. case agent.FieldUpdatedAt:
  809. return m.UpdatedAt()
  810. case agent.FieldDeletedAt:
  811. return m.DeletedAt()
  812. case agent.FieldName:
  813. return m.Name()
  814. case agent.FieldRole:
  815. return m.Role()
  816. case agent.FieldStatus:
  817. return m.Status()
  818. case agent.FieldBackground:
  819. return m.Background()
  820. case agent.FieldExamples:
  821. return m.Examples()
  822. case agent.FieldOrganizationID:
  823. return m.OrganizationID()
  824. case agent.FieldDatasetID:
  825. return m.DatasetID()
  826. case agent.FieldCollectionID:
  827. return m.CollectionID()
  828. }
  829. return nil, false
  830. }
  831. // OldField returns the old value of the field from the database. An error is
  832. // returned if the mutation operation is not UpdateOne, or the query to the
  833. // database failed.
  834. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  835. switch name {
  836. case agent.FieldCreatedAt:
  837. return m.OldCreatedAt(ctx)
  838. case agent.FieldUpdatedAt:
  839. return m.OldUpdatedAt(ctx)
  840. case agent.FieldDeletedAt:
  841. return m.OldDeletedAt(ctx)
  842. case agent.FieldName:
  843. return m.OldName(ctx)
  844. case agent.FieldRole:
  845. return m.OldRole(ctx)
  846. case agent.FieldStatus:
  847. return m.OldStatus(ctx)
  848. case agent.FieldBackground:
  849. return m.OldBackground(ctx)
  850. case agent.FieldExamples:
  851. return m.OldExamples(ctx)
  852. case agent.FieldOrganizationID:
  853. return m.OldOrganizationID(ctx)
  854. case agent.FieldDatasetID:
  855. return m.OldDatasetID(ctx)
  856. case agent.FieldCollectionID:
  857. return m.OldCollectionID(ctx)
  858. }
  859. return nil, fmt.Errorf("unknown Agent field %s", name)
  860. }
  861. // SetField sets the value of a field with the given name. It returns an error if
  862. // the field is not defined in the schema, or if the type mismatched the field
  863. // type.
  864. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  865. switch name {
  866. case agent.FieldCreatedAt:
  867. v, ok := value.(time.Time)
  868. if !ok {
  869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  870. }
  871. m.SetCreatedAt(v)
  872. return nil
  873. case agent.FieldUpdatedAt:
  874. v, ok := value.(time.Time)
  875. if !ok {
  876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  877. }
  878. m.SetUpdatedAt(v)
  879. return nil
  880. case agent.FieldDeletedAt:
  881. v, ok := value.(time.Time)
  882. if !ok {
  883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  884. }
  885. m.SetDeletedAt(v)
  886. return nil
  887. case agent.FieldName:
  888. v, ok := value.(string)
  889. if !ok {
  890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  891. }
  892. m.SetName(v)
  893. return nil
  894. case agent.FieldRole:
  895. v, ok := value.(string)
  896. if !ok {
  897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  898. }
  899. m.SetRole(v)
  900. return nil
  901. case agent.FieldStatus:
  902. v, ok := value.(int)
  903. if !ok {
  904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  905. }
  906. m.SetStatus(v)
  907. return nil
  908. case agent.FieldBackground:
  909. v, ok := value.(string)
  910. if !ok {
  911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  912. }
  913. m.SetBackground(v)
  914. return nil
  915. case agent.FieldExamples:
  916. v, ok := value.(string)
  917. if !ok {
  918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  919. }
  920. m.SetExamples(v)
  921. return nil
  922. case agent.FieldOrganizationID:
  923. v, ok := value.(uint64)
  924. if !ok {
  925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  926. }
  927. m.SetOrganizationID(v)
  928. return nil
  929. case agent.FieldDatasetID:
  930. v, ok := value.(string)
  931. if !ok {
  932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  933. }
  934. m.SetDatasetID(v)
  935. return nil
  936. case agent.FieldCollectionID:
  937. v, ok := value.(string)
  938. if !ok {
  939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  940. }
  941. m.SetCollectionID(v)
  942. return nil
  943. }
  944. return fmt.Errorf("unknown Agent field %s", name)
  945. }
  946. // AddedFields returns all numeric fields that were incremented/decremented during
  947. // this mutation.
  948. func (m *AgentMutation) AddedFields() []string {
  949. var fields []string
  950. if m.addstatus != nil {
  951. fields = append(fields, agent.FieldStatus)
  952. }
  953. if m.addorganization_id != nil {
  954. fields = append(fields, agent.FieldOrganizationID)
  955. }
  956. return fields
  957. }
  958. // AddedField returns the numeric value that was incremented/decremented on a field
  959. // with the given name. The second boolean return value indicates that this field
  960. // was not set, or was not defined in the schema.
  961. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  962. switch name {
  963. case agent.FieldStatus:
  964. return m.AddedStatus()
  965. case agent.FieldOrganizationID:
  966. return m.AddedOrganizationID()
  967. }
  968. return nil, false
  969. }
  970. // AddField adds the value to the field with the given name. It returns an error if
  971. // the field is not defined in the schema, or if the type mismatched the field
  972. // type.
  973. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  974. switch name {
  975. case agent.FieldStatus:
  976. v, ok := value.(int)
  977. if !ok {
  978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  979. }
  980. m.AddStatus(v)
  981. return nil
  982. case agent.FieldOrganizationID:
  983. v, ok := value.(int64)
  984. if !ok {
  985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  986. }
  987. m.AddOrganizationID(v)
  988. return nil
  989. }
  990. return fmt.Errorf("unknown Agent numeric field %s", name)
  991. }
  992. // ClearedFields returns all nullable fields that were cleared during this
  993. // mutation.
  994. func (m *AgentMutation) ClearedFields() []string {
  995. var fields []string
  996. if m.FieldCleared(agent.FieldDeletedAt) {
  997. fields = append(fields, agent.FieldDeletedAt)
  998. }
  999. if m.FieldCleared(agent.FieldStatus) {
  1000. fields = append(fields, agent.FieldStatus)
  1001. }
  1002. if m.FieldCleared(agent.FieldBackground) {
  1003. fields = append(fields, agent.FieldBackground)
  1004. }
  1005. if m.FieldCleared(agent.FieldExamples) {
  1006. fields = append(fields, agent.FieldExamples)
  1007. }
  1008. return fields
  1009. }
  1010. // FieldCleared returns a boolean indicating if a field with the given name was
  1011. // cleared in this mutation.
  1012. func (m *AgentMutation) FieldCleared(name string) bool {
  1013. _, ok := m.clearedFields[name]
  1014. return ok
  1015. }
  1016. // ClearField clears the value of the field with the given name. It returns an
  1017. // error if the field is not defined in the schema.
  1018. func (m *AgentMutation) ClearField(name string) error {
  1019. switch name {
  1020. case agent.FieldDeletedAt:
  1021. m.ClearDeletedAt()
  1022. return nil
  1023. case agent.FieldStatus:
  1024. m.ClearStatus()
  1025. return nil
  1026. case agent.FieldBackground:
  1027. m.ClearBackground()
  1028. return nil
  1029. case agent.FieldExamples:
  1030. m.ClearExamples()
  1031. return nil
  1032. }
  1033. return fmt.Errorf("unknown Agent nullable field %s", name)
  1034. }
  1035. // ResetField resets all changes in the mutation for the field with the given name.
  1036. // It returns an error if the field is not defined in the schema.
  1037. func (m *AgentMutation) ResetField(name string) error {
  1038. switch name {
  1039. case agent.FieldCreatedAt:
  1040. m.ResetCreatedAt()
  1041. return nil
  1042. case agent.FieldUpdatedAt:
  1043. m.ResetUpdatedAt()
  1044. return nil
  1045. case agent.FieldDeletedAt:
  1046. m.ResetDeletedAt()
  1047. return nil
  1048. case agent.FieldName:
  1049. m.ResetName()
  1050. return nil
  1051. case agent.FieldRole:
  1052. m.ResetRole()
  1053. return nil
  1054. case agent.FieldStatus:
  1055. m.ResetStatus()
  1056. return nil
  1057. case agent.FieldBackground:
  1058. m.ResetBackground()
  1059. return nil
  1060. case agent.FieldExamples:
  1061. m.ResetExamples()
  1062. return nil
  1063. case agent.FieldOrganizationID:
  1064. m.ResetOrganizationID()
  1065. return nil
  1066. case agent.FieldDatasetID:
  1067. m.ResetDatasetID()
  1068. return nil
  1069. case agent.FieldCollectionID:
  1070. m.ResetCollectionID()
  1071. return nil
  1072. }
  1073. return fmt.Errorf("unknown Agent field %s", name)
  1074. }
  1075. // AddedEdges returns all edge names that were set/added in this mutation.
  1076. func (m *AgentMutation) AddedEdges() []string {
  1077. edges := make([]string, 0, 2)
  1078. if m.wx_agent != nil {
  1079. edges = append(edges, agent.EdgeWxAgent)
  1080. }
  1081. if m.token_agent != nil {
  1082. edges = append(edges, agent.EdgeTokenAgent)
  1083. }
  1084. return edges
  1085. }
  1086. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1087. // name in this mutation.
  1088. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1089. switch name {
  1090. case agent.EdgeWxAgent:
  1091. ids := make([]ent.Value, 0, len(m.wx_agent))
  1092. for id := range m.wx_agent {
  1093. ids = append(ids, id)
  1094. }
  1095. return ids
  1096. case agent.EdgeTokenAgent:
  1097. ids := make([]ent.Value, 0, len(m.token_agent))
  1098. for id := range m.token_agent {
  1099. ids = append(ids, id)
  1100. }
  1101. return ids
  1102. }
  1103. return nil
  1104. }
  1105. // RemovedEdges returns all edge names that were removed in this mutation.
  1106. func (m *AgentMutation) RemovedEdges() []string {
  1107. edges := make([]string, 0, 2)
  1108. if m.removedwx_agent != nil {
  1109. edges = append(edges, agent.EdgeWxAgent)
  1110. }
  1111. if m.removedtoken_agent != nil {
  1112. edges = append(edges, agent.EdgeTokenAgent)
  1113. }
  1114. return edges
  1115. }
  1116. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1117. // the given name in this mutation.
  1118. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1119. switch name {
  1120. case agent.EdgeWxAgent:
  1121. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1122. for id := range m.removedwx_agent {
  1123. ids = append(ids, id)
  1124. }
  1125. return ids
  1126. case agent.EdgeTokenAgent:
  1127. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1128. for id := range m.removedtoken_agent {
  1129. ids = append(ids, id)
  1130. }
  1131. return ids
  1132. }
  1133. return nil
  1134. }
  1135. // ClearedEdges returns all edge names that were cleared in this mutation.
  1136. func (m *AgentMutation) ClearedEdges() []string {
  1137. edges := make([]string, 0, 2)
  1138. if m.clearedwx_agent {
  1139. edges = append(edges, agent.EdgeWxAgent)
  1140. }
  1141. if m.clearedtoken_agent {
  1142. edges = append(edges, agent.EdgeTokenAgent)
  1143. }
  1144. return edges
  1145. }
  1146. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1147. // was cleared in this mutation.
  1148. func (m *AgentMutation) EdgeCleared(name string) bool {
  1149. switch name {
  1150. case agent.EdgeWxAgent:
  1151. return m.clearedwx_agent
  1152. case agent.EdgeTokenAgent:
  1153. return m.clearedtoken_agent
  1154. }
  1155. return false
  1156. }
  1157. // ClearEdge clears the value of the edge with the given name. It returns an error
  1158. // if that edge is not defined in the schema.
  1159. func (m *AgentMutation) ClearEdge(name string) error {
  1160. switch name {
  1161. }
  1162. return fmt.Errorf("unknown Agent unique edge %s", name)
  1163. }
  1164. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1165. // It returns an error if the edge is not defined in the schema.
  1166. func (m *AgentMutation) ResetEdge(name string) error {
  1167. switch name {
  1168. case agent.EdgeWxAgent:
  1169. m.ResetWxAgent()
  1170. return nil
  1171. case agent.EdgeTokenAgent:
  1172. m.ResetTokenAgent()
  1173. return nil
  1174. }
  1175. return fmt.Errorf("unknown Agent edge %s", name)
  1176. }
  1177. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1178. type AgentBaseMutation struct {
  1179. config
  1180. op Op
  1181. typ string
  1182. id *string
  1183. q *string
  1184. a *string
  1185. chunk_index *uint64
  1186. addchunk_index *int64
  1187. indexes *[]string
  1188. appendindexes []string
  1189. dataset_id *string
  1190. collection_id *string
  1191. source_name *string
  1192. can_write *[]bool
  1193. appendcan_write []bool
  1194. is_owner *[]bool
  1195. appendis_owner []bool
  1196. clearedFields map[string]struct{}
  1197. wx_agent map[uint64]struct{}
  1198. removedwx_agent map[uint64]struct{}
  1199. clearedwx_agent bool
  1200. done bool
  1201. oldValue func(context.Context) (*AgentBase, error)
  1202. predicates []predicate.AgentBase
  1203. }
  1204. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1205. // agentbaseOption allows management of the mutation configuration using functional options.
  1206. type agentbaseOption func(*AgentBaseMutation)
  1207. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1208. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1209. m := &AgentBaseMutation{
  1210. config: c,
  1211. op: op,
  1212. typ: TypeAgentBase,
  1213. clearedFields: make(map[string]struct{}),
  1214. }
  1215. for _, opt := range opts {
  1216. opt(m)
  1217. }
  1218. return m
  1219. }
  1220. // withAgentBaseID sets the ID field of the mutation.
  1221. func withAgentBaseID(id string) agentbaseOption {
  1222. return func(m *AgentBaseMutation) {
  1223. var (
  1224. err error
  1225. once sync.Once
  1226. value *AgentBase
  1227. )
  1228. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1229. once.Do(func() {
  1230. if m.done {
  1231. err = errors.New("querying old values post mutation is not allowed")
  1232. } else {
  1233. value, err = m.Client().AgentBase.Get(ctx, id)
  1234. }
  1235. })
  1236. return value, err
  1237. }
  1238. m.id = &id
  1239. }
  1240. }
  1241. // withAgentBase sets the old AgentBase of the mutation.
  1242. func withAgentBase(node *AgentBase) agentbaseOption {
  1243. return func(m *AgentBaseMutation) {
  1244. m.oldValue = func(context.Context) (*AgentBase, error) {
  1245. return node, nil
  1246. }
  1247. m.id = &node.ID
  1248. }
  1249. }
  1250. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1251. // executed in a transaction (ent.Tx), a transactional client is returned.
  1252. func (m AgentBaseMutation) Client() *Client {
  1253. client := &Client{config: m.config}
  1254. client.init()
  1255. return client
  1256. }
  1257. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1258. // it returns an error otherwise.
  1259. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1260. if _, ok := m.driver.(*txDriver); !ok {
  1261. return nil, errors.New("ent: mutation is not running in a transaction")
  1262. }
  1263. tx := &Tx{config: m.config}
  1264. tx.init()
  1265. return tx, nil
  1266. }
  1267. // SetID sets the value of the id field. Note that this
  1268. // operation is only accepted on creation of AgentBase entities.
  1269. func (m *AgentBaseMutation) SetID(id string) {
  1270. m.id = &id
  1271. }
  1272. // ID returns the ID value in the mutation. Note that the ID is only available
  1273. // if it was provided to the builder or after it was returned from the database.
  1274. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1275. if m.id == nil {
  1276. return
  1277. }
  1278. return *m.id, true
  1279. }
  1280. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1281. // That means, if the mutation is applied within a transaction with an isolation level such
  1282. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1283. // or updated by the mutation.
  1284. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1285. switch {
  1286. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1287. id, exists := m.ID()
  1288. if exists {
  1289. return []string{id}, nil
  1290. }
  1291. fallthrough
  1292. case m.op.Is(OpUpdate | OpDelete):
  1293. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1294. default:
  1295. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1296. }
  1297. }
  1298. // SetQ sets the "q" field.
  1299. func (m *AgentBaseMutation) SetQ(s string) {
  1300. m.q = &s
  1301. }
  1302. // Q returns the value of the "q" field in the mutation.
  1303. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1304. v := m.q
  1305. if v == nil {
  1306. return
  1307. }
  1308. return *v, true
  1309. }
  1310. // OldQ returns the old "q" field's value of the AgentBase entity.
  1311. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1313. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1314. if !m.op.Is(OpUpdateOne) {
  1315. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1316. }
  1317. if m.id == nil || m.oldValue == nil {
  1318. return v, errors.New("OldQ requires an ID field in the mutation")
  1319. }
  1320. oldValue, err := m.oldValue(ctx)
  1321. if err != nil {
  1322. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1323. }
  1324. return oldValue.Q, nil
  1325. }
  1326. // ClearQ clears the value of the "q" field.
  1327. func (m *AgentBaseMutation) ClearQ() {
  1328. m.q = nil
  1329. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1330. }
  1331. // QCleared returns if the "q" field was cleared in this mutation.
  1332. func (m *AgentBaseMutation) QCleared() bool {
  1333. _, ok := m.clearedFields[agentbase.FieldQ]
  1334. return ok
  1335. }
  1336. // ResetQ resets all changes to the "q" field.
  1337. func (m *AgentBaseMutation) ResetQ() {
  1338. m.q = nil
  1339. delete(m.clearedFields, agentbase.FieldQ)
  1340. }
  1341. // SetA sets the "a" field.
  1342. func (m *AgentBaseMutation) SetA(s string) {
  1343. m.a = &s
  1344. }
  1345. // A returns the value of the "a" field in the mutation.
  1346. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1347. v := m.a
  1348. if v == nil {
  1349. return
  1350. }
  1351. return *v, true
  1352. }
  1353. // OldA returns the old "a" field's value of the AgentBase entity.
  1354. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1356. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1357. if !m.op.Is(OpUpdateOne) {
  1358. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1359. }
  1360. if m.id == nil || m.oldValue == nil {
  1361. return v, errors.New("OldA requires an ID field in the mutation")
  1362. }
  1363. oldValue, err := m.oldValue(ctx)
  1364. if err != nil {
  1365. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1366. }
  1367. return oldValue.A, nil
  1368. }
  1369. // ClearA clears the value of the "a" field.
  1370. func (m *AgentBaseMutation) ClearA() {
  1371. m.a = nil
  1372. m.clearedFields[agentbase.FieldA] = struct{}{}
  1373. }
  1374. // ACleared returns if the "a" field was cleared in this mutation.
  1375. func (m *AgentBaseMutation) ACleared() bool {
  1376. _, ok := m.clearedFields[agentbase.FieldA]
  1377. return ok
  1378. }
  1379. // ResetA resets all changes to the "a" field.
  1380. func (m *AgentBaseMutation) ResetA() {
  1381. m.a = nil
  1382. delete(m.clearedFields, agentbase.FieldA)
  1383. }
  1384. // SetChunkIndex sets the "chunk_index" field.
  1385. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1386. m.chunk_index = &u
  1387. m.addchunk_index = nil
  1388. }
  1389. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1390. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1391. v := m.chunk_index
  1392. if v == nil {
  1393. return
  1394. }
  1395. return *v, true
  1396. }
  1397. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1398. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1400. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1401. if !m.op.Is(OpUpdateOne) {
  1402. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1403. }
  1404. if m.id == nil || m.oldValue == nil {
  1405. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1406. }
  1407. oldValue, err := m.oldValue(ctx)
  1408. if err != nil {
  1409. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1410. }
  1411. return oldValue.ChunkIndex, nil
  1412. }
  1413. // AddChunkIndex adds u to the "chunk_index" field.
  1414. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1415. if m.addchunk_index != nil {
  1416. *m.addchunk_index += u
  1417. } else {
  1418. m.addchunk_index = &u
  1419. }
  1420. }
  1421. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1422. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1423. v := m.addchunk_index
  1424. if v == nil {
  1425. return
  1426. }
  1427. return *v, true
  1428. }
  1429. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1430. func (m *AgentBaseMutation) ResetChunkIndex() {
  1431. m.chunk_index = nil
  1432. m.addchunk_index = nil
  1433. }
  1434. // SetIndexes sets the "indexes" field.
  1435. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1436. m.indexes = &s
  1437. m.appendindexes = nil
  1438. }
  1439. // Indexes returns the value of the "indexes" field in the mutation.
  1440. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1441. v := m.indexes
  1442. if v == nil {
  1443. return
  1444. }
  1445. return *v, true
  1446. }
  1447. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1448. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1450. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1451. if !m.op.Is(OpUpdateOne) {
  1452. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1453. }
  1454. if m.id == nil || m.oldValue == nil {
  1455. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1456. }
  1457. oldValue, err := m.oldValue(ctx)
  1458. if err != nil {
  1459. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1460. }
  1461. return oldValue.Indexes, nil
  1462. }
  1463. // AppendIndexes adds s to the "indexes" field.
  1464. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1465. m.appendindexes = append(m.appendindexes, s...)
  1466. }
  1467. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1468. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1469. if len(m.appendindexes) == 0 {
  1470. return nil, false
  1471. }
  1472. return m.appendindexes, true
  1473. }
  1474. // ClearIndexes clears the value of the "indexes" field.
  1475. func (m *AgentBaseMutation) ClearIndexes() {
  1476. m.indexes = nil
  1477. m.appendindexes = nil
  1478. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1479. }
  1480. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1481. func (m *AgentBaseMutation) IndexesCleared() bool {
  1482. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1483. return ok
  1484. }
  1485. // ResetIndexes resets all changes to the "indexes" field.
  1486. func (m *AgentBaseMutation) ResetIndexes() {
  1487. m.indexes = nil
  1488. m.appendindexes = nil
  1489. delete(m.clearedFields, agentbase.FieldIndexes)
  1490. }
  1491. // SetDatasetID sets the "dataset_id" field.
  1492. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1493. m.dataset_id = &s
  1494. }
  1495. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1496. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1497. v := m.dataset_id
  1498. if v == nil {
  1499. return
  1500. }
  1501. return *v, true
  1502. }
  1503. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1504. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1506. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1507. if !m.op.Is(OpUpdateOne) {
  1508. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1509. }
  1510. if m.id == nil || m.oldValue == nil {
  1511. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1512. }
  1513. oldValue, err := m.oldValue(ctx)
  1514. if err != nil {
  1515. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1516. }
  1517. return oldValue.DatasetID, nil
  1518. }
  1519. // ClearDatasetID clears the value of the "dataset_id" field.
  1520. func (m *AgentBaseMutation) ClearDatasetID() {
  1521. m.dataset_id = nil
  1522. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1523. }
  1524. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1525. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1526. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1527. return ok
  1528. }
  1529. // ResetDatasetID resets all changes to the "dataset_id" field.
  1530. func (m *AgentBaseMutation) ResetDatasetID() {
  1531. m.dataset_id = nil
  1532. delete(m.clearedFields, agentbase.FieldDatasetID)
  1533. }
  1534. // SetCollectionID sets the "collection_id" field.
  1535. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1536. m.collection_id = &s
  1537. }
  1538. // CollectionID returns the value of the "collection_id" field in the mutation.
  1539. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1540. v := m.collection_id
  1541. if v == nil {
  1542. return
  1543. }
  1544. return *v, true
  1545. }
  1546. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1547. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1549. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1550. if !m.op.Is(OpUpdateOne) {
  1551. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1552. }
  1553. if m.id == nil || m.oldValue == nil {
  1554. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1555. }
  1556. oldValue, err := m.oldValue(ctx)
  1557. if err != nil {
  1558. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1559. }
  1560. return oldValue.CollectionID, nil
  1561. }
  1562. // ClearCollectionID clears the value of the "collection_id" field.
  1563. func (m *AgentBaseMutation) ClearCollectionID() {
  1564. m.collection_id = nil
  1565. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1566. }
  1567. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1568. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1569. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1570. return ok
  1571. }
  1572. // ResetCollectionID resets all changes to the "collection_id" field.
  1573. func (m *AgentBaseMutation) ResetCollectionID() {
  1574. m.collection_id = nil
  1575. delete(m.clearedFields, agentbase.FieldCollectionID)
  1576. }
  1577. // SetSourceName sets the "source_name" field.
  1578. func (m *AgentBaseMutation) SetSourceName(s string) {
  1579. m.source_name = &s
  1580. }
  1581. // SourceName returns the value of the "source_name" field in the mutation.
  1582. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1583. v := m.source_name
  1584. if v == nil {
  1585. return
  1586. }
  1587. return *v, true
  1588. }
  1589. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1590. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1592. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1593. if !m.op.Is(OpUpdateOne) {
  1594. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1595. }
  1596. if m.id == nil || m.oldValue == nil {
  1597. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1598. }
  1599. oldValue, err := m.oldValue(ctx)
  1600. if err != nil {
  1601. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1602. }
  1603. return oldValue.SourceName, nil
  1604. }
  1605. // ClearSourceName clears the value of the "source_name" field.
  1606. func (m *AgentBaseMutation) ClearSourceName() {
  1607. m.source_name = nil
  1608. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1609. }
  1610. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1611. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1612. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1613. return ok
  1614. }
  1615. // ResetSourceName resets all changes to the "source_name" field.
  1616. func (m *AgentBaseMutation) ResetSourceName() {
  1617. m.source_name = nil
  1618. delete(m.clearedFields, agentbase.FieldSourceName)
  1619. }
  1620. // SetCanWrite sets the "can_write" field.
  1621. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1622. m.can_write = &b
  1623. m.appendcan_write = nil
  1624. }
  1625. // CanWrite returns the value of the "can_write" field in the mutation.
  1626. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1627. v := m.can_write
  1628. if v == nil {
  1629. return
  1630. }
  1631. return *v, true
  1632. }
  1633. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1634. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1636. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1637. if !m.op.Is(OpUpdateOne) {
  1638. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1639. }
  1640. if m.id == nil || m.oldValue == nil {
  1641. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1642. }
  1643. oldValue, err := m.oldValue(ctx)
  1644. if err != nil {
  1645. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1646. }
  1647. return oldValue.CanWrite, nil
  1648. }
  1649. // AppendCanWrite adds b to the "can_write" field.
  1650. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1651. m.appendcan_write = append(m.appendcan_write, b...)
  1652. }
  1653. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1654. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1655. if len(m.appendcan_write) == 0 {
  1656. return nil, false
  1657. }
  1658. return m.appendcan_write, true
  1659. }
  1660. // ClearCanWrite clears the value of the "can_write" field.
  1661. func (m *AgentBaseMutation) ClearCanWrite() {
  1662. m.can_write = nil
  1663. m.appendcan_write = nil
  1664. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1665. }
  1666. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1667. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1668. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1669. return ok
  1670. }
  1671. // ResetCanWrite resets all changes to the "can_write" field.
  1672. func (m *AgentBaseMutation) ResetCanWrite() {
  1673. m.can_write = nil
  1674. m.appendcan_write = nil
  1675. delete(m.clearedFields, agentbase.FieldCanWrite)
  1676. }
  1677. // SetIsOwner sets the "is_owner" field.
  1678. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1679. m.is_owner = &b
  1680. m.appendis_owner = nil
  1681. }
  1682. // IsOwner returns the value of the "is_owner" field in the mutation.
  1683. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1684. v := m.is_owner
  1685. if v == nil {
  1686. return
  1687. }
  1688. return *v, true
  1689. }
  1690. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1691. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1693. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1694. if !m.op.Is(OpUpdateOne) {
  1695. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1696. }
  1697. if m.id == nil || m.oldValue == nil {
  1698. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1699. }
  1700. oldValue, err := m.oldValue(ctx)
  1701. if err != nil {
  1702. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1703. }
  1704. return oldValue.IsOwner, nil
  1705. }
  1706. // AppendIsOwner adds b to the "is_owner" field.
  1707. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1708. m.appendis_owner = append(m.appendis_owner, b...)
  1709. }
  1710. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1711. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1712. if len(m.appendis_owner) == 0 {
  1713. return nil, false
  1714. }
  1715. return m.appendis_owner, true
  1716. }
  1717. // ClearIsOwner clears the value of the "is_owner" field.
  1718. func (m *AgentBaseMutation) ClearIsOwner() {
  1719. m.is_owner = nil
  1720. m.appendis_owner = nil
  1721. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1722. }
  1723. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1724. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1725. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1726. return ok
  1727. }
  1728. // ResetIsOwner resets all changes to the "is_owner" field.
  1729. func (m *AgentBaseMutation) ResetIsOwner() {
  1730. m.is_owner = nil
  1731. m.appendis_owner = nil
  1732. delete(m.clearedFields, agentbase.FieldIsOwner)
  1733. }
  1734. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1735. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1736. if m.wx_agent == nil {
  1737. m.wx_agent = make(map[uint64]struct{})
  1738. }
  1739. for i := range ids {
  1740. m.wx_agent[ids[i]] = struct{}{}
  1741. }
  1742. }
  1743. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1744. func (m *AgentBaseMutation) ClearWxAgent() {
  1745. m.clearedwx_agent = true
  1746. }
  1747. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1748. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1749. return m.clearedwx_agent
  1750. }
  1751. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1752. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1753. if m.removedwx_agent == nil {
  1754. m.removedwx_agent = make(map[uint64]struct{})
  1755. }
  1756. for i := range ids {
  1757. delete(m.wx_agent, ids[i])
  1758. m.removedwx_agent[ids[i]] = struct{}{}
  1759. }
  1760. }
  1761. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1762. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1763. for id := range m.removedwx_agent {
  1764. ids = append(ids, id)
  1765. }
  1766. return
  1767. }
  1768. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1769. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1770. for id := range m.wx_agent {
  1771. ids = append(ids, id)
  1772. }
  1773. return
  1774. }
  1775. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1776. func (m *AgentBaseMutation) ResetWxAgent() {
  1777. m.wx_agent = nil
  1778. m.clearedwx_agent = false
  1779. m.removedwx_agent = nil
  1780. }
  1781. // Where appends a list predicates to the AgentBaseMutation builder.
  1782. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1783. m.predicates = append(m.predicates, ps...)
  1784. }
  1785. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1786. // users can use type-assertion to append predicates that do not depend on any generated package.
  1787. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1788. p := make([]predicate.AgentBase, len(ps))
  1789. for i := range ps {
  1790. p[i] = ps[i]
  1791. }
  1792. m.Where(p...)
  1793. }
  1794. // Op returns the operation name.
  1795. func (m *AgentBaseMutation) Op() Op {
  1796. return m.op
  1797. }
  1798. // SetOp allows setting the mutation operation.
  1799. func (m *AgentBaseMutation) SetOp(op Op) {
  1800. m.op = op
  1801. }
  1802. // Type returns the node type of this mutation (AgentBase).
  1803. func (m *AgentBaseMutation) Type() string {
  1804. return m.typ
  1805. }
  1806. // Fields returns all fields that were changed during this mutation. Note that in
  1807. // order to get all numeric fields that were incremented/decremented, call
  1808. // AddedFields().
  1809. func (m *AgentBaseMutation) Fields() []string {
  1810. fields := make([]string, 0, 9)
  1811. if m.q != nil {
  1812. fields = append(fields, agentbase.FieldQ)
  1813. }
  1814. if m.a != nil {
  1815. fields = append(fields, agentbase.FieldA)
  1816. }
  1817. if m.chunk_index != nil {
  1818. fields = append(fields, agentbase.FieldChunkIndex)
  1819. }
  1820. if m.indexes != nil {
  1821. fields = append(fields, agentbase.FieldIndexes)
  1822. }
  1823. if m.dataset_id != nil {
  1824. fields = append(fields, agentbase.FieldDatasetID)
  1825. }
  1826. if m.collection_id != nil {
  1827. fields = append(fields, agentbase.FieldCollectionID)
  1828. }
  1829. if m.source_name != nil {
  1830. fields = append(fields, agentbase.FieldSourceName)
  1831. }
  1832. if m.can_write != nil {
  1833. fields = append(fields, agentbase.FieldCanWrite)
  1834. }
  1835. if m.is_owner != nil {
  1836. fields = append(fields, agentbase.FieldIsOwner)
  1837. }
  1838. return fields
  1839. }
  1840. // Field returns the value of a field with the given name. The second boolean
  1841. // return value indicates that this field was not set, or was not defined in the
  1842. // schema.
  1843. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1844. switch name {
  1845. case agentbase.FieldQ:
  1846. return m.Q()
  1847. case agentbase.FieldA:
  1848. return m.A()
  1849. case agentbase.FieldChunkIndex:
  1850. return m.ChunkIndex()
  1851. case agentbase.FieldIndexes:
  1852. return m.Indexes()
  1853. case agentbase.FieldDatasetID:
  1854. return m.DatasetID()
  1855. case agentbase.FieldCollectionID:
  1856. return m.CollectionID()
  1857. case agentbase.FieldSourceName:
  1858. return m.SourceName()
  1859. case agentbase.FieldCanWrite:
  1860. return m.CanWrite()
  1861. case agentbase.FieldIsOwner:
  1862. return m.IsOwner()
  1863. }
  1864. return nil, false
  1865. }
  1866. // OldField returns the old value of the field from the database. An error is
  1867. // returned if the mutation operation is not UpdateOne, or the query to the
  1868. // database failed.
  1869. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1870. switch name {
  1871. case agentbase.FieldQ:
  1872. return m.OldQ(ctx)
  1873. case agentbase.FieldA:
  1874. return m.OldA(ctx)
  1875. case agentbase.FieldChunkIndex:
  1876. return m.OldChunkIndex(ctx)
  1877. case agentbase.FieldIndexes:
  1878. return m.OldIndexes(ctx)
  1879. case agentbase.FieldDatasetID:
  1880. return m.OldDatasetID(ctx)
  1881. case agentbase.FieldCollectionID:
  1882. return m.OldCollectionID(ctx)
  1883. case agentbase.FieldSourceName:
  1884. return m.OldSourceName(ctx)
  1885. case agentbase.FieldCanWrite:
  1886. return m.OldCanWrite(ctx)
  1887. case agentbase.FieldIsOwner:
  1888. return m.OldIsOwner(ctx)
  1889. }
  1890. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1891. }
  1892. // SetField sets the value of a field with the given name. It returns an error if
  1893. // the field is not defined in the schema, or if the type mismatched the field
  1894. // type.
  1895. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1896. switch name {
  1897. case agentbase.FieldQ:
  1898. v, ok := value.(string)
  1899. if !ok {
  1900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1901. }
  1902. m.SetQ(v)
  1903. return nil
  1904. case agentbase.FieldA:
  1905. v, ok := value.(string)
  1906. if !ok {
  1907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1908. }
  1909. m.SetA(v)
  1910. return nil
  1911. case agentbase.FieldChunkIndex:
  1912. v, ok := value.(uint64)
  1913. if !ok {
  1914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1915. }
  1916. m.SetChunkIndex(v)
  1917. return nil
  1918. case agentbase.FieldIndexes:
  1919. v, ok := value.([]string)
  1920. if !ok {
  1921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1922. }
  1923. m.SetIndexes(v)
  1924. return nil
  1925. case agentbase.FieldDatasetID:
  1926. v, ok := value.(string)
  1927. if !ok {
  1928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1929. }
  1930. m.SetDatasetID(v)
  1931. return nil
  1932. case agentbase.FieldCollectionID:
  1933. v, ok := value.(string)
  1934. if !ok {
  1935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1936. }
  1937. m.SetCollectionID(v)
  1938. return nil
  1939. case agentbase.FieldSourceName:
  1940. v, ok := value.(string)
  1941. if !ok {
  1942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1943. }
  1944. m.SetSourceName(v)
  1945. return nil
  1946. case agentbase.FieldCanWrite:
  1947. v, ok := value.([]bool)
  1948. if !ok {
  1949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1950. }
  1951. m.SetCanWrite(v)
  1952. return nil
  1953. case agentbase.FieldIsOwner:
  1954. v, ok := value.([]bool)
  1955. if !ok {
  1956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1957. }
  1958. m.SetIsOwner(v)
  1959. return nil
  1960. }
  1961. return fmt.Errorf("unknown AgentBase field %s", name)
  1962. }
  1963. // AddedFields returns all numeric fields that were incremented/decremented during
  1964. // this mutation.
  1965. func (m *AgentBaseMutation) AddedFields() []string {
  1966. var fields []string
  1967. if m.addchunk_index != nil {
  1968. fields = append(fields, agentbase.FieldChunkIndex)
  1969. }
  1970. return fields
  1971. }
  1972. // AddedField returns the numeric value that was incremented/decremented on a field
  1973. // with the given name. The second boolean return value indicates that this field
  1974. // was not set, or was not defined in the schema.
  1975. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1976. switch name {
  1977. case agentbase.FieldChunkIndex:
  1978. return m.AddedChunkIndex()
  1979. }
  1980. return nil, false
  1981. }
  1982. // AddField adds the value to the field with the given name. It returns an error if
  1983. // the field is not defined in the schema, or if the type mismatched the field
  1984. // type.
  1985. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1986. switch name {
  1987. case agentbase.FieldChunkIndex:
  1988. v, ok := value.(int64)
  1989. if !ok {
  1990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1991. }
  1992. m.AddChunkIndex(v)
  1993. return nil
  1994. }
  1995. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  1996. }
  1997. // ClearedFields returns all nullable fields that were cleared during this
  1998. // mutation.
  1999. func (m *AgentBaseMutation) ClearedFields() []string {
  2000. var fields []string
  2001. if m.FieldCleared(agentbase.FieldQ) {
  2002. fields = append(fields, agentbase.FieldQ)
  2003. }
  2004. if m.FieldCleared(agentbase.FieldA) {
  2005. fields = append(fields, agentbase.FieldA)
  2006. }
  2007. if m.FieldCleared(agentbase.FieldIndexes) {
  2008. fields = append(fields, agentbase.FieldIndexes)
  2009. }
  2010. if m.FieldCleared(agentbase.FieldDatasetID) {
  2011. fields = append(fields, agentbase.FieldDatasetID)
  2012. }
  2013. if m.FieldCleared(agentbase.FieldCollectionID) {
  2014. fields = append(fields, agentbase.FieldCollectionID)
  2015. }
  2016. if m.FieldCleared(agentbase.FieldSourceName) {
  2017. fields = append(fields, agentbase.FieldSourceName)
  2018. }
  2019. if m.FieldCleared(agentbase.FieldCanWrite) {
  2020. fields = append(fields, agentbase.FieldCanWrite)
  2021. }
  2022. if m.FieldCleared(agentbase.FieldIsOwner) {
  2023. fields = append(fields, agentbase.FieldIsOwner)
  2024. }
  2025. return fields
  2026. }
  2027. // FieldCleared returns a boolean indicating if a field with the given name was
  2028. // cleared in this mutation.
  2029. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2030. _, ok := m.clearedFields[name]
  2031. return ok
  2032. }
  2033. // ClearField clears the value of the field with the given name. It returns an
  2034. // error if the field is not defined in the schema.
  2035. func (m *AgentBaseMutation) ClearField(name string) error {
  2036. switch name {
  2037. case agentbase.FieldQ:
  2038. m.ClearQ()
  2039. return nil
  2040. case agentbase.FieldA:
  2041. m.ClearA()
  2042. return nil
  2043. case agentbase.FieldIndexes:
  2044. m.ClearIndexes()
  2045. return nil
  2046. case agentbase.FieldDatasetID:
  2047. m.ClearDatasetID()
  2048. return nil
  2049. case agentbase.FieldCollectionID:
  2050. m.ClearCollectionID()
  2051. return nil
  2052. case agentbase.FieldSourceName:
  2053. m.ClearSourceName()
  2054. return nil
  2055. case agentbase.FieldCanWrite:
  2056. m.ClearCanWrite()
  2057. return nil
  2058. case agentbase.FieldIsOwner:
  2059. m.ClearIsOwner()
  2060. return nil
  2061. }
  2062. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2063. }
  2064. // ResetField resets all changes in the mutation for the field with the given name.
  2065. // It returns an error if the field is not defined in the schema.
  2066. func (m *AgentBaseMutation) ResetField(name string) error {
  2067. switch name {
  2068. case agentbase.FieldQ:
  2069. m.ResetQ()
  2070. return nil
  2071. case agentbase.FieldA:
  2072. m.ResetA()
  2073. return nil
  2074. case agentbase.FieldChunkIndex:
  2075. m.ResetChunkIndex()
  2076. return nil
  2077. case agentbase.FieldIndexes:
  2078. m.ResetIndexes()
  2079. return nil
  2080. case agentbase.FieldDatasetID:
  2081. m.ResetDatasetID()
  2082. return nil
  2083. case agentbase.FieldCollectionID:
  2084. m.ResetCollectionID()
  2085. return nil
  2086. case agentbase.FieldSourceName:
  2087. m.ResetSourceName()
  2088. return nil
  2089. case agentbase.FieldCanWrite:
  2090. m.ResetCanWrite()
  2091. return nil
  2092. case agentbase.FieldIsOwner:
  2093. m.ResetIsOwner()
  2094. return nil
  2095. }
  2096. return fmt.Errorf("unknown AgentBase field %s", name)
  2097. }
  2098. // AddedEdges returns all edge names that were set/added in this mutation.
  2099. func (m *AgentBaseMutation) AddedEdges() []string {
  2100. edges := make([]string, 0, 1)
  2101. if m.wx_agent != nil {
  2102. edges = append(edges, agentbase.EdgeWxAgent)
  2103. }
  2104. return edges
  2105. }
  2106. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2107. // name in this mutation.
  2108. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2109. switch name {
  2110. case agentbase.EdgeWxAgent:
  2111. ids := make([]ent.Value, 0, len(m.wx_agent))
  2112. for id := range m.wx_agent {
  2113. ids = append(ids, id)
  2114. }
  2115. return ids
  2116. }
  2117. return nil
  2118. }
  2119. // RemovedEdges returns all edge names that were removed in this mutation.
  2120. func (m *AgentBaseMutation) RemovedEdges() []string {
  2121. edges := make([]string, 0, 1)
  2122. if m.removedwx_agent != nil {
  2123. edges = append(edges, agentbase.EdgeWxAgent)
  2124. }
  2125. return edges
  2126. }
  2127. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2128. // the given name in this mutation.
  2129. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2130. switch name {
  2131. case agentbase.EdgeWxAgent:
  2132. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2133. for id := range m.removedwx_agent {
  2134. ids = append(ids, id)
  2135. }
  2136. return ids
  2137. }
  2138. return nil
  2139. }
  2140. // ClearedEdges returns all edge names that were cleared in this mutation.
  2141. func (m *AgentBaseMutation) ClearedEdges() []string {
  2142. edges := make([]string, 0, 1)
  2143. if m.clearedwx_agent {
  2144. edges = append(edges, agentbase.EdgeWxAgent)
  2145. }
  2146. return edges
  2147. }
  2148. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2149. // was cleared in this mutation.
  2150. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2151. switch name {
  2152. case agentbase.EdgeWxAgent:
  2153. return m.clearedwx_agent
  2154. }
  2155. return false
  2156. }
  2157. // ClearEdge clears the value of the edge with the given name. It returns an error
  2158. // if that edge is not defined in the schema.
  2159. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2160. switch name {
  2161. }
  2162. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2163. }
  2164. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2165. // It returns an error if the edge is not defined in the schema.
  2166. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2167. switch name {
  2168. case agentbase.EdgeWxAgent:
  2169. m.ResetWxAgent()
  2170. return nil
  2171. }
  2172. return fmt.Errorf("unknown AgentBase edge %s", name)
  2173. }
  2174. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2175. type AliyunAvatarMutation struct {
  2176. config
  2177. op Op
  2178. typ string
  2179. id *uint64
  2180. created_at *time.Time
  2181. updated_at *time.Time
  2182. deleted_at *time.Time
  2183. user_id *uint64
  2184. adduser_id *int64
  2185. biz_id *string
  2186. access_key_id *string
  2187. access_key_secret *string
  2188. app_id *string
  2189. tenant_id *uint64
  2190. addtenant_id *int64
  2191. response *string
  2192. token *string
  2193. session_id *string
  2194. clearedFields map[string]struct{}
  2195. done bool
  2196. oldValue func(context.Context) (*AliyunAvatar, error)
  2197. predicates []predicate.AliyunAvatar
  2198. }
  2199. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2200. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2201. type aliyunavatarOption func(*AliyunAvatarMutation)
  2202. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2203. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2204. m := &AliyunAvatarMutation{
  2205. config: c,
  2206. op: op,
  2207. typ: TypeAliyunAvatar,
  2208. clearedFields: make(map[string]struct{}),
  2209. }
  2210. for _, opt := range opts {
  2211. opt(m)
  2212. }
  2213. return m
  2214. }
  2215. // withAliyunAvatarID sets the ID field of the mutation.
  2216. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2217. return func(m *AliyunAvatarMutation) {
  2218. var (
  2219. err error
  2220. once sync.Once
  2221. value *AliyunAvatar
  2222. )
  2223. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2224. once.Do(func() {
  2225. if m.done {
  2226. err = errors.New("querying old values post mutation is not allowed")
  2227. } else {
  2228. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2229. }
  2230. })
  2231. return value, err
  2232. }
  2233. m.id = &id
  2234. }
  2235. }
  2236. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2237. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2238. return func(m *AliyunAvatarMutation) {
  2239. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2240. return node, nil
  2241. }
  2242. m.id = &node.ID
  2243. }
  2244. }
  2245. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2246. // executed in a transaction (ent.Tx), a transactional client is returned.
  2247. func (m AliyunAvatarMutation) Client() *Client {
  2248. client := &Client{config: m.config}
  2249. client.init()
  2250. return client
  2251. }
  2252. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2253. // it returns an error otherwise.
  2254. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2255. if _, ok := m.driver.(*txDriver); !ok {
  2256. return nil, errors.New("ent: mutation is not running in a transaction")
  2257. }
  2258. tx := &Tx{config: m.config}
  2259. tx.init()
  2260. return tx, nil
  2261. }
  2262. // SetID sets the value of the id field. Note that this
  2263. // operation is only accepted on creation of AliyunAvatar entities.
  2264. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2265. m.id = &id
  2266. }
  2267. // ID returns the ID value in the mutation. Note that the ID is only available
  2268. // if it was provided to the builder or after it was returned from the database.
  2269. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2270. if m.id == nil {
  2271. return
  2272. }
  2273. return *m.id, true
  2274. }
  2275. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2276. // That means, if the mutation is applied within a transaction with an isolation level such
  2277. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2278. // or updated by the mutation.
  2279. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2280. switch {
  2281. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2282. id, exists := m.ID()
  2283. if exists {
  2284. return []uint64{id}, nil
  2285. }
  2286. fallthrough
  2287. case m.op.Is(OpUpdate | OpDelete):
  2288. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2289. default:
  2290. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2291. }
  2292. }
  2293. // SetCreatedAt sets the "created_at" field.
  2294. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2295. m.created_at = &t
  2296. }
  2297. // CreatedAt returns the value of the "created_at" field in the mutation.
  2298. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2299. v := m.created_at
  2300. if v == nil {
  2301. return
  2302. }
  2303. return *v, true
  2304. }
  2305. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2306. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2308. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2309. if !m.op.Is(OpUpdateOne) {
  2310. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2311. }
  2312. if m.id == nil || m.oldValue == nil {
  2313. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2314. }
  2315. oldValue, err := m.oldValue(ctx)
  2316. if err != nil {
  2317. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2318. }
  2319. return oldValue.CreatedAt, nil
  2320. }
  2321. // ResetCreatedAt resets all changes to the "created_at" field.
  2322. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2323. m.created_at = nil
  2324. }
  2325. // SetUpdatedAt sets the "updated_at" field.
  2326. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2327. m.updated_at = &t
  2328. }
  2329. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2330. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2331. v := m.updated_at
  2332. if v == nil {
  2333. return
  2334. }
  2335. return *v, true
  2336. }
  2337. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2338. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2340. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2341. if !m.op.Is(OpUpdateOne) {
  2342. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2343. }
  2344. if m.id == nil || m.oldValue == nil {
  2345. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2346. }
  2347. oldValue, err := m.oldValue(ctx)
  2348. if err != nil {
  2349. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2350. }
  2351. return oldValue.UpdatedAt, nil
  2352. }
  2353. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2354. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2355. m.updated_at = nil
  2356. }
  2357. // SetDeletedAt sets the "deleted_at" field.
  2358. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2359. m.deleted_at = &t
  2360. }
  2361. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2362. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2363. v := m.deleted_at
  2364. if v == nil {
  2365. return
  2366. }
  2367. return *v, true
  2368. }
  2369. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2370. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2372. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2373. if !m.op.Is(OpUpdateOne) {
  2374. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2375. }
  2376. if m.id == nil || m.oldValue == nil {
  2377. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2378. }
  2379. oldValue, err := m.oldValue(ctx)
  2380. if err != nil {
  2381. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2382. }
  2383. return oldValue.DeletedAt, nil
  2384. }
  2385. // ClearDeletedAt clears the value of the "deleted_at" field.
  2386. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2387. m.deleted_at = nil
  2388. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2389. }
  2390. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2391. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2392. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2393. return ok
  2394. }
  2395. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2396. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2397. m.deleted_at = nil
  2398. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2399. }
  2400. // SetUserID sets the "user_id" field.
  2401. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2402. m.user_id = &u
  2403. m.adduser_id = nil
  2404. }
  2405. // UserID returns the value of the "user_id" field in the mutation.
  2406. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2407. v := m.user_id
  2408. if v == nil {
  2409. return
  2410. }
  2411. return *v, true
  2412. }
  2413. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2414. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2416. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2417. if !m.op.Is(OpUpdateOne) {
  2418. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2419. }
  2420. if m.id == nil || m.oldValue == nil {
  2421. return v, errors.New("OldUserID requires an ID field in the mutation")
  2422. }
  2423. oldValue, err := m.oldValue(ctx)
  2424. if err != nil {
  2425. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2426. }
  2427. return oldValue.UserID, nil
  2428. }
  2429. // AddUserID adds u to the "user_id" field.
  2430. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2431. if m.adduser_id != nil {
  2432. *m.adduser_id += u
  2433. } else {
  2434. m.adduser_id = &u
  2435. }
  2436. }
  2437. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2438. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2439. v := m.adduser_id
  2440. if v == nil {
  2441. return
  2442. }
  2443. return *v, true
  2444. }
  2445. // ResetUserID resets all changes to the "user_id" field.
  2446. func (m *AliyunAvatarMutation) ResetUserID() {
  2447. m.user_id = nil
  2448. m.adduser_id = nil
  2449. }
  2450. // SetBizID sets the "biz_id" field.
  2451. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2452. m.biz_id = &s
  2453. }
  2454. // BizID returns the value of the "biz_id" field in the mutation.
  2455. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2456. v := m.biz_id
  2457. if v == nil {
  2458. return
  2459. }
  2460. return *v, true
  2461. }
  2462. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2463. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2465. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2466. if !m.op.Is(OpUpdateOne) {
  2467. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2468. }
  2469. if m.id == nil || m.oldValue == nil {
  2470. return v, errors.New("OldBizID requires an ID field in the mutation")
  2471. }
  2472. oldValue, err := m.oldValue(ctx)
  2473. if err != nil {
  2474. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2475. }
  2476. return oldValue.BizID, nil
  2477. }
  2478. // ResetBizID resets all changes to the "biz_id" field.
  2479. func (m *AliyunAvatarMutation) ResetBizID() {
  2480. m.biz_id = nil
  2481. }
  2482. // SetAccessKeyID sets the "access_key_id" field.
  2483. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2484. m.access_key_id = &s
  2485. }
  2486. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2487. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2488. v := m.access_key_id
  2489. if v == nil {
  2490. return
  2491. }
  2492. return *v, true
  2493. }
  2494. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2495. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2497. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2498. if !m.op.Is(OpUpdateOne) {
  2499. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2500. }
  2501. if m.id == nil || m.oldValue == nil {
  2502. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2503. }
  2504. oldValue, err := m.oldValue(ctx)
  2505. if err != nil {
  2506. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2507. }
  2508. return oldValue.AccessKeyID, nil
  2509. }
  2510. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2511. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2512. m.access_key_id = nil
  2513. }
  2514. // SetAccessKeySecret sets the "access_key_secret" field.
  2515. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2516. m.access_key_secret = &s
  2517. }
  2518. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2519. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2520. v := m.access_key_secret
  2521. if v == nil {
  2522. return
  2523. }
  2524. return *v, true
  2525. }
  2526. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2527. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2529. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2530. if !m.op.Is(OpUpdateOne) {
  2531. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2532. }
  2533. if m.id == nil || m.oldValue == nil {
  2534. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2535. }
  2536. oldValue, err := m.oldValue(ctx)
  2537. if err != nil {
  2538. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2539. }
  2540. return oldValue.AccessKeySecret, nil
  2541. }
  2542. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2543. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2544. m.access_key_secret = nil
  2545. }
  2546. // SetAppID sets the "app_id" field.
  2547. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2548. m.app_id = &s
  2549. }
  2550. // AppID returns the value of the "app_id" field in the mutation.
  2551. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2552. v := m.app_id
  2553. if v == nil {
  2554. return
  2555. }
  2556. return *v, true
  2557. }
  2558. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2559. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2561. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2562. if !m.op.Is(OpUpdateOne) {
  2563. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2564. }
  2565. if m.id == nil || m.oldValue == nil {
  2566. return v, errors.New("OldAppID requires an ID field in the mutation")
  2567. }
  2568. oldValue, err := m.oldValue(ctx)
  2569. if err != nil {
  2570. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2571. }
  2572. return oldValue.AppID, nil
  2573. }
  2574. // ClearAppID clears the value of the "app_id" field.
  2575. func (m *AliyunAvatarMutation) ClearAppID() {
  2576. m.app_id = nil
  2577. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2578. }
  2579. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2580. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2581. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2582. return ok
  2583. }
  2584. // ResetAppID resets all changes to the "app_id" field.
  2585. func (m *AliyunAvatarMutation) ResetAppID() {
  2586. m.app_id = nil
  2587. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2588. }
  2589. // SetTenantID sets the "tenant_id" field.
  2590. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2591. m.tenant_id = &u
  2592. m.addtenant_id = nil
  2593. }
  2594. // TenantID returns the value of the "tenant_id" field in the mutation.
  2595. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2596. v := m.tenant_id
  2597. if v == nil {
  2598. return
  2599. }
  2600. return *v, true
  2601. }
  2602. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2603. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2605. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2606. if !m.op.Is(OpUpdateOne) {
  2607. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2608. }
  2609. if m.id == nil || m.oldValue == nil {
  2610. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2611. }
  2612. oldValue, err := m.oldValue(ctx)
  2613. if err != nil {
  2614. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2615. }
  2616. return oldValue.TenantID, nil
  2617. }
  2618. // AddTenantID adds u to the "tenant_id" field.
  2619. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2620. if m.addtenant_id != nil {
  2621. *m.addtenant_id += u
  2622. } else {
  2623. m.addtenant_id = &u
  2624. }
  2625. }
  2626. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2627. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2628. v := m.addtenant_id
  2629. if v == nil {
  2630. return
  2631. }
  2632. return *v, true
  2633. }
  2634. // ResetTenantID resets all changes to the "tenant_id" field.
  2635. func (m *AliyunAvatarMutation) ResetTenantID() {
  2636. m.tenant_id = nil
  2637. m.addtenant_id = nil
  2638. }
  2639. // SetResponse sets the "response" field.
  2640. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2641. m.response = &s
  2642. }
  2643. // Response returns the value of the "response" field in the mutation.
  2644. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2645. v := m.response
  2646. if v == nil {
  2647. return
  2648. }
  2649. return *v, true
  2650. }
  2651. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2652. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2654. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2655. if !m.op.Is(OpUpdateOne) {
  2656. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2657. }
  2658. if m.id == nil || m.oldValue == nil {
  2659. return v, errors.New("OldResponse requires an ID field in the mutation")
  2660. }
  2661. oldValue, err := m.oldValue(ctx)
  2662. if err != nil {
  2663. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2664. }
  2665. return oldValue.Response, nil
  2666. }
  2667. // ResetResponse resets all changes to the "response" field.
  2668. func (m *AliyunAvatarMutation) ResetResponse() {
  2669. m.response = nil
  2670. }
  2671. // SetToken sets the "token" field.
  2672. func (m *AliyunAvatarMutation) SetToken(s string) {
  2673. m.token = &s
  2674. }
  2675. // Token returns the value of the "token" field in the mutation.
  2676. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2677. v := m.token
  2678. if v == nil {
  2679. return
  2680. }
  2681. return *v, true
  2682. }
  2683. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2684. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2686. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2687. if !m.op.Is(OpUpdateOne) {
  2688. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2689. }
  2690. if m.id == nil || m.oldValue == nil {
  2691. return v, errors.New("OldToken requires an ID field in the mutation")
  2692. }
  2693. oldValue, err := m.oldValue(ctx)
  2694. if err != nil {
  2695. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2696. }
  2697. return oldValue.Token, nil
  2698. }
  2699. // ResetToken resets all changes to the "token" field.
  2700. func (m *AliyunAvatarMutation) ResetToken() {
  2701. m.token = nil
  2702. }
  2703. // SetSessionID sets the "session_id" field.
  2704. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2705. m.session_id = &s
  2706. }
  2707. // SessionID returns the value of the "session_id" field in the mutation.
  2708. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2709. v := m.session_id
  2710. if v == nil {
  2711. return
  2712. }
  2713. return *v, true
  2714. }
  2715. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2716. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2718. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2719. if !m.op.Is(OpUpdateOne) {
  2720. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2721. }
  2722. if m.id == nil || m.oldValue == nil {
  2723. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2724. }
  2725. oldValue, err := m.oldValue(ctx)
  2726. if err != nil {
  2727. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2728. }
  2729. return oldValue.SessionID, nil
  2730. }
  2731. // ResetSessionID resets all changes to the "session_id" field.
  2732. func (m *AliyunAvatarMutation) ResetSessionID() {
  2733. m.session_id = nil
  2734. }
  2735. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2736. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2737. m.predicates = append(m.predicates, ps...)
  2738. }
  2739. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2740. // users can use type-assertion to append predicates that do not depend on any generated package.
  2741. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2742. p := make([]predicate.AliyunAvatar, len(ps))
  2743. for i := range ps {
  2744. p[i] = ps[i]
  2745. }
  2746. m.Where(p...)
  2747. }
  2748. // Op returns the operation name.
  2749. func (m *AliyunAvatarMutation) Op() Op {
  2750. return m.op
  2751. }
  2752. // SetOp allows setting the mutation operation.
  2753. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2754. m.op = op
  2755. }
  2756. // Type returns the node type of this mutation (AliyunAvatar).
  2757. func (m *AliyunAvatarMutation) Type() string {
  2758. return m.typ
  2759. }
  2760. // Fields returns all fields that were changed during this mutation. Note that in
  2761. // order to get all numeric fields that were incremented/decremented, call
  2762. // AddedFields().
  2763. func (m *AliyunAvatarMutation) Fields() []string {
  2764. fields := make([]string, 0, 12)
  2765. if m.created_at != nil {
  2766. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2767. }
  2768. if m.updated_at != nil {
  2769. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2770. }
  2771. if m.deleted_at != nil {
  2772. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2773. }
  2774. if m.user_id != nil {
  2775. fields = append(fields, aliyunavatar.FieldUserID)
  2776. }
  2777. if m.biz_id != nil {
  2778. fields = append(fields, aliyunavatar.FieldBizID)
  2779. }
  2780. if m.access_key_id != nil {
  2781. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2782. }
  2783. if m.access_key_secret != nil {
  2784. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2785. }
  2786. if m.app_id != nil {
  2787. fields = append(fields, aliyunavatar.FieldAppID)
  2788. }
  2789. if m.tenant_id != nil {
  2790. fields = append(fields, aliyunavatar.FieldTenantID)
  2791. }
  2792. if m.response != nil {
  2793. fields = append(fields, aliyunavatar.FieldResponse)
  2794. }
  2795. if m.token != nil {
  2796. fields = append(fields, aliyunavatar.FieldToken)
  2797. }
  2798. if m.session_id != nil {
  2799. fields = append(fields, aliyunavatar.FieldSessionID)
  2800. }
  2801. return fields
  2802. }
  2803. // Field returns the value of a field with the given name. The second boolean
  2804. // return value indicates that this field was not set, or was not defined in the
  2805. // schema.
  2806. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2807. switch name {
  2808. case aliyunavatar.FieldCreatedAt:
  2809. return m.CreatedAt()
  2810. case aliyunavatar.FieldUpdatedAt:
  2811. return m.UpdatedAt()
  2812. case aliyunavatar.FieldDeletedAt:
  2813. return m.DeletedAt()
  2814. case aliyunavatar.FieldUserID:
  2815. return m.UserID()
  2816. case aliyunavatar.FieldBizID:
  2817. return m.BizID()
  2818. case aliyunavatar.FieldAccessKeyID:
  2819. return m.AccessKeyID()
  2820. case aliyunavatar.FieldAccessKeySecret:
  2821. return m.AccessKeySecret()
  2822. case aliyunavatar.FieldAppID:
  2823. return m.AppID()
  2824. case aliyunavatar.FieldTenantID:
  2825. return m.TenantID()
  2826. case aliyunavatar.FieldResponse:
  2827. return m.Response()
  2828. case aliyunavatar.FieldToken:
  2829. return m.Token()
  2830. case aliyunavatar.FieldSessionID:
  2831. return m.SessionID()
  2832. }
  2833. return nil, false
  2834. }
  2835. // OldField returns the old value of the field from the database. An error is
  2836. // returned if the mutation operation is not UpdateOne, or the query to the
  2837. // database failed.
  2838. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2839. switch name {
  2840. case aliyunavatar.FieldCreatedAt:
  2841. return m.OldCreatedAt(ctx)
  2842. case aliyunavatar.FieldUpdatedAt:
  2843. return m.OldUpdatedAt(ctx)
  2844. case aliyunavatar.FieldDeletedAt:
  2845. return m.OldDeletedAt(ctx)
  2846. case aliyunavatar.FieldUserID:
  2847. return m.OldUserID(ctx)
  2848. case aliyunavatar.FieldBizID:
  2849. return m.OldBizID(ctx)
  2850. case aliyunavatar.FieldAccessKeyID:
  2851. return m.OldAccessKeyID(ctx)
  2852. case aliyunavatar.FieldAccessKeySecret:
  2853. return m.OldAccessKeySecret(ctx)
  2854. case aliyunavatar.FieldAppID:
  2855. return m.OldAppID(ctx)
  2856. case aliyunavatar.FieldTenantID:
  2857. return m.OldTenantID(ctx)
  2858. case aliyunavatar.FieldResponse:
  2859. return m.OldResponse(ctx)
  2860. case aliyunavatar.FieldToken:
  2861. return m.OldToken(ctx)
  2862. case aliyunavatar.FieldSessionID:
  2863. return m.OldSessionID(ctx)
  2864. }
  2865. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2866. }
  2867. // SetField sets the value of a field with the given name. It returns an error if
  2868. // the field is not defined in the schema, or if the type mismatched the field
  2869. // type.
  2870. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2871. switch name {
  2872. case aliyunavatar.FieldCreatedAt:
  2873. v, ok := value.(time.Time)
  2874. if !ok {
  2875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2876. }
  2877. m.SetCreatedAt(v)
  2878. return nil
  2879. case aliyunavatar.FieldUpdatedAt:
  2880. v, ok := value.(time.Time)
  2881. if !ok {
  2882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2883. }
  2884. m.SetUpdatedAt(v)
  2885. return nil
  2886. case aliyunavatar.FieldDeletedAt:
  2887. v, ok := value.(time.Time)
  2888. if !ok {
  2889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2890. }
  2891. m.SetDeletedAt(v)
  2892. return nil
  2893. case aliyunavatar.FieldUserID:
  2894. v, ok := value.(uint64)
  2895. if !ok {
  2896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2897. }
  2898. m.SetUserID(v)
  2899. return nil
  2900. case aliyunavatar.FieldBizID:
  2901. v, ok := value.(string)
  2902. if !ok {
  2903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2904. }
  2905. m.SetBizID(v)
  2906. return nil
  2907. case aliyunavatar.FieldAccessKeyID:
  2908. v, ok := value.(string)
  2909. if !ok {
  2910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2911. }
  2912. m.SetAccessKeyID(v)
  2913. return nil
  2914. case aliyunavatar.FieldAccessKeySecret:
  2915. v, ok := value.(string)
  2916. if !ok {
  2917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2918. }
  2919. m.SetAccessKeySecret(v)
  2920. return nil
  2921. case aliyunavatar.FieldAppID:
  2922. v, ok := value.(string)
  2923. if !ok {
  2924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2925. }
  2926. m.SetAppID(v)
  2927. return nil
  2928. case aliyunavatar.FieldTenantID:
  2929. v, ok := value.(uint64)
  2930. if !ok {
  2931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2932. }
  2933. m.SetTenantID(v)
  2934. return nil
  2935. case aliyunavatar.FieldResponse:
  2936. v, ok := value.(string)
  2937. if !ok {
  2938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2939. }
  2940. m.SetResponse(v)
  2941. return nil
  2942. case aliyunavatar.FieldToken:
  2943. v, ok := value.(string)
  2944. if !ok {
  2945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2946. }
  2947. m.SetToken(v)
  2948. return nil
  2949. case aliyunavatar.FieldSessionID:
  2950. v, ok := value.(string)
  2951. if !ok {
  2952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2953. }
  2954. m.SetSessionID(v)
  2955. return nil
  2956. }
  2957. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2958. }
  2959. // AddedFields returns all numeric fields that were incremented/decremented during
  2960. // this mutation.
  2961. func (m *AliyunAvatarMutation) AddedFields() []string {
  2962. var fields []string
  2963. if m.adduser_id != nil {
  2964. fields = append(fields, aliyunavatar.FieldUserID)
  2965. }
  2966. if m.addtenant_id != nil {
  2967. fields = append(fields, aliyunavatar.FieldTenantID)
  2968. }
  2969. return fields
  2970. }
  2971. // AddedField returns the numeric value that was incremented/decremented on a field
  2972. // with the given name. The second boolean return value indicates that this field
  2973. // was not set, or was not defined in the schema.
  2974. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2975. switch name {
  2976. case aliyunavatar.FieldUserID:
  2977. return m.AddedUserID()
  2978. case aliyunavatar.FieldTenantID:
  2979. return m.AddedTenantID()
  2980. }
  2981. return nil, false
  2982. }
  2983. // AddField adds the value to the field with the given name. It returns an error if
  2984. // the field is not defined in the schema, or if the type mismatched the field
  2985. // type.
  2986. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  2987. switch name {
  2988. case aliyunavatar.FieldUserID:
  2989. v, ok := value.(int64)
  2990. if !ok {
  2991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2992. }
  2993. m.AddUserID(v)
  2994. return nil
  2995. case aliyunavatar.FieldTenantID:
  2996. v, ok := value.(int64)
  2997. if !ok {
  2998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2999. }
  3000. m.AddTenantID(v)
  3001. return nil
  3002. }
  3003. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3004. }
  3005. // ClearedFields returns all nullable fields that were cleared during this
  3006. // mutation.
  3007. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3008. var fields []string
  3009. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3010. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3011. }
  3012. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3013. fields = append(fields, aliyunavatar.FieldAppID)
  3014. }
  3015. return fields
  3016. }
  3017. // FieldCleared returns a boolean indicating if a field with the given name was
  3018. // cleared in this mutation.
  3019. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3020. _, ok := m.clearedFields[name]
  3021. return ok
  3022. }
  3023. // ClearField clears the value of the field with the given name. It returns an
  3024. // error if the field is not defined in the schema.
  3025. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3026. switch name {
  3027. case aliyunavatar.FieldDeletedAt:
  3028. m.ClearDeletedAt()
  3029. return nil
  3030. case aliyunavatar.FieldAppID:
  3031. m.ClearAppID()
  3032. return nil
  3033. }
  3034. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3035. }
  3036. // ResetField resets all changes in the mutation for the field with the given name.
  3037. // It returns an error if the field is not defined in the schema.
  3038. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3039. switch name {
  3040. case aliyunavatar.FieldCreatedAt:
  3041. m.ResetCreatedAt()
  3042. return nil
  3043. case aliyunavatar.FieldUpdatedAt:
  3044. m.ResetUpdatedAt()
  3045. return nil
  3046. case aliyunavatar.FieldDeletedAt:
  3047. m.ResetDeletedAt()
  3048. return nil
  3049. case aliyunavatar.FieldUserID:
  3050. m.ResetUserID()
  3051. return nil
  3052. case aliyunavatar.FieldBizID:
  3053. m.ResetBizID()
  3054. return nil
  3055. case aliyunavatar.FieldAccessKeyID:
  3056. m.ResetAccessKeyID()
  3057. return nil
  3058. case aliyunavatar.FieldAccessKeySecret:
  3059. m.ResetAccessKeySecret()
  3060. return nil
  3061. case aliyunavatar.FieldAppID:
  3062. m.ResetAppID()
  3063. return nil
  3064. case aliyunavatar.FieldTenantID:
  3065. m.ResetTenantID()
  3066. return nil
  3067. case aliyunavatar.FieldResponse:
  3068. m.ResetResponse()
  3069. return nil
  3070. case aliyunavatar.FieldToken:
  3071. m.ResetToken()
  3072. return nil
  3073. case aliyunavatar.FieldSessionID:
  3074. m.ResetSessionID()
  3075. return nil
  3076. }
  3077. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3078. }
  3079. // AddedEdges returns all edge names that were set/added in this mutation.
  3080. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3081. edges := make([]string, 0, 0)
  3082. return edges
  3083. }
  3084. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3085. // name in this mutation.
  3086. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3087. return nil
  3088. }
  3089. // RemovedEdges returns all edge names that were removed in this mutation.
  3090. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3091. edges := make([]string, 0, 0)
  3092. return edges
  3093. }
  3094. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3095. // the given name in this mutation.
  3096. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3097. return nil
  3098. }
  3099. // ClearedEdges returns all edge names that were cleared in this mutation.
  3100. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3101. edges := make([]string, 0, 0)
  3102. return edges
  3103. }
  3104. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3105. // was cleared in this mutation.
  3106. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3107. return false
  3108. }
  3109. // ClearEdge clears the value of the edge with the given name. It returns an error
  3110. // if that edge is not defined in the schema.
  3111. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3112. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3113. }
  3114. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3115. // It returns an error if the edge is not defined in the schema.
  3116. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3117. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3118. }
  3119. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3120. type AllocAgentMutation struct {
  3121. config
  3122. op Op
  3123. typ string
  3124. id *uint64
  3125. created_at *time.Time
  3126. updated_at *time.Time
  3127. deleted_at *time.Time
  3128. user_id *string
  3129. organization_id *uint64
  3130. addorganization_id *int64
  3131. agents *[]uint64
  3132. appendagents []uint64
  3133. status *int
  3134. addstatus *int
  3135. clearedFields map[string]struct{}
  3136. done bool
  3137. oldValue func(context.Context) (*AllocAgent, error)
  3138. predicates []predicate.AllocAgent
  3139. }
  3140. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3141. // allocagentOption allows management of the mutation configuration using functional options.
  3142. type allocagentOption func(*AllocAgentMutation)
  3143. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3144. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3145. m := &AllocAgentMutation{
  3146. config: c,
  3147. op: op,
  3148. typ: TypeAllocAgent,
  3149. clearedFields: make(map[string]struct{}),
  3150. }
  3151. for _, opt := range opts {
  3152. opt(m)
  3153. }
  3154. return m
  3155. }
  3156. // withAllocAgentID sets the ID field of the mutation.
  3157. func withAllocAgentID(id uint64) allocagentOption {
  3158. return func(m *AllocAgentMutation) {
  3159. var (
  3160. err error
  3161. once sync.Once
  3162. value *AllocAgent
  3163. )
  3164. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3165. once.Do(func() {
  3166. if m.done {
  3167. err = errors.New("querying old values post mutation is not allowed")
  3168. } else {
  3169. value, err = m.Client().AllocAgent.Get(ctx, id)
  3170. }
  3171. })
  3172. return value, err
  3173. }
  3174. m.id = &id
  3175. }
  3176. }
  3177. // withAllocAgent sets the old AllocAgent of the mutation.
  3178. func withAllocAgent(node *AllocAgent) allocagentOption {
  3179. return func(m *AllocAgentMutation) {
  3180. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3181. return node, nil
  3182. }
  3183. m.id = &node.ID
  3184. }
  3185. }
  3186. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3187. // executed in a transaction (ent.Tx), a transactional client is returned.
  3188. func (m AllocAgentMutation) Client() *Client {
  3189. client := &Client{config: m.config}
  3190. client.init()
  3191. return client
  3192. }
  3193. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3194. // it returns an error otherwise.
  3195. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3196. if _, ok := m.driver.(*txDriver); !ok {
  3197. return nil, errors.New("ent: mutation is not running in a transaction")
  3198. }
  3199. tx := &Tx{config: m.config}
  3200. tx.init()
  3201. return tx, nil
  3202. }
  3203. // SetID sets the value of the id field. Note that this
  3204. // operation is only accepted on creation of AllocAgent entities.
  3205. func (m *AllocAgentMutation) SetID(id uint64) {
  3206. m.id = &id
  3207. }
  3208. // ID returns the ID value in the mutation. Note that the ID is only available
  3209. // if it was provided to the builder or after it was returned from the database.
  3210. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3211. if m.id == nil {
  3212. return
  3213. }
  3214. return *m.id, true
  3215. }
  3216. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3217. // That means, if the mutation is applied within a transaction with an isolation level such
  3218. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3219. // or updated by the mutation.
  3220. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3221. switch {
  3222. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3223. id, exists := m.ID()
  3224. if exists {
  3225. return []uint64{id}, nil
  3226. }
  3227. fallthrough
  3228. case m.op.Is(OpUpdate | OpDelete):
  3229. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3230. default:
  3231. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3232. }
  3233. }
  3234. // SetCreatedAt sets the "created_at" field.
  3235. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3236. m.created_at = &t
  3237. }
  3238. // CreatedAt returns the value of the "created_at" field in the mutation.
  3239. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3240. v := m.created_at
  3241. if v == nil {
  3242. return
  3243. }
  3244. return *v, true
  3245. }
  3246. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3247. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3249. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3250. if !m.op.Is(OpUpdateOne) {
  3251. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3252. }
  3253. if m.id == nil || m.oldValue == nil {
  3254. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3255. }
  3256. oldValue, err := m.oldValue(ctx)
  3257. if err != nil {
  3258. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3259. }
  3260. return oldValue.CreatedAt, nil
  3261. }
  3262. // ResetCreatedAt resets all changes to the "created_at" field.
  3263. func (m *AllocAgentMutation) ResetCreatedAt() {
  3264. m.created_at = nil
  3265. }
  3266. // SetUpdatedAt sets the "updated_at" field.
  3267. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3268. m.updated_at = &t
  3269. }
  3270. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3271. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3272. v := m.updated_at
  3273. if v == nil {
  3274. return
  3275. }
  3276. return *v, true
  3277. }
  3278. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3279. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3281. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3282. if !m.op.Is(OpUpdateOne) {
  3283. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3284. }
  3285. if m.id == nil || m.oldValue == nil {
  3286. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3287. }
  3288. oldValue, err := m.oldValue(ctx)
  3289. if err != nil {
  3290. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3291. }
  3292. return oldValue.UpdatedAt, nil
  3293. }
  3294. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3295. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3296. m.updated_at = nil
  3297. }
  3298. // SetDeletedAt sets the "deleted_at" field.
  3299. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3300. m.deleted_at = &t
  3301. }
  3302. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3303. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3304. v := m.deleted_at
  3305. if v == nil {
  3306. return
  3307. }
  3308. return *v, true
  3309. }
  3310. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3311. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3313. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3314. if !m.op.Is(OpUpdateOne) {
  3315. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3316. }
  3317. if m.id == nil || m.oldValue == nil {
  3318. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3319. }
  3320. oldValue, err := m.oldValue(ctx)
  3321. if err != nil {
  3322. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3323. }
  3324. return oldValue.DeletedAt, nil
  3325. }
  3326. // ClearDeletedAt clears the value of the "deleted_at" field.
  3327. func (m *AllocAgentMutation) ClearDeletedAt() {
  3328. m.deleted_at = nil
  3329. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3330. }
  3331. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3332. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3333. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3334. return ok
  3335. }
  3336. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3337. func (m *AllocAgentMutation) ResetDeletedAt() {
  3338. m.deleted_at = nil
  3339. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3340. }
  3341. // SetUserID sets the "user_id" field.
  3342. func (m *AllocAgentMutation) SetUserID(s string) {
  3343. m.user_id = &s
  3344. }
  3345. // UserID returns the value of the "user_id" field in the mutation.
  3346. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3347. v := m.user_id
  3348. if v == nil {
  3349. return
  3350. }
  3351. return *v, true
  3352. }
  3353. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3354. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3356. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3357. if !m.op.Is(OpUpdateOne) {
  3358. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3359. }
  3360. if m.id == nil || m.oldValue == nil {
  3361. return v, errors.New("OldUserID requires an ID field in the mutation")
  3362. }
  3363. oldValue, err := m.oldValue(ctx)
  3364. if err != nil {
  3365. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3366. }
  3367. return oldValue.UserID, nil
  3368. }
  3369. // ClearUserID clears the value of the "user_id" field.
  3370. func (m *AllocAgentMutation) ClearUserID() {
  3371. m.user_id = nil
  3372. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3373. }
  3374. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3375. func (m *AllocAgentMutation) UserIDCleared() bool {
  3376. _, ok := m.clearedFields[allocagent.FieldUserID]
  3377. return ok
  3378. }
  3379. // ResetUserID resets all changes to the "user_id" field.
  3380. func (m *AllocAgentMutation) ResetUserID() {
  3381. m.user_id = nil
  3382. delete(m.clearedFields, allocagent.FieldUserID)
  3383. }
  3384. // SetOrganizationID sets the "organization_id" field.
  3385. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3386. m.organization_id = &u
  3387. m.addorganization_id = nil
  3388. }
  3389. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3390. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3391. v := m.organization_id
  3392. if v == nil {
  3393. return
  3394. }
  3395. return *v, true
  3396. }
  3397. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3398. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3400. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3401. if !m.op.Is(OpUpdateOne) {
  3402. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3403. }
  3404. if m.id == nil || m.oldValue == nil {
  3405. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3406. }
  3407. oldValue, err := m.oldValue(ctx)
  3408. if err != nil {
  3409. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3410. }
  3411. return oldValue.OrganizationID, nil
  3412. }
  3413. // AddOrganizationID adds u to the "organization_id" field.
  3414. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3415. if m.addorganization_id != nil {
  3416. *m.addorganization_id += u
  3417. } else {
  3418. m.addorganization_id = &u
  3419. }
  3420. }
  3421. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3422. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3423. v := m.addorganization_id
  3424. if v == nil {
  3425. return
  3426. }
  3427. return *v, true
  3428. }
  3429. // ClearOrganizationID clears the value of the "organization_id" field.
  3430. func (m *AllocAgentMutation) ClearOrganizationID() {
  3431. m.organization_id = nil
  3432. m.addorganization_id = nil
  3433. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3434. }
  3435. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3436. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3437. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3438. return ok
  3439. }
  3440. // ResetOrganizationID resets all changes to the "organization_id" field.
  3441. func (m *AllocAgentMutation) ResetOrganizationID() {
  3442. m.organization_id = nil
  3443. m.addorganization_id = nil
  3444. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3445. }
  3446. // SetAgents sets the "agents" field.
  3447. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3448. m.agents = &u
  3449. m.appendagents = nil
  3450. }
  3451. // Agents returns the value of the "agents" field in the mutation.
  3452. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3453. v := m.agents
  3454. if v == nil {
  3455. return
  3456. }
  3457. return *v, true
  3458. }
  3459. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3460. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3462. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3463. if !m.op.Is(OpUpdateOne) {
  3464. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3465. }
  3466. if m.id == nil || m.oldValue == nil {
  3467. return v, errors.New("OldAgents requires an ID field in the mutation")
  3468. }
  3469. oldValue, err := m.oldValue(ctx)
  3470. if err != nil {
  3471. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3472. }
  3473. return oldValue.Agents, nil
  3474. }
  3475. // AppendAgents adds u to the "agents" field.
  3476. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3477. m.appendagents = append(m.appendagents, u...)
  3478. }
  3479. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3480. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3481. if len(m.appendagents) == 0 {
  3482. return nil, false
  3483. }
  3484. return m.appendagents, true
  3485. }
  3486. // ResetAgents resets all changes to the "agents" field.
  3487. func (m *AllocAgentMutation) ResetAgents() {
  3488. m.agents = nil
  3489. m.appendagents = nil
  3490. }
  3491. // SetStatus sets the "status" field.
  3492. func (m *AllocAgentMutation) SetStatus(i int) {
  3493. m.status = &i
  3494. m.addstatus = nil
  3495. }
  3496. // Status returns the value of the "status" field in the mutation.
  3497. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3498. v := m.status
  3499. if v == nil {
  3500. return
  3501. }
  3502. return *v, true
  3503. }
  3504. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3505. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3507. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3508. if !m.op.Is(OpUpdateOne) {
  3509. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3510. }
  3511. if m.id == nil || m.oldValue == nil {
  3512. return v, errors.New("OldStatus requires an ID field in the mutation")
  3513. }
  3514. oldValue, err := m.oldValue(ctx)
  3515. if err != nil {
  3516. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3517. }
  3518. return oldValue.Status, nil
  3519. }
  3520. // AddStatus adds i to the "status" field.
  3521. func (m *AllocAgentMutation) AddStatus(i int) {
  3522. if m.addstatus != nil {
  3523. *m.addstatus += i
  3524. } else {
  3525. m.addstatus = &i
  3526. }
  3527. }
  3528. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3529. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3530. v := m.addstatus
  3531. if v == nil {
  3532. return
  3533. }
  3534. return *v, true
  3535. }
  3536. // ClearStatus clears the value of the "status" field.
  3537. func (m *AllocAgentMutation) ClearStatus() {
  3538. m.status = nil
  3539. m.addstatus = nil
  3540. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3541. }
  3542. // StatusCleared returns if the "status" field was cleared in this mutation.
  3543. func (m *AllocAgentMutation) StatusCleared() bool {
  3544. _, ok := m.clearedFields[allocagent.FieldStatus]
  3545. return ok
  3546. }
  3547. // ResetStatus resets all changes to the "status" field.
  3548. func (m *AllocAgentMutation) ResetStatus() {
  3549. m.status = nil
  3550. m.addstatus = nil
  3551. delete(m.clearedFields, allocagent.FieldStatus)
  3552. }
  3553. // Where appends a list predicates to the AllocAgentMutation builder.
  3554. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3555. m.predicates = append(m.predicates, ps...)
  3556. }
  3557. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3558. // users can use type-assertion to append predicates that do not depend on any generated package.
  3559. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3560. p := make([]predicate.AllocAgent, len(ps))
  3561. for i := range ps {
  3562. p[i] = ps[i]
  3563. }
  3564. m.Where(p...)
  3565. }
  3566. // Op returns the operation name.
  3567. func (m *AllocAgentMutation) Op() Op {
  3568. return m.op
  3569. }
  3570. // SetOp allows setting the mutation operation.
  3571. func (m *AllocAgentMutation) SetOp(op Op) {
  3572. m.op = op
  3573. }
  3574. // Type returns the node type of this mutation (AllocAgent).
  3575. func (m *AllocAgentMutation) Type() string {
  3576. return m.typ
  3577. }
  3578. // Fields returns all fields that were changed during this mutation. Note that in
  3579. // order to get all numeric fields that were incremented/decremented, call
  3580. // AddedFields().
  3581. func (m *AllocAgentMutation) Fields() []string {
  3582. fields := make([]string, 0, 7)
  3583. if m.created_at != nil {
  3584. fields = append(fields, allocagent.FieldCreatedAt)
  3585. }
  3586. if m.updated_at != nil {
  3587. fields = append(fields, allocagent.FieldUpdatedAt)
  3588. }
  3589. if m.deleted_at != nil {
  3590. fields = append(fields, allocagent.FieldDeletedAt)
  3591. }
  3592. if m.user_id != nil {
  3593. fields = append(fields, allocagent.FieldUserID)
  3594. }
  3595. if m.organization_id != nil {
  3596. fields = append(fields, allocagent.FieldOrganizationID)
  3597. }
  3598. if m.agents != nil {
  3599. fields = append(fields, allocagent.FieldAgents)
  3600. }
  3601. if m.status != nil {
  3602. fields = append(fields, allocagent.FieldStatus)
  3603. }
  3604. return fields
  3605. }
  3606. // Field returns the value of a field with the given name. The second boolean
  3607. // return value indicates that this field was not set, or was not defined in the
  3608. // schema.
  3609. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3610. switch name {
  3611. case allocagent.FieldCreatedAt:
  3612. return m.CreatedAt()
  3613. case allocagent.FieldUpdatedAt:
  3614. return m.UpdatedAt()
  3615. case allocagent.FieldDeletedAt:
  3616. return m.DeletedAt()
  3617. case allocagent.FieldUserID:
  3618. return m.UserID()
  3619. case allocagent.FieldOrganizationID:
  3620. return m.OrganizationID()
  3621. case allocagent.FieldAgents:
  3622. return m.Agents()
  3623. case allocagent.FieldStatus:
  3624. return m.Status()
  3625. }
  3626. return nil, false
  3627. }
  3628. // OldField returns the old value of the field from the database. An error is
  3629. // returned if the mutation operation is not UpdateOne, or the query to the
  3630. // database failed.
  3631. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3632. switch name {
  3633. case allocagent.FieldCreatedAt:
  3634. return m.OldCreatedAt(ctx)
  3635. case allocagent.FieldUpdatedAt:
  3636. return m.OldUpdatedAt(ctx)
  3637. case allocagent.FieldDeletedAt:
  3638. return m.OldDeletedAt(ctx)
  3639. case allocagent.FieldUserID:
  3640. return m.OldUserID(ctx)
  3641. case allocagent.FieldOrganizationID:
  3642. return m.OldOrganizationID(ctx)
  3643. case allocagent.FieldAgents:
  3644. return m.OldAgents(ctx)
  3645. case allocagent.FieldStatus:
  3646. return m.OldStatus(ctx)
  3647. }
  3648. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3649. }
  3650. // SetField sets the value of a field with the given name. It returns an error if
  3651. // the field is not defined in the schema, or if the type mismatched the field
  3652. // type.
  3653. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3654. switch name {
  3655. case allocagent.FieldCreatedAt:
  3656. v, ok := value.(time.Time)
  3657. if !ok {
  3658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3659. }
  3660. m.SetCreatedAt(v)
  3661. return nil
  3662. case allocagent.FieldUpdatedAt:
  3663. v, ok := value.(time.Time)
  3664. if !ok {
  3665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3666. }
  3667. m.SetUpdatedAt(v)
  3668. return nil
  3669. case allocagent.FieldDeletedAt:
  3670. v, ok := value.(time.Time)
  3671. if !ok {
  3672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3673. }
  3674. m.SetDeletedAt(v)
  3675. return nil
  3676. case allocagent.FieldUserID:
  3677. v, ok := value.(string)
  3678. if !ok {
  3679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3680. }
  3681. m.SetUserID(v)
  3682. return nil
  3683. case allocagent.FieldOrganizationID:
  3684. v, ok := value.(uint64)
  3685. if !ok {
  3686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3687. }
  3688. m.SetOrganizationID(v)
  3689. return nil
  3690. case allocagent.FieldAgents:
  3691. v, ok := value.([]uint64)
  3692. if !ok {
  3693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3694. }
  3695. m.SetAgents(v)
  3696. return nil
  3697. case allocagent.FieldStatus:
  3698. v, ok := value.(int)
  3699. if !ok {
  3700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3701. }
  3702. m.SetStatus(v)
  3703. return nil
  3704. }
  3705. return fmt.Errorf("unknown AllocAgent field %s", name)
  3706. }
  3707. // AddedFields returns all numeric fields that were incremented/decremented during
  3708. // this mutation.
  3709. func (m *AllocAgentMutation) AddedFields() []string {
  3710. var fields []string
  3711. if m.addorganization_id != nil {
  3712. fields = append(fields, allocagent.FieldOrganizationID)
  3713. }
  3714. if m.addstatus != nil {
  3715. fields = append(fields, allocagent.FieldStatus)
  3716. }
  3717. return fields
  3718. }
  3719. // AddedField returns the numeric value that was incremented/decremented on a field
  3720. // with the given name. The second boolean return value indicates that this field
  3721. // was not set, or was not defined in the schema.
  3722. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3723. switch name {
  3724. case allocagent.FieldOrganizationID:
  3725. return m.AddedOrganizationID()
  3726. case allocagent.FieldStatus:
  3727. return m.AddedStatus()
  3728. }
  3729. return nil, false
  3730. }
  3731. // AddField adds the value to the field with the given name. It returns an error if
  3732. // the field is not defined in the schema, or if the type mismatched the field
  3733. // type.
  3734. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3735. switch name {
  3736. case allocagent.FieldOrganizationID:
  3737. v, ok := value.(int64)
  3738. if !ok {
  3739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3740. }
  3741. m.AddOrganizationID(v)
  3742. return nil
  3743. case allocagent.FieldStatus:
  3744. v, ok := value.(int)
  3745. if !ok {
  3746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3747. }
  3748. m.AddStatus(v)
  3749. return nil
  3750. }
  3751. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3752. }
  3753. // ClearedFields returns all nullable fields that were cleared during this
  3754. // mutation.
  3755. func (m *AllocAgentMutation) ClearedFields() []string {
  3756. var fields []string
  3757. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3758. fields = append(fields, allocagent.FieldDeletedAt)
  3759. }
  3760. if m.FieldCleared(allocagent.FieldUserID) {
  3761. fields = append(fields, allocagent.FieldUserID)
  3762. }
  3763. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3764. fields = append(fields, allocagent.FieldOrganizationID)
  3765. }
  3766. if m.FieldCleared(allocagent.FieldStatus) {
  3767. fields = append(fields, allocagent.FieldStatus)
  3768. }
  3769. return fields
  3770. }
  3771. // FieldCleared returns a boolean indicating if a field with the given name was
  3772. // cleared in this mutation.
  3773. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3774. _, ok := m.clearedFields[name]
  3775. return ok
  3776. }
  3777. // ClearField clears the value of the field with the given name. It returns an
  3778. // error if the field is not defined in the schema.
  3779. func (m *AllocAgentMutation) ClearField(name string) error {
  3780. switch name {
  3781. case allocagent.FieldDeletedAt:
  3782. m.ClearDeletedAt()
  3783. return nil
  3784. case allocagent.FieldUserID:
  3785. m.ClearUserID()
  3786. return nil
  3787. case allocagent.FieldOrganizationID:
  3788. m.ClearOrganizationID()
  3789. return nil
  3790. case allocagent.FieldStatus:
  3791. m.ClearStatus()
  3792. return nil
  3793. }
  3794. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3795. }
  3796. // ResetField resets all changes in the mutation for the field with the given name.
  3797. // It returns an error if the field is not defined in the schema.
  3798. func (m *AllocAgentMutation) ResetField(name string) error {
  3799. switch name {
  3800. case allocagent.FieldCreatedAt:
  3801. m.ResetCreatedAt()
  3802. return nil
  3803. case allocagent.FieldUpdatedAt:
  3804. m.ResetUpdatedAt()
  3805. return nil
  3806. case allocagent.FieldDeletedAt:
  3807. m.ResetDeletedAt()
  3808. return nil
  3809. case allocagent.FieldUserID:
  3810. m.ResetUserID()
  3811. return nil
  3812. case allocagent.FieldOrganizationID:
  3813. m.ResetOrganizationID()
  3814. return nil
  3815. case allocagent.FieldAgents:
  3816. m.ResetAgents()
  3817. return nil
  3818. case allocagent.FieldStatus:
  3819. m.ResetStatus()
  3820. return nil
  3821. }
  3822. return fmt.Errorf("unknown AllocAgent field %s", name)
  3823. }
  3824. // AddedEdges returns all edge names that were set/added in this mutation.
  3825. func (m *AllocAgentMutation) AddedEdges() []string {
  3826. edges := make([]string, 0, 0)
  3827. return edges
  3828. }
  3829. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3830. // name in this mutation.
  3831. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3832. return nil
  3833. }
  3834. // RemovedEdges returns all edge names that were removed in this mutation.
  3835. func (m *AllocAgentMutation) RemovedEdges() []string {
  3836. edges := make([]string, 0, 0)
  3837. return edges
  3838. }
  3839. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3840. // the given name in this mutation.
  3841. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3842. return nil
  3843. }
  3844. // ClearedEdges returns all edge names that were cleared in this mutation.
  3845. func (m *AllocAgentMutation) ClearedEdges() []string {
  3846. edges := make([]string, 0, 0)
  3847. return edges
  3848. }
  3849. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3850. // was cleared in this mutation.
  3851. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3852. return false
  3853. }
  3854. // ClearEdge clears the value of the edge with the given name. It returns an error
  3855. // if that edge is not defined in the schema.
  3856. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3857. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3858. }
  3859. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3860. // It returns an error if the edge is not defined in the schema.
  3861. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3862. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3863. }
  3864. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3865. type BatchMsgMutation struct {
  3866. config
  3867. op Op
  3868. typ string
  3869. id *uint64
  3870. created_at *time.Time
  3871. updated_at *time.Time
  3872. deleted_at *time.Time
  3873. status *uint8
  3874. addstatus *int8
  3875. batch_no *string
  3876. task_name *string
  3877. fromwxid *string
  3878. msg *string
  3879. tag *string
  3880. tagids *string
  3881. total *int32
  3882. addtotal *int32
  3883. success *int32
  3884. addsuccess *int32
  3885. fail *int32
  3886. addfail *int32
  3887. start_time *time.Time
  3888. stop_time *time.Time
  3889. send_time *time.Time
  3890. _type *int32
  3891. add_type *int32
  3892. organization_id *uint64
  3893. addorganization_id *int64
  3894. clearedFields map[string]struct{}
  3895. done bool
  3896. oldValue func(context.Context) (*BatchMsg, error)
  3897. predicates []predicate.BatchMsg
  3898. }
  3899. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3900. // batchmsgOption allows management of the mutation configuration using functional options.
  3901. type batchmsgOption func(*BatchMsgMutation)
  3902. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3903. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3904. m := &BatchMsgMutation{
  3905. config: c,
  3906. op: op,
  3907. typ: TypeBatchMsg,
  3908. clearedFields: make(map[string]struct{}),
  3909. }
  3910. for _, opt := range opts {
  3911. opt(m)
  3912. }
  3913. return m
  3914. }
  3915. // withBatchMsgID sets the ID field of the mutation.
  3916. func withBatchMsgID(id uint64) batchmsgOption {
  3917. return func(m *BatchMsgMutation) {
  3918. var (
  3919. err error
  3920. once sync.Once
  3921. value *BatchMsg
  3922. )
  3923. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3924. once.Do(func() {
  3925. if m.done {
  3926. err = errors.New("querying old values post mutation is not allowed")
  3927. } else {
  3928. value, err = m.Client().BatchMsg.Get(ctx, id)
  3929. }
  3930. })
  3931. return value, err
  3932. }
  3933. m.id = &id
  3934. }
  3935. }
  3936. // withBatchMsg sets the old BatchMsg of the mutation.
  3937. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3938. return func(m *BatchMsgMutation) {
  3939. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3940. return node, nil
  3941. }
  3942. m.id = &node.ID
  3943. }
  3944. }
  3945. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3946. // executed in a transaction (ent.Tx), a transactional client is returned.
  3947. func (m BatchMsgMutation) Client() *Client {
  3948. client := &Client{config: m.config}
  3949. client.init()
  3950. return client
  3951. }
  3952. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3953. // it returns an error otherwise.
  3954. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3955. if _, ok := m.driver.(*txDriver); !ok {
  3956. return nil, errors.New("ent: mutation is not running in a transaction")
  3957. }
  3958. tx := &Tx{config: m.config}
  3959. tx.init()
  3960. return tx, nil
  3961. }
  3962. // SetID sets the value of the id field. Note that this
  3963. // operation is only accepted on creation of BatchMsg entities.
  3964. func (m *BatchMsgMutation) SetID(id uint64) {
  3965. m.id = &id
  3966. }
  3967. // ID returns the ID value in the mutation. Note that the ID is only available
  3968. // if it was provided to the builder or after it was returned from the database.
  3969. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3970. if m.id == nil {
  3971. return
  3972. }
  3973. return *m.id, true
  3974. }
  3975. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3976. // That means, if the mutation is applied within a transaction with an isolation level such
  3977. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3978. // or updated by the mutation.
  3979. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3980. switch {
  3981. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3982. id, exists := m.ID()
  3983. if exists {
  3984. return []uint64{id}, nil
  3985. }
  3986. fallthrough
  3987. case m.op.Is(OpUpdate | OpDelete):
  3988. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  3989. default:
  3990. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3991. }
  3992. }
  3993. // SetCreatedAt sets the "created_at" field.
  3994. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  3995. m.created_at = &t
  3996. }
  3997. // CreatedAt returns the value of the "created_at" field in the mutation.
  3998. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  3999. v := m.created_at
  4000. if v == nil {
  4001. return
  4002. }
  4003. return *v, true
  4004. }
  4005. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4006. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4008. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4009. if !m.op.Is(OpUpdateOne) {
  4010. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4011. }
  4012. if m.id == nil || m.oldValue == nil {
  4013. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4014. }
  4015. oldValue, err := m.oldValue(ctx)
  4016. if err != nil {
  4017. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4018. }
  4019. return oldValue.CreatedAt, nil
  4020. }
  4021. // ResetCreatedAt resets all changes to the "created_at" field.
  4022. func (m *BatchMsgMutation) ResetCreatedAt() {
  4023. m.created_at = nil
  4024. }
  4025. // SetUpdatedAt sets the "updated_at" field.
  4026. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4027. m.updated_at = &t
  4028. }
  4029. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4030. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4031. v := m.updated_at
  4032. if v == nil {
  4033. return
  4034. }
  4035. return *v, true
  4036. }
  4037. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4038. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4040. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4041. if !m.op.Is(OpUpdateOne) {
  4042. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4043. }
  4044. if m.id == nil || m.oldValue == nil {
  4045. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4046. }
  4047. oldValue, err := m.oldValue(ctx)
  4048. if err != nil {
  4049. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4050. }
  4051. return oldValue.UpdatedAt, nil
  4052. }
  4053. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4054. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4055. m.updated_at = nil
  4056. }
  4057. // SetDeletedAt sets the "deleted_at" field.
  4058. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4059. m.deleted_at = &t
  4060. }
  4061. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4062. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4063. v := m.deleted_at
  4064. if v == nil {
  4065. return
  4066. }
  4067. return *v, true
  4068. }
  4069. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4070. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4072. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4073. if !m.op.Is(OpUpdateOne) {
  4074. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4075. }
  4076. if m.id == nil || m.oldValue == nil {
  4077. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4078. }
  4079. oldValue, err := m.oldValue(ctx)
  4080. if err != nil {
  4081. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4082. }
  4083. return oldValue.DeletedAt, nil
  4084. }
  4085. // ClearDeletedAt clears the value of the "deleted_at" field.
  4086. func (m *BatchMsgMutation) ClearDeletedAt() {
  4087. m.deleted_at = nil
  4088. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4089. }
  4090. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4091. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4092. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4093. return ok
  4094. }
  4095. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4096. func (m *BatchMsgMutation) ResetDeletedAt() {
  4097. m.deleted_at = nil
  4098. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4099. }
  4100. // SetStatus sets the "status" field.
  4101. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4102. m.status = &u
  4103. m.addstatus = nil
  4104. }
  4105. // Status returns the value of the "status" field in the mutation.
  4106. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4107. v := m.status
  4108. if v == nil {
  4109. return
  4110. }
  4111. return *v, true
  4112. }
  4113. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4114. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4116. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4117. if !m.op.Is(OpUpdateOne) {
  4118. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4119. }
  4120. if m.id == nil || m.oldValue == nil {
  4121. return v, errors.New("OldStatus requires an ID field in the mutation")
  4122. }
  4123. oldValue, err := m.oldValue(ctx)
  4124. if err != nil {
  4125. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4126. }
  4127. return oldValue.Status, nil
  4128. }
  4129. // AddStatus adds u to the "status" field.
  4130. func (m *BatchMsgMutation) AddStatus(u int8) {
  4131. if m.addstatus != nil {
  4132. *m.addstatus += u
  4133. } else {
  4134. m.addstatus = &u
  4135. }
  4136. }
  4137. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4138. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4139. v := m.addstatus
  4140. if v == nil {
  4141. return
  4142. }
  4143. return *v, true
  4144. }
  4145. // ClearStatus clears the value of the "status" field.
  4146. func (m *BatchMsgMutation) ClearStatus() {
  4147. m.status = nil
  4148. m.addstatus = nil
  4149. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4150. }
  4151. // StatusCleared returns if the "status" field was cleared in this mutation.
  4152. func (m *BatchMsgMutation) StatusCleared() bool {
  4153. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4154. return ok
  4155. }
  4156. // ResetStatus resets all changes to the "status" field.
  4157. func (m *BatchMsgMutation) ResetStatus() {
  4158. m.status = nil
  4159. m.addstatus = nil
  4160. delete(m.clearedFields, batchmsg.FieldStatus)
  4161. }
  4162. // SetBatchNo sets the "batch_no" field.
  4163. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4164. m.batch_no = &s
  4165. }
  4166. // BatchNo returns the value of the "batch_no" field in the mutation.
  4167. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4168. v := m.batch_no
  4169. if v == nil {
  4170. return
  4171. }
  4172. return *v, true
  4173. }
  4174. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4175. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4177. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4178. if !m.op.Is(OpUpdateOne) {
  4179. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4180. }
  4181. if m.id == nil || m.oldValue == nil {
  4182. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4183. }
  4184. oldValue, err := m.oldValue(ctx)
  4185. if err != nil {
  4186. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4187. }
  4188. return oldValue.BatchNo, nil
  4189. }
  4190. // ClearBatchNo clears the value of the "batch_no" field.
  4191. func (m *BatchMsgMutation) ClearBatchNo() {
  4192. m.batch_no = nil
  4193. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4194. }
  4195. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4196. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4197. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4198. return ok
  4199. }
  4200. // ResetBatchNo resets all changes to the "batch_no" field.
  4201. func (m *BatchMsgMutation) ResetBatchNo() {
  4202. m.batch_no = nil
  4203. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4204. }
  4205. // SetTaskName sets the "task_name" field.
  4206. func (m *BatchMsgMutation) SetTaskName(s string) {
  4207. m.task_name = &s
  4208. }
  4209. // TaskName returns the value of the "task_name" field in the mutation.
  4210. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4211. v := m.task_name
  4212. if v == nil {
  4213. return
  4214. }
  4215. return *v, true
  4216. }
  4217. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4218. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4220. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4221. if !m.op.Is(OpUpdateOne) {
  4222. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4223. }
  4224. if m.id == nil || m.oldValue == nil {
  4225. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4226. }
  4227. oldValue, err := m.oldValue(ctx)
  4228. if err != nil {
  4229. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4230. }
  4231. return oldValue.TaskName, nil
  4232. }
  4233. // ClearTaskName clears the value of the "task_name" field.
  4234. func (m *BatchMsgMutation) ClearTaskName() {
  4235. m.task_name = nil
  4236. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4237. }
  4238. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4239. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4240. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4241. return ok
  4242. }
  4243. // ResetTaskName resets all changes to the "task_name" field.
  4244. func (m *BatchMsgMutation) ResetTaskName() {
  4245. m.task_name = nil
  4246. delete(m.clearedFields, batchmsg.FieldTaskName)
  4247. }
  4248. // SetFromwxid sets the "fromwxid" field.
  4249. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4250. m.fromwxid = &s
  4251. }
  4252. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4253. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4254. v := m.fromwxid
  4255. if v == nil {
  4256. return
  4257. }
  4258. return *v, true
  4259. }
  4260. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4261. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4263. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4264. if !m.op.Is(OpUpdateOne) {
  4265. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4266. }
  4267. if m.id == nil || m.oldValue == nil {
  4268. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4269. }
  4270. oldValue, err := m.oldValue(ctx)
  4271. if err != nil {
  4272. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4273. }
  4274. return oldValue.Fromwxid, nil
  4275. }
  4276. // ClearFromwxid clears the value of the "fromwxid" field.
  4277. func (m *BatchMsgMutation) ClearFromwxid() {
  4278. m.fromwxid = nil
  4279. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4280. }
  4281. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4282. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4283. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4284. return ok
  4285. }
  4286. // ResetFromwxid resets all changes to the "fromwxid" field.
  4287. func (m *BatchMsgMutation) ResetFromwxid() {
  4288. m.fromwxid = nil
  4289. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4290. }
  4291. // SetMsg sets the "msg" field.
  4292. func (m *BatchMsgMutation) SetMsg(s string) {
  4293. m.msg = &s
  4294. }
  4295. // Msg returns the value of the "msg" field in the mutation.
  4296. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4297. v := m.msg
  4298. if v == nil {
  4299. return
  4300. }
  4301. return *v, true
  4302. }
  4303. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4304. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4306. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4307. if !m.op.Is(OpUpdateOne) {
  4308. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4309. }
  4310. if m.id == nil || m.oldValue == nil {
  4311. return v, errors.New("OldMsg requires an ID field in the mutation")
  4312. }
  4313. oldValue, err := m.oldValue(ctx)
  4314. if err != nil {
  4315. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4316. }
  4317. return oldValue.Msg, nil
  4318. }
  4319. // ClearMsg clears the value of the "msg" field.
  4320. func (m *BatchMsgMutation) ClearMsg() {
  4321. m.msg = nil
  4322. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4323. }
  4324. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4325. func (m *BatchMsgMutation) MsgCleared() bool {
  4326. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4327. return ok
  4328. }
  4329. // ResetMsg resets all changes to the "msg" field.
  4330. func (m *BatchMsgMutation) ResetMsg() {
  4331. m.msg = nil
  4332. delete(m.clearedFields, batchmsg.FieldMsg)
  4333. }
  4334. // SetTag sets the "tag" field.
  4335. func (m *BatchMsgMutation) SetTag(s string) {
  4336. m.tag = &s
  4337. }
  4338. // Tag returns the value of the "tag" field in the mutation.
  4339. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4340. v := m.tag
  4341. if v == nil {
  4342. return
  4343. }
  4344. return *v, true
  4345. }
  4346. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4347. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4349. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4350. if !m.op.Is(OpUpdateOne) {
  4351. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4352. }
  4353. if m.id == nil || m.oldValue == nil {
  4354. return v, errors.New("OldTag requires an ID field in the mutation")
  4355. }
  4356. oldValue, err := m.oldValue(ctx)
  4357. if err != nil {
  4358. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4359. }
  4360. return oldValue.Tag, nil
  4361. }
  4362. // ClearTag clears the value of the "tag" field.
  4363. func (m *BatchMsgMutation) ClearTag() {
  4364. m.tag = nil
  4365. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4366. }
  4367. // TagCleared returns if the "tag" field was cleared in this mutation.
  4368. func (m *BatchMsgMutation) TagCleared() bool {
  4369. _, ok := m.clearedFields[batchmsg.FieldTag]
  4370. return ok
  4371. }
  4372. // ResetTag resets all changes to the "tag" field.
  4373. func (m *BatchMsgMutation) ResetTag() {
  4374. m.tag = nil
  4375. delete(m.clearedFields, batchmsg.FieldTag)
  4376. }
  4377. // SetTagids sets the "tagids" field.
  4378. func (m *BatchMsgMutation) SetTagids(s string) {
  4379. m.tagids = &s
  4380. }
  4381. // Tagids returns the value of the "tagids" field in the mutation.
  4382. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4383. v := m.tagids
  4384. if v == nil {
  4385. return
  4386. }
  4387. return *v, true
  4388. }
  4389. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4390. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4392. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4393. if !m.op.Is(OpUpdateOne) {
  4394. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4395. }
  4396. if m.id == nil || m.oldValue == nil {
  4397. return v, errors.New("OldTagids requires an ID field in the mutation")
  4398. }
  4399. oldValue, err := m.oldValue(ctx)
  4400. if err != nil {
  4401. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4402. }
  4403. return oldValue.Tagids, nil
  4404. }
  4405. // ClearTagids clears the value of the "tagids" field.
  4406. func (m *BatchMsgMutation) ClearTagids() {
  4407. m.tagids = nil
  4408. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4409. }
  4410. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4411. func (m *BatchMsgMutation) TagidsCleared() bool {
  4412. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4413. return ok
  4414. }
  4415. // ResetTagids resets all changes to the "tagids" field.
  4416. func (m *BatchMsgMutation) ResetTagids() {
  4417. m.tagids = nil
  4418. delete(m.clearedFields, batchmsg.FieldTagids)
  4419. }
  4420. // SetTotal sets the "total" field.
  4421. func (m *BatchMsgMutation) SetTotal(i int32) {
  4422. m.total = &i
  4423. m.addtotal = nil
  4424. }
  4425. // Total returns the value of the "total" field in the mutation.
  4426. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4427. v := m.total
  4428. if v == nil {
  4429. return
  4430. }
  4431. return *v, true
  4432. }
  4433. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4434. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4436. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4437. if !m.op.Is(OpUpdateOne) {
  4438. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4439. }
  4440. if m.id == nil || m.oldValue == nil {
  4441. return v, errors.New("OldTotal requires an ID field in the mutation")
  4442. }
  4443. oldValue, err := m.oldValue(ctx)
  4444. if err != nil {
  4445. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4446. }
  4447. return oldValue.Total, nil
  4448. }
  4449. // AddTotal adds i to the "total" field.
  4450. func (m *BatchMsgMutation) AddTotal(i int32) {
  4451. if m.addtotal != nil {
  4452. *m.addtotal += i
  4453. } else {
  4454. m.addtotal = &i
  4455. }
  4456. }
  4457. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4458. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4459. v := m.addtotal
  4460. if v == nil {
  4461. return
  4462. }
  4463. return *v, true
  4464. }
  4465. // ClearTotal clears the value of the "total" field.
  4466. func (m *BatchMsgMutation) ClearTotal() {
  4467. m.total = nil
  4468. m.addtotal = nil
  4469. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4470. }
  4471. // TotalCleared returns if the "total" field was cleared in this mutation.
  4472. func (m *BatchMsgMutation) TotalCleared() bool {
  4473. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4474. return ok
  4475. }
  4476. // ResetTotal resets all changes to the "total" field.
  4477. func (m *BatchMsgMutation) ResetTotal() {
  4478. m.total = nil
  4479. m.addtotal = nil
  4480. delete(m.clearedFields, batchmsg.FieldTotal)
  4481. }
  4482. // SetSuccess sets the "success" field.
  4483. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4484. m.success = &i
  4485. m.addsuccess = nil
  4486. }
  4487. // Success returns the value of the "success" field in the mutation.
  4488. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4489. v := m.success
  4490. if v == nil {
  4491. return
  4492. }
  4493. return *v, true
  4494. }
  4495. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4496. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4498. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4499. if !m.op.Is(OpUpdateOne) {
  4500. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4501. }
  4502. if m.id == nil || m.oldValue == nil {
  4503. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4504. }
  4505. oldValue, err := m.oldValue(ctx)
  4506. if err != nil {
  4507. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4508. }
  4509. return oldValue.Success, nil
  4510. }
  4511. // AddSuccess adds i to the "success" field.
  4512. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4513. if m.addsuccess != nil {
  4514. *m.addsuccess += i
  4515. } else {
  4516. m.addsuccess = &i
  4517. }
  4518. }
  4519. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4520. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4521. v := m.addsuccess
  4522. if v == nil {
  4523. return
  4524. }
  4525. return *v, true
  4526. }
  4527. // ClearSuccess clears the value of the "success" field.
  4528. func (m *BatchMsgMutation) ClearSuccess() {
  4529. m.success = nil
  4530. m.addsuccess = nil
  4531. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4532. }
  4533. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4534. func (m *BatchMsgMutation) SuccessCleared() bool {
  4535. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4536. return ok
  4537. }
  4538. // ResetSuccess resets all changes to the "success" field.
  4539. func (m *BatchMsgMutation) ResetSuccess() {
  4540. m.success = nil
  4541. m.addsuccess = nil
  4542. delete(m.clearedFields, batchmsg.FieldSuccess)
  4543. }
  4544. // SetFail sets the "fail" field.
  4545. func (m *BatchMsgMutation) SetFail(i int32) {
  4546. m.fail = &i
  4547. m.addfail = nil
  4548. }
  4549. // Fail returns the value of the "fail" field in the mutation.
  4550. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4551. v := m.fail
  4552. if v == nil {
  4553. return
  4554. }
  4555. return *v, true
  4556. }
  4557. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4558. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4560. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4561. if !m.op.Is(OpUpdateOne) {
  4562. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4563. }
  4564. if m.id == nil || m.oldValue == nil {
  4565. return v, errors.New("OldFail requires an ID field in the mutation")
  4566. }
  4567. oldValue, err := m.oldValue(ctx)
  4568. if err != nil {
  4569. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4570. }
  4571. return oldValue.Fail, nil
  4572. }
  4573. // AddFail adds i to the "fail" field.
  4574. func (m *BatchMsgMutation) AddFail(i int32) {
  4575. if m.addfail != nil {
  4576. *m.addfail += i
  4577. } else {
  4578. m.addfail = &i
  4579. }
  4580. }
  4581. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4582. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4583. v := m.addfail
  4584. if v == nil {
  4585. return
  4586. }
  4587. return *v, true
  4588. }
  4589. // ClearFail clears the value of the "fail" field.
  4590. func (m *BatchMsgMutation) ClearFail() {
  4591. m.fail = nil
  4592. m.addfail = nil
  4593. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4594. }
  4595. // FailCleared returns if the "fail" field was cleared in this mutation.
  4596. func (m *BatchMsgMutation) FailCleared() bool {
  4597. _, ok := m.clearedFields[batchmsg.FieldFail]
  4598. return ok
  4599. }
  4600. // ResetFail resets all changes to the "fail" field.
  4601. func (m *BatchMsgMutation) ResetFail() {
  4602. m.fail = nil
  4603. m.addfail = nil
  4604. delete(m.clearedFields, batchmsg.FieldFail)
  4605. }
  4606. // SetStartTime sets the "start_time" field.
  4607. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4608. m.start_time = &t
  4609. }
  4610. // StartTime returns the value of the "start_time" field in the mutation.
  4611. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4612. v := m.start_time
  4613. if v == nil {
  4614. return
  4615. }
  4616. return *v, true
  4617. }
  4618. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4619. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4621. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4622. if !m.op.Is(OpUpdateOne) {
  4623. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4624. }
  4625. if m.id == nil || m.oldValue == nil {
  4626. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4627. }
  4628. oldValue, err := m.oldValue(ctx)
  4629. if err != nil {
  4630. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4631. }
  4632. return oldValue.StartTime, nil
  4633. }
  4634. // ClearStartTime clears the value of the "start_time" field.
  4635. func (m *BatchMsgMutation) ClearStartTime() {
  4636. m.start_time = nil
  4637. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4638. }
  4639. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4640. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4641. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4642. return ok
  4643. }
  4644. // ResetStartTime resets all changes to the "start_time" field.
  4645. func (m *BatchMsgMutation) ResetStartTime() {
  4646. m.start_time = nil
  4647. delete(m.clearedFields, batchmsg.FieldStartTime)
  4648. }
  4649. // SetStopTime sets the "stop_time" field.
  4650. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4651. m.stop_time = &t
  4652. }
  4653. // StopTime returns the value of the "stop_time" field in the mutation.
  4654. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4655. v := m.stop_time
  4656. if v == nil {
  4657. return
  4658. }
  4659. return *v, true
  4660. }
  4661. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4662. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4664. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4665. if !m.op.Is(OpUpdateOne) {
  4666. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4667. }
  4668. if m.id == nil || m.oldValue == nil {
  4669. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4670. }
  4671. oldValue, err := m.oldValue(ctx)
  4672. if err != nil {
  4673. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4674. }
  4675. return oldValue.StopTime, nil
  4676. }
  4677. // ClearStopTime clears the value of the "stop_time" field.
  4678. func (m *BatchMsgMutation) ClearStopTime() {
  4679. m.stop_time = nil
  4680. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4681. }
  4682. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4683. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4684. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4685. return ok
  4686. }
  4687. // ResetStopTime resets all changes to the "stop_time" field.
  4688. func (m *BatchMsgMutation) ResetStopTime() {
  4689. m.stop_time = nil
  4690. delete(m.clearedFields, batchmsg.FieldStopTime)
  4691. }
  4692. // SetSendTime sets the "send_time" field.
  4693. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4694. m.send_time = &t
  4695. }
  4696. // SendTime returns the value of the "send_time" field in the mutation.
  4697. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4698. v := m.send_time
  4699. if v == nil {
  4700. return
  4701. }
  4702. return *v, true
  4703. }
  4704. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4705. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4707. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4708. if !m.op.Is(OpUpdateOne) {
  4709. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4710. }
  4711. if m.id == nil || m.oldValue == nil {
  4712. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4713. }
  4714. oldValue, err := m.oldValue(ctx)
  4715. if err != nil {
  4716. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4717. }
  4718. return oldValue.SendTime, nil
  4719. }
  4720. // ClearSendTime clears the value of the "send_time" field.
  4721. func (m *BatchMsgMutation) ClearSendTime() {
  4722. m.send_time = nil
  4723. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4724. }
  4725. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4726. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4727. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4728. return ok
  4729. }
  4730. // ResetSendTime resets all changes to the "send_time" field.
  4731. func (m *BatchMsgMutation) ResetSendTime() {
  4732. m.send_time = nil
  4733. delete(m.clearedFields, batchmsg.FieldSendTime)
  4734. }
  4735. // SetType sets the "type" field.
  4736. func (m *BatchMsgMutation) SetType(i int32) {
  4737. m._type = &i
  4738. m.add_type = nil
  4739. }
  4740. // GetType returns the value of the "type" field in the mutation.
  4741. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4742. v := m._type
  4743. if v == nil {
  4744. return
  4745. }
  4746. return *v, true
  4747. }
  4748. // OldType returns the old "type" field's value of the BatchMsg entity.
  4749. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4751. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4752. if !m.op.Is(OpUpdateOne) {
  4753. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4754. }
  4755. if m.id == nil || m.oldValue == nil {
  4756. return v, errors.New("OldType requires an ID field in the mutation")
  4757. }
  4758. oldValue, err := m.oldValue(ctx)
  4759. if err != nil {
  4760. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4761. }
  4762. return oldValue.Type, nil
  4763. }
  4764. // AddType adds i to the "type" field.
  4765. func (m *BatchMsgMutation) AddType(i int32) {
  4766. if m.add_type != nil {
  4767. *m.add_type += i
  4768. } else {
  4769. m.add_type = &i
  4770. }
  4771. }
  4772. // AddedType returns the value that was added to the "type" field in this mutation.
  4773. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4774. v := m.add_type
  4775. if v == nil {
  4776. return
  4777. }
  4778. return *v, true
  4779. }
  4780. // ClearType clears the value of the "type" field.
  4781. func (m *BatchMsgMutation) ClearType() {
  4782. m._type = nil
  4783. m.add_type = nil
  4784. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4785. }
  4786. // TypeCleared returns if the "type" field was cleared in this mutation.
  4787. func (m *BatchMsgMutation) TypeCleared() bool {
  4788. _, ok := m.clearedFields[batchmsg.FieldType]
  4789. return ok
  4790. }
  4791. // ResetType resets all changes to the "type" field.
  4792. func (m *BatchMsgMutation) ResetType() {
  4793. m._type = nil
  4794. m.add_type = nil
  4795. delete(m.clearedFields, batchmsg.FieldType)
  4796. }
  4797. // SetOrganizationID sets the "organization_id" field.
  4798. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4799. m.organization_id = &u
  4800. m.addorganization_id = nil
  4801. }
  4802. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4803. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4804. v := m.organization_id
  4805. if v == nil {
  4806. return
  4807. }
  4808. return *v, true
  4809. }
  4810. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4811. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4813. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4814. if !m.op.Is(OpUpdateOne) {
  4815. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4816. }
  4817. if m.id == nil || m.oldValue == nil {
  4818. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4819. }
  4820. oldValue, err := m.oldValue(ctx)
  4821. if err != nil {
  4822. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4823. }
  4824. return oldValue.OrganizationID, nil
  4825. }
  4826. // AddOrganizationID adds u to the "organization_id" field.
  4827. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4828. if m.addorganization_id != nil {
  4829. *m.addorganization_id += u
  4830. } else {
  4831. m.addorganization_id = &u
  4832. }
  4833. }
  4834. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4835. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4836. v := m.addorganization_id
  4837. if v == nil {
  4838. return
  4839. }
  4840. return *v, true
  4841. }
  4842. // ResetOrganizationID resets all changes to the "organization_id" field.
  4843. func (m *BatchMsgMutation) ResetOrganizationID() {
  4844. m.organization_id = nil
  4845. m.addorganization_id = nil
  4846. }
  4847. // Where appends a list predicates to the BatchMsgMutation builder.
  4848. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4849. m.predicates = append(m.predicates, ps...)
  4850. }
  4851. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4852. // users can use type-assertion to append predicates that do not depend on any generated package.
  4853. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4854. p := make([]predicate.BatchMsg, len(ps))
  4855. for i := range ps {
  4856. p[i] = ps[i]
  4857. }
  4858. m.Where(p...)
  4859. }
  4860. // Op returns the operation name.
  4861. func (m *BatchMsgMutation) Op() Op {
  4862. return m.op
  4863. }
  4864. // SetOp allows setting the mutation operation.
  4865. func (m *BatchMsgMutation) SetOp(op Op) {
  4866. m.op = op
  4867. }
  4868. // Type returns the node type of this mutation (BatchMsg).
  4869. func (m *BatchMsgMutation) Type() string {
  4870. return m.typ
  4871. }
  4872. // Fields returns all fields that were changed during this mutation. Note that in
  4873. // order to get all numeric fields that were incremented/decremented, call
  4874. // AddedFields().
  4875. func (m *BatchMsgMutation) Fields() []string {
  4876. fields := make([]string, 0, 18)
  4877. if m.created_at != nil {
  4878. fields = append(fields, batchmsg.FieldCreatedAt)
  4879. }
  4880. if m.updated_at != nil {
  4881. fields = append(fields, batchmsg.FieldUpdatedAt)
  4882. }
  4883. if m.deleted_at != nil {
  4884. fields = append(fields, batchmsg.FieldDeletedAt)
  4885. }
  4886. if m.status != nil {
  4887. fields = append(fields, batchmsg.FieldStatus)
  4888. }
  4889. if m.batch_no != nil {
  4890. fields = append(fields, batchmsg.FieldBatchNo)
  4891. }
  4892. if m.task_name != nil {
  4893. fields = append(fields, batchmsg.FieldTaskName)
  4894. }
  4895. if m.fromwxid != nil {
  4896. fields = append(fields, batchmsg.FieldFromwxid)
  4897. }
  4898. if m.msg != nil {
  4899. fields = append(fields, batchmsg.FieldMsg)
  4900. }
  4901. if m.tag != nil {
  4902. fields = append(fields, batchmsg.FieldTag)
  4903. }
  4904. if m.tagids != nil {
  4905. fields = append(fields, batchmsg.FieldTagids)
  4906. }
  4907. if m.total != nil {
  4908. fields = append(fields, batchmsg.FieldTotal)
  4909. }
  4910. if m.success != nil {
  4911. fields = append(fields, batchmsg.FieldSuccess)
  4912. }
  4913. if m.fail != nil {
  4914. fields = append(fields, batchmsg.FieldFail)
  4915. }
  4916. if m.start_time != nil {
  4917. fields = append(fields, batchmsg.FieldStartTime)
  4918. }
  4919. if m.stop_time != nil {
  4920. fields = append(fields, batchmsg.FieldStopTime)
  4921. }
  4922. if m.send_time != nil {
  4923. fields = append(fields, batchmsg.FieldSendTime)
  4924. }
  4925. if m._type != nil {
  4926. fields = append(fields, batchmsg.FieldType)
  4927. }
  4928. if m.organization_id != nil {
  4929. fields = append(fields, batchmsg.FieldOrganizationID)
  4930. }
  4931. return fields
  4932. }
  4933. // Field returns the value of a field with the given name. The second boolean
  4934. // return value indicates that this field was not set, or was not defined in the
  4935. // schema.
  4936. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4937. switch name {
  4938. case batchmsg.FieldCreatedAt:
  4939. return m.CreatedAt()
  4940. case batchmsg.FieldUpdatedAt:
  4941. return m.UpdatedAt()
  4942. case batchmsg.FieldDeletedAt:
  4943. return m.DeletedAt()
  4944. case batchmsg.FieldStatus:
  4945. return m.Status()
  4946. case batchmsg.FieldBatchNo:
  4947. return m.BatchNo()
  4948. case batchmsg.FieldTaskName:
  4949. return m.TaskName()
  4950. case batchmsg.FieldFromwxid:
  4951. return m.Fromwxid()
  4952. case batchmsg.FieldMsg:
  4953. return m.Msg()
  4954. case batchmsg.FieldTag:
  4955. return m.Tag()
  4956. case batchmsg.FieldTagids:
  4957. return m.Tagids()
  4958. case batchmsg.FieldTotal:
  4959. return m.Total()
  4960. case batchmsg.FieldSuccess:
  4961. return m.Success()
  4962. case batchmsg.FieldFail:
  4963. return m.Fail()
  4964. case batchmsg.FieldStartTime:
  4965. return m.StartTime()
  4966. case batchmsg.FieldStopTime:
  4967. return m.StopTime()
  4968. case batchmsg.FieldSendTime:
  4969. return m.SendTime()
  4970. case batchmsg.FieldType:
  4971. return m.GetType()
  4972. case batchmsg.FieldOrganizationID:
  4973. return m.OrganizationID()
  4974. }
  4975. return nil, false
  4976. }
  4977. // OldField returns the old value of the field from the database. An error is
  4978. // returned if the mutation operation is not UpdateOne, or the query to the
  4979. // database failed.
  4980. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4981. switch name {
  4982. case batchmsg.FieldCreatedAt:
  4983. return m.OldCreatedAt(ctx)
  4984. case batchmsg.FieldUpdatedAt:
  4985. return m.OldUpdatedAt(ctx)
  4986. case batchmsg.FieldDeletedAt:
  4987. return m.OldDeletedAt(ctx)
  4988. case batchmsg.FieldStatus:
  4989. return m.OldStatus(ctx)
  4990. case batchmsg.FieldBatchNo:
  4991. return m.OldBatchNo(ctx)
  4992. case batchmsg.FieldTaskName:
  4993. return m.OldTaskName(ctx)
  4994. case batchmsg.FieldFromwxid:
  4995. return m.OldFromwxid(ctx)
  4996. case batchmsg.FieldMsg:
  4997. return m.OldMsg(ctx)
  4998. case batchmsg.FieldTag:
  4999. return m.OldTag(ctx)
  5000. case batchmsg.FieldTagids:
  5001. return m.OldTagids(ctx)
  5002. case batchmsg.FieldTotal:
  5003. return m.OldTotal(ctx)
  5004. case batchmsg.FieldSuccess:
  5005. return m.OldSuccess(ctx)
  5006. case batchmsg.FieldFail:
  5007. return m.OldFail(ctx)
  5008. case batchmsg.FieldStartTime:
  5009. return m.OldStartTime(ctx)
  5010. case batchmsg.FieldStopTime:
  5011. return m.OldStopTime(ctx)
  5012. case batchmsg.FieldSendTime:
  5013. return m.OldSendTime(ctx)
  5014. case batchmsg.FieldType:
  5015. return m.OldType(ctx)
  5016. case batchmsg.FieldOrganizationID:
  5017. return m.OldOrganizationID(ctx)
  5018. }
  5019. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5020. }
  5021. // SetField sets the value of a field with the given name. It returns an error if
  5022. // the field is not defined in the schema, or if the type mismatched the field
  5023. // type.
  5024. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5025. switch name {
  5026. case batchmsg.FieldCreatedAt:
  5027. v, ok := value.(time.Time)
  5028. if !ok {
  5029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5030. }
  5031. m.SetCreatedAt(v)
  5032. return nil
  5033. case batchmsg.FieldUpdatedAt:
  5034. v, ok := value.(time.Time)
  5035. if !ok {
  5036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5037. }
  5038. m.SetUpdatedAt(v)
  5039. return nil
  5040. case batchmsg.FieldDeletedAt:
  5041. v, ok := value.(time.Time)
  5042. if !ok {
  5043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5044. }
  5045. m.SetDeletedAt(v)
  5046. return nil
  5047. case batchmsg.FieldStatus:
  5048. v, ok := value.(uint8)
  5049. if !ok {
  5050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5051. }
  5052. m.SetStatus(v)
  5053. return nil
  5054. case batchmsg.FieldBatchNo:
  5055. v, ok := value.(string)
  5056. if !ok {
  5057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5058. }
  5059. m.SetBatchNo(v)
  5060. return nil
  5061. case batchmsg.FieldTaskName:
  5062. v, ok := value.(string)
  5063. if !ok {
  5064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5065. }
  5066. m.SetTaskName(v)
  5067. return nil
  5068. case batchmsg.FieldFromwxid:
  5069. v, ok := value.(string)
  5070. if !ok {
  5071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5072. }
  5073. m.SetFromwxid(v)
  5074. return nil
  5075. case batchmsg.FieldMsg:
  5076. v, ok := value.(string)
  5077. if !ok {
  5078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5079. }
  5080. m.SetMsg(v)
  5081. return nil
  5082. case batchmsg.FieldTag:
  5083. v, ok := value.(string)
  5084. if !ok {
  5085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5086. }
  5087. m.SetTag(v)
  5088. return nil
  5089. case batchmsg.FieldTagids:
  5090. v, ok := value.(string)
  5091. if !ok {
  5092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5093. }
  5094. m.SetTagids(v)
  5095. return nil
  5096. case batchmsg.FieldTotal:
  5097. v, ok := value.(int32)
  5098. if !ok {
  5099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5100. }
  5101. m.SetTotal(v)
  5102. return nil
  5103. case batchmsg.FieldSuccess:
  5104. v, ok := value.(int32)
  5105. if !ok {
  5106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5107. }
  5108. m.SetSuccess(v)
  5109. return nil
  5110. case batchmsg.FieldFail:
  5111. v, ok := value.(int32)
  5112. if !ok {
  5113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5114. }
  5115. m.SetFail(v)
  5116. return nil
  5117. case batchmsg.FieldStartTime:
  5118. v, ok := value.(time.Time)
  5119. if !ok {
  5120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5121. }
  5122. m.SetStartTime(v)
  5123. return nil
  5124. case batchmsg.FieldStopTime:
  5125. v, ok := value.(time.Time)
  5126. if !ok {
  5127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5128. }
  5129. m.SetStopTime(v)
  5130. return nil
  5131. case batchmsg.FieldSendTime:
  5132. v, ok := value.(time.Time)
  5133. if !ok {
  5134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5135. }
  5136. m.SetSendTime(v)
  5137. return nil
  5138. case batchmsg.FieldType:
  5139. v, ok := value.(int32)
  5140. if !ok {
  5141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5142. }
  5143. m.SetType(v)
  5144. return nil
  5145. case batchmsg.FieldOrganizationID:
  5146. v, ok := value.(uint64)
  5147. if !ok {
  5148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5149. }
  5150. m.SetOrganizationID(v)
  5151. return nil
  5152. }
  5153. return fmt.Errorf("unknown BatchMsg field %s", name)
  5154. }
  5155. // AddedFields returns all numeric fields that were incremented/decremented during
  5156. // this mutation.
  5157. func (m *BatchMsgMutation) AddedFields() []string {
  5158. var fields []string
  5159. if m.addstatus != nil {
  5160. fields = append(fields, batchmsg.FieldStatus)
  5161. }
  5162. if m.addtotal != nil {
  5163. fields = append(fields, batchmsg.FieldTotal)
  5164. }
  5165. if m.addsuccess != nil {
  5166. fields = append(fields, batchmsg.FieldSuccess)
  5167. }
  5168. if m.addfail != nil {
  5169. fields = append(fields, batchmsg.FieldFail)
  5170. }
  5171. if m.add_type != nil {
  5172. fields = append(fields, batchmsg.FieldType)
  5173. }
  5174. if m.addorganization_id != nil {
  5175. fields = append(fields, batchmsg.FieldOrganizationID)
  5176. }
  5177. return fields
  5178. }
  5179. // AddedField returns the numeric value that was incremented/decremented on a field
  5180. // with the given name. The second boolean return value indicates that this field
  5181. // was not set, or was not defined in the schema.
  5182. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5183. switch name {
  5184. case batchmsg.FieldStatus:
  5185. return m.AddedStatus()
  5186. case batchmsg.FieldTotal:
  5187. return m.AddedTotal()
  5188. case batchmsg.FieldSuccess:
  5189. return m.AddedSuccess()
  5190. case batchmsg.FieldFail:
  5191. return m.AddedFail()
  5192. case batchmsg.FieldType:
  5193. return m.AddedType()
  5194. case batchmsg.FieldOrganizationID:
  5195. return m.AddedOrganizationID()
  5196. }
  5197. return nil, false
  5198. }
  5199. // AddField adds the value to the field with the given name. It returns an error if
  5200. // the field is not defined in the schema, or if the type mismatched the field
  5201. // type.
  5202. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5203. switch name {
  5204. case batchmsg.FieldStatus:
  5205. v, ok := value.(int8)
  5206. if !ok {
  5207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5208. }
  5209. m.AddStatus(v)
  5210. return nil
  5211. case batchmsg.FieldTotal:
  5212. v, ok := value.(int32)
  5213. if !ok {
  5214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5215. }
  5216. m.AddTotal(v)
  5217. return nil
  5218. case batchmsg.FieldSuccess:
  5219. v, ok := value.(int32)
  5220. if !ok {
  5221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5222. }
  5223. m.AddSuccess(v)
  5224. return nil
  5225. case batchmsg.FieldFail:
  5226. v, ok := value.(int32)
  5227. if !ok {
  5228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5229. }
  5230. m.AddFail(v)
  5231. return nil
  5232. case batchmsg.FieldType:
  5233. v, ok := value.(int32)
  5234. if !ok {
  5235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5236. }
  5237. m.AddType(v)
  5238. return nil
  5239. case batchmsg.FieldOrganizationID:
  5240. v, ok := value.(int64)
  5241. if !ok {
  5242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5243. }
  5244. m.AddOrganizationID(v)
  5245. return nil
  5246. }
  5247. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5248. }
  5249. // ClearedFields returns all nullable fields that were cleared during this
  5250. // mutation.
  5251. func (m *BatchMsgMutation) ClearedFields() []string {
  5252. var fields []string
  5253. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5254. fields = append(fields, batchmsg.FieldDeletedAt)
  5255. }
  5256. if m.FieldCleared(batchmsg.FieldStatus) {
  5257. fields = append(fields, batchmsg.FieldStatus)
  5258. }
  5259. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5260. fields = append(fields, batchmsg.FieldBatchNo)
  5261. }
  5262. if m.FieldCleared(batchmsg.FieldTaskName) {
  5263. fields = append(fields, batchmsg.FieldTaskName)
  5264. }
  5265. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5266. fields = append(fields, batchmsg.FieldFromwxid)
  5267. }
  5268. if m.FieldCleared(batchmsg.FieldMsg) {
  5269. fields = append(fields, batchmsg.FieldMsg)
  5270. }
  5271. if m.FieldCleared(batchmsg.FieldTag) {
  5272. fields = append(fields, batchmsg.FieldTag)
  5273. }
  5274. if m.FieldCleared(batchmsg.FieldTagids) {
  5275. fields = append(fields, batchmsg.FieldTagids)
  5276. }
  5277. if m.FieldCleared(batchmsg.FieldTotal) {
  5278. fields = append(fields, batchmsg.FieldTotal)
  5279. }
  5280. if m.FieldCleared(batchmsg.FieldSuccess) {
  5281. fields = append(fields, batchmsg.FieldSuccess)
  5282. }
  5283. if m.FieldCleared(batchmsg.FieldFail) {
  5284. fields = append(fields, batchmsg.FieldFail)
  5285. }
  5286. if m.FieldCleared(batchmsg.FieldStartTime) {
  5287. fields = append(fields, batchmsg.FieldStartTime)
  5288. }
  5289. if m.FieldCleared(batchmsg.FieldStopTime) {
  5290. fields = append(fields, batchmsg.FieldStopTime)
  5291. }
  5292. if m.FieldCleared(batchmsg.FieldSendTime) {
  5293. fields = append(fields, batchmsg.FieldSendTime)
  5294. }
  5295. if m.FieldCleared(batchmsg.FieldType) {
  5296. fields = append(fields, batchmsg.FieldType)
  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 *BatchMsgMutation) 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 *BatchMsgMutation) ClearField(name string) error {
  5309. switch name {
  5310. case batchmsg.FieldDeletedAt:
  5311. m.ClearDeletedAt()
  5312. return nil
  5313. case batchmsg.FieldStatus:
  5314. m.ClearStatus()
  5315. return nil
  5316. case batchmsg.FieldBatchNo:
  5317. m.ClearBatchNo()
  5318. return nil
  5319. case batchmsg.FieldTaskName:
  5320. m.ClearTaskName()
  5321. return nil
  5322. case batchmsg.FieldFromwxid:
  5323. m.ClearFromwxid()
  5324. return nil
  5325. case batchmsg.FieldMsg:
  5326. m.ClearMsg()
  5327. return nil
  5328. case batchmsg.FieldTag:
  5329. m.ClearTag()
  5330. return nil
  5331. case batchmsg.FieldTagids:
  5332. m.ClearTagids()
  5333. return nil
  5334. case batchmsg.FieldTotal:
  5335. m.ClearTotal()
  5336. return nil
  5337. case batchmsg.FieldSuccess:
  5338. m.ClearSuccess()
  5339. return nil
  5340. case batchmsg.FieldFail:
  5341. m.ClearFail()
  5342. return nil
  5343. case batchmsg.FieldStartTime:
  5344. m.ClearStartTime()
  5345. return nil
  5346. case batchmsg.FieldStopTime:
  5347. m.ClearStopTime()
  5348. return nil
  5349. case batchmsg.FieldSendTime:
  5350. m.ClearSendTime()
  5351. return nil
  5352. case batchmsg.FieldType:
  5353. m.ClearType()
  5354. return nil
  5355. }
  5356. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5357. }
  5358. // ResetField resets all changes in the mutation for the field with the given name.
  5359. // It returns an error if the field is not defined in the schema.
  5360. func (m *BatchMsgMutation) ResetField(name string) error {
  5361. switch name {
  5362. case batchmsg.FieldCreatedAt:
  5363. m.ResetCreatedAt()
  5364. return nil
  5365. case batchmsg.FieldUpdatedAt:
  5366. m.ResetUpdatedAt()
  5367. return nil
  5368. case batchmsg.FieldDeletedAt:
  5369. m.ResetDeletedAt()
  5370. return nil
  5371. case batchmsg.FieldStatus:
  5372. m.ResetStatus()
  5373. return nil
  5374. case batchmsg.FieldBatchNo:
  5375. m.ResetBatchNo()
  5376. return nil
  5377. case batchmsg.FieldTaskName:
  5378. m.ResetTaskName()
  5379. return nil
  5380. case batchmsg.FieldFromwxid:
  5381. m.ResetFromwxid()
  5382. return nil
  5383. case batchmsg.FieldMsg:
  5384. m.ResetMsg()
  5385. return nil
  5386. case batchmsg.FieldTag:
  5387. m.ResetTag()
  5388. return nil
  5389. case batchmsg.FieldTagids:
  5390. m.ResetTagids()
  5391. return nil
  5392. case batchmsg.FieldTotal:
  5393. m.ResetTotal()
  5394. return nil
  5395. case batchmsg.FieldSuccess:
  5396. m.ResetSuccess()
  5397. return nil
  5398. case batchmsg.FieldFail:
  5399. m.ResetFail()
  5400. return nil
  5401. case batchmsg.FieldStartTime:
  5402. m.ResetStartTime()
  5403. return nil
  5404. case batchmsg.FieldStopTime:
  5405. m.ResetStopTime()
  5406. return nil
  5407. case batchmsg.FieldSendTime:
  5408. m.ResetSendTime()
  5409. return nil
  5410. case batchmsg.FieldType:
  5411. m.ResetType()
  5412. return nil
  5413. case batchmsg.FieldOrganizationID:
  5414. m.ResetOrganizationID()
  5415. return nil
  5416. }
  5417. return fmt.Errorf("unknown BatchMsg field %s", name)
  5418. }
  5419. // AddedEdges returns all edge names that were set/added in this mutation.
  5420. func (m *BatchMsgMutation) AddedEdges() []string {
  5421. edges := make([]string, 0, 0)
  5422. return edges
  5423. }
  5424. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5425. // name in this mutation.
  5426. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5427. return nil
  5428. }
  5429. // RemovedEdges returns all edge names that were removed in this mutation.
  5430. func (m *BatchMsgMutation) RemovedEdges() []string {
  5431. edges := make([]string, 0, 0)
  5432. return edges
  5433. }
  5434. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5435. // the given name in this mutation.
  5436. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5437. return nil
  5438. }
  5439. // ClearedEdges returns all edge names that were cleared in this mutation.
  5440. func (m *BatchMsgMutation) ClearedEdges() []string {
  5441. edges := make([]string, 0, 0)
  5442. return edges
  5443. }
  5444. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5445. // was cleared in this mutation.
  5446. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5447. return false
  5448. }
  5449. // ClearEdge clears the value of the edge with the given name. It returns an error
  5450. // if that edge is not defined in the schema.
  5451. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5452. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5453. }
  5454. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5455. // It returns an error if the edge is not defined in the schema.
  5456. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5457. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5458. }
  5459. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5460. type CategoryMutation struct {
  5461. config
  5462. op Op
  5463. typ string
  5464. id *uint64
  5465. created_at *time.Time
  5466. updated_at *time.Time
  5467. deleted_at *time.Time
  5468. name *string
  5469. organization_id *uint64
  5470. addorganization_id *int64
  5471. clearedFields map[string]struct{}
  5472. done bool
  5473. oldValue func(context.Context) (*Category, error)
  5474. predicates []predicate.Category
  5475. }
  5476. var _ ent.Mutation = (*CategoryMutation)(nil)
  5477. // categoryOption allows management of the mutation configuration using functional options.
  5478. type categoryOption func(*CategoryMutation)
  5479. // newCategoryMutation creates new mutation for the Category entity.
  5480. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5481. m := &CategoryMutation{
  5482. config: c,
  5483. op: op,
  5484. typ: TypeCategory,
  5485. clearedFields: make(map[string]struct{}),
  5486. }
  5487. for _, opt := range opts {
  5488. opt(m)
  5489. }
  5490. return m
  5491. }
  5492. // withCategoryID sets the ID field of the mutation.
  5493. func withCategoryID(id uint64) categoryOption {
  5494. return func(m *CategoryMutation) {
  5495. var (
  5496. err error
  5497. once sync.Once
  5498. value *Category
  5499. )
  5500. m.oldValue = func(ctx context.Context) (*Category, error) {
  5501. once.Do(func() {
  5502. if m.done {
  5503. err = errors.New("querying old values post mutation is not allowed")
  5504. } else {
  5505. value, err = m.Client().Category.Get(ctx, id)
  5506. }
  5507. })
  5508. return value, err
  5509. }
  5510. m.id = &id
  5511. }
  5512. }
  5513. // withCategory sets the old Category of the mutation.
  5514. func withCategory(node *Category) categoryOption {
  5515. return func(m *CategoryMutation) {
  5516. m.oldValue = func(context.Context) (*Category, error) {
  5517. return node, nil
  5518. }
  5519. m.id = &node.ID
  5520. }
  5521. }
  5522. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5523. // executed in a transaction (ent.Tx), a transactional client is returned.
  5524. func (m CategoryMutation) Client() *Client {
  5525. client := &Client{config: m.config}
  5526. client.init()
  5527. return client
  5528. }
  5529. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5530. // it returns an error otherwise.
  5531. func (m CategoryMutation) Tx() (*Tx, error) {
  5532. if _, ok := m.driver.(*txDriver); !ok {
  5533. return nil, errors.New("ent: mutation is not running in a transaction")
  5534. }
  5535. tx := &Tx{config: m.config}
  5536. tx.init()
  5537. return tx, nil
  5538. }
  5539. // SetID sets the value of the id field. Note that this
  5540. // operation is only accepted on creation of Category entities.
  5541. func (m *CategoryMutation) SetID(id uint64) {
  5542. m.id = &id
  5543. }
  5544. // ID returns the ID value in the mutation. Note that the ID is only available
  5545. // if it was provided to the builder or after it was returned from the database.
  5546. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5547. if m.id == nil {
  5548. return
  5549. }
  5550. return *m.id, true
  5551. }
  5552. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5553. // That means, if the mutation is applied within a transaction with an isolation level such
  5554. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5555. // or updated by the mutation.
  5556. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5557. switch {
  5558. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5559. id, exists := m.ID()
  5560. if exists {
  5561. return []uint64{id}, nil
  5562. }
  5563. fallthrough
  5564. case m.op.Is(OpUpdate | OpDelete):
  5565. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5566. default:
  5567. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5568. }
  5569. }
  5570. // SetCreatedAt sets the "created_at" field.
  5571. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5572. m.created_at = &t
  5573. }
  5574. // CreatedAt returns the value of the "created_at" field in the mutation.
  5575. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5576. v := m.created_at
  5577. if v == nil {
  5578. return
  5579. }
  5580. return *v, true
  5581. }
  5582. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5583. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5585. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5586. if !m.op.Is(OpUpdateOne) {
  5587. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5588. }
  5589. if m.id == nil || m.oldValue == nil {
  5590. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5591. }
  5592. oldValue, err := m.oldValue(ctx)
  5593. if err != nil {
  5594. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5595. }
  5596. return oldValue.CreatedAt, nil
  5597. }
  5598. // ResetCreatedAt resets all changes to the "created_at" field.
  5599. func (m *CategoryMutation) ResetCreatedAt() {
  5600. m.created_at = nil
  5601. }
  5602. // SetUpdatedAt sets the "updated_at" field.
  5603. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5604. m.updated_at = &t
  5605. }
  5606. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5607. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5608. v := m.updated_at
  5609. if v == nil {
  5610. return
  5611. }
  5612. return *v, true
  5613. }
  5614. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5615. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5617. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5618. if !m.op.Is(OpUpdateOne) {
  5619. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5620. }
  5621. if m.id == nil || m.oldValue == nil {
  5622. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5623. }
  5624. oldValue, err := m.oldValue(ctx)
  5625. if err != nil {
  5626. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5627. }
  5628. return oldValue.UpdatedAt, nil
  5629. }
  5630. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5631. func (m *CategoryMutation) ResetUpdatedAt() {
  5632. m.updated_at = nil
  5633. }
  5634. // SetDeletedAt sets the "deleted_at" field.
  5635. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5636. m.deleted_at = &t
  5637. }
  5638. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5639. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5640. v := m.deleted_at
  5641. if v == nil {
  5642. return
  5643. }
  5644. return *v, true
  5645. }
  5646. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5647. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5649. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5650. if !m.op.Is(OpUpdateOne) {
  5651. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5652. }
  5653. if m.id == nil || m.oldValue == nil {
  5654. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5655. }
  5656. oldValue, err := m.oldValue(ctx)
  5657. if err != nil {
  5658. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5659. }
  5660. return oldValue.DeletedAt, nil
  5661. }
  5662. // ClearDeletedAt clears the value of the "deleted_at" field.
  5663. func (m *CategoryMutation) ClearDeletedAt() {
  5664. m.deleted_at = nil
  5665. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5666. }
  5667. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5668. func (m *CategoryMutation) DeletedAtCleared() bool {
  5669. _, ok := m.clearedFields[category.FieldDeletedAt]
  5670. return ok
  5671. }
  5672. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5673. func (m *CategoryMutation) ResetDeletedAt() {
  5674. m.deleted_at = nil
  5675. delete(m.clearedFields, category.FieldDeletedAt)
  5676. }
  5677. // SetName sets the "name" field.
  5678. func (m *CategoryMutation) SetName(s string) {
  5679. m.name = &s
  5680. }
  5681. // Name returns the value of the "name" field in the mutation.
  5682. func (m *CategoryMutation) Name() (r string, exists bool) {
  5683. v := m.name
  5684. if v == nil {
  5685. return
  5686. }
  5687. return *v, true
  5688. }
  5689. // OldName returns the old "name" field's value of the Category entity.
  5690. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5692. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5693. if !m.op.Is(OpUpdateOne) {
  5694. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5695. }
  5696. if m.id == nil || m.oldValue == nil {
  5697. return v, errors.New("OldName requires an ID field in the mutation")
  5698. }
  5699. oldValue, err := m.oldValue(ctx)
  5700. if err != nil {
  5701. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5702. }
  5703. return oldValue.Name, nil
  5704. }
  5705. // ResetName resets all changes to the "name" field.
  5706. func (m *CategoryMutation) ResetName() {
  5707. m.name = nil
  5708. }
  5709. // SetOrganizationID sets the "organization_id" field.
  5710. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5711. m.organization_id = &u
  5712. m.addorganization_id = nil
  5713. }
  5714. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5715. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5716. v := m.organization_id
  5717. if v == nil {
  5718. return
  5719. }
  5720. return *v, true
  5721. }
  5722. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  5723. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5725. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5726. if !m.op.Is(OpUpdateOne) {
  5727. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5728. }
  5729. if m.id == nil || m.oldValue == nil {
  5730. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5731. }
  5732. oldValue, err := m.oldValue(ctx)
  5733. if err != nil {
  5734. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5735. }
  5736. return oldValue.OrganizationID, nil
  5737. }
  5738. // AddOrganizationID adds u to the "organization_id" field.
  5739. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5740. if m.addorganization_id != nil {
  5741. *m.addorganization_id += u
  5742. } else {
  5743. m.addorganization_id = &u
  5744. }
  5745. }
  5746. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5747. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5748. v := m.addorganization_id
  5749. if v == nil {
  5750. return
  5751. }
  5752. return *v, true
  5753. }
  5754. // ResetOrganizationID resets all changes to the "organization_id" field.
  5755. func (m *CategoryMutation) ResetOrganizationID() {
  5756. m.organization_id = nil
  5757. m.addorganization_id = nil
  5758. }
  5759. // Where appends a list predicates to the CategoryMutation builder.
  5760. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5761. m.predicates = append(m.predicates, ps...)
  5762. }
  5763. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5764. // users can use type-assertion to append predicates that do not depend on any generated package.
  5765. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5766. p := make([]predicate.Category, len(ps))
  5767. for i := range ps {
  5768. p[i] = ps[i]
  5769. }
  5770. m.Where(p...)
  5771. }
  5772. // Op returns the operation name.
  5773. func (m *CategoryMutation) Op() Op {
  5774. return m.op
  5775. }
  5776. // SetOp allows setting the mutation operation.
  5777. func (m *CategoryMutation) SetOp(op Op) {
  5778. m.op = op
  5779. }
  5780. // Type returns the node type of this mutation (Category).
  5781. func (m *CategoryMutation) Type() string {
  5782. return m.typ
  5783. }
  5784. // Fields returns all fields that were changed during this mutation. Note that in
  5785. // order to get all numeric fields that were incremented/decremented, call
  5786. // AddedFields().
  5787. func (m *CategoryMutation) Fields() []string {
  5788. fields := make([]string, 0, 5)
  5789. if m.created_at != nil {
  5790. fields = append(fields, category.FieldCreatedAt)
  5791. }
  5792. if m.updated_at != nil {
  5793. fields = append(fields, category.FieldUpdatedAt)
  5794. }
  5795. if m.deleted_at != nil {
  5796. fields = append(fields, category.FieldDeletedAt)
  5797. }
  5798. if m.name != nil {
  5799. fields = append(fields, category.FieldName)
  5800. }
  5801. if m.organization_id != nil {
  5802. fields = append(fields, category.FieldOrganizationID)
  5803. }
  5804. return fields
  5805. }
  5806. // Field returns the value of a field with the given name. The second boolean
  5807. // return value indicates that this field was not set, or was not defined in the
  5808. // schema.
  5809. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5810. switch name {
  5811. case category.FieldCreatedAt:
  5812. return m.CreatedAt()
  5813. case category.FieldUpdatedAt:
  5814. return m.UpdatedAt()
  5815. case category.FieldDeletedAt:
  5816. return m.DeletedAt()
  5817. case category.FieldName:
  5818. return m.Name()
  5819. case category.FieldOrganizationID:
  5820. return m.OrganizationID()
  5821. }
  5822. return nil, false
  5823. }
  5824. // OldField returns the old value of the field from the database. An error is
  5825. // returned if the mutation operation is not UpdateOne, or the query to the
  5826. // database failed.
  5827. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5828. switch name {
  5829. case category.FieldCreatedAt:
  5830. return m.OldCreatedAt(ctx)
  5831. case category.FieldUpdatedAt:
  5832. return m.OldUpdatedAt(ctx)
  5833. case category.FieldDeletedAt:
  5834. return m.OldDeletedAt(ctx)
  5835. case category.FieldName:
  5836. return m.OldName(ctx)
  5837. case category.FieldOrganizationID:
  5838. return m.OldOrganizationID(ctx)
  5839. }
  5840. return nil, fmt.Errorf("unknown Category field %s", name)
  5841. }
  5842. // SetField sets the value of a field with the given name. It returns an error if
  5843. // the field is not defined in the schema, or if the type mismatched the field
  5844. // type.
  5845. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5846. switch name {
  5847. case category.FieldCreatedAt:
  5848. v, ok := value.(time.Time)
  5849. if !ok {
  5850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5851. }
  5852. m.SetCreatedAt(v)
  5853. return nil
  5854. case category.FieldUpdatedAt:
  5855. v, ok := value.(time.Time)
  5856. if !ok {
  5857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5858. }
  5859. m.SetUpdatedAt(v)
  5860. return nil
  5861. case category.FieldDeletedAt:
  5862. v, ok := value.(time.Time)
  5863. if !ok {
  5864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5865. }
  5866. m.SetDeletedAt(v)
  5867. return nil
  5868. case category.FieldName:
  5869. v, ok := value.(string)
  5870. if !ok {
  5871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5872. }
  5873. m.SetName(v)
  5874. return nil
  5875. case category.FieldOrganizationID:
  5876. v, ok := value.(uint64)
  5877. if !ok {
  5878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5879. }
  5880. m.SetOrganizationID(v)
  5881. return nil
  5882. }
  5883. return fmt.Errorf("unknown Category field %s", name)
  5884. }
  5885. // AddedFields returns all numeric fields that were incremented/decremented during
  5886. // this mutation.
  5887. func (m *CategoryMutation) AddedFields() []string {
  5888. var fields []string
  5889. if m.addorganization_id != nil {
  5890. fields = append(fields, category.FieldOrganizationID)
  5891. }
  5892. return fields
  5893. }
  5894. // AddedField returns the numeric value that was incremented/decremented on a field
  5895. // with the given name. The second boolean return value indicates that this field
  5896. // was not set, or was not defined in the schema.
  5897. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5898. switch name {
  5899. case category.FieldOrganizationID:
  5900. return m.AddedOrganizationID()
  5901. }
  5902. return nil, false
  5903. }
  5904. // AddField adds the value to the field with the given name. It returns an error if
  5905. // the field is not defined in the schema, or if the type mismatched the field
  5906. // type.
  5907. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5908. switch name {
  5909. case category.FieldOrganizationID:
  5910. v, ok := value.(int64)
  5911. if !ok {
  5912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5913. }
  5914. m.AddOrganizationID(v)
  5915. return nil
  5916. }
  5917. return fmt.Errorf("unknown Category numeric field %s", name)
  5918. }
  5919. // ClearedFields returns all nullable fields that were cleared during this
  5920. // mutation.
  5921. func (m *CategoryMutation) ClearedFields() []string {
  5922. var fields []string
  5923. if m.FieldCleared(category.FieldDeletedAt) {
  5924. fields = append(fields, category.FieldDeletedAt)
  5925. }
  5926. return fields
  5927. }
  5928. // FieldCleared returns a boolean indicating if a field with the given name was
  5929. // cleared in this mutation.
  5930. func (m *CategoryMutation) FieldCleared(name string) bool {
  5931. _, ok := m.clearedFields[name]
  5932. return ok
  5933. }
  5934. // ClearField clears the value of the field with the given name. It returns an
  5935. // error if the field is not defined in the schema.
  5936. func (m *CategoryMutation) ClearField(name string) error {
  5937. switch name {
  5938. case category.FieldDeletedAt:
  5939. m.ClearDeletedAt()
  5940. return nil
  5941. }
  5942. return fmt.Errorf("unknown Category nullable field %s", name)
  5943. }
  5944. // ResetField resets all changes in the mutation for the field with the given name.
  5945. // It returns an error if the field is not defined in the schema.
  5946. func (m *CategoryMutation) ResetField(name string) error {
  5947. switch name {
  5948. case category.FieldCreatedAt:
  5949. m.ResetCreatedAt()
  5950. return nil
  5951. case category.FieldUpdatedAt:
  5952. m.ResetUpdatedAt()
  5953. return nil
  5954. case category.FieldDeletedAt:
  5955. m.ResetDeletedAt()
  5956. return nil
  5957. case category.FieldName:
  5958. m.ResetName()
  5959. return nil
  5960. case category.FieldOrganizationID:
  5961. m.ResetOrganizationID()
  5962. return nil
  5963. }
  5964. return fmt.Errorf("unknown Category field %s", name)
  5965. }
  5966. // AddedEdges returns all edge names that were set/added in this mutation.
  5967. func (m *CategoryMutation) AddedEdges() []string {
  5968. edges := make([]string, 0, 0)
  5969. return edges
  5970. }
  5971. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5972. // name in this mutation.
  5973. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5974. return nil
  5975. }
  5976. // RemovedEdges returns all edge names that were removed in this mutation.
  5977. func (m *CategoryMutation) RemovedEdges() []string {
  5978. edges := make([]string, 0, 0)
  5979. return edges
  5980. }
  5981. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5982. // the given name in this mutation.
  5983. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5984. return nil
  5985. }
  5986. // ClearedEdges returns all edge names that were cleared in this mutation.
  5987. func (m *CategoryMutation) ClearedEdges() []string {
  5988. edges := make([]string, 0, 0)
  5989. return edges
  5990. }
  5991. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5992. // was cleared in this mutation.
  5993. func (m *CategoryMutation) EdgeCleared(name string) bool {
  5994. return false
  5995. }
  5996. // ClearEdge clears the value of the edge with the given name. It returns an error
  5997. // if that edge is not defined in the schema.
  5998. func (m *CategoryMutation) ClearEdge(name string) error {
  5999. return fmt.Errorf("unknown Category unique edge %s", name)
  6000. }
  6001. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6002. // It returns an error if the edge is not defined in the schema.
  6003. func (m *CategoryMutation) ResetEdge(name string) error {
  6004. return fmt.Errorf("unknown Category edge %s", name)
  6005. }
  6006. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6007. type ChatRecordsMutation struct {
  6008. config
  6009. op Op
  6010. typ string
  6011. id *uint64
  6012. created_at *time.Time
  6013. updated_at *time.Time
  6014. deleted_at *time.Time
  6015. content *string
  6016. content_type *uint8
  6017. addcontent_type *int8
  6018. session_id *uint64
  6019. addsession_id *int64
  6020. user_id *uint64
  6021. adduser_id *int64
  6022. bot_id *uint64
  6023. addbot_id *int64
  6024. bot_type *uint8
  6025. addbot_type *int8
  6026. clearedFields map[string]struct{}
  6027. done bool
  6028. oldValue func(context.Context) (*ChatRecords, error)
  6029. predicates []predicate.ChatRecords
  6030. }
  6031. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6032. // chatrecordsOption allows management of the mutation configuration using functional options.
  6033. type chatrecordsOption func(*ChatRecordsMutation)
  6034. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6035. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6036. m := &ChatRecordsMutation{
  6037. config: c,
  6038. op: op,
  6039. typ: TypeChatRecords,
  6040. clearedFields: make(map[string]struct{}),
  6041. }
  6042. for _, opt := range opts {
  6043. opt(m)
  6044. }
  6045. return m
  6046. }
  6047. // withChatRecordsID sets the ID field of the mutation.
  6048. func withChatRecordsID(id uint64) chatrecordsOption {
  6049. return func(m *ChatRecordsMutation) {
  6050. var (
  6051. err error
  6052. once sync.Once
  6053. value *ChatRecords
  6054. )
  6055. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6056. once.Do(func() {
  6057. if m.done {
  6058. err = errors.New("querying old values post mutation is not allowed")
  6059. } else {
  6060. value, err = m.Client().ChatRecords.Get(ctx, id)
  6061. }
  6062. })
  6063. return value, err
  6064. }
  6065. m.id = &id
  6066. }
  6067. }
  6068. // withChatRecords sets the old ChatRecords of the mutation.
  6069. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6070. return func(m *ChatRecordsMutation) {
  6071. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6072. return node, nil
  6073. }
  6074. m.id = &node.ID
  6075. }
  6076. }
  6077. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6078. // executed in a transaction (ent.Tx), a transactional client is returned.
  6079. func (m ChatRecordsMutation) Client() *Client {
  6080. client := &Client{config: m.config}
  6081. client.init()
  6082. return client
  6083. }
  6084. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6085. // it returns an error otherwise.
  6086. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6087. if _, ok := m.driver.(*txDriver); !ok {
  6088. return nil, errors.New("ent: mutation is not running in a transaction")
  6089. }
  6090. tx := &Tx{config: m.config}
  6091. tx.init()
  6092. return tx, nil
  6093. }
  6094. // SetID sets the value of the id field. Note that this
  6095. // operation is only accepted on creation of ChatRecords entities.
  6096. func (m *ChatRecordsMutation) SetID(id uint64) {
  6097. m.id = &id
  6098. }
  6099. // ID returns the ID value in the mutation. Note that the ID is only available
  6100. // if it was provided to the builder or after it was returned from the database.
  6101. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6102. if m.id == nil {
  6103. return
  6104. }
  6105. return *m.id, true
  6106. }
  6107. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6108. // That means, if the mutation is applied within a transaction with an isolation level such
  6109. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6110. // or updated by the mutation.
  6111. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6112. switch {
  6113. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6114. id, exists := m.ID()
  6115. if exists {
  6116. return []uint64{id}, nil
  6117. }
  6118. fallthrough
  6119. case m.op.Is(OpUpdate | OpDelete):
  6120. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6121. default:
  6122. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6123. }
  6124. }
  6125. // SetCreatedAt sets the "created_at" field.
  6126. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6127. m.created_at = &t
  6128. }
  6129. // CreatedAt returns the value of the "created_at" field in the mutation.
  6130. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6131. v := m.created_at
  6132. if v == nil {
  6133. return
  6134. }
  6135. return *v, true
  6136. }
  6137. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6138. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6140. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6141. if !m.op.Is(OpUpdateOne) {
  6142. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6143. }
  6144. if m.id == nil || m.oldValue == nil {
  6145. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6146. }
  6147. oldValue, err := m.oldValue(ctx)
  6148. if err != nil {
  6149. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6150. }
  6151. return oldValue.CreatedAt, nil
  6152. }
  6153. // ResetCreatedAt resets all changes to the "created_at" field.
  6154. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6155. m.created_at = nil
  6156. }
  6157. // SetUpdatedAt sets the "updated_at" field.
  6158. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6159. m.updated_at = &t
  6160. }
  6161. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6162. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6163. v := m.updated_at
  6164. if v == nil {
  6165. return
  6166. }
  6167. return *v, true
  6168. }
  6169. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6170. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6172. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6173. if !m.op.Is(OpUpdateOne) {
  6174. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6175. }
  6176. if m.id == nil || m.oldValue == nil {
  6177. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6178. }
  6179. oldValue, err := m.oldValue(ctx)
  6180. if err != nil {
  6181. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6182. }
  6183. return oldValue.UpdatedAt, nil
  6184. }
  6185. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6186. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6187. m.updated_at = nil
  6188. }
  6189. // SetDeletedAt sets the "deleted_at" field.
  6190. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6191. m.deleted_at = &t
  6192. }
  6193. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6194. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6195. v := m.deleted_at
  6196. if v == nil {
  6197. return
  6198. }
  6199. return *v, true
  6200. }
  6201. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6202. // If the ChatRecords 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 *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6205. if !m.op.Is(OpUpdateOne) {
  6206. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6207. }
  6208. if m.id == nil || m.oldValue == nil {
  6209. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  6214. }
  6215. return oldValue.DeletedAt, nil
  6216. }
  6217. // ClearDeletedAt clears the value of the "deleted_at" field.
  6218. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6219. m.deleted_at = nil
  6220. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6221. }
  6222. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6223. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6224. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6225. return ok
  6226. }
  6227. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6228. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6229. m.deleted_at = nil
  6230. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6231. }
  6232. // SetContent sets the "content" field.
  6233. func (m *ChatRecordsMutation) SetContent(s string) {
  6234. m.content = &s
  6235. }
  6236. // Content returns the value of the "content" field in the mutation.
  6237. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6238. v := m.content
  6239. if v == nil {
  6240. return
  6241. }
  6242. return *v, true
  6243. }
  6244. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6245. // If the ChatRecords 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 *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6248. if !m.op.Is(OpUpdateOne) {
  6249. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6250. }
  6251. if m.id == nil || m.oldValue == nil {
  6252. return v, errors.New("OldContent 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 OldContent: %w", err)
  6257. }
  6258. return oldValue.Content, nil
  6259. }
  6260. // ResetContent resets all changes to the "content" field.
  6261. func (m *ChatRecordsMutation) ResetContent() {
  6262. m.content = nil
  6263. }
  6264. // SetContentType sets the "content_type" field.
  6265. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6266. m.content_type = &u
  6267. m.addcontent_type = nil
  6268. }
  6269. // ContentType returns the value of the "content_type" field in the mutation.
  6270. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6271. v := m.content_type
  6272. if v == nil {
  6273. return
  6274. }
  6275. return *v, true
  6276. }
  6277. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6278. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6280. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6281. if !m.op.Is(OpUpdateOne) {
  6282. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6283. }
  6284. if m.id == nil || m.oldValue == nil {
  6285. return v, errors.New("OldContentType requires an ID field in the mutation")
  6286. }
  6287. oldValue, err := m.oldValue(ctx)
  6288. if err != nil {
  6289. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6290. }
  6291. return oldValue.ContentType, nil
  6292. }
  6293. // AddContentType adds u to the "content_type" field.
  6294. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6295. if m.addcontent_type != nil {
  6296. *m.addcontent_type += u
  6297. } else {
  6298. m.addcontent_type = &u
  6299. }
  6300. }
  6301. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6302. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6303. v := m.addcontent_type
  6304. if v == nil {
  6305. return
  6306. }
  6307. return *v, true
  6308. }
  6309. // ResetContentType resets all changes to the "content_type" field.
  6310. func (m *ChatRecordsMutation) ResetContentType() {
  6311. m.content_type = nil
  6312. m.addcontent_type = nil
  6313. }
  6314. // SetSessionID sets the "session_id" field.
  6315. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6316. m.session_id = &u
  6317. m.addsession_id = nil
  6318. }
  6319. // SessionID returns the value of the "session_id" field in the mutation.
  6320. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6321. v := m.session_id
  6322. if v == nil {
  6323. return
  6324. }
  6325. return *v, true
  6326. }
  6327. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6328. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6330. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6331. if !m.op.Is(OpUpdateOne) {
  6332. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6333. }
  6334. if m.id == nil || m.oldValue == nil {
  6335. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6336. }
  6337. oldValue, err := m.oldValue(ctx)
  6338. if err != nil {
  6339. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6340. }
  6341. return oldValue.SessionID, nil
  6342. }
  6343. // AddSessionID adds u to the "session_id" field.
  6344. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6345. if m.addsession_id != nil {
  6346. *m.addsession_id += u
  6347. } else {
  6348. m.addsession_id = &u
  6349. }
  6350. }
  6351. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6352. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6353. v := m.addsession_id
  6354. if v == nil {
  6355. return
  6356. }
  6357. return *v, true
  6358. }
  6359. // ResetSessionID resets all changes to the "session_id" field.
  6360. func (m *ChatRecordsMutation) ResetSessionID() {
  6361. m.session_id = nil
  6362. m.addsession_id = nil
  6363. }
  6364. // SetUserID sets the "user_id" field.
  6365. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6366. m.user_id = &u
  6367. m.adduser_id = nil
  6368. }
  6369. // UserID returns the value of the "user_id" field in the mutation.
  6370. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6371. v := m.user_id
  6372. if v == nil {
  6373. return
  6374. }
  6375. return *v, true
  6376. }
  6377. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6378. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6380. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6381. if !m.op.Is(OpUpdateOne) {
  6382. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6383. }
  6384. if m.id == nil || m.oldValue == nil {
  6385. return v, errors.New("OldUserID requires an ID field in the mutation")
  6386. }
  6387. oldValue, err := m.oldValue(ctx)
  6388. if err != nil {
  6389. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6390. }
  6391. return oldValue.UserID, nil
  6392. }
  6393. // AddUserID adds u to the "user_id" field.
  6394. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6395. if m.adduser_id != nil {
  6396. *m.adduser_id += u
  6397. } else {
  6398. m.adduser_id = &u
  6399. }
  6400. }
  6401. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6402. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6403. v := m.adduser_id
  6404. if v == nil {
  6405. return
  6406. }
  6407. return *v, true
  6408. }
  6409. // ResetUserID resets all changes to the "user_id" field.
  6410. func (m *ChatRecordsMutation) ResetUserID() {
  6411. m.user_id = nil
  6412. m.adduser_id = nil
  6413. }
  6414. // SetBotID sets the "bot_id" field.
  6415. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6416. m.bot_id = &u
  6417. m.addbot_id = nil
  6418. }
  6419. // BotID returns the value of the "bot_id" field in the mutation.
  6420. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6421. v := m.bot_id
  6422. if v == nil {
  6423. return
  6424. }
  6425. return *v, true
  6426. }
  6427. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6428. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6430. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6431. if !m.op.Is(OpUpdateOne) {
  6432. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6433. }
  6434. if m.id == nil || m.oldValue == nil {
  6435. return v, errors.New("OldBotID requires an ID field in the mutation")
  6436. }
  6437. oldValue, err := m.oldValue(ctx)
  6438. if err != nil {
  6439. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6440. }
  6441. return oldValue.BotID, nil
  6442. }
  6443. // AddBotID adds u to the "bot_id" field.
  6444. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6445. if m.addbot_id != nil {
  6446. *m.addbot_id += u
  6447. } else {
  6448. m.addbot_id = &u
  6449. }
  6450. }
  6451. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6452. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6453. v := m.addbot_id
  6454. if v == nil {
  6455. return
  6456. }
  6457. return *v, true
  6458. }
  6459. // ResetBotID resets all changes to the "bot_id" field.
  6460. func (m *ChatRecordsMutation) ResetBotID() {
  6461. m.bot_id = nil
  6462. m.addbot_id = nil
  6463. }
  6464. // SetBotType sets the "bot_type" field.
  6465. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6466. m.bot_type = &u
  6467. m.addbot_type = nil
  6468. }
  6469. // BotType returns the value of the "bot_type" field in the mutation.
  6470. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6471. v := m.bot_type
  6472. if v == nil {
  6473. return
  6474. }
  6475. return *v, true
  6476. }
  6477. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6478. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6480. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6481. if !m.op.Is(OpUpdateOne) {
  6482. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6483. }
  6484. if m.id == nil || m.oldValue == nil {
  6485. return v, errors.New("OldBotType requires an ID field in the mutation")
  6486. }
  6487. oldValue, err := m.oldValue(ctx)
  6488. if err != nil {
  6489. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6490. }
  6491. return oldValue.BotType, nil
  6492. }
  6493. // AddBotType adds u to the "bot_type" field.
  6494. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6495. if m.addbot_type != nil {
  6496. *m.addbot_type += u
  6497. } else {
  6498. m.addbot_type = &u
  6499. }
  6500. }
  6501. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6502. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6503. v := m.addbot_type
  6504. if v == nil {
  6505. return
  6506. }
  6507. return *v, true
  6508. }
  6509. // ResetBotType resets all changes to the "bot_type" field.
  6510. func (m *ChatRecordsMutation) ResetBotType() {
  6511. m.bot_type = nil
  6512. m.addbot_type = nil
  6513. }
  6514. // Where appends a list predicates to the ChatRecordsMutation builder.
  6515. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6516. m.predicates = append(m.predicates, ps...)
  6517. }
  6518. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6519. // users can use type-assertion to append predicates that do not depend on any generated package.
  6520. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6521. p := make([]predicate.ChatRecords, len(ps))
  6522. for i := range ps {
  6523. p[i] = ps[i]
  6524. }
  6525. m.Where(p...)
  6526. }
  6527. // Op returns the operation name.
  6528. func (m *ChatRecordsMutation) Op() Op {
  6529. return m.op
  6530. }
  6531. // SetOp allows setting the mutation operation.
  6532. func (m *ChatRecordsMutation) SetOp(op Op) {
  6533. m.op = op
  6534. }
  6535. // Type returns the node type of this mutation (ChatRecords).
  6536. func (m *ChatRecordsMutation) Type() string {
  6537. return m.typ
  6538. }
  6539. // Fields returns all fields that were changed during this mutation. Note that in
  6540. // order to get all numeric fields that were incremented/decremented, call
  6541. // AddedFields().
  6542. func (m *ChatRecordsMutation) Fields() []string {
  6543. fields := make([]string, 0, 9)
  6544. if m.created_at != nil {
  6545. fields = append(fields, chatrecords.FieldCreatedAt)
  6546. }
  6547. if m.updated_at != nil {
  6548. fields = append(fields, chatrecords.FieldUpdatedAt)
  6549. }
  6550. if m.deleted_at != nil {
  6551. fields = append(fields, chatrecords.FieldDeletedAt)
  6552. }
  6553. if m.content != nil {
  6554. fields = append(fields, chatrecords.FieldContent)
  6555. }
  6556. if m.content_type != nil {
  6557. fields = append(fields, chatrecords.FieldContentType)
  6558. }
  6559. if m.session_id != nil {
  6560. fields = append(fields, chatrecords.FieldSessionID)
  6561. }
  6562. if m.user_id != nil {
  6563. fields = append(fields, chatrecords.FieldUserID)
  6564. }
  6565. if m.bot_id != nil {
  6566. fields = append(fields, chatrecords.FieldBotID)
  6567. }
  6568. if m.bot_type != nil {
  6569. fields = append(fields, chatrecords.FieldBotType)
  6570. }
  6571. return fields
  6572. }
  6573. // Field returns the value of a field with the given name. The second boolean
  6574. // return value indicates that this field was not set, or was not defined in the
  6575. // schema.
  6576. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6577. switch name {
  6578. case chatrecords.FieldCreatedAt:
  6579. return m.CreatedAt()
  6580. case chatrecords.FieldUpdatedAt:
  6581. return m.UpdatedAt()
  6582. case chatrecords.FieldDeletedAt:
  6583. return m.DeletedAt()
  6584. case chatrecords.FieldContent:
  6585. return m.Content()
  6586. case chatrecords.FieldContentType:
  6587. return m.ContentType()
  6588. case chatrecords.FieldSessionID:
  6589. return m.SessionID()
  6590. case chatrecords.FieldUserID:
  6591. return m.UserID()
  6592. case chatrecords.FieldBotID:
  6593. return m.BotID()
  6594. case chatrecords.FieldBotType:
  6595. return m.BotType()
  6596. }
  6597. return nil, false
  6598. }
  6599. // OldField returns the old value of the field from the database. An error is
  6600. // returned if the mutation operation is not UpdateOne, or the query to the
  6601. // database failed.
  6602. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6603. switch name {
  6604. case chatrecords.FieldCreatedAt:
  6605. return m.OldCreatedAt(ctx)
  6606. case chatrecords.FieldUpdatedAt:
  6607. return m.OldUpdatedAt(ctx)
  6608. case chatrecords.FieldDeletedAt:
  6609. return m.OldDeletedAt(ctx)
  6610. case chatrecords.FieldContent:
  6611. return m.OldContent(ctx)
  6612. case chatrecords.FieldContentType:
  6613. return m.OldContentType(ctx)
  6614. case chatrecords.FieldSessionID:
  6615. return m.OldSessionID(ctx)
  6616. case chatrecords.FieldUserID:
  6617. return m.OldUserID(ctx)
  6618. case chatrecords.FieldBotID:
  6619. return m.OldBotID(ctx)
  6620. case chatrecords.FieldBotType:
  6621. return m.OldBotType(ctx)
  6622. }
  6623. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6624. }
  6625. // SetField sets the value of a field with the given name. It returns an error if
  6626. // the field is not defined in the schema, or if the type mismatched the field
  6627. // type.
  6628. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6629. switch name {
  6630. case chatrecords.FieldCreatedAt:
  6631. v, ok := value.(time.Time)
  6632. if !ok {
  6633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6634. }
  6635. m.SetCreatedAt(v)
  6636. return nil
  6637. case chatrecords.FieldUpdatedAt:
  6638. v, ok := value.(time.Time)
  6639. if !ok {
  6640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6641. }
  6642. m.SetUpdatedAt(v)
  6643. return nil
  6644. case chatrecords.FieldDeletedAt:
  6645. v, ok := value.(time.Time)
  6646. if !ok {
  6647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6648. }
  6649. m.SetDeletedAt(v)
  6650. return nil
  6651. case chatrecords.FieldContent:
  6652. v, ok := value.(string)
  6653. if !ok {
  6654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6655. }
  6656. m.SetContent(v)
  6657. return nil
  6658. case chatrecords.FieldContentType:
  6659. v, ok := value.(uint8)
  6660. if !ok {
  6661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6662. }
  6663. m.SetContentType(v)
  6664. return nil
  6665. case chatrecords.FieldSessionID:
  6666. v, ok := value.(uint64)
  6667. if !ok {
  6668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6669. }
  6670. m.SetSessionID(v)
  6671. return nil
  6672. case chatrecords.FieldUserID:
  6673. v, ok := value.(uint64)
  6674. if !ok {
  6675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6676. }
  6677. m.SetUserID(v)
  6678. return nil
  6679. case chatrecords.FieldBotID:
  6680. v, ok := value.(uint64)
  6681. if !ok {
  6682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6683. }
  6684. m.SetBotID(v)
  6685. return nil
  6686. case chatrecords.FieldBotType:
  6687. v, ok := value.(uint8)
  6688. if !ok {
  6689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6690. }
  6691. m.SetBotType(v)
  6692. return nil
  6693. }
  6694. return fmt.Errorf("unknown ChatRecords field %s", name)
  6695. }
  6696. // AddedFields returns all numeric fields that were incremented/decremented during
  6697. // this mutation.
  6698. func (m *ChatRecordsMutation) AddedFields() []string {
  6699. var fields []string
  6700. if m.addcontent_type != nil {
  6701. fields = append(fields, chatrecords.FieldContentType)
  6702. }
  6703. if m.addsession_id != nil {
  6704. fields = append(fields, chatrecords.FieldSessionID)
  6705. }
  6706. if m.adduser_id != nil {
  6707. fields = append(fields, chatrecords.FieldUserID)
  6708. }
  6709. if m.addbot_id != nil {
  6710. fields = append(fields, chatrecords.FieldBotID)
  6711. }
  6712. if m.addbot_type != nil {
  6713. fields = append(fields, chatrecords.FieldBotType)
  6714. }
  6715. return fields
  6716. }
  6717. // AddedField returns the numeric value that was incremented/decremented on a field
  6718. // with the given name. The second boolean return value indicates that this field
  6719. // was not set, or was not defined in the schema.
  6720. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6721. switch name {
  6722. case chatrecords.FieldContentType:
  6723. return m.AddedContentType()
  6724. case chatrecords.FieldSessionID:
  6725. return m.AddedSessionID()
  6726. case chatrecords.FieldUserID:
  6727. return m.AddedUserID()
  6728. case chatrecords.FieldBotID:
  6729. return m.AddedBotID()
  6730. case chatrecords.FieldBotType:
  6731. return m.AddedBotType()
  6732. }
  6733. return nil, false
  6734. }
  6735. // AddField adds the value to the field with the given name. It returns an error if
  6736. // the field is not defined in the schema, or if the type mismatched the field
  6737. // type.
  6738. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6739. switch name {
  6740. case chatrecords.FieldContentType:
  6741. v, ok := value.(int8)
  6742. if !ok {
  6743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6744. }
  6745. m.AddContentType(v)
  6746. return nil
  6747. case chatrecords.FieldSessionID:
  6748. v, ok := value.(int64)
  6749. if !ok {
  6750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6751. }
  6752. m.AddSessionID(v)
  6753. return nil
  6754. case chatrecords.FieldUserID:
  6755. v, ok := value.(int64)
  6756. if !ok {
  6757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6758. }
  6759. m.AddUserID(v)
  6760. return nil
  6761. case chatrecords.FieldBotID:
  6762. v, ok := value.(int64)
  6763. if !ok {
  6764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6765. }
  6766. m.AddBotID(v)
  6767. return nil
  6768. case chatrecords.FieldBotType:
  6769. v, ok := value.(int8)
  6770. if !ok {
  6771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6772. }
  6773. m.AddBotType(v)
  6774. return nil
  6775. }
  6776. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6777. }
  6778. // ClearedFields returns all nullable fields that were cleared during this
  6779. // mutation.
  6780. func (m *ChatRecordsMutation) ClearedFields() []string {
  6781. var fields []string
  6782. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6783. fields = append(fields, chatrecords.FieldDeletedAt)
  6784. }
  6785. return fields
  6786. }
  6787. // FieldCleared returns a boolean indicating if a field with the given name was
  6788. // cleared in this mutation.
  6789. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6790. _, ok := m.clearedFields[name]
  6791. return ok
  6792. }
  6793. // ClearField clears the value of the field with the given name. It returns an
  6794. // error if the field is not defined in the schema.
  6795. func (m *ChatRecordsMutation) ClearField(name string) error {
  6796. switch name {
  6797. case chatrecords.FieldDeletedAt:
  6798. m.ClearDeletedAt()
  6799. return nil
  6800. }
  6801. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6802. }
  6803. // ResetField resets all changes in the mutation for the field with the given name.
  6804. // It returns an error if the field is not defined in the schema.
  6805. func (m *ChatRecordsMutation) ResetField(name string) error {
  6806. switch name {
  6807. case chatrecords.FieldCreatedAt:
  6808. m.ResetCreatedAt()
  6809. return nil
  6810. case chatrecords.FieldUpdatedAt:
  6811. m.ResetUpdatedAt()
  6812. return nil
  6813. case chatrecords.FieldDeletedAt:
  6814. m.ResetDeletedAt()
  6815. return nil
  6816. case chatrecords.FieldContent:
  6817. m.ResetContent()
  6818. return nil
  6819. case chatrecords.FieldContentType:
  6820. m.ResetContentType()
  6821. return nil
  6822. case chatrecords.FieldSessionID:
  6823. m.ResetSessionID()
  6824. return nil
  6825. case chatrecords.FieldUserID:
  6826. m.ResetUserID()
  6827. return nil
  6828. case chatrecords.FieldBotID:
  6829. m.ResetBotID()
  6830. return nil
  6831. case chatrecords.FieldBotType:
  6832. m.ResetBotType()
  6833. return nil
  6834. }
  6835. return fmt.Errorf("unknown ChatRecords field %s", name)
  6836. }
  6837. // AddedEdges returns all edge names that were set/added in this mutation.
  6838. func (m *ChatRecordsMutation) AddedEdges() []string {
  6839. edges := make([]string, 0, 0)
  6840. return edges
  6841. }
  6842. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6843. // name in this mutation.
  6844. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6845. return nil
  6846. }
  6847. // RemovedEdges returns all edge names that were removed in this mutation.
  6848. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6849. edges := make([]string, 0, 0)
  6850. return edges
  6851. }
  6852. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6853. // the given name in this mutation.
  6854. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6855. return nil
  6856. }
  6857. // ClearedEdges returns all edge names that were cleared in this mutation.
  6858. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6859. edges := make([]string, 0, 0)
  6860. return edges
  6861. }
  6862. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6863. // was cleared in this mutation.
  6864. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6865. return false
  6866. }
  6867. // ClearEdge clears the value of the edge with the given name. It returns an error
  6868. // if that edge is not defined in the schema.
  6869. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6870. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6871. }
  6872. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6873. // It returns an error if the edge is not defined in the schema.
  6874. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6875. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6876. }
  6877. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6878. type ChatSessionMutation struct {
  6879. config
  6880. op Op
  6881. typ string
  6882. id *uint64
  6883. created_at *time.Time
  6884. updated_at *time.Time
  6885. deleted_at *time.Time
  6886. name *string
  6887. user_id *uint64
  6888. adduser_id *int64
  6889. bot_id *uint64
  6890. addbot_id *int64
  6891. bot_type *uint8
  6892. addbot_type *int8
  6893. clearedFields map[string]struct{}
  6894. done bool
  6895. oldValue func(context.Context) (*ChatSession, error)
  6896. predicates []predicate.ChatSession
  6897. }
  6898. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6899. // chatsessionOption allows management of the mutation configuration using functional options.
  6900. type chatsessionOption func(*ChatSessionMutation)
  6901. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6902. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6903. m := &ChatSessionMutation{
  6904. config: c,
  6905. op: op,
  6906. typ: TypeChatSession,
  6907. clearedFields: make(map[string]struct{}),
  6908. }
  6909. for _, opt := range opts {
  6910. opt(m)
  6911. }
  6912. return m
  6913. }
  6914. // withChatSessionID sets the ID field of the mutation.
  6915. func withChatSessionID(id uint64) chatsessionOption {
  6916. return func(m *ChatSessionMutation) {
  6917. var (
  6918. err error
  6919. once sync.Once
  6920. value *ChatSession
  6921. )
  6922. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6923. once.Do(func() {
  6924. if m.done {
  6925. err = errors.New("querying old values post mutation is not allowed")
  6926. } else {
  6927. value, err = m.Client().ChatSession.Get(ctx, id)
  6928. }
  6929. })
  6930. return value, err
  6931. }
  6932. m.id = &id
  6933. }
  6934. }
  6935. // withChatSession sets the old ChatSession of the mutation.
  6936. func withChatSession(node *ChatSession) chatsessionOption {
  6937. return func(m *ChatSessionMutation) {
  6938. m.oldValue = func(context.Context) (*ChatSession, error) {
  6939. return node, nil
  6940. }
  6941. m.id = &node.ID
  6942. }
  6943. }
  6944. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6945. // executed in a transaction (ent.Tx), a transactional client is returned.
  6946. func (m ChatSessionMutation) Client() *Client {
  6947. client := &Client{config: m.config}
  6948. client.init()
  6949. return client
  6950. }
  6951. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6952. // it returns an error otherwise.
  6953. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6954. if _, ok := m.driver.(*txDriver); !ok {
  6955. return nil, errors.New("ent: mutation is not running in a transaction")
  6956. }
  6957. tx := &Tx{config: m.config}
  6958. tx.init()
  6959. return tx, nil
  6960. }
  6961. // SetID sets the value of the id field. Note that this
  6962. // operation is only accepted on creation of ChatSession entities.
  6963. func (m *ChatSessionMutation) SetID(id uint64) {
  6964. m.id = &id
  6965. }
  6966. // ID returns the ID value in the mutation. Note that the ID is only available
  6967. // if it was provided to the builder or after it was returned from the database.
  6968. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6969. if m.id == nil {
  6970. return
  6971. }
  6972. return *m.id, true
  6973. }
  6974. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6975. // That means, if the mutation is applied within a transaction with an isolation level such
  6976. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6977. // or updated by the mutation.
  6978. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6979. switch {
  6980. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6981. id, exists := m.ID()
  6982. if exists {
  6983. return []uint64{id}, nil
  6984. }
  6985. fallthrough
  6986. case m.op.Is(OpUpdate | OpDelete):
  6987. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  6988. default:
  6989. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6990. }
  6991. }
  6992. // SetCreatedAt sets the "created_at" field.
  6993. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  6994. m.created_at = &t
  6995. }
  6996. // CreatedAt returns the value of the "created_at" field in the mutation.
  6997. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  6998. v := m.created_at
  6999. if v == nil {
  7000. return
  7001. }
  7002. return *v, true
  7003. }
  7004. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7005. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7007. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7008. if !m.op.Is(OpUpdateOne) {
  7009. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7010. }
  7011. if m.id == nil || m.oldValue == nil {
  7012. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7013. }
  7014. oldValue, err := m.oldValue(ctx)
  7015. if err != nil {
  7016. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7017. }
  7018. return oldValue.CreatedAt, nil
  7019. }
  7020. // ResetCreatedAt resets all changes to the "created_at" field.
  7021. func (m *ChatSessionMutation) ResetCreatedAt() {
  7022. m.created_at = nil
  7023. }
  7024. // SetUpdatedAt sets the "updated_at" field.
  7025. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7026. m.updated_at = &t
  7027. }
  7028. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7029. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7030. v := m.updated_at
  7031. if v == nil {
  7032. return
  7033. }
  7034. return *v, true
  7035. }
  7036. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7037. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7039. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7040. if !m.op.Is(OpUpdateOne) {
  7041. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7042. }
  7043. if m.id == nil || m.oldValue == nil {
  7044. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7045. }
  7046. oldValue, err := m.oldValue(ctx)
  7047. if err != nil {
  7048. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7049. }
  7050. return oldValue.UpdatedAt, nil
  7051. }
  7052. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7053. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7054. m.updated_at = nil
  7055. }
  7056. // SetDeletedAt sets the "deleted_at" field.
  7057. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7058. m.deleted_at = &t
  7059. }
  7060. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7061. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7062. v := m.deleted_at
  7063. if v == nil {
  7064. return
  7065. }
  7066. return *v, true
  7067. }
  7068. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7069. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7071. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7072. if !m.op.Is(OpUpdateOne) {
  7073. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7074. }
  7075. if m.id == nil || m.oldValue == nil {
  7076. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7077. }
  7078. oldValue, err := m.oldValue(ctx)
  7079. if err != nil {
  7080. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7081. }
  7082. return oldValue.DeletedAt, nil
  7083. }
  7084. // ClearDeletedAt clears the value of the "deleted_at" field.
  7085. func (m *ChatSessionMutation) ClearDeletedAt() {
  7086. m.deleted_at = nil
  7087. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7088. }
  7089. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7090. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7091. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7092. return ok
  7093. }
  7094. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7095. func (m *ChatSessionMutation) ResetDeletedAt() {
  7096. m.deleted_at = nil
  7097. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7098. }
  7099. // SetName sets the "name" field.
  7100. func (m *ChatSessionMutation) SetName(s string) {
  7101. m.name = &s
  7102. }
  7103. // Name returns the value of the "name" field in the mutation.
  7104. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7105. v := m.name
  7106. if v == nil {
  7107. return
  7108. }
  7109. return *v, true
  7110. }
  7111. // OldName returns the old "name" field's value of the ChatSession entity.
  7112. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7114. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7115. if !m.op.Is(OpUpdateOne) {
  7116. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7117. }
  7118. if m.id == nil || m.oldValue == nil {
  7119. return v, errors.New("OldName requires an ID field in the mutation")
  7120. }
  7121. oldValue, err := m.oldValue(ctx)
  7122. if err != nil {
  7123. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7124. }
  7125. return oldValue.Name, nil
  7126. }
  7127. // ResetName resets all changes to the "name" field.
  7128. func (m *ChatSessionMutation) ResetName() {
  7129. m.name = nil
  7130. }
  7131. // SetUserID sets the "user_id" field.
  7132. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7133. m.user_id = &u
  7134. m.adduser_id = nil
  7135. }
  7136. // UserID returns the value of the "user_id" field in the mutation.
  7137. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7138. v := m.user_id
  7139. if v == nil {
  7140. return
  7141. }
  7142. return *v, true
  7143. }
  7144. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7145. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7147. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7148. if !m.op.Is(OpUpdateOne) {
  7149. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7150. }
  7151. if m.id == nil || m.oldValue == nil {
  7152. return v, errors.New("OldUserID requires an ID field in the mutation")
  7153. }
  7154. oldValue, err := m.oldValue(ctx)
  7155. if err != nil {
  7156. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7157. }
  7158. return oldValue.UserID, nil
  7159. }
  7160. // AddUserID adds u to the "user_id" field.
  7161. func (m *ChatSessionMutation) AddUserID(u int64) {
  7162. if m.adduser_id != nil {
  7163. *m.adduser_id += u
  7164. } else {
  7165. m.adduser_id = &u
  7166. }
  7167. }
  7168. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7169. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7170. v := m.adduser_id
  7171. if v == nil {
  7172. return
  7173. }
  7174. return *v, true
  7175. }
  7176. // ResetUserID resets all changes to the "user_id" field.
  7177. func (m *ChatSessionMutation) ResetUserID() {
  7178. m.user_id = nil
  7179. m.adduser_id = nil
  7180. }
  7181. // SetBotID sets the "bot_id" field.
  7182. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7183. m.bot_id = &u
  7184. m.addbot_id = nil
  7185. }
  7186. // BotID returns the value of the "bot_id" field in the mutation.
  7187. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7188. v := m.bot_id
  7189. if v == nil {
  7190. return
  7191. }
  7192. return *v, true
  7193. }
  7194. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7195. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7197. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7198. if !m.op.Is(OpUpdateOne) {
  7199. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7200. }
  7201. if m.id == nil || m.oldValue == nil {
  7202. return v, errors.New("OldBotID requires an ID field in the mutation")
  7203. }
  7204. oldValue, err := m.oldValue(ctx)
  7205. if err != nil {
  7206. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7207. }
  7208. return oldValue.BotID, nil
  7209. }
  7210. // AddBotID adds u to the "bot_id" field.
  7211. func (m *ChatSessionMutation) AddBotID(u int64) {
  7212. if m.addbot_id != nil {
  7213. *m.addbot_id += u
  7214. } else {
  7215. m.addbot_id = &u
  7216. }
  7217. }
  7218. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7219. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7220. v := m.addbot_id
  7221. if v == nil {
  7222. return
  7223. }
  7224. return *v, true
  7225. }
  7226. // ResetBotID resets all changes to the "bot_id" field.
  7227. func (m *ChatSessionMutation) ResetBotID() {
  7228. m.bot_id = nil
  7229. m.addbot_id = nil
  7230. }
  7231. // SetBotType sets the "bot_type" field.
  7232. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7233. m.bot_type = &u
  7234. m.addbot_type = nil
  7235. }
  7236. // BotType returns the value of the "bot_type" field in the mutation.
  7237. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7238. v := m.bot_type
  7239. if v == nil {
  7240. return
  7241. }
  7242. return *v, true
  7243. }
  7244. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7245. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7247. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7248. if !m.op.Is(OpUpdateOne) {
  7249. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7250. }
  7251. if m.id == nil || m.oldValue == nil {
  7252. return v, errors.New("OldBotType requires an ID field in the mutation")
  7253. }
  7254. oldValue, err := m.oldValue(ctx)
  7255. if err != nil {
  7256. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7257. }
  7258. return oldValue.BotType, nil
  7259. }
  7260. // AddBotType adds u to the "bot_type" field.
  7261. func (m *ChatSessionMutation) AddBotType(u int8) {
  7262. if m.addbot_type != nil {
  7263. *m.addbot_type += u
  7264. } else {
  7265. m.addbot_type = &u
  7266. }
  7267. }
  7268. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7269. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7270. v := m.addbot_type
  7271. if v == nil {
  7272. return
  7273. }
  7274. return *v, true
  7275. }
  7276. // ResetBotType resets all changes to the "bot_type" field.
  7277. func (m *ChatSessionMutation) ResetBotType() {
  7278. m.bot_type = nil
  7279. m.addbot_type = nil
  7280. }
  7281. // Where appends a list predicates to the ChatSessionMutation builder.
  7282. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7283. m.predicates = append(m.predicates, ps...)
  7284. }
  7285. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7286. // users can use type-assertion to append predicates that do not depend on any generated package.
  7287. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7288. p := make([]predicate.ChatSession, len(ps))
  7289. for i := range ps {
  7290. p[i] = ps[i]
  7291. }
  7292. m.Where(p...)
  7293. }
  7294. // Op returns the operation name.
  7295. func (m *ChatSessionMutation) Op() Op {
  7296. return m.op
  7297. }
  7298. // SetOp allows setting the mutation operation.
  7299. func (m *ChatSessionMutation) SetOp(op Op) {
  7300. m.op = op
  7301. }
  7302. // Type returns the node type of this mutation (ChatSession).
  7303. func (m *ChatSessionMutation) Type() string {
  7304. return m.typ
  7305. }
  7306. // Fields returns all fields that were changed during this mutation. Note that in
  7307. // order to get all numeric fields that were incremented/decremented, call
  7308. // AddedFields().
  7309. func (m *ChatSessionMutation) Fields() []string {
  7310. fields := make([]string, 0, 7)
  7311. if m.created_at != nil {
  7312. fields = append(fields, chatsession.FieldCreatedAt)
  7313. }
  7314. if m.updated_at != nil {
  7315. fields = append(fields, chatsession.FieldUpdatedAt)
  7316. }
  7317. if m.deleted_at != nil {
  7318. fields = append(fields, chatsession.FieldDeletedAt)
  7319. }
  7320. if m.name != nil {
  7321. fields = append(fields, chatsession.FieldName)
  7322. }
  7323. if m.user_id != nil {
  7324. fields = append(fields, chatsession.FieldUserID)
  7325. }
  7326. if m.bot_id != nil {
  7327. fields = append(fields, chatsession.FieldBotID)
  7328. }
  7329. if m.bot_type != nil {
  7330. fields = append(fields, chatsession.FieldBotType)
  7331. }
  7332. return fields
  7333. }
  7334. // Field returns the value of a field with the given name. The second boolean
  7335. // return value indicates that this field was not set, or was not defined in the
  7336. // schema.
  7337. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7338. switch name {
  7339. case chatsession.FieldCreatedAt:
  7340. return m.CreatedAt()
  7341. case chatsession.FieldUpdatedAt:
  7342. return m.UpdatedAt()
  7343. case chatsession.FieldDeletedAt:
  7344. return m.DeletedAt()
  7345. case chatsession.FieldName:
  7346. return m.Name()
  7347. case chatsession.FieldUserID:
  7348. return m.UserID()
  7349. case chatsession.FieldBotID:
  7350. return m.BotID()
  7351. case chatsession.FieldBotType:
  7352. return m.BotType()
  7353. }
  7354. return nil, false
  7355. }
  7356. // OldField returns the old value of the field from the database. An error is
  7357. // returned if the mutation operation is not UpdateOne, or the query to the
  7358. // database failed.
  7359. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7360. switch name {
  7361. case chatsession.FieldCreatedAt:
  7362. return m.OldCreatedAt(ctx)
  7363. case chatsession.FieldUpdatedAt:
  7364. return m.OldUpdatedAt(ctx)
  7365. case chatsession.FieldDeletedAt:
  7366. return m.OldDeletedAt(ctx)
  7367. case chatsession.FieldName:
  7368. return m.OldName(ctx)
  7369. case chatsession.FieldUserID:
  7370. return m.OldUserID(ctx)
  7371. case chatsession.FieldBotID:
  7372. return m.OldBotID(ctx)
  7373. case chatsession.FieldBotType:
  7374. return m.OldBotType(ctx)
  7375. }
  7376. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7377. }
  7378. // SetField sets the value of a field with the given name. It returns an error if
  7379. // the field is not defined in the schema, or if the type mismatched the field
  7380. // type.
  7381. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7382. switch name {
  7383. case chatsession.FieldCreatedAt:
  7384. v, ok := value.(time.Time)
  7385. if !ok {
  7386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7387. }
  7388. m.SetCreatedAt(v)
  7389. return nil
  7390. case chatsession.FieldUpdatedAt:
  7391. v, ok := value.(time.Time)
  7392. if !ok {
  7393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7394. }
  7395. m.SetUpdatedAt(v)
  7396. return nil
  7397. case chatsession.FieldDeletedAt:
  7398. v, ok := value.(time.Time)
  7399. if !ok {
  7400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7401. }
  7402. m.SetDeletedAt(v)
  7403. return nil
  7404. case chatsession.FieldName:
  7405. v, ok := value.(string)
  7406. if !ok {
  7407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7408. }
  7409. m.SetName(v)
  7410. return nil
  7411. case chatsession.FieldUserID:
  7412. v, ok := value.(uint64)
  7413. if !ok {
  7414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7415. }
  7416. m.SetUserID(v)
  7417. return nil
  7418. case chatsession.FieldBotID:
  7419. v, ok := value.(uint64)
  7420. if !ok {
  7421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7422. }
  7423. m.SetBotID(v)
  7424. return nil
  7425. case chatsession.FieldBotType:
  7426. v, ok := value.(uint8)
  7427. if !ok {
  7428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7429. }
  7430. m.SetBotType(v)
  7431. return nil
  7432. }
  7433. return fmt.Errorf("unknown ChatSession field %s", name)
  7434. }
  7435. // AddedFields returns all numeric fields that were incremented/decremented during
  7436. // this mutation.
  7437. func (m *ChatSessionMutation) AddedFields() []string {
  7438. var fields []string
  7439. if m.adduser_id != nil {
  7440. fields = append(fields, chatsession.FieldUserID)
  7441. }
  7442. if m.addbot_id != nil {
  7443. fields = append(fields, chatsession.FieldBotID)
  7444. }
  7445. if m.addbot_type != nil {
  7446. fields = append(fields, chatsession.FieldBotType)
  7447. }
  7448. return fields
  7449. }
  7450. // AddedField returns the numeric value that was incremented/decremented on a field
  7451. // with the given name. The second boolean return value indicates that this field
  7452. // was not set, or was not defined in the schema.
  7453. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7454. switch name {
  7455. case chatsession.FieldUserID:
  7456. return m.AddedUserID()
  7457. case chatsession.FieldBotID:
  7458. return m.AddedBotID()
  7459. case chatsession.FieldBotType:
  7460. return m.AddedBotType()
  7461. }
  7462. return nil, false
  7463. }
  7464. // AddField adds the value to the field with the given name. It returns an error if
  7465. // the field is not defined in the schema, or if the type mismatched the field
  7466. // type.
  7467. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7468. switch name {
  7469. case chatsession.FieldUserID:
  7470. v, ok := value.(int64)
  7471. if !ok {
  7472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7473. }
  7474. m.AddUserID(v)
  7475. return nil
  7476. case chatsession.FieldBotID:
  7477. v, ok := value.(int64)
  7478. if !ok {
  7479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7480. }
  7481. m.AddBotID(v)
  7482. return nil
  7483. case chatsession.FieldBotType:
  7484. v, ok := value.(int8)
  7485. if !ok {
  7486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7487. }
  7488. m.AddBotType(v)
  7489. return nil
  7490. }
  7491. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7492. }
  7493. // ClearedFields returns all nullable fields that were cleared during this
  7494. // mutation.
  7495. func (m *ChatSessionMutation) ClearedFields() []string {
  7496. var fields []string
  7497. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7498. fields = append(fields, chatsession.FieldDeletedAt)
  7499. }
  7500. return fields
  7501. }
  7502. // FieldCleared returns a boolean indicating if a field with the given name was
  7503. // cleared in this mutation.
  7504. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7505. _, ok := m.clearedFields[name]
  7506. return ok
  7507. }
  7508. // ClearField clears the value of the field with the given name. It returns an
  7509. // error if the field is not defined in the schema.
  7510. func (m *ChatSessionMutation) ClearField(name string) error {
  7511. switch name {
  7512. case chatsession.FieldDeletedAt:
  7513. m.ClearDeletedAt()
  7514. return nil
  7515. }
  7516. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7517. }
  7518. // ResetField resets all changes in the mutation for the field with the given name.
  7519. // It returns an error if the field is not defined in the schema.
  7520. func (m *ChatSessionMutation) ResetField(name string) error {
  7521. switch name {
  7522. case chatsession.FieldCreatedAt:
  7523. m.ResetCreatedAt()
  7524. return nil
  7525. case chatsession.FieldUpdatedAt:
  7526. m.ResetUpdatedAt()
  7527. return nil
  7528. case chatsession.FieldDeletedAt:
  7529. m.ResetDeletedAt()
  7530. return nil
  7531. case chatsession.FieldName:
  7532. m.ResetName()
  7533. return nil
  7534. case chatsession.FieldUserID:
  7535. m.ResetUserID()
  7536. return nil
  7537. case chatsession.FieldBotID:
  7538. m.ResetBotID()
  7539. return nil
  7540. case chatsession.FieldBotType:
  7541. m.ResetBotType()
  7542. return nil
  7543. }
  7544. return fmt.Errorf("unknown ChatSession field %s", name)
  7545. }
  7546. // AddedEdges returns all edge names that were set/added in this mutation.
  7547. func (m *ChatSessionMutation) AddedEdges() []string {
  7548. edges := make([]string, 0, 0)
  7549. return edges
  7550. }
  7551. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7552. // name in this mutation.
  7553. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7554. return nil
  7555. }
  7556. // RemovedEdges returns all edge names that were removed in this mutation.
  7557. func (m *ChatSessionMutation) RemovedEdges() []string {
  7558. edges := make([]string, 0, 0)
  7559. return edges
  7560. }
  7561. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7562. // the given name in this mutation.
  7563. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7564. return nil
  7565. }
  7566. // ClearedEdges returns all edge names that were cleared in this mutation.
  7567. func (m *ChatSessionMutation) ClearedEdges() []string {
  7568. edges := make([]string, 0, 0)
  7569. return edges
  7570. }
  7571. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7572. // was cleared in this mutation.
  7573. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7574. return false
  7575. }
  7576. // ClearEdge clears the value of the edge with the given name. It returns an error
  7577. // if that edge is not defined in the schema.
  7578. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7579. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7580. }
  7581. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7582. // It returns an error if the edge is not defined in the schema.
  7583. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7584. return fmt.Errorf("unknown ChatSession edge %s", name)
  7585. }
  7586. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7587. type ContactMutation struct {
  7588. config
  7589. op Op
  7590. typ string
  7591. id *uint64
  7592. created_at *time.Time
  7593. updated_at *time.Time
  7594. status *uint8
  7595. addstatus *int8
  7596. deleted_at *time.Time
  7597. wx_wxid *string
  7598. _type *int
  7599. add_type *int
  7600. wxid *string
  7601. account *string
  7602. nickname *string
  7603. markname *string
  7604. headimg *string
  7605. sex *int
  7606. addsex *int
  7607. starrole *string
  7608. dontseeit *int
  7609. adddontseeit *int
  7610. dontseeme *int
  7611. adddontseeme *int
  7612. lag *string
  7613. gid *string
  7614. gname *string
  7615. v3 *string
  7616. organization_id *uint64
  7617. addorganization_id *int64
  7618. clearedFields map[string]struct{}
  7619. contact_relationships map[uint64]struct{}
  7620. removedcontact_relationships map[uint64]struct{}
  7621. clearedcontact_relationships bool
  7622. contact_messages map[uint64]struct{}
  7623. removedcontact_messages map[uint64]struct{}
  7624. clearedcontact_messages bool
  7625. done bool
  7626. oldValue func(context.Context) (*Contact, error)
  7627. predicates []predicate.Contact
  7628. }
  7629. var _ ent.Mutation = (*ContactMutation)(nil)
  7630. // contactOption allows management of the mutation configuration using functional options.
  7631. type contactOption func(*ContactMutation)
  7632. // newContactMutation creates new mutation for the Contact entity.
  7633. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7634. m := &ContactMutation{
  7635. config: c,
  7636. op: op,
  7637. typ: TypeContact,
  7638. clearedFields: make(map[string]struct{}),
  7639. }
  7640. for _, opt := range opts {
  7641. opt(m)
  7642. }
  7643. return m
  7644. }
  7645. // withContactID sets the ID field of the mutation.
  7646. func withContactID(id uint64) contactOption {
  7647. return func(m *ContactMutation) {
  7648. var (
  7649. err error
  7650. once sync.Once
  7651. value *Contact
  7652. )
  7653. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7654. once.Do(func() {
  7655. if m.done {
  7656. err = errors.New("querying old values post mutation is not allowed")
  7657. } else {
  7658. value, err = m.Client().Contact.Get(ctx, id)
  7659. }
  7660. })
  7661. return value, err
  7662. }
  7663. m.id = &id
  7664. }
  7665. }
  7666. // withContact sets the old Contact of the mutation.
  7667. func withContact(node *Contact) contactOption {
  7668. return func(m *ContactMutation) {
  7669. m.oldValue = func(context.Context) (*Contact, error) {
  7670. return node, nil
  7671. }
  7672. m.id = &node.ID
  7673. }
  7674. }
  7675. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7676. // executed in a transaction (ent.Tx), a transactional client is returned.
  7677. func (m ContactMutation) Client() *Client {
  7678. client := &Client{config: m.config}
  7679. client.init()
  7680. return client
  7681. }
  7682. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7683. // it returns an error otherwise.
  7684. func (m ContactMutation) Tx() (*Tx, error) {
  7685. if _, ok := m.driver.(*txDriver); !ok {
  7686. return nil, errors.New("ent: mutation is not running in a transaction")
  7687. }
  7688. tx := &Tx{config: m.config}
  7689. tx.init()
  7690. return tx, nil
  7691. }
  7692. // SetID sets the value of the id field. Note that this
  7693. // operation is only accepted on creation of Contact entities.
  7694. func (m *ContactMutation) SetID(id uint64) {
  7695. m.id = &id
  7696. }
  7697. // ID returns the ID value in the mutation. Note that the ID is only available
  7698. // if it was provided to the builder or after it was returned from the database.
  7699. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7700. if m.id == nil {
  7701. return
  7702. }
  7703. return *m.id, true
  7704. }
  7705. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7706. // That means, if the mutation is applied within a transaction with an isolation level such
  7707. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7708. // or updated by the mutation.
  7709. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7710. switch {
  7711. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7712. id, exists := m.ID()
  7713. if exists {
  7714. return []uint64{id}, nil
  7715. }
  7716. fallthrough
  7717. case m.op.Is(OpUpdate | OpDelete):
  7718. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7719. default:
  7720. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7721. }
  7722. }
  7723. // SetCreatedAt sets the "created_at" field.
  7724. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7725. m.created_at = &t
  7726. }
  7727. // CreatedAt returns the value of the "created_at" field in the mutation.
  7728. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7729. v := m.created_at
  7730. if v == nil {
  7731. return
  7732. }
  7733. return *v, true
  7734. }
  7735. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7736. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7738. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7739. if !m.op.Is(OpUpdateOne) {
  7740. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7741. }
  7742. if m.id == nil || m.oldValue == nil {
  7743. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7744. }
  7745. oldValue, err := m.oldValue(ctx)
  7746. if err != nil {
  7747. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7748. }
  7749. return oldValue.CreatedAt, nil
  7750. }
  7751. // ResetCreatedAt resets all changes to the "created_at" field.
  7752. func (m *ContactMutation) ResetCreatedAt() {
  7753. m.created_at = nil
  7754. }
  7755. // SetUpdatedAt sets the "updated_at" field.
  7756. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7757. m.updated_at = &t
  7758. }
  7759. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7760. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7761. v := m.updated_at
  7762. if v == nil {
  7763. return
  7764. }
  7765. return *v, true
  7766. }
  7767. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7768. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7770. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7771. if !m.op.Is(OpUpdateOne) {
  7772. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7773. }
  7774. if m.id == nil || m.oldValue == nil {
  7775. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7776. }
  7777. oldValue, err := m.oldValue(ctx)
  7778. if err != nil {
  7779. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7780. }
  7781. return oldValue.UpdatedAt, nil
  7782. }
  7783. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7784. func (m *ContactMutation) ResetUpdatedAt() {
  7785. m.updated_at = nil
  7786. }
  7787. // SetStatus sets the "status" field.
  7788. func (m *ContactMutation) SetStatus(u uint8) {
  7789. m.status = &u
  7790. m.addstatus = nil
  7791. }
  7792. // Status returns the value of the "status" field in the mutation.
  7793. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7794. v := m.status
  7795. if v == nil {
  7796. return
  7797. }
  7798. return *v, true
  7799. }
  7800. // OldStatus returns the old "status" field's value of the Contact entity.
  7801. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7803. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7804. if !m.op.Is(OpUpdateOne) {
  7805. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7806. }
  7807. if m.id == nil || m.oldValue == nil {
  7808. return v, errors.New("OldStatus requires an ID field in the mutation")
  7809. }
  7810. oldValue, err := m.oldValue(ctx)
  7811. if err != nil {
  7812. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7813. }
  7814. return oldValue.Status, nil
  7815. }
  7816. // AddStatus adds u to the "status" field.
  7817. func (m *ContactMutation) AddStatus(u int8) {
  7818. if m.addstatus != nil {
  7819. *m.addstatus += u
  7820. } else {
  7821. m.addstatus = &u
  7822. }
  7823. }
  7824. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7825. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7826. v := m.addstatus
  7827. if v == nil {
  7828. return
  7829. }
  7830. return *v, true
  7831. }
  7832. // ClearStatus clears the value of the "status" field.
  7833. func (m *ContactMutation) ClearStatus() {
  7834. m.status = nil
  7835. m.addstatus = nil
  7836. m.clearedFields[contact.FieldStatus] = struct{}{}
  7837. }
  7838. // StatusCleared returns if the "status" field was cleared in this mutation.
  7839. func (m *ContactMutation) StatusCleared() bool {
  7840. _, ok := m.clearedFields[contact.FieldStatus]
  7841. return ok
  7842. }
  7843. // ResetStatus resets all changes to the "status" field.
  7844. func (m *ContactMutation) ResetStatus() {
  7845. m.status = nil
  7846. m.addstatus = nil
  7847. delete(m.clearedFields, contact.FieldStatus)
  7848. }
  7849. // SetDeletedAt sets the "deleted_at" field.
  7850. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7851. m.deleted_at = &t
  7852. }
  7853. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7854. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7855. v := m.deleted_at
  7856. if v == nil {
  7857. return
  7858. }
  7859. return *v, true
  7860. }
  7861. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7862. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7864. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7865. if !m.op.Is(OpUpdateOne) {
  7866. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7867. }
  7868. if m.id == nil || m.oldValue == nil {
  7869. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7870. }
  7871. oldValue, err := m.oldValue(ctx)
  7872. if err != nil {
  7873. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7874. }
  7875. return oldValue.DeletedAt, nil
  7876. }
  7877. // ClearDeletedAt clears the value of the "deleted_at" field.
  7878. func (m *ContactMutation) ClearDeletedAt() {
  7879. m.deleted_at = nil
  7880. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7881. }
  7882. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7883. func (m *ContactMutation) DeletedAtCleared() bool {
  7884. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7885. return ok
  7886. }
  7887. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7888. func (m *ContactMutation) ResetDeletedAt() {
  7889. m.deleted_at = nil
  7890. delete(m.clearedFields, contact.FieldDeletedAt)
  7891. }
  7892. // SetWxWxid sets the "wx_wxid" field.
  7893. func (m *ContactMutation) SetWxWxid(s string) {
  7894. m.wx_wxid = &s
  7895. }
  7896. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7897. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7898. v := m.wx_wxid
  7899. if v == nil {
  7900. return
  7901. }
  7902. return *v, true
  7903. }
  7904. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7905. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7907. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7908. if !m.op.Is(OpUpdateOne) {
  7909. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7910. }
  7911. if m.id == nil || m.oldValue == nil {
  7912. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7913. }
  7914. oldValue, err := m.oldValue(ctx)
  7915. if err != nil {
  7916. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7917. }
  7918. return oldValue.WxWxid, nil
  7919. }
  7920. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7921. func (m *ContactMutation) ResetWxWxid() {
  7922. m.wx_wxid = nil
  7923. }
  7924. // SetType sets the "type" field.
  7925. func (m *ContactMutation) SetType(i int) {
  7926. m._type = &i
  7927. m.add_type = nil
  7928. }
  7929. // GetType returns the value of the "type" field in the mutation.
  7930. func (m *ContactMutation) GetType() (r int, exists bool) {
  7931. v := m._type
  7932. if v == nil {
  7933. return
  7934. }
  7935. return *v, true
  7936. }
  7937. // OldType returns the old "type" field's value of the Contact entity.
  7938. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7940. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7941. if !m.op.Is(OpUpdateOne) {
  7942. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7943. }
  7944. if m.id == nil || m.oldValue == nil {
  7945. return v, errors.New("OldType requires an ID field in the mutation")
  7946. }
  7947. oldValue, err := m.oldValue(ctx)
  7948. if err != nil {
  7949. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7950. }
  7951. return oldValue.Type, nil
  7952. }
  7953. // AddType adds i to the "type" field.
  7954. func (m *ContactMutation) AddType(i int) {
  7955. if m.add_type != nil {
  7956. *m.add_type += i
  7957. } else {
  7958. m.add_type = &i
  7959. }
  7960. }
  7961. // AddedType returns the value that was added to the "type" field in this mutation.
  7962. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7963. v := m.add_type
  7964. if v == nil {
  7965. return
  7966. }
  7967. return *v, true
  7968. }
  7969. // ClearType clears the value of the "type" field.
  7970. func (m *ContactMutation) ClearType() {
  7971. m._type = nil
  7972. m.add_type = nil
  7973. m.clearedFields[contact.FieldType] = struct{}{}
  7974. }
  7975. // TypeCleared returns if the "type" field was cleared in this mutation.
  7976. func (m *ContactMutation) TypeCleared() bool {
  7977. _, ok := m.clearedFields[contact.FieldType]
  7978. return ok
  7979. }
  7980. // ResetType resets all changes to the "type" field.
  7981. func (m *ContactMutation) ResetType() {
  7982. m._type = nil
  7983. m.add_type = nil
  7984. delete(m.clearedFields, contact.FieldType)
  7985. }
  7986. // SetWxid sets the "wxid" field.
  7987. func (m *ContactMutation) SetWxid(s string) {
  7988. m.wxid = &s
  7989. }
  7990. // Wxid returns the value of the "wxid" field in the mutation.
  7991. func (m *ContactMutation) Wxid() (r string, exists bool) {
  7992. v := m.wxid
  7993. if v == nil {
  7994. return
  7995. }
  7996. return *v, true
  7997. }
  7998. // OldWxid returns the old "wxid" field's value of the Contact entity.
  7999. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8001. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8002. if !m.op.Is(OpUpdateOne) {
  8003. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8004. }
  8005. if m.id == nil || m.oldValue == nil {
  8006. return v, errors.New("OldWxid requires an ID field in the mutation")
  8007. }
  8008. oldValue, err := m.oldValue(ctx)
  8009. if err != nil {
  8010. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8011. }
  8012. return oldValue.Wxid, nil
  8013. }
  8014. // ResetWxid resets all changes to the "wxid" field.
  8015. func (m *ContactMutation) ResetWxid() {
  8016. m.wxid = nil
  8017. }
  8018. // SetAccount sets the "account" field.
  8019. func (m *ContactMutation) SetAccount(s string) {
  8020. m.account = &s
  8021. }
  8022. // Account returns the value of the "account" field in the mutation.
  8023. func (m *ContactMutation) Account() (r string, exists bool) {
  8024. v := m.account
  8025. if v == nil {
  8026. return
  8027. }
  8028. return *v, true
  8029. }
  8030. // OldAccount returns the old "account" field's value of the Contact entity.
  8031. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8033. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8034. if !m.op.Is(OpUpdateOne) {
  8035. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8036. }
  8037. if m.id == nil || m.oldValue == nil {
  8038. return v, errors.New("OldAccount requires an ID field in the mutation")
  8039. }
  8040. oldValue, err := m.oldValue(ctx)
  8041. if err != nil {
  8042. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8043. }
  8044. return oldValue.Account, nil
  8045. }
  8046. // ResetAccount resets all changes to the "account" field.
  8047. func (m *ContactMutation) ResetAccount() {
  8048. m.account = nil
  8049. }
  8050. // SetNickname sets the "nickname" field.
  8051. func (m *ContactMutation) SetNickname(s string) {
  8052. m.nickname = &s
  8053. }
  8054. // Nickname returns the value of the "nickname" field in the mutation.
  8055. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8056. v := m.nickname
  8057. if v == nil {
  8058. return
  8059. }
  8060. return *v, true
  8061. }
  8062. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8063. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8065. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8066. if !m.op.Is(OpUpdateOne) {
  8067. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8068. }
  8069. if m.id == nil || m.oldValue == nil {
  8070. return v, errors.New("OldNickname requires an ID field in the mutation")
  8071. }
  8072. oldValue, err := m.oldValue(ctx)
  8073. if err != nil {
  8074. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8075. }
  8076. return oldValue.Nickname, nil
  8077. }
  8078. // ResetNickname resets all changes to the "nickname" field.
  8079. func (m *ContactMutation) ResetNickname() {
  8080. m.nickname = nil
  8081. }
  8082. // SetMarkname sets the "markname" field.
  8083. func (m *ContactMutation) SetMarkname(s string) {
  8084. m.markname = &s
  8085. }
  8086. // Markname returns the value of the "markname" field in the mutation.
  8087. func (m *ContactMutation) Markname() (r string, exists bool) {
  8088. v := m.markname
  8089. if v == nil {
  8090. return
  8091. }
  8092. return *v, true
  8093. }
  8094. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8095. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8097. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8098. if !m.op.Is(OpUpdateOne) {
  8099. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8100. }
  8101. if m.id == nil || m.oldValue == nil {
  8102. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8103. }
  8104. oldValue, err := m.oldValue(ctx)
  8105. if err != nil {
  8106. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8107. }
  8108. return oldValue.Markname, nil
  8109. }
  8110. // ResetMarkname resets all changes to the "markname" field.
  8111. func (m *ContactMutation) ResetMarkname() {
  8112. m.markname = nil
  8113. }
  8114. // SetHeadimg sets the "headimg" field.
  8115. func (m *ContactMutation) SetHeadimg(s string) {
  8116. m.headimg = &s
  8117. }
  8118. // Headimg returns the value of the "headimg" field in the mutation.
  8119. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8120. v := m.headimg
  8121. if v == nil {
  8122. return
  8123. }
  8124. return *v, true
  8125. }
  8126. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8127. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8129. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8130. if !m.op.Is(OpUpdateOne) {
  8131. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8132. }
  8133. if m.id == nil || m.oldValue == nil {
  8134. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8135. }
  8136. oldValue, err := m.oldValue(ctx)
  8137. if err != nil {
  8138. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8139. }
  8140. return oldValue.Headimg, nil
  8141. }
  8142. // ResetHeadimg resets all changes to the "headimg" field.
  8143. func (m *ContactMutation) ResetHeadimg() {
  8144. m.headimg = nil
  8145. }
  8146. // SetSex sets the "sex" field.
  8147. func (m *ContactMutation) SetSex(i int) {
  8148. m.sex = &i
  8149. m.addsex = nil
  8150. }
  8151. // Sex returns the value of the "sex" field in the mutation.
  8152. func (m *ContactMutation) Sex() (r int, exists bool) {
  8153. v := m.sex
  8154. if v == nil {
  8155. return
  8156. }
  8157. return *v, true
  8158. }
  8159. // OldSex returns the old "sex" field's value of the Contact entity.
  8160. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8162. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8163. if !m.op.Is(OpUpdateOne) {
  8164. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8165. }
  8166. if m.id == nil || m.oldValue == nil {
  8167. return v, errors.New("OldSex requires an ID field in the mutation")
  8168. }
  8169. oldValue, err := m.oldValue(ctx)
  8170. if err != nil {
  8171. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8172. }
  8173. return oldValue.Sex, nil
  8174. }
  8175. // AddSex adds i to the "sex" field.
  8176. func (m *ContactMutation) AddSex(i int) {
  8177. if m.addsex != nil {
  8178. *m.addsex += i
  8179. } else {
  8180. m.addsex = &i
  8181. }
  8182. }
  8183. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8184. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8185. v := m.addsex
  8186. if v == nil {
  8187. return
  8188. }
  8189. return *v, true
  8190. }
  8191. // ResetSex resets all changes to the "sex" field.
  8192. func (m *ContactMutation) ResetSex() {
  8193. m.sex = nil
  8194. m.addsex = nil
  8195. }
  8196. // SetStarrole sets the "starrole" field.
  8197. func (m *ContactMutation) SetStarrole(s string) {
  8198. m.starrole = &s
  8199. }
  8200. // Starrole returns the value of the "starrole" field in the mutation.
  8201. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8202. v := m.starrole
  8203. if v == nil {
  8204. return
  8205. }
  8206. return *v, true
  8207. }
  8208. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8209. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8211. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8212. if !m.op.Is(OpUpdateOne) {
  8213. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8214. }
  8215. if m.id == nil || m.oldValue == nil {
  8216. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8217. }
  8218. oldValue, err := m.oldValue(ctx)
  8219. if err != nil {
  8220. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8221. }
  8222. return oldValue.Starrole, nil
  8223. }
  8224. // ResetStarrole resets all changes to the "starrole" field.
  8225. func (m *ContactMutation) ResetStarrole() {
  8226. m.starrole = nil
  8227. }
  8228. // SetDontseeit sets the "dontseeit" field.
  8229. func (m *ContactMutation) SetDontseeit(i int) {
  8230. m.dontseeit = &i
  8231. m.adddontseeit = nil
  8232. }
  8233. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8234. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8235. v := m.dontseeit
  8236. if v == nil {
  8237. return
  8238. }
  8239. return *v, true
  8240. }
  8241. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8242. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8244. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8245. if !m.op.Is(OpUpdateOne) {
  8246. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8247. }
  8248. if m.id == nil || m.oldValue == nil {
  8249. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8250. }
  8251. oldValue, err := m.oldValue(ctx)
  8252. if err != nil {
  8253. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8254. }
  8255. return oldValue.Dontseeit, nil
  8256. }
  8257. // AddDontseeit adds i to the "dontseeit" field.
  8258. func (m *ContactMutation) AddDontseeit(i int) {
  8259. if m.adddontseeit != nil {
  8260. *m.adddontseeit += i
  8261. } else {
  8262. m.adddontseeit = &i
  8263. }
  8264. }
  8265. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8266. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8267. v := m.adddontseeit
  8268. if v == nil {
  8269. return
  8270. }
  8271. return *v, true
  8272. }
  8273. // ResetDontseeit resets all changes to the "dontseeit" field.
  8274. func (m *ContactMutation) ResetDontseeit() {
  8275. m.dontseeit = nil
  8276. m.adddontseeit = nil
  8277. }
  8278. // SetDontseeme sets the "dontseeme" field.
  8279. func (m *ContactMutation) SetDontseeme(i int) {
  8280. m.dontseeme = &i
  8281. m.adddontseeme = nil
  8282. }
  8283. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8284. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8285. v := m.dontseeme
  8286. if v == nil {
  8287. return
  8288. }
  8289. return *v, true
  8290. }
  8291. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8292. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8294. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8295. if !m.op.Is(OpUpdateOne) {
  8296. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8297. }
  8298. if m.id == nil || m.oldValue == nil {
  8299. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8300. }
  8301. oldValue, err := m.oldValue(ctx)
  8302. if err != nil {
  8303. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8304. }
  8305. return oldValue.Dontseeme, nil
  8306. }
  8307. // AddDontseeme adds i to the "dontseeme" field.
  8308. func (m *ContactMutation) AddDontseeme(i int) {
  8309. if m.adddontseeme != nil {
  8310. *m.adddontseeme += i
  8311. } else {
  8312. m.adddontseeme = &i
  8313. }
  8314. }
  8315. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8316. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8317. v := m.adddontseeme
  8318. if v == nil {
  8319. return
  8320. }
  8321. return *v, true
  8322. }
  8323. // ResetDontseeme resets all changes to the "dontseeme" field.
  8324. func (m *ContactMutation) ResetDontseeme() {
  8325. m.dontseeme = nil
  8326. m.adddontseeme = nil
  8327. }
  8328. // SetLag sets the "lag" field.
  8329. func (m *ContactMutation) SetLag(s string) {
  8330. m.lag = &s
  8331. }
  8332. // Lag returns the value of the "lag" field in the mutation.
  8333. func (m *ContactMutation) Lag() (r string, exists bool) {
  8334. v := m.lag
  8335. if v == nil {
  8336. return
  8337. }
  8338. return *v, true
  8339. }
  8340. // OldLag returns the old "lag" field's value of the Contact entity.
  8341. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8343. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8344. if !m.op.Is(OpUpdateOne) {
  8345. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8346. }
  8347. if m.id == nil || m.oldValue == nil {
  8348. return v, errors.New("OldLag requires an ID field in the mutation")
  8349. }
  8350. oldValue, err := m.oldValue(ctx)
  8351. if err != nil {
  8352. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8353. }
  8354. return oldValue.Lag, nil
  8355. }
  8356. // ResetLag resets all changes to the "lag" field.
  8357. func (m *ContactMutation) ResetLag() {
  8358. m.lag = nil
  8359. }
  8360. // SetGid sets the "gid" field.
  8361. func (m *ContactMutation) SetGid(s string) {
  8362. m.gid = &s
  8363. }
  8364. // Gid returns the value of the "gid" field in the mutation.
  8365. func (m *ContactMutation) Gid() (r string, exists bool) {
  8366. v := m.gid
  8367. if v == nil {
  8368. return
  8369. }
  8370. return *v, true
  8371. }
  8372. // OldGid returns the old "gid" field's value of the Contact entity.
  8373. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8375. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8376. if !m.op.Is(OpUpdateOne) {
  8377. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8378. }
  8379. if m.id == nil || m.oldValue == nil {
  8380. return v, errors.New("OldGid requires an ID field in the mutation")
  8381. }
  8382. oldValue, err := m.oldValue(ctx)
  8383. if err != nil {
  8384. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8385. }
  8386. return oldValue.Gid, nil
  8387. }
  8388. // ResetGid resets all changes to the "gid" field.
  8389. func (m *ContactMutation) ResetGid() {
  8390. m.gid = nil
  8391. }
  8392. // SetGname sets the "gname" field.
  8393. func (m *ContactMutation) SetGname(s string) {
  8394. m.gname = &s
  8395. }
  8396. // Gname returns the value of the "gname" field in the mutation.
  8397. func (m *ContactMutation) Gname() (r string, exists bool) {
  8398. v := m.gname
  8399. if v == nil {
  8400. return
  8401. }
  8402. return *v, true
  8403. }
  8404. // OldGname returns the old "gname" field's value of the Contact entity.
  8405. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8407. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8408. if !m.op.Is(OpUpdateOne) {
  8409. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8410. }
  8411. if m.id == nil || m.oldValue == nil {
  8412. return v, errors.New("OldGname requires an ID field in the mutation")
  8413. }
  8414. oldValue, err := m.oldValue(ctx)
  8415. if err != nil {
  8416. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8417. }
  8418. return oldValue.Gname, nil
  8419. }
  8420. // ResetGname resets all changes to the "gname" field.
  8421. func (m *ContactMutation) ResetGname() {
  8422. m.gname = nil
  8423. }
  8424. // SetV3 sets the "v3" field.
  8425. func (m *ContactMutation) SetV3(s string) {
  8426. m.v3 = &s
  8427. }
  8428. // V3 returns the value of the "v3" field in the mutation.
  8429. func (m *ContactMutation) V3() (r string, exists bool) {
  8430. v := m.v3
  8431. if v == nil {
  8432. return
  8433. }
  8434. return *v, true
  8435. }
  8436. // OldV3 returns the old "v3" field's value of the Contact entity.
  8437. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8439. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8440. if !m.op.Is(OpUpdateOne) {
  8441. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8442. }
  8443. if m.id == nil || m.oldValue == nil {
  8444. return v, errors.New("OldV3 requires an ID field in the mutation")
  8445. }
  8446. oldValue, err := m.oldValue(ctx)
  8447. if err != nil {
  8448. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8449. }
  8450. return oldValue.V3, nil
  8451. }
  8452. // ResetV3 resets all changes to the "v3" field.
  8453. func (m *ContactMutation) ResetV3() {
  8454. m.v3 = nil
  8455. }
  8456. // SetOrganizationID sets the "organization_id" field.
  8457. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8458. m.organization_id = &u
  8459. m.addorganization_id = nil
  8460. }
  8461. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8462. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8463. v := m.organization_id
  8464. if v == nil {
  8465. return
  8466. }
  8467. return *v, true
  8468. }
  8469. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8470. // If the Contact 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 *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8473. if !m.op.Is(OpUpdateOne) {
  8474. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8475. }
  8476. if m.id == nil || m.oldValue == nil {
  8477. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  8482. }
  8483. return oldValue.OrganizationID, nil
  8484. }
  8485. // AddOrganizationID adds u to the "organization_id" field.
  8486. func (m *ContactMutation) AddOrganizationID(u int64) {
  8487. if m.addorganization_id != nil {
  8488. *m.addorganization_id += u
  8489. } else {
  8490. m.addorganization_id = &u
  8491. }
  8492. }
  8493. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8494. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8495. v := m.addorganization_id
  8496. if v == nil {
  8497. return
  8498. }
  8499. return *v, true
  8500. }
  8501. // ClearOrganizationID clears the value of the "organization_id" field.
  8502. func (m *ContactMutation) ClearOrganizationID() {
  8503. m.organization_id = nil
  8504. m.addorganization_id = nil
  8505. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8506. }
  8507. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8508. func (m *ContactMutation) OrganizationIDCleared() bool {
  8509. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8510. return ok
  8511. }
  8512. // ResetOrganizationID resets all changes to the "organization_id" field.
  8513. func (m *ContactMutation) ResetOrganizationID() {
  8514. m.organization_id = nil
  8515. m.addorganization_id = nil
  8516. delete(m.clearedFields, contact.FieldOrganizationID)
  8517. }
  8518. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8519. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8520. if m.contact_relationships == nil {
  8521. m.contact_relationships = make(map[uint64]struct{})
  8522. }
  8523. for i := range ids {
  8524. m.contact_relationships[ids[i]] = struct{}{}
  8525. }
  8526. }
  8527. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8528. func (m *ContactMutation) ClearContactRelationships() {
  8529. m.clearedcontact_relationships = true
  8530. }
  8531. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8532. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8533. return m.clearedcontact_relationships
  8534. }
  8535. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8536. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8537. if m.removedcontact_relationships == nil {
  8538. m.removedcontact_relationships = make(map[uint64]struct{})
  8539. }
  8540. for i := range ids {
  8541. delete(m.contact_relationships, ids[i])
  8542. m.removedcontact_relationships[ids[i]] = struct{}{}
  8543. }
  8544. }
  8545. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8546. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8547. for id := range m.removedcontact_relationships {
  8548. ids = append(ids, id)
  8549. }
  8550. return
  8551. }
  8552. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8553. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8554. for id := range m.contact_relationships {
  8555. ids = append(ids, id)
  8556. }
  8557. return
  8558. }
  8559. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8560. func (m *ContactMutation) ResetContactRelationships() {
  8561. m.contact_relationships = nil
  8562. m.clearedcontact_relationships = false
  8563. m.removedcontact_relationships = nil
  8564. }
  8565. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8566. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8567. if m.contact_messages == nil {
  8568. m.contact_messages = make(map[uint64]struct{})
  8569. }
  8570. for i := range ids {
  8571. m.contact_messages[ids[i]] = struct{}{}
  8572. }
  8573. }
  8574. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8575. func (m *ContactMutation) ClearContactMessages() {
  8576. m.clearedcontact_messages = true
  8577. }
  8578. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8579. func (m *ContactMutation) ContactMessagesCleared() bool {
  8580. return m.clearedcontact_messages
  8581. }
  8582. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8583. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8584. if m.removedcontact_messages == nil {
  8585. m.removedcontact_messages = make(map[uint64]struct{})
  8586. }
  8587. for i := range ids {
  8588. delete(m.contact_messages, ids[i])
  8589. m.removedcontact_messages[ids[i]] = struct{}{}
  8590. }
  8591. }
  8592. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8593. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8594. for id := range m.removedcontact_messages {
  8595. ids = append(ids, id)
  8596. }
  8597. return
  8598. }
  8599. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8600. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8601. for id := range m.contact_messages {
  8602. ids = append(ids, id)
  8603. }
  8604. return
  8605. }
  8606. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8607. func (m *ContactMutation) ResetContactMessages() {
  8608. m.contact_messages = nil
  8609. m.clearedcontact_messages = false
  8610. m.removedcontact_messages = nil
  8611. }
  8612. // Where appends a list predicates to the ContactMutation builder.
  8613. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8614. m.predicates = append(m.predicates, ps...)
  8615. }
  8616. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8617. // users can use type-assertion to append predicates that do not depend on any generated package.
  8618. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8619. p := make([]predicate.Contact, len(ps))
  8620. for i := range ps {
  8621. p[i] = ps[i]
  8622. }
  8623. m.Where(p...)
  8624. }
  8625. // Op returns the operation name.
  8626. func (m *ContactMutation) Op() Op {
  8627. return m.op
  8628. }
  8629. // SetOp allows setting the mutation operation.
  8630. func (m *ContactMutation) SetOp(op Op) {
  8631. m.op = op
  8632. }
  8633. // Type returns the node type of this mutation (Contact).
  8634. func (m *ContactMutation) Type() string {
  8635. return m.typ
  8636. }
  8637. // Fields returns all fields that were changed during this mutation. Note that in
  8638. // order to get all numeric fields that were incremented/decremented, call
  8639. // AddedFields().
  8640. func (m *ContactMutation) Fields() []string {
  8641. fields := make([]string, 0, 20)
  8642. if m.created_at != nil {
  8643. fields = append(fields, contact.FieldCreatedAt)
  8644. }
  8645. if m.updated_at != nil {
  8646. fields = append(fields, contact.FieldUpdatedAt)
  8647. }
  8648. if m.status != nil {
  8649. fields = append(fields, contact.FieldStatus)
  8650. }
  8651. if m.deleted_at != nil {
  8652. fields = append(fields, contact.FieldDeletedAt)
  8653. }
  8654. if m.wx_wxid != nil {
  8655. fields = append(fields, contact.FieldWxWxid)
  8656. }
  8657. if m._type != nil {
  8658. fields = append(fields, contact.FieldType)
  8659. }
  8660. if m.wxid != nil {
  8661. fields = append(fields, contact.FieldWxid)
  8662. }
  8663. if m.account != nil {
  8664. fields = append(fields, contact.FieldAccount)
  8665. }
  8666. if m.nickname != nil {
  8667. fields = append(fields, contact.FieldNickname)
  8668. }
  8669. if m.markname != nil {
  8670. fields = append(fields, contact.FieldMarkname)
  8671. }
  8672. if m.headimg != nil {
  8673. fields = append(fields, contact.FieldHeadimg)
  8674. }
  8675. if m.sex != nil {
  8676. fields = append(fields, contact.FieldSex)
  8677. }
  8678. if m.starrole != nil {
  8679. fields = append(fields, contact.FieldStarrole)
  8680. }
  8681. if m.dontseeit != nil {
  8682. fields = append(fields, contact.FieldDontseeit)
  8683. }
  8684. if m.dontseeme != nil {
  8685. fields = append(fields, contact.FieldDontseeme)
  8686. }
  8687. if m.lag != nil {
  8688. fields = append(fields, contact.FieldLag)
  8689. }
  8690. if m.gid != nil {
  8691. fields = append(fields, contact.FieldGid)
  8692. }
  8693. if m.gname != nil {
  8694. fields = append(fields, contact.FieldGname)
  8695. }
  8696. if m.v3 != nil {
  8697. fields = append(fields, contact.FieldV3)
  8698. }
  8699. if m.organization_id != nil {
  8700. fields = append(fields, contact.FieldOrganizationID)
  8701. }
  8702. return fields
  8703. }
  8704. // Field returns the value of a field with the given name. The second boolean
  8705. // return value indicates that this field was not set, or was not defined in the
  8706. // schema.
  8707. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8708. switch name {
  8709. case contact.FieldCreatedAt:
  8710. return m.CreatedAt()
  8711. case contact.FieldUpdatedAt:
  8712. return m.UpdatedAt()
  8713. case contact.FieldStatus:
  8714. return m.Status()
  8715. case contact.FieldDeletedAt:
  8716. return m.DeletedAt()
  8717. case contact.FieldWxWxid:
  8718. return m.WxWxid()
  8719. case contact.FieldType:
  8720. return m.GetType()
  8721. case contact.FieldWxid:
  8722. return m.Wxid()
  8723. case contact.FieldAccount:
  8724. return m.Account()
  8725. case contact.FieldNickname:
  8726. return m.Nickname()
  8727. case contact.FieldMarkname:
  8728. return m.Markname()
  8729. case contact.FieldHeadimg:
  8730. return m.Headimg()
  8731. case contact.FieldSex:
  8732. return m.Sex()
  8733. case contact.FieldStarrole:
  8734. return m.Starrole()
  8735. case contact.FieldDontseeit:
  8736. return m.Dontseeit()
  8737. case contact.FieldDontseeme:
  8738. return m.Dontseeme()
  8739. case contact.FieldLag:
  8740. return m.Lag()
  8741. case contact.FieldGid:
  8742. return m.Gid()
  8743. case contact.FieldGname:
  8744. return m.Gname()
  8745. case contact.FieldV3:
  8746. return m.V3()
  8747. case contact.FieldOrganizationID:
  8748. return m.OrganizationID()
  8749. }
  8750. return nil, false
  8751. }
  8752. // OldField returns the old value of the field from the database. An error is
  8753. // returned if the mutation operation is not UpdateOne, or the query to the
  8754. // database failed.
  8755. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8756. switch name {
  8757. case contact.FieldCreatedAt:
  8758. return m.OldCreatedAt(ctx)
  8759. case contact.FieldUpdatedAt:
  8760. return m.OldUpdatedAt(ctx)
  8761. case contact.FieldStatus:
  8762. return m.OldStatus(ctx)
  8763. case contact.FieldDeletedAt:
  8764. return m.OldDeletedAt(ctx)
  8765. case contact.FieldWxWxid:
  8766. return m.OldWxWxid(ctx)
  8767. case contact.FieldType:
  8768. return m.OldType(ctx)
  8769. case contact.FieldWxid:
  8770. return m.OldWxid(ctx)
  8771. case contact.FieldAccount:
  8772. return m.OldAccount(ctx)
  8773. case contact.FieldNickname:
  8774. return m.OldNickname(ctx)
  8775. case contact.FieldMarkname:
  8776. return m.OldMarkname(ctx)
  8777. case contact.FieldHeadimg:
  8778. return m.OldHeadimg(ctx)
  8779. case contact.FieldSex:
  8780. return m.OldSex(ctx)
  8781. case contact.FieldStarrole:
  8782. return m.OldStarrole(ctx)
  8783. case contact.FieldDontseeit:
  8784. return m.OldDontseeit(ctx)
  8785. case contact.FieldDontseeme:
  8786. return m.OldDontseeme(ctx)
  8787. case contact.FieldLag:
  8788. return m.OldLag(ctx)
  8789. case contact.FieldGid:
  8790. return m.OldGid(ctx)
  8791. case contact.FieldGname:
  8792. return m.OldGname(ctx)
  8793. case contact.FieldV3:
  8794. return m.OldV3(ctx)
  8795. case contact.FieldOrganizationID:
  8796. return m.OldOrganizationID(ctx)
  8797. }
  8798. return nil, fmt.Errorf("unknown Contact field %s", name)
  8799. }
  8800. // SetField sets the value of a field with the given name. It returns an error if
  8801. // the field is not defined in the schema, or if the type mismatched the field
  8802. // type.
  8803. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8804. switch name {
  8805. case contact.FieldCreatedAt:
  8806. v, ok := value.(time.Time)
  8807. if !ok {
  8808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8809. }
  8810. m.SetCreatedAt(v)
  8811. return nil
  8812. case contact.FieldUpdatedAt:
  8813. v, ok := value.(time.Time)
  8814. if !ok {
  8815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8816. }
  8817. m.SetUpdatedAt(v)
  8818. return nil
  8819. case contact.FieldStatus:
  8820. v, ok := value.(uint8)
  8821. if !ok {
  8822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8823. }
  8824. m.SetStatus(v)
  8825. return nil
  8826. case contact.FieldDeletedAt:
  8827. v, ok := value.(time.Time)
  8828. if !ok {
  8829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8830. }
  8831. m.SetDeletedAt(v)
  8832. return nil
  8833. case contact.FieldWxWxid:
  8834. v, ok := value.(string)
  8835. if !ok {
  8836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8837. }
  8838. m.SetWxWxid(v)
  8839. return nil
  8840. case contact.FieldType:
  8841. v, ok := value.(int)
  8842. if !ok {
  8843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8844. }
  8845. m.SetType(v)
  8846. return nil
  8847. case contact.FieldWxid:
  8848. v, ok := value.(string)
  8849. if !ok {
  8850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8851. }
  8852. m.SetWxid(v)
  8853. return nil
  8854. case contact.FieldAccount:
  8855. v, ok := value.(string)
  8856. if !ok {
  8857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8858. }
  8859. m.SetAccount(v)
  8860. return nil
  8861. case contact.FieldNickname:
  8862. v, ok := value.(string)
  8863. if !ok {
  8864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8865. }
  8866. m.SetNickname(v)
  8867. return nil
  8868. case contact.FieldMarkname:
  8869. v, ok := value.(string)
  8870. if !ok {
  8871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8872. }
  8873. m.SetMarkname(v)
  8874. return nil
  8875. case contact.FieldHeadimg:
  8876. v, ok := value.(string)
  8877. if !ok {
  8878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8879. }
  8880. m.SetHeadimg(v)
  8881. return nil
  8882. case contact.FieldSex:
  8883. v, ok := value.(int)
  8884. if !ok {
  8885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8886. }
  8887. m.SetSex(v)
  8888. return nil
  8889. case contact.FieldStarrole:
  8890. v, ok := value.(string)
  8891. if !ok {
  8892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8893. }
  8894. m.SetStarrole(v)
  8895. return nil
  8896. case contact.FieldDontseeit:
  8897. v, ok := value.(int)
  8898. if !ok {
  8899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8900. }
  8901. m.SetDontseeit(v)
  8902. return nil
  8903. case contact.FieldDontseeme:
  8904. v, ok := value.(int)
  8905. if !ok {
  8906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8907. }
  8908. m.SetDontseeme(v)
  8909. return nil
  8910. case contact.FieldLag:
  8911. v, ok := value.(string)
  8912. if !ok {
  8913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8914. }
  8915. m.SetLag(v)
  8916. return nil
  8917. case contact.FieldGid:
  8918. v, ok := value.(string)
  8919. if !ok {
  8920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8921. }
  8922. m.SetGid(v)
  8923. return nil
  8924. case contact.FieldGname:
  8925. v, ok := value.(string)
  8926. if !ok {
  8927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8928. }
  8929. m.SetGname(v)
  8930. return nil
  8931. case contact.FieldV3:
  8932. v, ok := value.(string)
  8933. if !ok {
  8934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8935. }
  8936. m.SetV3(v)
  8937. return nil
  8938. case contact.FieldOrganizationID:
  8939. v, ok := value.(uint64)
  8940. if !ok {
  8941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8942. }
  8943. m.SetOrganizationID(v)
  8944. return nil
  8945. }
  8946. return fmt.Errorf("unknown Contact field %s", name)
  8947. }
  8948. // AddedFields returns all numeric fields that were incremented/decremented during
  8949. // this mutation.
  8950. func (m *ContactMutation) AddedFields() []string {
  8951. var fields []string
  8952. if m.addstatus != nil {
  8953. fields = append(fields, contact.FieldStatus)
  8954. }
  8955. if m.add_type != nil {
  8956. fields = append(fields, contact.FieldType)
  8957. }
  8958. if m.addsex != nil {
  8959. fields = append(fields, contact.FieldSex)
  8960. }
  8961. if m.adddontseeit != nil {
  8962. fields = append(fields, contact.FieldDontseeit)
  8963. }
  8964. if m.adddontseeme != nil {
  8965. fields = append(fields, contact.FieldDontseeme)
  8966. }
  8967. if m.addorganization_id != nil {
  8968. fields = append(fields, contact.FieldOrganizationID)
  8969. }
  8970. return fields
  8971. }
  8972. // AddedField returns the numeric value that was incremented/decremented on a field
  8973. // with the given name. The second boolean return value indicates that this field
  8974. // was not set, or was not defined in the schema.
  8975. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8976. switch name {
  8977. case contact.FieldStatus:
  8978. return m.AddedStatus()
  8979. case contact.FieldType:
  8980. return m.AddedType()
  8981. case contact.FieldSex:
  8982. return m.AddedSex()
  8983. case contact.FieldDontseeit:
  8984. return m.AddedDontseeit()
  8985. case contact.FieldDontseeme:
  8986. return m.AddedDontseeme()
  8987. case contact.FieldOrganizationID:
  8988. return m.AddedOrganizationID()
  8989. }
  8990. return nil, false
  8991. }
  8992. // AddField adds the value to the field with the given name. It returns an error if
  8993. // the field is not defined in the schema, or if the type mismatched the field
  8994. // type.
  8995. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  8996. switch name {
  8997. case contact.FieldStatus:
  8998. v, ok := value.(int8)
  8999. if !ok {
  9000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9001. }
  9002. m.AddStatus(v)
  9003. return nil
  9004. case contact.FieldType:
  9005. v, ok := value.(int)
  9006. if !ok {
  9007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9008. }
  9009. m.AddType(v)
  9010. return nil
  9011. case contact.FieldSex:
  9012. v, ok := value.(int)
  9013. if !ok {
  9014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9015. }
  9016. m.AddSex(v)
  9017. return nil
  9018. case contact.FieldDontseeit:
  9019. v, ok := value.(int)
  9020. if !ok {
  9021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9022. }
  9023. m.AddDontseeit(v)
  9024. return nil
  9025. case contact.FieldDontseeme:
  9026. v, ok := value.(int)
  9027. if !ok {
  9028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9029. }
  9030. m.AddDontseeme(v)
  9031. return nil
  9032. case contact.FieldOrganizationID:
  9033. v, ok := value.(int64)
  9034. if !ok {
  9035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9036. }
  9037. m.AddOrganizationID(v)
  9038. return nil
  9039. }
  9040. return fmt.Errorf("unknown Contact numeric field %s", name)
  9041. }
  9042. // ClearedFields returns all nullable fields that were cleared during this
  9043. // mutation.
  9044. func (m *ContactMutation) ClearedFields() []string {
  9045. var fields []string
  9046. if m.FieldCleared(contact.FieldStatus) {
  9047. fields = append(fields, contact.FieldStatus)
  9048. }
  9049. if m.FieldCleared(contact.FieldDeletedAt) {
  9050. fields = append(fields, contact.FieldDeletedAt)
  9051. }
  9052. if m.FieldCleared(contact.FieldType) {
  9053. fields = append(fields, contact.FieldType)
  9054. }
  9055. if m.FieldCleared(contact.FieldOrganizationID) {
  9056. fields = append(fields, contact.FieldOrganizationID)
  9057. }
  9058. return fields
  9059. }
  9060. // FieldCleared returns a boolean indicating if a field with the given name was
  9061. // cleared in this mutation.
  9062. func (m *ContactMutation) FieldCleared(name string) bool {
  9063. _, ok := m.clearedFields[name]
  9064. return ok
  9065. }
  9066. // ClearField clears the value of the field with the given name. It returns an
  9067. // error if the field is not defined in the schema.
  9068. func (m *ContactMutation) ClearField(name string) error {
  9069. switch name {
  9070. case contact.FieldStatus:
  9071. m.ClearStatus()
  9072. return nil
  9073. case contact.FieldDeletedAt:
  9074. m.ClearDeletedAt()
  9075. return nil
  9076. case contact.FieldType:
  9077. m.ClearType()
  9078. return nil
  9079. case contact.FieldOrganizationID:
  9080. m.ClearOrganizationID()
  9081. return nil
  9082. }
  9083. return fmt.Errorf("unknown Contact nullable field %s", name)
  9084. }
  9085. // ResetField resets all changes in the mutation for the field with the given name.
  9086. // It returns an error if the field is not defined in the schema.
  9087. func (m *ContactMutation) ResetField(name string) error {
  9088. switch name {
  9089. case contact.FieldCreatedAt:
  9090. m.ResetCreatedAt()
  9091. return nil
  9092. case contact.FieldUpdatedAt:
  9093. m.ResetUpdatedAt()
  9094. return nil
  9095. case contact.FieldStatus:
  9096. m.ResetStatus()
  9097. return nil
  9098. case contact.FieldDeletedAt:
  9099. m.ResetDeletedAt()
  9100. return nil
  9101. case contact.FieldWxWxid:
  9102. m.ResetWxWxid()
  9103. return nil
  9104. case contact.FieldType:
  9105. m.ResetType()
  9106. return nil
  9107. case contact.FieldWxid:
  9108. m.ResetWxid()
  9109. return nil
  9110. case contact.FieldAccount:
  9111. m.ResetAccount()
  9112. return nil
  9113. case contact.FieldNickname:
  9114. m.ResetNickname()
  9115. return nil
  9116. case contact.FieldMarkname:
  9117. m.ResetMarkname()
  9118. return nil
  9119. case contact.FieldHeadimg:
  9120. m.ResetHeadimg()
  9121. return nil
  9122. case contact.FieldSex:
  9123. m.ResetSex()
  9124. return nil
  9125. case contact.FieldStarrole:
  9126. m.ResetStarrole()
  9127. return nil
  9128. case contact.FieldDontseeit:
  9129. m.ResetDontseeit()
  9130. return nil
  9131. case contact.FieldDontseeme:
  9132. m.ResetDontseeme()
  9133. return nil
  9134. case contact.FieldLag:
  9135. m.ResetLag()
  9136. return nil
  9137. case contact.FieldGid:
  9138. m.ResetGid()
  9139. return nil
  9140. case contact.FieldGname:
  9141. m.ResetGname()
  9142. return nil
  9143. case contact.FieldV3:
  9144. m.ResetV3()
  9145. return nil
  9146. case contact.FieldOrganizationID:
  9147. m.ResetOrganizationID()
  9148. return nil
  9149. }
  9150. return fmt.Errorf("unknown Contact field %s", name)
  9151. }
  9152. // AddedEdges returns all edge names that were set/added in this mutation.
  9153. func (m *ContactMutation) AddedEdges() []string {
  9154. edges := make([]string, 0, 2)
  9155. if m.contact_relationships != nil {
  9156. edges = append(edges, contact.EdgeContactRelationships)
  9157. }
  9158. if m.contact_messages != nil {
  9159. edges = append(edges, contact.EdgeContactMessages)
  9160. }
  9161. return edges
  9162. }
  9163. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9164. // name in this mutation.
  9165. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9166. switch name {
  9167. case contact.EdgeContactRelationships:
  9168. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9169. for id := range m.contact_relationships {
  9170. ids = append(ids, id)
  9171. }
  9172. return ids
  9173. case contact.EdgeContactMessages:
  9174. ids := make([]ent.Value, 0, len(m.contact_messages))
  9175. for id := range m.contact_messages {
  9176. ids = append(ids, id)
  9177. }
  9178. return ids
  9179. }
  9180. return nil
  9181. }
  9182. // RemovedEdges returns all edge names that were removed in this mutation.
  9183. func (m *ContactMutation) RemovedEdges() []string {
  9184. edges := make([]string, 0, 2)
  9185. if m.removedcontact_relationships != nil {
  9186. edges = append(edges, contact.EdgeContactRelationships)
  9187. }
  9188. if m.removedcontact_messages != nil {
  9189. edges = append(edges, contact.EdgeContactMessages)
  9190. }
  9191. return edges
  9192. }
  9193. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9194. // the given name in this mutation.
  9195. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9196. switch name {
  9197. case contact.EdgeContactRelationships:
  9198. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9199. for id := range m.removedcontact_relationships {
  9200. ids = append(ids, id)
  9201. }
  9202. return ids
  9203. case contact.EdgeContactMessages:
  9204. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9205. for id := range m.removedcontact_messages {
  9206. ids = append(ids, id)
  9207. }
  9208. return ids
  9209. }
  9210. return nil
  9211. }
  9212. // ClearedEdges returns all edge names that were cleared in this mutation.
  9213. func (m *ContactMutation) ClearedEdges() []string {
  9214. edges := make([]string, 0, 2)
  9215. if m.clearedcontact_relationships {
  9216. edges = append(edges, contact.EdgeContactRelationships)
  9217. }
  9218. if m.clearedcontact_messages {
  9219. edges = append(edges, contact.EdgeContactMessages)
  9220. }
  9221. return edges
  9222. }
  9223. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9224. // was cleared in this mutation.
  9225. func (m *ContactMutation) EdgeCleared(name string) bool {
  9226. switch name {
  9227. case contact.EdgeContactRelationships:
  9228. return m.clearedcontact_relationships
  9229. case contact.EdgeContactMessages:
  9230. return m.clearedcontact_messages
  9231. }
  9232. return false
  9233. }
  9234. // ClearEdge clears the value of the edge with the given name. It returns an error
  9235. // if that edge is not defined in the schema.
  9236. func (m *ContactMutation) ClearEdge(name string) error {
  9237. switch name {
  9238. }
  9239. return fmt.Errorf("unknown Contact unique edge %s", name)
  9240. }
  9241. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9242. // It returns an error if the edge is not defined in the schema.
  9243. func (m *ContactMutation) ResetEdge(name string) error {
  9244. switch name {
  9245. case contact.EdgeContactRelationships:
  9246. m.ResetContactRelationships()
  9247. return nil
  9248. case contact.EdgeContactMessages:
  9249. m.ResetContactMessages()
  9250. return nil
  9251. }
  9252. return fmt.Errorf("unknown Contact edge %s", name)
  9253. }
  9254. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  9255. type EmployeeMutation struct {
  9256. config
  9257. op Op
  9258. typ string
  9259. id *uint64
  9260. created_at *time.Time
  9261. updated_at *time.Time
  9262. deleted_at *time.Time
  9263. title *string
  9264. avatar *string
  9265. tags *string
  9266. hire_count *int
  9267. addhire_count *int
  9268. service_count *int
  9269. addservice_count *int
  9270. achievement_count *int
  9271. addachievement_count *int
  9272. intro *string
  9273. estimate *string
  9274. skill *string
  9275. ability_type *string
  9276. scene *string
  9277. switch_in *string
  9278. video_url *string
  9279. organization_id *uint64
  9280. addorganization_id *int64
  9281. category_id *uint64
  9282. addcategory_id *int64
  9283. api_base *string
  9284. api_key *string
  9285. ai_info *string
  9286. is_vip *int
  9287. addis_vip *int
  9288. chat_url *string
  9289. clearedFields map[string]struct{}
  9290. em_work_experiences map[uint64]struct{}
  9291. removedem_work_experiences map[uint64]struct{}
  9292. clearedem_work_experiences bool
  9293. em_tutorial map[uint64]struct{}
  9294. removedem_tutorial map[uint64]struct{}
  9295. clearedem_tutorial bool
  9296. done bool
  9297. oldValue func(context.Context) (*Employee, error)
  9298. predicates []predicate.Employee
  9299. }
  9300. var _ ent.Mutation = (*EmployeeMutation)(nil)
  9301. // employeeOption allows management of the mutation configuration using functional options.
  9302. type employeeOption func(*EmployeeMutation)
  9303. // newEmployeeMutation creates new mutation for the Employee entity.
  9304. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  9305. m := &EmployeeMutation{
  9306. config: c,
  9307. op: op,
  9308. typ: TypeEmployee,
  9309. clearedFields: make(map[string]struct{}),
  9310. }
  9311. for _, opt := range opts {
  9312. opt(m)
  9313. }
  9314. return m
  9315. }
  9316. // withEmployeeID sets the ID field of the mutation.
  9317. func withEmployeeID(id uint64) employeeOption {
  9318. return func(m *EmployeeMutation) {
  9319. var (
  9320. err error
  9321. once sync.Once
  9322. value *Employee
  9323. )
  9324. m.oldValue = func(ctx context.Context) (*Employee, error) {
  9325. once.Do(func() {
  9326. if m.done {
  9327. err = errors.New("querying old values post mutation is not allowed")
  9328. } else {
  9329. value, err = m.Client().Employee.Get(ctx, id)
  9330. }
  9331. })
  9332. return value, err
  9333. }
  9334. m.id = &id
  9335. }
  9336. }
  9337. // withEmployee sets the old Employee of the mutation.
  9338. func withEmployee(node *Employee) employeeOption {
  9339. return func(m *EmployeeMutation) {
  9340. m.oldValue = func(context.Context) (*Employee, error) {
  9341. return node, nil
  9342. }
  9343. m.id = &node.ID
  9344. }
  9345. }
  9346. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9347. // executed in a transaction (ent.Tx), a transactional client is returned.
  9348. func (m EmployeeMutation) Client() *Client {
  9349. client := &Client{config: m.config}
  9350. client.init()
  9351. return client
  9352. }
  9353. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9354. // it returns an error otherwise.
  9355. func (m EmployeeMutation) Tx() (*Tx, error) {
  9356. if _, ok := m.driver.(*txDriver); !ok {
  9357. return nil, errors.New("ent: mutation is not running in a transaction")
  9358. }
  9359. tx := &Tx{config: m.config}
  9360. tx.init()
  9361. return tx, nil
  9362. }
  9363. // SetID sets the value of the id field. Note that this
  9364. // operation is only accepted on creation of Employee entities.
  9365. func (m *EmployeeMutation) SetID(id uint64) {
  9366. m.id = &id
  9367. }
  9368. // ID returns the ID value in the mutation. Note that the ID is only available
  9369. // if it was provided to the builder or after it was returned from the database.
  9370. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  9371. if m.id == nil {
  9372. return
  9373. }
  9374. return *m.id, true
  9375. }
  9376. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9377. // That means, if the mutation is applied within a transaction with an isolation level such
  9378. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9379. // or updated by the mutation.
  9380. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  9381. switch {
  9382. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9383. id, exists := m.ID()
  9384. if exists {
  9385. return []uint64{id}, nil
  9386. }
  9387. fallthrough
  9388. case m.op.Is(OpUpdate | OpDelete):
  9389. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  9390. default:
  9391. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9392. }
  9393. }
  9394. // SetCreatedAt sets the "created_at" field.
  9395. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  9396. m.created_at = &t
  9397. }
  9398. // CreatedAt returns the value of the "created_at" field in the mutation.
  9399. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  9400. v := m.created_at
  9401. if v == nil {
  9402. return
  9403. }
  9404. return *v, true
  9405. }
  9406. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  9407. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9409. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9410. if !m.op.Is(OpUpdateOne) {
  9411. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9412. }
  9413. if m.id == nil || m.oldValue == nil {
  9414. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9415. }
  9416. oldValue, err := m.oldValue(ctx)
  9417. if err != nil {
  9418. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9419. }
  9420. return oldValue.CreatedAt, nil
  9421. }
  9422. // ResetCreatedAt resets all changes to the "created_at" field.
  9423. func (m *EmployeeMutation) ResetCreatedAt() {
  9424. m.created_at = nil
  9425. }
  9426. // SetUpdatedAt sets the "updated_at" field.
  9427. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  9428. m.updated_at = &t
  9429. }
  9430. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9431. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  9432. v := m.updated_at
  9433. if v == nil {
  9434. return
  9435. }
  9436. return *v, true
  9437. }
  9438. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  9439. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9441. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9442. if !m.op.Is(OpUpdateOne) {
  9443. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9444. }
  9445. if m.id == nil || m.oldValue == nil {
  9446. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9447. }
  9448. oldValue, err := m.oldValue(ctx)
  9449. if err != nil {
  9450. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9451. }
  9452. return oldValue.UpdatedAt, nil
  9453. }
  9454. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9455. func (m *EmployeeMutation) ResetUpdatedAt() {
  9456. m.updated_at = nil
  9457. }
  9458. // SetDeletedAt sets the "deleted_at" field.
  9459. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  9460. m.deleted_at = &t
  9461. }
  9462. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9463. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  9464. v := m.deleted_at
  9465. if v == nil {
  9466. return
  9467. }
  9468. return *v, true
  9469. }
  9470. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  9471. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9473. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9474. if !m.op.Is(OpUpdateOne) {
  9475. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9476. }
  9477. if m.id == nil || m.oldValue == nil {
  9478. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9479. }
  9480. oldValue, err := m.oldValue(ctx)
  9481. if err != nil {
  9482. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9483. }
  9484. return oldValue.DeletedAt, nil
  9485. }
  9486. // ClearDeletedAt clears the value of the "deleted_at" field.
  9487. func (m *EmployeeMutation) ClearDeletedAt() {
  9488. m.deleted_at = nil
  9489. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  9490. }
  9491. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9492. func (m *EmployeeMutation) DeletedAtCleared() bool {
  9493. _, ok := m.clearedFields[employee.FieldDeletedAt]
  9494. return ok
  9495. }
  9496. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9497. func (m *EmployeeMutation) ResetDeletedAt() {
  9498. m.deleted_at = nil
  9499. delete(m.clearedFields, employee.FieldDeletedAt)
  9500. }
  9501. // SetTitle sets the "title" field.
  9502. func (m *EmployeeMutation) SetTitle(s string) {
  9503. m.title = &s
  9504. }
  9505. // Title returns the value of the "title" field in the mutation.
  9506. func (m *EmployeeMutation) Title() (r string, exists bool) {
  9507. v := m.title
  9508. if v == nil {
  9509. return
  9510. }
  9511. return *v, true
  9512. }
  9513. // OldTitle returns the old "title" field's value of the Employee entity.
  9514. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9516. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  9517. if !m.op.Is(OpUpdateOne) {
  9518. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  9519. }
  9520. if m.id == nil || m.oldValue == nil {
  9521. return v, errors.New("OldTitle requires an ID field in the mutation")
  9522. }
  9523. oldValue, err := m.oldValue(ctx)
  9524. if err != nil {
  9525. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  9526. }
  9527. return oldValue.Title, nil
  9528. }
  9529. // ResetTitle resets all changes to the "title" field.
  9530. func (m *EmployeeMutation) ResetTitle() {
  9531. m.title = nil
  9532. }
  9533. // SetAvatar sets the "avatar" field.
  9534. func (m *EmployeeMutation) SetAvatar(s string) {
  9535. m.avatar = &s
  9536. }
  9537. // Avatar returns the value of the "avatar" field in the mutation.
  9538. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  9539. v := m.avatar
  9540. if v == nil {
  9541. return
  9542. }
  9543. return *v, true
  9544. }
  9545. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  9546. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9548. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  9549. if !m.op.Is(OpUpdateOne) {
  9550. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  9551. }
  9552. if m.id == nil || m.oldValue == nil {
  9553. return v, errors.New("OldAvatar requires an ID field in the mutation")
  9554. }
  9555. oldValue, err := m.oldValue(ctx)
  9556. if err != nil {
  9557. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  9558. }
  9559. return oldValue.Avatar, nil
  9560. }
  9561. // ResetAvatar resets all changes to the "avatar" field.
  9562. func (m *EmployeeMutation) ResetAvatar() {
  9563. m.avatar = nil
  9564. }
  9565. // SetTags sets the "tags" field.
  9566. func (m *EmployeeMutation) SetTags(s string) {
  9567. m.tags = &s
  9568. }
  9569. // Tags returns the value of the "tags" field in the mutation.
  9570. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  9571. v := m.tags
  9572. if v == nil {
  9573. return
  9574. }
  9575. return *v, true
  9576. }
  9577. // OldTags returns the old "tags" field's value of the Employee entity.
  9578. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9580. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  9581. if !m.op.Is(OpUpdateOne) {
  9582. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  9583. }
  9584. if m.id == nil || m.oldValue == nil {
  9585. return v, errors.New("OldTags requires an ID field in the mutation")
  9586. }
  9587. oldValue, err := m.oldValue(ctx)
  9588. if err != nil {
  9589. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  9590. }
  9591. return oldValue.Tags, nil
  9592. }
  9593. // ResetTags resets all changes to the "tags" field.
  9594. func (m *EmployeeMutation) ResetTags() {
  9595. m.tags = nil
  9596. }
  9597. // SetHireCount sets the "hire_count" field.
  9598. func (m *EmployeeMutation) SetHireCount(i int) {
  9599. m.hire_count = &i
  9600. m.addhire_count = nil
  9601. }
  9602. // HireCount returns the value of the "hire_count" field in the mutation.
  9603. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  9604. v := m.hire_count
  9605. if v == nil {
  9606. return
  9607. }
  9608. return *v, true
  9609. }
  9610. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  9611. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9613. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  9614. if !m.op.Is(OpUpdateOne) {
  9615. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  9616. }
  9617. if m.id == nil || m.oldValue == nil {
  9618. return v, errors.New("OldHireCount requires an ID field in the mutation")
  9619. }
  9620. oldValue, err := m.oldValue(ctx)
  9621. if err != nil {
  9622. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  9623. }
  9624. return oldValue.HireCount, nil
  9625. }
  9626. // AddHireCount adds i to the "hire_count" field.
  9627. func (m *EmployeeMutation) AddHireCount(i int) {
  9628. if m.addhire_count != nil {
  9629. *m.addhire_count += i
  9630. } else {
  9631. m.addhire_count = &i
  9632. }
  9633. }
  9634. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  9635. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  9636. v := m.addhire_count
  9637. if v == nil {
  9638. return
  9639. }
  9640. return *v, true
  9641. }
  9642. // ResetHireCount resets all changes to the "hire_count" field.
  9643. func (m *EmployeeMutation) ResetHireCount() {
  9644. m.hire_count = nil
  9645. m.addhire_count = nil
  9646. }
  9647. // SetServiceCount sets the "service_count" field.
  9648. func (m *EmployeeMutation) SetServiceCount(i int) {
  9649. m.service_count = &i
  9650. m.addservice_count = nil
  9651. }
  9652. // ServiceCount returns the value of the "service_count" field in the mutation.
  9653. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  9654. v := m.service_count
  9655. if v == nil {
  9656. return
  9657. }
  9658. return *v, true
  9659. }
  9660. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  9661. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9663. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  9664. if !m.op.Is(OpUpdateOne) {
  9665. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  9666. }
  9667. if m.id == nil || m.oldValue == nil {
  9668. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  9669. }
  9670. oldValue, err := m.oldValue(ctx)
  9671. if err != nil {
  9672. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  9673. }
  9674. return oldValue.ServiceCount, nil
  9675. }
  9676. // AddServiceCount adds i to the "service_count" field.
  9677. func (m *EmployeeMutation) AddServiceCount(i int) {
  9678. if m.addservice_count != nil {
  9679. *m.addservice_count += i
  9680. } else {
  9681. m.addservice_count = &i
  9682. }
  9683. }
  9684. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  9685. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  9686. v := m.addservice_count
  9687. if v == nil {
  9688. return
  9689. }
  9690. return *v, true
  9691. }
  9692. // ResetServiceCount resets all changes to the "service_count" field.
  9693. func (m *EmployeeMutation) ResetServiceCount() {
  9694. m.service_count = nil
  9695. m.addservice_count = nil
  9696. }
  9697. // SetAchievementCount sets the "achievement_count" field.
  9698. func (m *EmployeeMutation) SetAchievementCount(i int) {
  9699. m.achievement_count = &i
  9700. m.addachievement_count = nil
  9701. }
  9702. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  9703. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  9704. v := m.achievement_count
  9705. if v == nil {
  9706. return
  9707. }
  9708. return *v, true
  9709. }
  9710. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  9711. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9713. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  9714. if !m.op.Is(OpUpdateOne) {
  9715. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  9716. }
  9717. if m.id == nil || m.oldValue == nil {
  9718. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  9719. }
  9720. oldValue, err := m.oldValue(ctx)
  9721. if err != nil {
  9722. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  9723. }
  9724. return oldValue.AchievementCount, nil
  9725. }
  9726. // AddAchievementCount adds i to the "achievement_count" field.
  9727. func (m *EmployeeMutation) AddAchievementCount(i int) {
  9728. if m.addachievement_count != nil {
  9729. *m.addachievement_count += i
  9730. } else {
  9731. m.addachievement_count = &i
  9732. }
  9733. }
  9734. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  9735. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  9736. v := m.addachievement_count
  9737. if v == nil {
  9738. return
  9739. }
  9740. return *v, true
  9741. }
  9742. // ResetAchievementCount resets all changes to the "achievement_count" field.
  9743. func (m *EmployeeMutation) ResetAchievementCount() {
  9744. m.achievement_count = nil
  9745. m.addachievement_count = nil
  9746. }
  9747. // SetIntro sets the "intro" field.
  9748. func (m *EmployeeMutation) SetIntro(s string) {
  9749. m.intro = &s
  9750. }
  9751. // Intro returns the value of the "intro" field in the mutation.
  9752. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  9753. v := m.intro
  9754. if v == nil {
  9755. return
  9756. }
  9757. return *v, true
  9758. }
  9759. // OldIntro returns the old "intro" field's value of the Employee entity.
  9760. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9762. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  9763. if !m.op.Is(OpUpdateOne) {
  9764. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  9765. }
  9766. if m.id == nil || m.oldValue == nil {
  9767. return v, errors.New("OldIntro requires an ID field in the mutation")
  9768. }
  9769. oldValue, err := m.oldValue(ctx)
  9770. if err != nil {
  9771. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  9772. }
  9773. return oldValue.Intro, nil
  9774. }
  9775. // ResetIntro resets all changes to the "intro" field.
  9776. func (m *EmployeeMutation) ResetIntro() {
  9777. m.intro = nil
  9778. }
  9779. // SetEstimate sets the "estimate" field.
  9780. func (m *EmployeeMutation) SetEstimate(s string) {
  9781. m.estimate = &s
  9782. }
  9783. // Estimate returns the value of the "estimate" field in the mutation.
  9784. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  9785. v := m.estimate
  9786. if v == nil {
  9787. return
  9788. }
  9789. return *v, true
  9790. }
  9791. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  9792. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9794. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  9795. if !m.op.Is(OpUpdateOne) {
  9796. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  9797. }
  9798. if m.id == nil || m.oldValue == nil {
  9799. return v, errors.New("OldEstimate requires an ID field in the mutation")
  9800. }
  9801. oldValue, err := m.oldValue(ctx)
  9802. if err != nil {
  9803. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  9804. }
  9805. return oldValue.Estimate, nil
  9806. }
  9807. // ResetEstimate resets all changes to the "estimate" field.
  9808. func (m *EmployeeMutation) ResetEstimate() {
  9809. m.estimate = nil
  9810. }
  9811. // SetSkill sets the "skill" field.
  9812. func (m *EmployeeMutation) SetSkill(s string) {
  9813. m.skill = &s
  9814. }
  9815. // Skill returns the value of the "skill" field in the mutation.
  9816. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  9817. v := m.skill
  9818. if v == nil {
  9819. return
  9820. }
  9821. return *v, true
  9822. }
  9823. // OldSkill returns the old "skill" field's value of the Employee entity.
  9824. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9826. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  9827. if !m.op.Is(OpUpdateOne) {
  9828. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  9829. }
  9830. if m.id == nil || m.oldValue == nil {
  9831. return v, errors.New("OldSkill requires an ID field in the mutation")
  9832. }
  9833. oldValue, err := m.oldValue(ctx)
  9834. if err != nil {
  9835. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  9836. }
  9837. return oldValue.Skill, nil
  9838. }
  9839. // ResetSkill resets all changes to the "skill" field.
  9840. func (m *EmployeeMutation) ResetSkill() {
  9841. m.skill = nil
  9842. }
  9843. // SetAbilityType sets the "ability_type" field.
  9844. func (m *EmployeeMutation) SetAbilityType(s string) {
  9845. m.ability_type = &s
  9846. }
  9847. // AbilityType returns the value of the "ability_type" field in the mutation.
  9848. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  9849. v := m.ability_type
  9850. if v == nil {
  9851. return
  9852. }
  9853. return *v, true
  9854. }
  9855. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  9856. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9858. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  9859. if !m.op.Is(OpUpdateOne) {
  9860. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  9861. }
  9862. if m.id == nil || m.oldValue == nil {
  9863. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  9864. }
  9865. oldValue, err := m.oldValue(ctx)
  9866. if err != nil {
  9867. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  9868. }
  9869. return oldValue.AbilityType, nil
  9870. }
  9871. // ResetAbilityType resets all changes to the "ability_type" field.
  9872. func (m *EmployeeMutation) ResetAbilityType() {
  9873. m.ability_type = nil
  9874. }
  9875. // SetScene sets the "scene" field.
  9876. func (m *EmployeeMutation) SetScene(s string) {
  9877. m.scene = &s
  9878. }
  9879. // Scene returns the value of the "scene" field in the mutation.
  9880. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  9881. v := m.scene
  9882. if v == nil {
  9883. return
  9884. }
  9885. return *v, true
  9886. }
  9887. // OldScene returns the old "scene" field's value of the Employee entity.
  9888. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9890. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  9891. if !m.op.Is(OpUpdateOne) {
  9892. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  9893. }
  9894. if m.id == nil || m.oldValue == nil {
  9895. return v, errors.New("OldScene requires an ID field in the mutation")
  9896. }
  9897. oldValue, err := m.oldValue(ctx)
  9898. if err != nil {
  9899. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  9900. }
  9901. return oldValue.Scene, nil
  9902. }
  9903. // ResetScene resets all changes to the "scene" field.
  9904. func (m *EmployeeMutation) ResetScene() {
  9905. m.scene = nil
  9906. }
  9907. // SetSwitchIn sets the "switch_in" field.
  9908. func (m *EmployeeMutation) SetSwitchIn(s string) {
  9909. m.switch_in = &s
  9910. }
  9911. // SwitchIn returns the value of the "switch_in" field in the mutation.
  9912. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  9913. v := m.switch_in
  9914. if v == nil {
  9915. return
  9916. }
  9917. return *v, true
  9918. }
  9919. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  9920. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9922. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  9923. if !m.op.Is(OpUpdateOne) {
  9924. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  9925. }
  9926. if m.id == nil || m.oldValue == nil {
  9927. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  9928. }
  9929. oldValue, err := m.oldValue(ctx)
  9930. if err != nil {
  9931. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  9932. }
  9933. return oldValue.SwitchIn, nil
  9934. }
  9935. // ResetSwitchIn resets all changes to the "switch_in" field.
  9936. func (m *EmployeeMutation) ResetSwitchIn() {
  9937. m.switch_in = nil
  9938. }
  9939. // SetVideoURL sets the "video_url" field.
  9940. func (m *EmployeeMutation) SetVideoURL(s string) {
  9941. m.video_url = &s
  9942. }
  9943. // VideoURL returns the value of the "video_url" field in the mutation.
  9944. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  9945. v := m.video_url
  9946. if v == nil {
  9947. return
  9948. }
  9949. return *v, true
  9950. }
  9951. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  9952. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9954. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  9955. if !m.op.Is(OpUpdateOne) {
  9956. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  9957. }
  9958. if m.id == nil || m.oldValue == nil {
  9959. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  9960. }
  9961. oldValue, err := m.oldValue(ctx)
  9962. if err != nil {
  9963. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  9964. }
  9965. return oldValue.VideoURL, nil
  9966. }
  9967. // ResetVideoURL resets all changes to the "video_url" field.
  9968. func (m *EmployeeMutation) ResetVideoURL() {
  9969. m.video_url = nil
  9970. }
  9971. // SetOrganizationID sets the "organization_id" field.
  9972. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  9973. m.organization_id = &u
  9974. m.addorganization_id = nil
  9975. }
  9976. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9977. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  9978. v := m.organization_id
  9979. if v == nil {
  9980. return
  9981. }
  9982. return *v, true
  9983. }
  9984. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  9985. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9987. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9988. if !m.op.Is(OpUpdateOne) {
  9989. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9990. }
  9991. if m.id == nil || m.oldValue == nil {
  9992. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9993. }
  9994. oldValue, err := m.oldValue(ctx)
  9995. if err != nil {
  9996. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9997. }
  9998. return oldValue.OrganizationID, nil
  9999. }
  10000. // AddOrganizationID adds u to the "organization_id" field.
  10001. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  10002. if m.addorganization_id != nil {
  10003. *m.addorganization_id += u
  10004. } else {
  10005. m.addorganization_id = &u
  10006. }
  10007. }
  10008. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10009. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  10010. v := m.addorganization_id
  10011. if v == nil {
  10012. return
  10013. }
  10014. return *v, true
  10015. }
  10016. // ResetOrganizationID resets all changes to the "organization_id" field.
  10017. func (m *EmployeeMutation) ResetOrganizationID() {
  10018. m.organization_id = nil
  10019. m.addorganization_id = nil
  10020. }
  10021. // SetCategoryID sets the "category_id" field.
  10022. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  10023. m.category_id = &u
  10024. m.addcategory_id = nil
  10025. }
  10026. // CategoryID returns the value of the "category_id" field in the mutation.
  10027. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  10028. v := m.category_id
  10029. if v == nil {
  10030. return
  10031. }
  10032. return *v, true
  10033. }
  10034. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  10035. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10037. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  10038. if !m.op.Is(OpUpdateOne) {
  10039. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  10040. }
  10041. if m.id == nil || m.oldValue == nil {
  10042. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  10043. }
  10044. oldValue, err := m.oldValue(ctx)
  10045. if err != nil {
  10046. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  10047. }
  10048. return oldValue.CategoryID, nil
  10049. }
  10050. // AddCategoryID adds u to the "category_id" field.
  10051. func (m *EmployeeMutation) AddCategoryID(u int64) {
  10052. if m.addcategory_id != nil {
  10053. *m.addcategory_id += u
  10054. } else {
  10055. m.addcategory_id = &u
  10056. }
  10057. }
  10058. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  10059. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  10060. v := m.addcategory_id
  10061. if v == nil {
  10062. return
  10063. }
  10064. return *v, true
  10065. }
  10066. // ResetCategoryID resets all changes to the "category_id" field.
  10067. func (m *EmployeeMutation) ResetCategoryID() {
  10068. m.category_id = nil
  10069. m.addcategory_id = nil
  10070. }
  10071. // SetAPIBase sets the "api_base" field.
  10072. func (m *EmployeeMutation) SetAPIBase(s string) {
  10073. m.api_base = &s
  10074. }
  10075. // APIBase returns the value of the "api_base" field in the mutation.
  10076. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  10077. v := m.api_base
  10078. if v == nil {
  10079. return
  10080. }
  10081. return *v, true
  10082. }
  10083. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  10084. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10086. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  10087. if !m.op.Is(OpUpdateOne) {
  10088. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  10089. }
  10090. if m.id == nil || m.oldValue == nil {
  10091. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  10092. }
  10093. oldValue, err := m.oldValue(ctx)
  10094. if err != nil {
  10095. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  10096. }
  10097. return oldValue.APIBase, nil
  10098. }
  10099. // ResetAPIBase resets all changes to the "api_base" field.
  10100. func (m *EmployeeMutation) ResetAPIBase() {
  10101. m.api_base = nil
  10102. }
  10103. // SetAPIKey sets the "api_key" field.
  10104. func (m *EmployeeMutation) SetAPIKey(s string) {
  10105. m.api_key = &s
  10106. }
  10107. // APIKey returns the value of the "api_key" field in the mutation.
  10108. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  10109. v := m.api_key
  10110. if v == nil {
  10111. return
  10112. }
  10113. return *v, true
  10114. }
  10115. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  10116. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10118. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  10119. if !m.op.Is(OpUpdateOne) {
  10120. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  10121. }
  10122. if m.id == nil || m.oldValue == nil {
  10123. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  10124. }
  10125. oldValue, err := m.oldValue(ctx)
  10126. if err != nil {
  10127. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  10128. }
  10129. return oldValue.APIKey, nil
  10130. }
  10131. // ResetAPIKey resets all changes to the "api_key" field.
  10132. func (m *EmployeeMutation) ResetAPIKey() {
  10133. m.api_key = nil
  10134. }
  10135. // SetAiInfo sets the "ai_info" field.
  10136. func (m *EmployeeMutation) SetAiInfo(s string) {
  10137. m.ai_info = &s
  10138. }
  10139. // AiInfo returns the value of the "ai_info" field in the mutation.
  10140. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  10141. v := m.ai_info
  10142. if v == nil {
  10143. return
  10144. }
  10145. return *v, true
  10146. }
  10147. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  10148. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10150. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  10151. if !m.op.Is(OpUpdateOne) {
  10152. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  10153. }
  10154. if m.id == nil || m.oldValue == nil {
  10155. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  10156. }
  10157. oldValue, err := m.oldValue(ctx)
  10158. if err != nil {
  10159. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  10160. }
  10161. return oldValue.AiInfo, nil
  10162. }
  10163. // ClearAiInfo clears the value of the "ai_info" field.
  10164. func (m *EmployeeMutation) ClearAiInfo() {
  10165. m.ai_info = nil
  10166. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  10167. }
  10168. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  10169. func (m *EmployeeMutation) AiInfoCleared() bool {
  10170. _, ok := m.clearedFields[employee.FieldAiInfo]
  10171. return ok
  10172. }
  10173. // ResetAiInfo resets all changes to the "ai_info" field.
  10174. func (m *EmployeeMutation) ResetAiInfo() {
  10175. m.ai_info = nil
  10176. delete(m.clearedFields, employee.FieldAiInfo)
  10177. }
  10178. // SetIsVip sets the "is_vip" field.
  10179. func (m *EmployeeMutation) SetIsVip(i int) {
  10180. m.is_vip = &i
  10181. m.addis_vip = nil
  10182. }
  10183. // IsVip returns the value of the "is_vip" field in the mutation.
  10184. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  10185. v := m.is_vip
  10186. if v == nil {
  10187. return
  10188. }
  10189. return *v, true
  10190. }
  10191. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  10192. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10194. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  10195. if !m.op.Is(OpUpdateOne) {
  10196. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  10197. }
  10198. if m.id == nil || m.oldValue == nil {
  10199. return v, errors.New("OldIsVip requires an ID field in the mutation")
  10200. }
  10201. oldValue, err := m.oldValue(ctx)
  10202. if err != nil {
  10203. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  10204. }
  10205. return oldValue.IsVip, nil
  10206. }
  10207. // AddIsVip adds i to the "is_vip" field.
  10208. func (m *EmployeeMutation) AddIsVip(i int) {
  10209. if m.addis_vip != nil {
  10210. *m.addis_vip += i
  10211. } else {
  10212. m.addis_vip = &i
  10213. }
  10214. }
  10215. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  10216. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  10217. v := m.addis_vip
  10218. if v == nil {
  10219. return
  10220. }
  10221. return *v, true
  10222. }
  10223. // ResetIsVip resets all changes to the "is_vip" field.
  10224. func (m *EmployeeMutation) ResetIsVip() {
  10225. m.is_vip = nil
  10226. m.addis_vip = nil
  10227. }
  10228. // SetChatURL sets the "chat_url" field.
  10229. func (m *EmployeeMutation) SetChatURL(s string) {
  10230. m.chat_url = &s
  10231. }
  10232. // ChatURL returns the value of the "chat_url" field in the mutation.
  10233. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  10234. v := m.chat_url
  10235. if v == nil {
  10236. return
  10237. }
  10238. return *v, true
  10239. }
  10240. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  10241. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10243. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  10244. if !m.op.Is(OpUpdateOne) {
  10245. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  10246. }
  10247. if m.id == nil || m.oldValue == nil {
  10248. return v, errors.New("OldChatURL requires an ID field in the mutation")
  10249. }
  10250. oldValue, err := m.oldValue(ctx)
  10251. if err != nil {
  10252. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  10253. }
  10254. return oldValue.ChatURL, nil
  10255. }
  10256. // ResetChatURL resets all changes to the "chat_url" field.
  10257. func (m *EmployeeMutation) ResetChatURL() {
  10258. m.chat_url = nil
  10259. }
  10260. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  10261. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  10262. if m.em_work_experiences == nil {
  10263. m.em_work_experiences = make(map[uint64]struct{})
  10264. }
  10265. for i := range ids {
  10266. m.em_work_experiences[ids[i]] = struct{}{}
  10267. }
  10268. }
  10269. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  10270. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  10271. m.clearedem_work_experiences = true
  10272. }
  10273. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  10274. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  10275. return m.clearedem_work_experiences
  10276. }
  10277. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  10278. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  10279. if m.removedem_work_experiences == nil {
  10280. m.removedem_work_experiences = make(map[uint64]struct{})
  10281. }
  10282. for i := range ids {
  10283. delete(m.em_work_experiences, ids[i])
  10284. m.removedem_work_experiences[ids[i]] = struct{}{}
  10285. }
  10286. }
  10287. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  10288. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  10289. for id := range m.removedem_work_experiences {
  10290. ids = append(ids, id)
  10291. }
  10292. return
  10293. }
  10294. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  10295. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  10296. for id := range m.em_work_experiences {
  10297. ids = append(ids, id)
  10298. }
  10299. return
  10300. }
  10301. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  10302. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  10303. m.em_work_experiences = nil
  10304. m.clearedem_work_experiences = false
  10305. m.removedem_work_experiences = nil
  10306. }
  10307. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  10308. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  10309. if m.em_tutorial == nil {
  10310. m.em_tutorial = make(map[uint64]struct{})
  10311. }
  10312. for i := range ids {
  10313. m.em_tutorial[ids[i]] = struct{}{}
  10314. }
  10315. }
  10316. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  10317. func (m *EmployeeMutation) ClearEmTutorial() {
  10318. m.clearedem_tutorial = true
  10319. }
  10320. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  10321. func (m *EmployeeMutation) EmTutorialCleared() bool {
  10322. return m.clearedem_tutorial
  10323. }
  10324. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  10325. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  10326. if m.removedem_tutorial == nil {
  10327. m.removedem_tutorial = make(map[uint64]struct{})
  10328. }
  10329. for i := range ids {
  10330. delete(m.em_tutorial, ids[i])
  10331. m.removedem_tutorial[ids[i]] = struct{}{}
  10332. }
  10333. }
  10334. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  10335. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  10336. for id := range m.removedem_tutorial {
  10337. ids = append(ids, id)
  10338. }
  10339. return
  10340. }
  10341. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  10342. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  10343. for id := range m.em_tutorial {
  10344. ids = append(ids, id)
  10345. }
  10346. return
  10347. }
  10348. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  10349. func (m *EmployeeMutation) ResetEmTutorial() {
  10350. m.em_tutorial = nil
  10351. m.clearedem_tutorial = false
  10352. m.removedem_tutorial = nil
  10353. }
  10354. // Where appends a list predicates to the EmployeeMutation builder.
  10355. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  10356. m.predicates = append(m.predicates, ps...)
  10357. }
  10358. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  10359. // users can use type-assertion to append predicates that do not depend on any generated package.
  10360. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  10361. p := make([]predicate.Employee, len(ps))
  10362. for i := range ps {
  10363. p[i] = ps[i]
  10364. }
  10365. m.Where(p...)
  10366. }
  10367. // Op returns the operation name.
  10368. func (m *EmployeeMutation) Op() Op {
  10369. return m.op
  10370. }
  10371. // SetOp allows setting the mutation operation.
  10372. func (m *EmployeeMutation) SetOp(op Op) {
  10373. m.op = op
  10374. }
  10375. // Type returns the node type of this mutation (Employee).
  10376. func (m *EmployeeMutation) Type() string {
  10377. return m.typ
  10378. }
  10379. // Fields returns all fields that were changed during this mutation. Note that in
  10380. // order to get all numeric fields that were incremented/decremented, call
  10381. // AddedFields().
  10382. func (m *EmployeeMutation) Fields() []string {
  10383. fields := make([]string, 0, 23)
  10384. if m.created_at != nil {
  10385. fields = append(fields, employee.FieldCreatedAt)
  10386. }
  10387. if m.updated_at != nil {
  10388. fields = append(fields, employee.FieldUpdatedAt)
  10389. }
  10390. if m.deleted_at != nil {
  10391. fields = append(fields, employee.FieldDeletedAt)
  10392. }
  10393. if m.title != nil {
  10394. fields = append(fields, employee.FieldTitle)
  10395. }
  10396. if m.avatar != nil {
  10397. fields = append(fields, employee.FieldAvatar)
  10398. }
  10399. if m.tags != nil {
  10400. fields = append(fields, employee.FieldTags)
  10401. }
  10402. if m.hire_count != nil {
  10403. fields = append(fields, employee.FieldHireCount)
  10404. }
  10405. if m.service_count != nil {
  10406. fields = append(fields, employee.FieldServiceCount)
  10407. }
  10408. if m.achievement_count != nil {
  10409. fields = append(fields, employee.FieldAchievementCount)
  10410. }
  10411. if m.intro != nil {
  10412. fields = append(fields, employee.FieldIntro)
  10413. }
  10414. if m.estimate != nil {
  10415. fields = append(fields, employee.FieldEstimate)
  10416. }
  10417. if m.skill != nil {
  10418. fields = append(fields, employee.FieldSkill)
  10419. }
  10420. if m.ability_type != nil {
  10421. fields = append(fields, employee.FieldAbilityType)
  10422. }
  10423. if m.scene != nil {
  10424. fields = append(fields, employee.FieldScene)
  10425. }
  10426. if m.switch_in != nil {
  10427. fields = append(fields, employee.FieldSwitchIn)
  10428. }
  10429. if m.video_url != nil {
  10430. fields = append(fields, employee.FieldVideoURL)
  10431. }
  10432. if m.organization_id != nil {
  10433. fields = append(fields, employee.FieldOrganizationID)
  10434. }
  10435. if m.category_id != nil {
  10436. fields = append(fields, employee.FieldCategoryID)
  10437. }
  10438. if m.api_base != nil {
  10439. fields = append(fields, employee.FieldAPIBase)
  10440. }
  10441. if m.api_key != nil {
  10442. fields = append(fields, employee.FieldAPIKey)
  10443. }
  10444. if m.ai_info != nil {
  10445. fields = append(fields, employee.FieldAiInfo)
  10446. }
  10447. if m.is_vip != nil {
  10448. fields = append(fields, employee.FieldIsVip)
  10449. }
  10450. if m.chat_url != nil {
  10451. fields = append(fields, employee.FieldChatURL)
  10452. }
  10453. return fields
  10454. }
  10455. // Field returns the value of a field with the given name. The second boolean
  10456. // return value indicates that this field was not set, or was not defined in the
  10457. // schema.
  10458. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  10459. switch name {
  10460. case employee.FieldCreatedAt:
  10461. return m.CreatedAt()
  10462. case employee.FieldUpdatedAt:
  10463. return m.UpdatedAt()
  10464. case employee.FieldDeletedAt:
  10465. return m.DeletedAt()
  10466. case employee.FieldTitle:
  10467. return m.Title()
  10468. case employee.FieldAvatar:
  10469. return m.Avatar()
  10470. case employee.FieldTags:
  10471. return m.Tags()
  10472. case employee.FieldHireCount:
  10473. return m.HireCount()
  10474. case employee.FieldServiceCount:
  10475. return m.ServiceCount()
  10476. case employee.FieldAchievementCount:
  10477. return m.AchievementCount()
  10478. case employee.FieldIntro:
  10479. return m.Intro()
  10480. case employee.FieldEstimate:
  10481. return m.Estimate()
  10482. case employee.FieldSkill:
  10483. return m.Skill()
  10484. case employee.FieldAbilityType:
  10485. return m.AbilityType()
  10486. case employee.FieldScene:
  10487. return m.Scene()
  10488. case employee.FieldSwitchIn:
  10489. return m.SwitchIn()
  10490. case employee.FieldVideoURL:
  10491. return m.VideoURL()
  10492. case employee.FieldOrganizationID:
  10493. return m.OrganizationID()
  10494. case employee.FieldCategoryID:
  10495. return m.CategoryID()
  10496. case employee.FieldAPIBase:
  10497. return m.APIBase()
  10498. case employee.FieldAPIKey:
  10499. return m.APIKey()
  10500. case employee.FieldAiInfo:
  10501. return m.AiInfo()
  10502. case employee.FieldIsVip:
  10503. return m.IsVip()
  10504. case employee.FieldChatURL:
  10505. return m.ChatURL()
  10506. }
  10507. return nil, false
  10508. }
  10509. // OldField returns the old value of the field from the database. An error is
  10510. // returned if the mutation operation is not UpdateOne, or the query to the
  10511. // database failed.
  10512. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10513. switch name {
  10514. case employee.FieldCreatedAt:
  10515. return m.OldCreatedAt(ctx)
  10516. case employee.FieldUpdatedAt:
  10517. return m.OldUpdatedAt(ctx)
  10518. case employee.FieldDeletedAt:
  10519. return m.OldDeletedAt(ctx)
  10520. case employee.FieldTitle:
  10521. return m.OldTitle(ctx)
  10522. case employee.FieldAvatar:
  10523. return m.OldAvatar(ctx)
  10524. case employee.FieldTags:
  10525. return m.OldTags(ctx)
  10526. case employee.FieldHireCount:
  10527. return m.OldHireCount(ctx)
  10528. case employee.FieldServiceCount:
  10529. return m.OldServiceCount(ctx)
  10530. case employee.FieldAchievementCount:
  10531. return m.OldAchievementCount(ctx)
  10532. case employee.FieldIntro:
  10533. return m.OldIntro(ctx)
  10534. case employee.FieldEstimate:
  10535. return m.OldEstimate(ctx)
  10536. case employee.FieldSkill:
  10537. return m.OldSkill(ctx)
  10538. case employee.FieldAbilityType:
  10539. return m.OldAbilityType(ctx)
  10540. case employee.FieldScene:
  10541. return m.OldScene(ctx)
  10542. case employee.FieldSwitchIn:
  10543. return m.OldSwitchIn(ctx)
  10544. case employee.FieldVideoURL:
  10545. return m.OldVideoURL(ctx)
  10546. case employee.FieldOrganizationID:
  10547. return m.OldOrganizationID(ctx)
  10548. case employee.FieldCategoryID:
  10549. return m.OldCategoryID(ctx)
  10550. case employee.FieldAPIBase:
  10551. return m.OldAPIBase(ctx)
  10552. case employee.FieldAPIKey:
  10553. return m.OldAPIKey(ctx)
  10554. case employee.FieldAiInfo:
  10555. return m.OldAiInfo(ctx)
  10556. case employee.FieldIsVip:
  10557. return m.OldIsVip(ctx)
  10558. case employee.FieldChatURL:
  10559. return m.OldChatURL(ctx)
  10560. }
  10561. return nil, fmt.Errorf("unknown Employee field %s", name)
  10562. }
  10563. // SetField sets the value of a field with the given name. It returns an error if
  10564. // the field is not defined in the schema, or if the type mismatched the field
  10565. // type.
  10566. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  10567. switch name {
  10568. case employee.FieldCreatedAt:
  10569. v, ok := value.(time.Time)
  10570. if !ok {
  10571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10572. }
  10573. m.SetCreatedAt(v)
  10574. return nil
  10575. case employee.FieldUpdatedAt:
  10576. v, ok := value.(time.Time)
  10577. if !ok {
  10578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10579. }
  10580. m.SetUpdatedAt(v)
  10581. return nil
  10582. case employee.FieldDeletedAt:
  10583. v, ok := value.(time.Time)
  10584. if !ok {
  10585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10586. }
  10587. m.SetDeletedAt(v)
  10588. return nil
  10589. case employee.FieldTitle:
  10590. v, ok := value.(string)
  10591. if !ok {
  10592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10593. }
  10594. m.SetTitle(v)
  10595. return nil
  10596. case employee.FieldAvatar:
  10597. v, ok := value.(string)
  10598. if !ok {
  10599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10600. }
  10601. m.SetAvatar(v)
  10602. return nil
  10603. case employee.FieldTags:
  10604. v, ok := value.(string)
  10605. if !ok {
  10606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10607. }
  10608. m.SetTags(v)
  10609. return nil
  10610. case employee.FieldHireCount:
  10611. v, ok := value.(int)
  10612. if !ok {
  10613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10614. }
  10615. m.SetHireCount(v)
  10616. return nil
  10617. case employee.FieldServiceCount:
  10618. v, ok := value.(int)
  10619. if !ok {
  10620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10621. }
  10622. m.SetServiceCount(v)
  10623. return nil
  10624. case employee.FieldAchievementCount:
  10625. v, ok := value.(int)
  10626. if !ok {
  10627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10628. }
  10629. m.SetAchievementCount(v)
  10630. return nil
  10631. case employee.FieldIntro:
  10632. v, ok := value.(string)
  10633. if !ok {
  10634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10635. }
  10636. m.SetIntro(v)
  10637. return nil
  10638. case employee.FieldEstimate:
  10639. v, ok := value.(string)
  10640. if !ok {
  10641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10642. }
  10643. m.SetEstimate(v)
  10644. return nil
  10645. case employee.FieldSkill:
  10646. v, ok := value.(string)
  10647. if !ok {
  10648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10649. }
  10650. m.SetSkill(v)
  10651. return nil
  10652. case employee.FieldAbilityType:
  10653. v, ok := value.(string)
  10654. if !ok {
  10655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10656. }
  10657. m.SetAbilityType(v)
  10658. return nil
  10659. case employee.FieldScene:
  10660. v, ok := value.(string)
  10661. if !ok {
  10662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10663. }
  10664. m.SetScene(v)
  10665. return nil
  10666. case employee.FieldSwitchIn:
  10667. v, ok := value.(string)
  10668. if !ok {
  10669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10670. }
  10671. m.SetSwitchIn(v)
  10672. return nil
  10673. case employee.FieldVideoURL:
  10674. v, ok := value.(string)
  10675. if !ok {
  10676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10677. }
  10678. m.SetVideoURL(v)
  10679. return nil
  10680. case employee.FieldOrganizationID:
  10681. v, ok := value.(uint64)
  10682. if !ok {
  10683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10684. }
  10685. m.SetOrganizationID(v)
  10686. return nil
  10687. case employee.FieldCategoryID:
  10688. v, ok := value.(uint64)
  10689. if !ok {
  10690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10691. }
  10692. m.SetCategoryID(v)
  10693. return nil
  10694. case employee.FieldAPIBase:
  10695. v, ok := value.(string)
  10696. if !ok {
  10697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10698. }
  10699. m.SetAPIBase(v)
  10700. return nil
  10701. case employee.FieldAPIKey:
  10702. v, ok := value.(string)
  10703. if !ok {
  10704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10705. }
  10706. m.SetAPIKey(v)
  10707. return nil
  10708. case employee.FieldAiInfo:
  10709. v, ok := value.(string)
  10710. if !ok {
  10711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10712. }
  10713. m.SetAiInfo(v)
  10714. return nil
  10715. case employee.FieldIsVip:
  10716. v, ok := value.(int)
  10717. if !ok {
  10718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10719. }
  10720. m.SetIsVip(v)
  10721. return nil
  10722. case employee.FieldChatURL:
  10723. v, ok := value.(string)
  10724. if !ok {
  10725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10726. }
  10727. m.SetChatURL(v)
  10728. return nil
  10729. }
  10730. return fmt.Errorf("unknown Employee field %s", name)
  10731. }
  10732. // AddedFields returns all numeric fields that were incremented/decremented during
  10733. // this mutation.
  10734. func (m *EmployeeMutation) AddedFields() []string {
  10735. var fields []string
  10736. if m.addhire_count != nil {
  10737. fields = append(fields, employee.FieldHireCount)
  10738. }
  10739. if m.addservice_count != nil {
  10740. fields = append(fields, employee.FieldServiceCount)
  10741. }
  10742. if m.addachievement_count != nil {
  10743. fields = append(fields, employee.FieldAchievementCount)
  10744. }
  10745. if m.addorganization_id != nil {
  10746. fields = append(fields, employee.FieldOrganizationID)
  10747. }
  10748. if m.addcategory_id != nil {
  10749. fields = append(fields, employee.FieldCategoryID)
  10750. }
  10751. if m.addis_vip != nil {
  10752. fields = append(fields, employee.FieldIsVip)
  10753. }
  10754. return fields
  10755. }
  10756. // AddedField returns the numeric value that was incremented/decremented on a field
  10757. // with the given name. The second boolean return value indicates that this field
  10758. // was not set, or was not defined in the schema.
  10759. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  10760. switch name {
  10761. case employee.FieldHireCount:
  10762. return m.AddedHireCount()
  10763. case employee.FieldServiceCount:
  10764. return m.AddedServiceCount()
  10765. case employee.FieldAchievementCount:
  10766. return m.AddedAchievementCount()
  10767. case employee.FieldOrganizationID:
  10768. return m.AddedOrganizationID()
  10769. case employee.FieldCategoryID:
  10770. return m.AddedCategoryID()
  10771. case employee.FieldIsVip:
  10772. return m.AddedIsVip()
  10773. }
  10774. return nil, false
  10775. }
  10776. // AddField adds the value to the field with the given name. It returns an error if
  10777. // the field is not defined in the schema, or if the type mismatched the field
  10778. // type.
  10779. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  10780. switch name {
  10781. case employee.FieldHireCount:
  10782. v, ok := value.(int)
  10783. if !ok {
  10784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10785. }
  10786. m.AddHireCount(v)
  10787. return nil
  10788. case employee.FieldServiceCount:
  10789. v, ok := value.(int)
  10790. if !ok {
  10791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10792. }
  10793. m.AddServiceCount(v)
  10794. return nil
  10795. case employee.FieldAchievementCount:
  10796. v, ok := value.(int)
  10797. if !ok {
  10798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10799. }
  10800. m.AddAchievementCount(v)
  10801. return nil
  10802. case employee.FieldOrganizationID:
  10803. v, ok := value.(int64)
  10804. if !ok {
  10805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10806. }
  10807. m.AddOrganizationID(v)
  10808. return nil
  10809. case employee.FieldCategoryID:
  10810. v, ok := value.(int64)
  10811. if !ok {
  10812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10813. }
  10814. m.AddCategoryID(v)
  10815. return nil
  10816. case employee.FieldIsVip:
  10817. v, ok := value.(int)
  10818. if !ok {
  10819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10820. }
  10821. m.AddIsVip(v)
  10822. return nil
  10823. }
  10824. return fmt.Errorf("unknown Employee numeric field %s", name)
  10825. }
  10826. // ClearedFields returns all nullable fields that were cleared during this
  10827. // mutation.
  10828. func (m *EmployeeMutation) ClearedFields() []string {
  10829. var fields []string
  10830. if m.FieldCleared(employee.FieldDeletedAt) {
  10831. fields = append(fields, employee.FieldDeletedAt)
  10832. }
  10833. if m.FieldCleared(employee.FieldAiInfo) {
  10834. fields = append(fields, employee.FieldAiInfo)
  10835. }
  10836. return fields
  10837. }
  10838. // FieldCleared returns a boolean indicating if a field with the given name was
  10839. // cleared in this mutation.
  10840. func (m *EmployeeMutation) FieldCleared(name string) bool {
  10841. _, ok := m.clearedFields[name]
  10842. return ok
  10843. }
  10844. // ClearField clears the value of the field with the given name. It returns an
  10845. // error if the field is not defined in the schema.
  10846. func (m *EmployeeMutation) ClearField(name string) error {
  10847. switch name {
  10848. case employee.FieldDeletedAt:
  10849. m.ClearDeletedAt()
  10850. return nil
  10851. case employee.FieldAiInfo:
  10852. m.ClearAiInfo()
  10853. return nil
  10854. }
  10855. return fmt.Errorf("unknown Employee nullable field %s", name)
  10856. }
  10857. // ResetField resets all changes in the mutation for the field with the given name.
  10858. // It returns an error if the field is not defined in the schema.
  10859. func (m *EmployeeMutation) ResetField(name string) error {
  10860. switch name {
  10861. case employee.FieldCreatedAt:
  10862. m.ResetCreatedAt()
  10863. return nil
  10864. case employee.FieldUpdatedAt:
  10865. m.ResetUpdatedAt()
  10866. return nil
  10867. case employee.FieldDeletedAt:
  10868. m.ResetDeletedAt()
  10869. return nil
  10870. case employee.FieldTitle:
  10871. m.ResetTitle()
  10872. return nil
  10873. case employee.FieldAvatar:
  10874. m.ResetAvatar()
  10875. return nil
  10876. case employee.FieldTags:
  10877. m.ResetTags()
  10878. return nil
  10879. case employee.FieldHireCount:
  10880. m.ResetHireCount()
  10881. return nil
  10882. case employee.FieldServiceCount:
  10883. m.ResetServiceCount()
  10884. return nil
  10885. case employee.FieldAchievementCount:
  10886. m.ResetAchievementCount()
  10887. return nil
  10888. case employee.FieldIntro:
  10889. m.ResetIntro()
  10890. return nil
  10891. case employee.FieldEstimate:
  10892. m.ResetEstimate()
  10893. return nil
  10894. case employee.FieldSkill:
  10895. m.ResetSkill()
  10896. return nil
  10897. case employee.FieldAbilityType:
  10898. m.ResetAbilityType()
  10899. return nil
  10900. case employee.FieldScene:
  10901. m.ResetScene()
  10902. return nil
  10903. case employee.FieldSwitchIn:
  10904. m.ResetSwitchIn()
  10905. return nil
  10906. case employee.FieldVideoURL:
  10907. m.ResetVideoURL()
  10908. return nil
  10909. case employee.FieldOrganizationID:
  10910. m.ResetOrganizationID()
  10911. return nil
  10912. case employee.FieldCategoryID:
  10913. m.ResetCategoryID()
  10914. return nil
  10915. case employee.FieldAPIBase:
  10916. m.ResetAPIBase()
  10917. return nil
  10918. case employee.FieldAPIKey:
  10919. m.ResetAPIKey()
  10920. return nil
  10921. case employee.FieldAiInfo:
  10922. m.ResetAiInfo()
  10923. return nil
  10924. case employee.FieldIsVip:
  10925. m.ResetIsVip()
  10926. return nil
  10927. case employee.FieldChatURL:
  10928. m.ResetChatURL()
  10929. return nil
  10930. }
  10931. return fmt.Errorf("unknown Employee field %s", name)
  10932. }
  10933. // AddedEdges returns all edge names that were set/added in this mutation.
  10934. func (m *EmployeeMutation) AddedEdges() []string {
  10935. edges := make([]string, 0, 2)
  10936. if m.em_work_experiences != nil {
  10937. edges = append(edges, employee.EdgeEmWorkExperiences)
  10938. }
  10939. if m.em_tutorial != nil {
  10940. edges = append(edges, employee.EdgeEmTutorial)
  10941. }
  10942. return edges
  10943. }
  10944. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10945. // name in this mutation.
  10946. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  10947. switch name {
  10948. case employee.EdgeEmWorkExperiences:
  10949. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  10950. for id := range m.em_work_experiences {
  10951. ids = append(ids, id)
  10952. }
  10953. return ids
  10954. case employee.EdgeEmTutorial:
  10955. ids := make([]ent.Value, 0, len(m.em_tutorial))
  10956. for id := range m.em_tutorial {
  10957. ids = append(ids, id)
  10958. }
  10959. return ids
  10960. }
  10961. return nil
  10962. }
  10963. // RemovedEdges returns all edge names that were removed in this mutation.
  10964. func (m *EmployeeMutation) RemovedEdges() []string {
  10965. edges := make([]string, 0, 2)
  10966. if m.removedem_work_experiences != nil {
  10967. edges = append(edges, employee.EdgeEmWorkExperiences)
  10968. }
  10969. if m.removedem_tutorial != nil {
  10970. edges = append(edges, employee.EdgeEmTutorial)
  10971. }
  10972. return edges
  10973. }
  10974. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10975. // the given name in this mutation.
  10976. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  10977. switch name {
  10978. case employee.EdgeEmWorkExperiences:
  10979. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  10980. for id := range m.removedem_work_experiences {
  10981. ids = append(ids, id)
  10982. }
  10983. return ids
  10984. case employee.EdgeEmTutorial:
  10985. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  10986. for id := range m.removedem_tutorial {
  10987. ids = append(ids, id)
  10988. }
  10989. return ids
  10990. }
  10991. return nil
  10992. }
  10993. // ClearedEdges returns all edge names that were cleared in this mutation.
  10994. func (m *EmployeeMutation) ClearedEdges() []string {
  10995. edges := make([]string, 0, 2)
  10996. if m.clearedem_work_experiences {
  10997. edges = append(edges, employee.EdgeEmWorkExperiences)
  10998. }
  10999. if m.clearedem_tutorial {
  11000. edges = append(edges, employee.EdgeEmTutorial)
  11001. }
  11002. return edges
  11003. }
  11004. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11005. // was cleared in this mutation.
  11006. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  11007. switch name {
  11008. case employee.EdgeEmWorkExperiences:
  11009. return m.clearedem_work_experiences
  11010. case employee.EdgeEmTutorial:
  11011. return m.clearedem_tutorial
  11012. }
  11013. return false
  11014. }
  11015. // ClearEdge clears the value of the edge with the given name. It returns an error
  11016. // if that edge is not defined in the schema.
  11017. func (m *EmployeeMutation) ClearEdge(name string) error {
  11018. switch name {
  11019. }
  11020. return fmt.Errorf("unknown Employee unique edge %s", name)
  11021. }
  11022. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11023. // It returns an error if the edge is not defined in the schema.
  11024. func (m *EmployeeMutation) ResetEdge(name string) error {
  11025. switch name {
  11026. case employee.EdgeEmWorkExperiences:
  11027. m.ResetEmWorkExperiences()
  11028. return nil
  11029. case employee.EdgeEmTutorial:
  11030. m.ResetEmTutorial()
  11031. return nil
  11032. }
  11033. return fmt.Errorf("unknown Employee edge %s", name)
  11034. }
  11035. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  11036. type EmployeeConfigMutation struct {
  11037. config
  11038. op Op
  11039. typ string
  11040. id *uint64
  11041. created_at *time.Time
  11042. updated_at *time.Time
  11043. deleted_at *time.Time
  11044. stype *string
  11045. title *string
  11046. photo *string
  11047. organization_id *uint64
  11048. addorganization_id *int64
  11049. clearedFields map[string]struct{}
  11050. done bool
  11051. oldValue func(context.Context) (*EmployeeConfig, error)
  11052. predicates []predicate.EmployeeConfig
  11053. }
  11054. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  11055. // employeeconfigOption allows management of the mutation configuration using functional options.
  11056. type employeeconfigOption func(*EmployeeConfigMutation)
  11057. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  11058. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  11059. m := &EmployeeConfigMutation{
  11060. config: c,
  11061. op: op,
  11062. typ: TypeEmployeeConfig,
  11063. clearedFields: make(map[string]struct{}),
  11064. }
  11065. for _, opt := range opts {
  11066. opt(m)
  11067. }
  11068. return m
  11069. }
  11070. // withEmployeeConfigID sets the ID field of the mutation.
  11071. func withEmployeeConfigID(id uint64) employeeconfigOption {
  11072. return func(m *EmployeeConfigMutation) {
  11073. var (
  11074. err error
  11075. once sync.Once
  11076. value *EmployeeConfig
  11077. )
  11078. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  11079. once.Do(func() {
  11080. if m.done {
  11081. err = errors.New("querying old values post mutation is not allowed")
  11082. } else {
  11083. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  11084. }
  11085. })
  11086. return value, err
  11087. }
  11088. m.id = &id
  11089. }
  11090. }
  11091. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  11092. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  11093. return func(m *EmployeeConfigMutation) {
  11094. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  11095. return node, nil
  11096. }
  11097. m.id = &node.ID
  11098. }
  11099. }
  11100. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11101. // executed in a transaction (ent.Tx), a transactional client is returned.
  11102. func (m EmployeeConfigMutation) Client() *Client {
  11103. client := &Client{config: m.config}
  11104. client.init()
  11105. return client
  11106. }
  11107. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11108. // it returns an error otherwise.
  11109. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  11110. if _, ok := m.driver.(*txDriver); !ok {
  11111. return nil, errors.New("ent: mutation is not running in a transaction")
  11112. }
  11113. tx := &Tx{config: m.config}
  11114. tx.init()
  11115. return tx, nil
  11116. }
  11117. // SetID sets the value of the id field. Note that this
  11118. // operation is only accepted on creation of EmployeeConfig entities.
  11119. func (m *EmployeeConfigMutation) SetID(id uint64) {
  11120. m.id = &id
  11121. }
  11122. // ID returns the ID value in the mutation. Note that the ID is only available
  11123. // if it was provided to the builder or after it was returned from the database.
  11124. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  11125. if m.id == nil {
  11126. return
  11127. }
  11128. return *m.id, true
  11129. }
  11130. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11131. // That means, if the mutation is applied within a transaction with an isolation level such
  11132. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11133. // or updated by the mutation.
  11134. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  11135. switch {
  11136. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11137. id, exists := m.ID()
  11138. if exists {
  11139. return []uint64{id}, nil
  11140. }
  11141. fallthrough
  11142. case m.op.Is(OpUpdate | OpDelete):
  11143. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  11144. default:
  11145. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11146. }
  11147. }
  11148. // SetCreatedAt sets the "created_at" field.
  11149. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  11150. m.created_at = &t
  11151. }
  11152. // CreatedAt returns the value of the "created_at" field in the mutation.
  11153. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  11154. v := m.created_at
  11155. if v == nil {
  11156. return
  11157. }
  11158. return *v, true
  11159. }
  11160. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  11161. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11163. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11164. if !m.op.Is(OpUpdateOne) {
  11165. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11166. }
  11167. if m.id == nil || m.oldValue == nil {
  11168. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11169. }
  11170. oldValue, err := m.oldValue(ctx)
  11171. if err != nil {
  11172. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11173. }
  11174. return oldValue.CreatedAt, nil
  11175. }
  11176. // ResetCreatedAt resets all changes to the "created_at" field.
  11177. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  11178. m.created_at = nil
  11179. }
  11180. // SetUpdatedAt sets the "updated_at" field.
  11181. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  11182. m.updated_at = &t
  11183. }
  11184. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11185. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  11186. v := m.updated_at
  11187. if v == nil {
  11188. return
  11189. }
  11190. return *v, true
  11191. }
  11192. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  11193. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11195. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11196. if !m.op.Is(OpUpdateOne) {
  11197. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11198. }
  11199. if m.id == nil || m.oldValue == nil {
  11200. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11201. }
  11202. oldValue, err := m.oldValue(ctx)
  11203. if err != nil {
  11204. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11205. }
  11206. return oldValue.UpdatedAt, nil
  11207. }
  11208. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11209. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  11210. m.updated_at = nil
  11211. }
  11212. // SetDeletedAt sets the "deleted_at" field.
  11213. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  11214. m.deleted_at = &t
  11215. }
  11216. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11217. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  11218. v := m.deleted_at
  11219. if v == nil {
  11220. return
  11221. }
  11222. return *v, true
  11223. }
  11224. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  11225. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11227. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11228. if !m.op.Is(OpUpdateOne) {
  11229. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11230. }
  11231. if m.id == nil || m.oldValue == nil {
  11232. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11233. }
  11234. oldValue, err := m.oldValue(ctx)
  11235. if err != nil {
  11236. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11237. }
  11238. return oldValue.DeletedAt, nil
  11239. }
  11240. // ClearDeletedAt clears the value of the "deleted_at" field.
  11241. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  11242. m.deleted_at = nil
  11243. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  11244. }
  11245. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11246. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  11247. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  11248. return ok
  11249. }
  11250. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11251. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  11252. m.deleted_at = nil
  11253. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  11254. }
  11255. // SetStype sets the "stype" field.
  11256. func (m *EmployeeConfigMutation) SetStype(s string) {
  11257. m.stype = &s
  11258. }
  11259. // Stype returns the value of the "stype" field in the mutation.
  11260. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  11261. v := m.stype
  11262. if v == nil {
  11263. return
  11264. }
  11265. return *v, true
  11266. }
  11267. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  11268. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11270. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  11271. if !m.op.Is(OpUpdateOne) {
  11272. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  11273. }
  11274. if m.id == nil || m.oldValue == nil {
  11275. return v, errors.New("OldStype requires an ID field in the mutation")
  11276. }
  11277. oldValue, err := m.oldValue(ctx)
  11278. if err != nil {
  11279. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  11280. }
  11281. return oldValue.Stype, nil
  11282. }
  11283. // ResetStype resets all changes to the "stype" field.
  11284. func (m *EmployeeConfigMutation) ResetStype() {
  11285. m.stype = nil
  11286. }
  11287. // SetTitle sets the "title" field.
  11288. func (m *EmployeeConfigMutation) SetTitle(s string) {
  11289. m.title = &s
  11290. }
  11291. // Title returns the value of the "title" field in the mutation.
  11292. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  11293. v := m.title
  11294. if v == nil {
  11295. return
  11296. }
  11297. return *v, true
  11298. }
  11299. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  11300. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11302. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  11303. if !m.op.Is(OpUpdateOne) {
  11304. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11305. }
  11306. if m.id == nil || m.oldValue == nil {
  11307. return v, errors.New("OldTitle requires an ID field in the mutation")
  11308. }
  11309. oldValue, err := m.oldValue(ctx)
  11310. if err != nil {
  11311. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11312. }
  11313. return oldValue.Title, nil
  11314. }
  11315. // ResetTitle resets all changes to the "title" field.
  11316. func (m *EmployeeConfigMutation) ResetTitle() {
  11317. m.title = nil
  11318. }
  11319. // SetPhoto sets the "photo" field.
  11320. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  11321. m.photo = &s
  11322. }
  11323. // Photo returns the value of the "photo" field in the mutation.
  11324. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  11325. v := m.photo
  11326. if v == nil {
  11327. return
  11328. }
  11329. return *v, true
  11330. }
  11331. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  11332. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11334. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  11335. if !m.op.Is(OpUpdateOne) {
  11336. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  11337. }
  11338. if m.id == nil || m.oldValue == nil {
  11339. return v, errors.New("OldPhoto requires an ID field in the mutation")
  11340. }
  11341. oldValue, err := m.oldValue(ctx)
  11342. if err != nil {
  11343. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  11344. }
  11345. return oldValue.Photo, nil
  11346. }
  11347. // ResetPhoto resets all changes to the "photo" field.
  11348. func (m *EmployeeConfigMutation) ResetPhoto() {
  11349. m.photo = nil
  11350. }
  11351. // SetOrganizationID sets the "organization_id" field.
  11352. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  11353. m.organization_id = &u
  11354. m.addorganization_id = nil
  11355. }
  11356. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11357. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  11358. v := m.organization_id
  11359. if v == nil {
  11360. return
  11361. }
  11362. return *v, true
  11363. }
  11364. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  11365. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11367. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11368. if !m.op.Is(OpUpdateOne) {
  11369. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11370. }
  11371. if m.id == nil || m.oldValue == nil {
  11372. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11373. }
  11374. oldValue, err := m.oldValue(ctx)
  11375. if err != nil {
  11376. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11377. }
  11378. return oldValue.OrganizationID, nil
  11379. }
  11380. // AddOrganizationID adds u to the "organization_id" field.
  11381. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  11382. if m.addorganization_id != nil {
  11383. *m.addorganization_id += u
  11384. } else {
  11385. m.addorganization_id = &u
  11386. }
  11387. }
  11388. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11389. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  11390. v := m.addorganization_id
  11391. if v == nil {
  11392. return
  11393. }
  11394. return *v, true
  11395. }
  11396. // ClearOrganizationID clears the value of the "organization_id" field.
  11397. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  11398. m.organization_id = nil
  11399. m.addorganization_id = nil
  11400. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  11401. }
  11402. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11403. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  11404. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  11405. return ok
  11406. }
  11407. // ResetOrganizationID resets all changes to the "organization_id" field.
  11408. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  11409. m.organization_id = nil
  11410. m.addorganization_id = nil
  11411. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  11412. }
  11413. // Where appends a list predicates to the EmployeeConfigMutation builder.
  11414. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  11415. m.predicates = append(m.predicates, ps...)
  11416. }
  11417. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  11418. // users can use type-assertion to append predicates that do not depend on any generated package.
  11419. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  11420. p := make([]predicate.EmployeeConfig, len(ps))
  11421. for i := range ps {
  11422. p[i] = ps[i]
  11423. }
  11424. m.Where(p...)
  11425. }
  11426. // Op returns the operation name.
  11427. func (m *EmployeeConfigMutation) Op() Op {
  11428. return m.op
  11429. }
  11430. // SetOp allows setting the mutation operation.
  11431. func (m *EmployeeConfigMutation) SetOp(op Op) {
  11432. m.op = op
  11433. }
  11434. // Type returns the node type of this mutation (EmployeeConfig).
  11435. func (m *EmployeeConfigMutation) Type() string {
  11436. return m.typ
  11437. }
  11438. // Fields returns all fields that were changed during this mutation. Note that in
  11439. // order to get all numeric fields that were incremented/decremented, call
  11440. // AddedFields().
  11441. func (m *EmployeeConfigMutation) Fields() []string {
  11442. fields := make([]string, 0, 7)
  11443. if m.created_at != nil {
  11444. fields = append(fields, employeeconfig.FieldCreatedAt)
  11445. }
  11446. if m.updated_at != nil {
  11447. fields = append(fields, employeeconfig.FieldUpdatedAt)
  11448. }
  11449. if m.deleted_at != nil {
  11450. fields = append(fields, employeeconfig.FieldDeletedAt)
  11451. }
  11452. if m.stype != nil {
  11453. fields = append(fields, employeeconfig.FieldStype)
  11454. }
  11455. if m.title != nil {
  11456. fields = append(fields, employeeconfig.FieldTitle)
  11457. }
  11458. if m.photo != nil {
  11459. fields = append(fields, employeeconfig.FieldPhoto)
  11460. }
  11461. if m.organization_id != nil {
  11462. fields = append(fields, employeeconfig.FieldOrganizationID)
  11463. }
  11464. return fields
  11465. }
  11466. // Field returns the value of a field with the given name. The second boolean
  11467. // return value indicates that this field was not set, or was not defined in the
  11468. // schema.
  11469. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  11470. switch name {
  11471. case employeeconfig.FieldCreatedAt:
  11472. return m.CreatedAt()
  11473. case employeeconfig.FieldUpdatedAt:
  11474. return m.UpdatedAt()
  11475. case employeeconfig.FieldDeletedAt:
  11476. return m.DeletedAt()
  11477. case employeeconfig.FieldStype:
  11478. return m.Stype()
  11479. case employeeconfig.FieldTitle:
  11480. return m.Title()
  11481. case employeeconfig.FieldPhoto:
  11482. return m.Photo()
  11483. case employeeconfig.FieldOrganizationID:
  11484. return m.OrganizationID()
  11485. }
  11486. return nil, false
  11487. }
  11488. // OldField returns the old value of the field from the database. An error is
  11489. // returned if the mutation operation is not UpdateOne, or the query to the
  11490. // database failed.
  11491. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11492. switch name {
  11493. case employeeconfig.FieldCreatedAt:
  11494. return m.OldCreatedAt(ctx)
  11495. case employeeconfig.FieldUpdatedAt:
  11496. return m.OldUpdatedAt(ctx)
  11497. case employeeconfig.FieldDeletedAt:
  11498. return m.OldDeletedAt(ctx)
  11499. case employeeconfig.FieldStype:
  11500. return m.OldStype(ctx)
  11501. case employeeconfig.FieldTitle:
  11502. return m.OldTitle(ctx)
  11503. case employeeconfig.FieldPhoto:
  11504. return m.OldPhoto(ctx)
  11505. case employeeconfig.FieldOrganizationID:
  11506. return m.OldOrganizationID(ctx)
  11507. }
  11508. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  11509. }
  11510. // SetField sets the value of a field with the given name. It returns an error if
  11511. // the field is not defined in the schema, or if the type mismatched the field
  11512. // type.
  11513. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  11514. switch name {
  11515. case employeeconfig.FieldCreatedAt:
  11516. v, ok := value.(time.Time)
  11517. if !ok {
  11518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11519. }
  11520. m.SetCreatedAt(v)
  11521. return nil
  11522. case employeeconfig.FieldUpdatedAt:
  11523. v, ok := value.(time.Time)
  11524. if !ok {
  11525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11526. }
  11527. m.SetUpdatedAt(v)
  11528. return nil
  11529. case employeeconfig.FieldDeletedAt:
  11530. v, ok := value.(time.Time)
  11531. if !ok {
  11532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11533. }
  11534. m.SetDeletedAt(v)
  11535. return nil
  11536. case employeeconfig.FieldStype:
  11537. v, ok := value.(string)
  11538. if !ok {
  11539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11540. }
  11541. m.SetStype(v)
  11542. return nil
  11543. case employeeconfig.FieldTitle:
  11544. v, ok := value.(string)
  11545. if !ok {
  11546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11547. }
  11548. m.SetTitle(v)
  11549. return nil
  11550. case employeeconfig.FieldPhoto:
  11551. v, ok := value.(string)
  11552. if !ok {
  11553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11554. }
  11555. m.SetPhoto(v)
  11556. return nil
  11557. case employeeconfig.FieldOrganizationID:
  11558. v, ok := value.(uint64)
  11559. if !ok {
  11560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11561. }
  11562. m.SetOrganizationID(v)
  11563. return nil
  11564. }
  11565. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  11566. }
  11567. // AddedFields returns all numeric fields that were incremented/decremented during
  11568. // this mutation.
  11569. func (m *EmployeeConfigMutation) AddedFields() []string {
  11570. var fields []string
  11571. if m.addorganization_id != nil {
  11572. fields = append(fields, employeeconfig.FieldOrganizationID)
  11573. }
  11574. return fields
  11575. }
  11576. // AddedField returns the numeric value that was incremented/decremented on a field
  11577. // with the given name. The second boolean return value indicates that this field
  11578. // was not set, or was not defined in the schema.
  11579. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  11580. switch name {
  11581. case employeeconfig.FieldOrganizationID:
  11582. return m.AddedOrganizationID()
  11583. }
  11584. return nil, false
  11585. }
  11586. // AddField adds the value to the field with the given name. It returns an error if
  11587. // the field is not defined in the schema, or if the type mismatched the field
  11588. // type.
  11589. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  11590. switch name {
  11591. case employeeconfig.FieldOrganizationID:
  11592. v, ok := value.(int64)
  11593. if !ok {
  11594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11595. }
  11596. m.AddOrganizationID(v)
  11597. return nil
  11598. }
  11599. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  11600. }
  11601. // ClearedFields returns all nullable fields that were cleared during this
  11602. // mutation.
  11603. func (m *EmployeeConfigMutation) ClearedFields() []string {
  11604. var fields []string
  11605. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  11606. fields = append(fields, employeeconfig.FieldDeletedAt)
  11607. }
  11608. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  11609. fields = append(fields, employeeconfig.FieldOrganizationID)
  11610. }
  11611. return fields
  11612. }
  11613. // FieldCleared returns a boolean indicating if a field with the given name was
  11614. // cleared in this mutation.
  11615. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  11616. _, ok := m.clearedFields[name]
  11617. return ok
  11618. }
  11619. // ClearField clears the value of the field with the given name. It returns an
  11620. // error if the field is not defined in the schema.
  11621. func (m *EmployeeConfigMutation) ClearField(name string) error {
  11622. switch name {
  11623. case employeeconfig.FieldDeletedAt:
  11624. m.ClearDeletedAt()
  11625. return nil
  11626. case employeeconfig.FieldOrganizationID:
  11627. m.ClearOrganizationID()
  11628. return nil
  11629. }
  11630. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  11631. }
  11632. // ResetField resets all changes in the mutation for the field with the given name.
  11633. // It returns an error if the field is not defined in the schema.
  11634. func (m *EmployeeConfigMutation) ResetField(name string) error {
  11635. switch name {
  11636. case employeeconfig.FieldCreatedAt:
  11637. m.ResetCreatedAt()
  11638. return nil
  11639. case employeeconfig.FieldUpdatedAt:
  11640. m.ResetUpdatedAt()
  11641. return nil
  11642. case employeeconfig.FieldDeletedAt:
  11643. m.ResetDeletedAt()
  11644. return nil
  11645. case employeeconfig.FieldStype:
  11646. m.ResetStype()
  11647. return nil
  11648. case employeeconfig.FieldTitle:
  11649. m.ResetTitle()
  11650. return nil
  11651. case employeeconfig.FieldPhoto:
  11652. m.ResetPhoto()
  11653. return nil
  11654. case employeeconfig.FieldOrganizationID:
  11655. m.ResetOrganizationID()
  11656. return nil
  11657. }
  11658. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  11659. }
  11660. // AddedEdges returns all edge names that were set/added in this mutation.
  11661. func (m *EmployeeConfigMutation) AddedEdges() []string {
  11662. edges := make([]string, 0, 0)
  11663. return edges
  11664. }
  11665. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11666. // name in this mutation.
  11667. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  11668. return nil
  11669. }
  11670. // RemovedEdges returns all edge names that were removed in this mutation.
  11671. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  11672. edges := make([]string, 0, 0)
  11673. return edges
  11674. }
  11675. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11676. // the given name in this mutation.
  11677. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  11678. return nil
  11679. }
  11680. // ClearedEdges returns all edge names that were cleared in this mutation.
  11681. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  11682. edges := make([]string, 0, 0)
  11683. return edges
  11684. }
  11685. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11686. // was cleared in this mutation.
  11687. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  11688. return false
  11689. }
  11690. // ClearEdge clears the value of the edge with the given name. It returns an error
  11691. // if that edge is not defined in the schema.
  11692. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  11693. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  11694. }
  11695. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11696. // It returns an error if the edge is not defined in the schema.
  11697. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  11698. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  11699. }
  11700. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  11701. type LabelMutation struct {
  11702. config
  11703. op Op
  11704. typ string
  11705. id *uint64
  11706. created_at *time.Time
  11707. updated_at *time.Time
  11708. status *uint8
  11709. addstatus *int8
  11710. _type *int
  11711. add_type *int
  11712. name *string
  11713. from *int
  11714. addfrom *int
  11715. mode *int
  11716. addmode *int
  11717. conditions *string
  11718. organization_id *uint64
  11719. addorganization_id *int64
  11720. clearedFields map[string]struct{}
  11721. label_relationships map[uint64]struct{}
  11722. removedlabel_relationships map[uint64]struct{}
  11723. clearedlabel_relationships bool
  11724. done bool
  11725. oldValue func(context.Context) (*Label, error)
  11726. predicates []predicate.Label
  11727. }
  11728. var _ ent.Mutation = (*LabelMutation)(nil)
  11729. // labelOption allows management of the mutation configuration using functional options.
  11730. type labelOption func(*LabelMutation)
  11731. // newLabelMutation creates new mutation for the Label entity.
  11732. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  11733. m := &LabelMutation{
  11734. config: c,
  11735. op: op,
  11736. typ: TypeLabel,
  11737. clearedFields: make(map[string]struct{}),
  11738. }
  11739. for _, opt := range opts {
  11740. opt(m)
  11741. }
  11742. return m
  11743. }
  11744. // withLabelID sets the ID field of the mutation.
  11745. func withLabelID(id uint64) labelOption {
  11746. return func(m *LabelMutation) {
  11747. var (
  11748. err error
  11749. once sync.Once
  11750. value *Label
  11751. )
  11752. m.oldValue = func(ctx context.Context) (*Label, error) {
  11753. once.Do(func() {
  11754. if m.done {
  11755. err = errors.New("querying old values post mutation is not allowed")
  11756. } else {
  11757. value, err = m.Client().Label.Get(ctx, id)
  11758. }
  11759. })
  11760. return value, err
  11761. }
  11762. m.id = &id
  11763. }
  11764. }
  11765. // withLabel sets the old Label of the mutation.
  11766. func withLabel(node *Label) labelOption {
  11767. return func(m *LabelMutation) {
  11768. m.oldValue = func(context.Context) (*Label, error) {
  11769. return node, nil
  11770. }
  11771. m.id = &node.ID
  11772. }
  11773. }
  11774. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11775. // executed in a transaction (ent.Tx), a transactional client is returned.
  11776. func (m LabelMutation) Client() *Client {
  11777. client := &Client{config: m.config}
  11778. client.init()
  11779. return client
  11780. }
  11781. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11782. // it returns an error otherwise.
  11783. func (m LabelMutation) Tx() (*Tx, error) {
  11784. if _, ok := m.driver.(*txDriver); !ok {
  11785. return nil, errors.New("ent: mutation is not running in a transaction")
  11786. }
  11787. tx := &Tx{config: m.config}
  11788. tx.init()
  11789. return tx, nil
  11790. }
  11791. // SetID sets the value of the id field. Note that this
  11792. // operation is only accepted on creation of Label entities.
  11793. func (m *LabelMutation) SetID(id uint64) {
  11794. m.id = &id
  11795. }
  11796. // ID returns the ID value in the mutation. Note that the ID is only available
  11797. // if it was provided to the builder or after it was returned from the database.
  11798. func (m *LabelMutation) ID() (id uint64, exists bool) {
  11799. if m.id == nil {
  11800. return
  11801. }
  11802. return *m.id, true
  11803. }
  11804. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11805. // That means, if the mutation is applied within a transaction with an isolation level such
  11806. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11807. // or updated by the mutation.
  11808. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  11809. switch {
  11810. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11811. id, exists := m.ID()
  11812. if exists {
  11813. return []uint64{id}, nil
  11814. }
  11815. fallthrough
  11816. case m.op.Is(OpUpdate | OpDelete):
  11817. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  11818. default:
  11819. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11820. }
  11821. }
  11822. // SetCreatedAt sets the "created_at" field.
  11823. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  11824. m.created_at = &t
  11825. }
  11826. // CreatedAt returns the value of the "created_at" field in the mutation.
  11827. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  11828. v := m.created_at
  11829. if v == nil {
  11830. return
  11831. }
  11832. return *v, true
  11833. }
  11834. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  11835. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11837. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11838. if !m.op.Is(OpUpdateOne) {
  11839. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11840. }
  11841. if m.id == nil || m.oldValue == nil {
  11842. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11843. }
  11844. oldValue, err := m.oldValue(ctx)
  11845. if err != nil {
  11846. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11847. }
  11848. return oldValue.CreatedAt, nil
  11849. }
  11850. // ResetCreatedAt resets all changes to the "created_at" field.
  11851. func (m *LabelMutation) ResetCreatedAt() {
  11852. m.created_at = nil
  11853. }
  11854. // SetUpdatedAt sets the "updated_at" field.
  11855. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  11856. m.updated_at = &t
  11857. }
  11858. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11859. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  11860. v := m.updated_at
  11861. if v == nil {
  11862. return
  11863. }
  11864. return *v, true
  11865. }
  11866. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  11867. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11869. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11870. if !m.op.Is(OpUpdateOne) {
  11871. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11872. }
  11873. if m.id == nil || m.oldValue == nil {
  11874. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11875. }
  11876. oldValue, err := m.oldValue(ctx)
  11877. if err != nil {
  11878. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11879. }
  11880. return oldValue.UpdatedAt, nil
  11881. }
  11882. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11883. func (m *LabelMutation) ResetUpdatedAt() {
  11884. m.updated_at = nil
  11885. }
  11886. // SetStatus sets the "status" field.
  11887. func (m *LabelMutation) SetStatus(u uint8) {
  11888. m.status = &u
  11889. m.addstatus = nil
  11890. }
  11891. // Status returns the value of the "status" field in the mutation.
  11892. func (m *LabelMutation) Status() (r uint8, exists bool) {
  11893. v := m.status
  11894. if v == nil {
  11895. return
  11896. }
  11897. return *v, true
  11898. }
  11899. // OldStatus returns the old "status" field's value of the Label entity.
  11900. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11902. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11903. if !m.op.Is(OpUpdateOne) {
  11904. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11905. }
  11906. if m.id == nil || m.oldValue == nil {
  11907. return v, errors.New("OldStatus requires an ID field in the mutation")
  11908. }
  11909. oldValue, err := m.oldValue(ctx)
  11910. if err != nil {
  11911. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11912. }
  11913. return oldValue.Status, nil
  11914. }
  11915. // AddStatus adds u to the "status" field.
  11916. func (m *LabelMutation) AddStatus(u int8) {
  11917. if m.addstatus != nil {
  11918. *m.addstatus += u
  11919. } else {
  11920. m.addstatus = &u
  11921. }
  11922. }
  11923. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11924. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  11925. v := m.addstatus
  11926. if v == nil {
  11927. return
  11928. }
  11929. return *v, true
  11930. }
  11931. // ClearStatus clears the value of the "status" field.
  11932. func (m *LabelMutation) ClearStatus() {
  11933. m.status = nil
  11934. m.addstatus = nil
  11935. m.clearedFields[label.FieldStatus] = struct{}{}
  11936. }
  11937. // StatusCleared returns if the "status" field was cleared in this mutation.
  11938. func (m *LabelMutation) StatusCleared() bool {
  11939. _, ok := m.clearedFields[label.FieldStatus]
  11940. return ok
  11941. }
  11942. // ResetStatus resets all changes to the "status" field.
  11943. func (m *LabelMutation) ResetStatus() {
  11944. m.status = nil
  11945. m.addstatus = nil
  11946. delete(m.clearedFields, label.FieldStatus)
  11947. }
  11948. // SetType sets the "type" field.
  11949. func (m *LabelMutation) SetType(i int) {
  11950. m._type = &i
  11951. m.add_type = nil
  11952. }
  11953. // GetType returns the value of the "type" field in the mutation.
  11954. func (m *LabelMutation) GetType() (r int, exists bool) {
  11955. v := m._type
  11956. if v == nil {
  11957. return
  11958. }
  11959. return *v, true
  11960. }
  11961. // OldType returns the old "type" field's value of the Label entity.
  11962. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11964. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  11965. if !m.op.Is(OpUpdateOne) {
  11966. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11967. }
  11968. if m.id == nil || m.oldValue == nil {
  11969. return v, errors.New("OldType requires an ID field in the mutation")
  11970. }
  11971. oldValue, err := m.oldValue(ctx)
  11972. if err != nil {
  11973. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11974. }
  11975. return oldValue.Type, nil
  11976. }
  11977. // AddType adds i to the "type" field.
  11978. func (m *LabelMutation) AddType(i int) {
  11979. if m.add_type != nil {
  11980. *m.add_type += i
  11981. } else {
  11982. m.add_type = &i
  11983. }
  11984. }
  11985. // AddedType returns the value that was added to the "type" field in this mutation.
  11986. func (m *LabelMutation) AddedType() (r int, exists bool) {
  11987. v := m.add_type
  11988. if v == nil {
  11989. return
  11990. }
  11991. return *v, true
  11992. }
  11993. // ResetType resets all changes to the "type" field.
  11994. func (m *LabelMutation) ResetType() {
  11995. m._type = nil
  11996. m.add_type = nil
  11997. }
  11998. // SetName sets the "name" field.
  11999. func (m *LabelMutation) SetName(s string) {
  12000. m.name = &s
  12001. }
  12002. // Name returns the value of the "name" field in the mutation.
  12003. func (m *LabelMutation) Name() (r string, exists bool) {
  12004. v := m.name
  12005. if v == nil {
  12006. return
  12007. }
  12008. return *v, true
  12009. }
  12010. // OldName returns the old "name" field's value of the Label entity.
  12011. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12013. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  12014. if !m.op.Is(OpUpdateOne) {
  12015. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12016. }
  12017. if m.id == nil || m.oldValue == nil {
  12018. return v, errors.New("OldName requires an ID field in the mutation")
  12019. }
  12020. oldValue, err := m.oldValue(ctx)
  12021. if err != nil {
  12022. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12023. }
  12024. return oldValue.Name, nil
  12025. }
  12026. // ResetName resets all changes to the "name" field.
  12027. func (m *LabelMutation) ResetName() {
  12028. m.name = nil
  12029. }
  12030. // SetFrom sets the "from" field.
  12031. func (m *LabelMutation) SetFrom(i int) {
  12032. m.from = &i
  12033. m.addfrom = nil
  12034. }
  12035. // From returns the value of the "from" field in the mutation.
  12036. func (m *LabelMutation) From() (r int, exists bool) {
  12037. v := m.from
  12038. if v == nil {
  12039. return
  12040. }
  12041. return *v, true
  12042. }
  12043. // OldFrom returns the old "from" field's value of the Label entity.
  12044. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12046. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  12047. if !m.op.Is(OpUpdateOne) {
  12048. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  12049. }
  12050. if m.id == nil || m.oldValue == nil {
  12051. return v, errors.New("OldFrom requires an ID field in the mutation")
  12052. }
  12053. oldValue, err := m.oldValue(ctx)
  12054. if err != nil {
  12055. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  12056. }
  12057. return oldValue.From, nil
  12058. }
  12059. // AddFrom adds i to the "from" field.
  12060. func (m *LabelMutation) AddFrom(i int) {
  12061. if m.addfrom != nil {
  12062. *m.addfrom += i
  12063. } else {
  12064. m.addfrom = &i
  12065. }
  12066. }
  12067. // AddedFrom returns the value that was added to the "from" field in this mutation.
  12068. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  12069. v := m.addfrom
  12070. if v == nil {
  12071. return
  12072. }
  12073. return *v, true
  12074. }
  12075. // ResetFrom resets all changes to the "from" field.
  12076. func (m *LabelMutation) ResetFrom() {
  12077. m.from = nil
  12078. m.addfrom = nil
  12079. }
  12080. // SetMode sets the "mode" field.
  12081. func (m *LabelMutation) SetMode(i int) {
  12082. m.mode = &i
  12083. m.addmode = nil
  12084. }
  12085. // Mode returns the value of the "mode" field in the mutation.
  12086. func (m *LabelMutation) Mode() (r int, exists bool) {
  12087. v := m.mode
  12088. if v == nil {
  12089. return
  12090. }
  12091. return *v, true
  12092. }
  12093. // OldMode returns the old "mode" field's value of the Label entity.
  12094. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12096. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  12097. if !m.op.Is(OpUpdateOne) {
  12098. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  12099. }
  12100. if m.id == nil || m.oldValue == nil {
  12101. return v, errors.New("OldMode requires an ID field in the mutation")
  12102. }
  12103. oldValue, err := m.oldValue(ctx)
  12104. if err != nil {
  12105. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  12106. }
  12107. return oldValue.Mode, nil
  12108. }
  12109. // AddMode adds i to the "mode" field.
  12110. func (m *LabelMutation) AddMode(i int) {
  12111. if m.addmode != nil {
  12112. *m.addmode += i
  12113. } else {
  12114. m.addmode = &i
  12115. }
  12116. }
  12117. // AddedMode returns the value that was added to the "mode" field in this mutation.
  12118. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  12119. v := m.addmode
  12120. if v == nil {
  12121. return
  12122. }
  12123. return *v, true
  12124. }
  12125. // ResetMode resets all changes to the "mode" field.
  12126. func (m *LabelMutation) ResetMode() {
  12127. m.mode = nil
  12128. m.addmode = nil
  12129. }
  12130. // SetConditions sets the "conditions" field.
  12131. func (m *LabelMutation) SetConditions(s string) {
  12132. m.conditions = &s
  12133. }
  12134. // Conditions returns the value of the "conditions" field in the mutation.
  12135. func (m *LabelMutation) Conditions() (r string, exists bool) {
  12136. v := m.conditions
  12137. if v == nil {
  12138. return
  12139. }
  12140. return *v, true
  12141. }
  12142. // OldConditions returns the old "conditions" field's value of the Label entity.
  12143. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12145. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  12146. if !m.op.Is(OpUpdateOne) {
  12147. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  12148. }
  12149. if m.id == nil || m.oldValue == nil {
  12150. return v, errors.New("OldConditions requires an ID field in the mutation")
  12151. }
  12152. oldValue, err := m.oldValue(ctx)
  12153. if err != nil {
  12154. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  12155. }
  12156. return oldValue.Conditions, nil
  12157. }
  12158. // ClearConditions clears the value of the "conditions" field.
  12159. func (m *LabelMutation) ClearConditions() {
  12160. m.conditions = nil
  12161. m.clearedFields[label.FieldConditions] = struct{}{}
  12162. }
  12163. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  12164. func (m *LabelMutation) ConditionsCleared() bool {
  12165. _, ok := m.clearedFields[label.FieldConditions]
  12166. return ok
  12167. }
  12168. // ResetConditions resets all changes to the "conditions" field.
  12169. func (m *LabelMutation) ResetConditions() {
  12170. m.conditions = nil
  12171. delete(m.clearedFields, label.FieldConditions)
  12172. }
  12173. // SetOrganizationID sets the "organization_id" field.
  12174. func (m *LabelMutation) SetOrganizationID(u uint64) {
  12175. m.organization_id = &u
  12176. m.addorganization_id = nil
  12177. }
  12178. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12179. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  12180. v := m.organization_id
  12181. if v == nil {
  12182. return
  12183. }
  12184. return *v, true
  12185. }
  12186. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  12187. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12189. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12190. if !m.op.Is(OpUpdateOne) {
  12191. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12192. }
  12193. if m.id == nil || m.oldValue == nil {
  12194. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12195. }
  12196. oldValue, err := m.oldValue(ctx)
  12197. if err != nil {
  12198. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12199. }
  12200. return oldValue.OrganizationID, nil
  12201. }
  12202. // AddOrganizationID adds u to the "organization_id" field.
  12203. func (m *LabelMutation) AddOrganizationID(u int64) {
  12204. if m.addorganization_id != nil {
  12205. *m.addorganization_id += u
  12206. } else {
  12207. m.addorganization_id = &u
  12208. }
  12209. }
  12210. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12211. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  12212. v := m.addorganization_id
  12213. if v == nil {
  12214. return
  12215. }
  12216. return *v, true
  12217. }
  12218. // ClearOrganizationID clears the value of the "organization_id" field.
  12219. func (m *LabelMutation) ClearOrganizationID() {
  12220. m.organization_id = nil
  12221. m.addorganization_id = nil
  12222. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  12223. }
  12224. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12225. func (m *LabelMutation) OrganizationIDCleared() bool {
  12226. _, ok := m.clearedFields[label.FieldOrganizationID]
  12227. return ok
  12228. }
  12229. // ResetOrganizationID resets all changes to the "organization_id" field.
  12230. func (m *LabelMutation) ResetOrganizationID() {
  12231. m.organization_id = nil
  12232. m.addorganization_id = nil
  12233. delete(m.clearedFields, label.FieldOrganizationID)
  12234. }
  12235. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  12236. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  12237. if m.label_relationships == nil {
  12238. m.label_relationships = make(map[uint64]struct{})
  12239. }
  12240. for i := range ids {
  12241. m.label_relationships[ids[i]] = struct{}{}
  12242. }
  12243. }
  12244. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  12245. func (m *LabelMutation) ClearLabelRelationships() {
  12246. m.clearedlabel_relationships = true
  12247. }
  12248. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  12249. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  12250. return m.clearedlabel_relationships
  12251. }
  12252. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  12253. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  12254. if m.removedlabel_relationships == nil {
  12255. m.removedlabel_relationships = make(map[uint64]struct{})
  12256. }
  12257. for i := range ids {
  12258. delete(m.label_relationships, ids[i])
  12259. m.removedlabel_relationships[ids[i]] = struct{}{}
  12260. }
  12261. }
  12262. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  12263. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  12264. for id := range m.removedlabel_relationships {
  12265. ids = append(ids, id)
  12266. }
  12267. return
  12268. }
  12269. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  12270. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  12271. for id := range m.label_relationships {
  12272. ids = append(ids, id)
  12273. }
  12274. return
  12275. }
  12276. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  12277. func (m *LabelMutation) ResetLabelRelationships() {
  12278. m.label_relationships = nil
  12279. m.clearedlabel_relationships = false
  12280. m.removedlabel_relationships = nil
  12281. }
  12282. // Where appends a list predicates to the LabelMutation builder.
  12283. func (m *LabelMutation) Where(ps ...predicate.Label) {
  12284. m.predicates = append(m.predicates, ps...)
  12285. }
  12286. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  12287. // users can use type-assertion to append predicates that do not depend on any generated package.
  12288. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  12289. p := make([]predicate.Label, len(ps))
  12290. for i := range ps {
  12291. p[i] = ps[i]
  12292. }
  12293. m.Where(p...)
  12294. }
  12295. // Op returns the operation name.
  12296. func (m *LabelMutation) Op() Op {
  12297. return m.op
  12298. }
  12299. // SetOp allows setting the mutation operation.
  12300. func (m *LabelMutation) SetOp(op Op) {
  12301. m.op = op
  12302. }
  12303. // Type returns the node type of this mutation (Label).
  12304. func (m *LabelMutation) Type() string {
  12305. return m.typ
  12306. }
  12307. // Fields returns all fields that were changed during this mutation. Note that in
  12308. // order to get all numeric fields that were incremented/decremented, call
  12309. // AddedFields().
  12310. func (m *LabelMutation) Fields() []string {
  12311. fields := make([]string, 0, 9)
  12312. if m.created_at != nil {
  12313. fields = append(fields, label.FieldCreatedAt)
  12314. }
  12315. if m.updated_at != nil {
  12316. fields = append(fields, label.FieldUpdatedAt)
  12317. }
  12318. if m.status != nil {
  12319. fields = append(fields, label.FieldStatus)
  12320. }
  12321. if m._type != nil {
  12322. fields = append(fields, label.FieldType)
  12323. }
  12324. if m.name != nil {
  12325. fields = append(fields, label.FieldName)
  12326. }
  12327. if m.from != nil {
  12328. fields = append(fields, label.FieldFrom)
  12329. }
  12330. if m.mode != nil {
  12331. fields = append(fields, label.FieldMode)
  12332. }
  12333. if m.conditions != nil {
  12334. fields = append(fields, label.FieldConditions)
  12335. }
  12336. if m.organization_id != nil {
  12337. fields = append(fields, label.FieldOrganizationID)
  12338. }
  12339. return fields
  12340. }
  12341. // Field returns the value of a field with the given name. The second boolean
  12342. // return value indicates that this field was not set, or was not defined in the
  12343. // schema.
  12344. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  12345. switch name {
  12346. case label.FieldCreatedAt:
  12347. return m.CreatedAt()
  12348. case label.FieldUpdatedAt:
  12349. return m.UpdatedAt()
  12350. case label.FieldStatus:
  12351. return m.Status()
  12352. case label.FieldType:
  12353. return m.GetType()
  12354. case label.FieldName:
  12355. return m.Name()
  12356. case label.FieldFrom:
  12357. return m.From()
  12358. case label.FieldMode:
  12359. return m.Mode()
  12360. case label.FieldConditions:
  12361. return m.Conditions()
  12362. case label.FieldOrganizationID:
  12363. return m.OrganizationID()
  12364. }
  12365. return nil, false
  12366. }
  12367. // OldField returns the old value of the field from the database. An error is
  12368. // returned if the mutation operation is not UpdateOne, or the query to the
  12369. // database failed.
  12370. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12371. switch name {
  12372. case label.FieldCreatedAt:
  12373. return m.OldCreatedAt(ctx)
  12374. case label.FieldUpdatedAt:
  12375. return m.OldUpdatedAt(ctx)
  12376. case label.FieldStatus:
  12377. return m.OldStatus(ctx)
  12378. case label.FieldType:
  12379. return m.OldType(ctx)
  12380. case label.FieldName:
  12381. return m.OldName(ctx)
  12382. case label.FieldFrom:
  12383. return m.OldFrom(ctx)
  12384. case label.FieldMode:
  12385. return m.OldMode(ctx)
  12386. case label.FieldConditions:
  12387. return m.OldConditions(ctx)
  12388. case label.FieldOrganizationID:
  12389. return m.OldOrganizationID(ctx)
  12390. }
  12391. return nil, fmt.Errorf("unknown Label field %s", name)
  12392. }
  12393. // SetField sets the value of a field with the given name. It returns an error if
  12394. // the field is not defined in the schema, or if the type mismatched the field
  12395. // type.
  12396. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  12397. switch name {
  12398. case label.FieldCreatedAt:
  12399. v, ok := value.(time.Time)
  12400. if !ok {
  12401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12402. }
  12403. m.SetCreatedAt(v)
  12404. return nil
  12405. case label.FieldUpdatedAt:
  12406. v, ok := value.(time.Time)
  12407. if !ok {
  12408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12409. }
  12410. m.SetUpdatedAt(v)
  12411. return nil
  12412. case label.FieldStatus:
  12413. v, ok := value.(uint8)
  12414. if !ok {
  12415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12416. }
  12417. m.SetStatus(v)
  12418. return nil
  12419. case label.FieldType:
  12420. v, ok := value.(int)
  12421. if !ok {
  12422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12423. }
  12424. m.SetType(v)
  12425. return nil
  12426. case label.FieldName:
  12427. v, ok := value.(string)
  12428. if !ok {
  12429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12430. }
  12431. m.SetName(v)
  12432. return nil
  12433. case label.FieldFrom:
  12434. v, ok := value.(int)
  12435. if !ok {
  12436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12437. }
  12438. m.SetFrom(v)
  12439. return nil
  12440. case label.FieldMode:
  12441. v, ok := value.(int)
  12442. if !ok {
  12443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12444. }
  12445. m.SetMode(v)
  12446. return nil
  12447. case label.FieldConditions:
  12448. v, ok := value.(string)
  12449. if !ok {
  12450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12451. }
  12452. m.SetConditions(v)
  12453. return nil
  12454. case label.FieldOrganizationID:
  12455. v, ok := value.(uint64)
  12456. if !ok {
  12457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12458. }
  12459. m.SetOrganizationID(v)
  12460. return nil
  12461. }
  12462. return fmt.Errorf("unknown Label field %s", name)
  12463. }
  12464. // AddedFields returns all numeric fields that were incremented/decremented during
  12465. // this mutation.
  12466. func (m *LabelMutation) AddedFields() []string {
  12467. var fields []string
  12468. if m.addstatus != nil {
  12469. fields = append(fields, label.FieldStatus)
  12470. }
  12471. if m.add_type != nil {
  12472. fields = append(fields, label.FieldType)
  12473. }
  12474. if m.addfrom != nil {
  12475. fields = append(fields, label.FieldFrom)
  12476. }
  12477. if m.addmode != nil {
  12478. fields = append(fields, label.FieldMode)
  12479. }
  12480. if m.addorganization_id != nil {
  12481. fields = append(fields, label.FieldOrganizationID)
  12482. }
  12483. return fields
  12484. }
  12485. // AddedField returns the numeric value that was incremented/decremented on a field
  12486. // with the given name. The second boolean return value indicates that this field
  12487. // was not set, or was not defined in the schema.
  12488. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  12489. switch name {
  12490. case label.FieldStatus:
  12491. return m.AddedStatus()
  12492. case label.FieldType:
  12493. return m.AddedType()
  12494. case label.FieldFrom:
  12495. return m.AddedFrom()
  12496. case label.FieldMode:
  12497. return m.AddedMode()
  12498. case label.FieldOrganizationID:
  12499. return m.AddedOrganizationID()
  12500. }
  12501. return nil, false
  12502. }
  12503. // AddField adds the value to the field with the given name. It returns an error if
  12504. // the field is not defined in the schema, or if the type mismatched the field
  12505. // type.
  12506. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  12507. switch name {
  12508. case label.FieldStatus:
  12509. v, ok := value.(int8)
  12510. if !ok {
  12511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12512. }
  12513. m.AddStatus(v)
  12514. return nil
  12515. case label.FieldType:
  12516. v, ok := value.(int)
  12517. if !ok {
  12518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12519. }
  12520. m.AddType(v)
  12521. return nil
  12522. case label.FieldFrom:
  12523. v, ok := value.(int)
  12524. if !ok {
  12525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12526. }
  12527. m.AddFrom(v)
  12528. return nil
  12529. case label.FieldMode:
  12530. v, ok := value.(int)
  12531. if !ok {
  12532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12533. }
  12534. m.AddMode(v)
  12535. return nil
  12536. case label.FieldOrganizationID:
  12537. v, ok := value.(int64)
  12538. if !ok {
  12539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12540. }
  12541. m.AddOrganizationID(v)
  12542. return nil
  12543. }
  12544. return fmt.Errorf("unknown Label numeric field %s", name)
  12545. }
  12546. // ClearedFields returns all nullable fields that were cleared during this
  12547. // mutation.
  12548. func (m *LabelMutation) ClearedFields() []string {
  12549. var fields []string
  12550. if m.FieldCleared(label.FieldStatus) {
  12551. fields = append(fields, label.FieldStatus)
  12552. }
  12553. if m.FieldCleared(label.FieldConditions) {
  12554. fields = append(fields, label.FieldConditions)
  12555. }
  12556. if m.FieldCleared(label.FieldOrganizationID) {
  12557. fields = append(fields, label.FieldOrganizationID)
  12558. }
  12559. return fields
  12560. }
  12561. // FieldCleared returns a boolean indicating if a field with the given name was
  12562. // cleared in this mutation.
  12563. func (m *LabelMutation) FieldCleared(name string) bool {
  12564. _, ok := m.clearedFields[name]
  12565. return ok
  12566. }
  12567. // ClearField clears the value of the field with the given name. It returns an
  12568. // error if the field is not defined in the schema.
  12569. func (m *LabelMutation) ClearField(name string) error {
  12570. switch name {
  12571. case label.FieldStatus:
  12572. m.ClearStatus()
  12573. return nil
  12574. case label.FieldConditions:
  12575. m.ClearConditions()
  12576. return nil
  12577. case label.FieldOrganizationID:
  12578. m.ClearOrganizationID()
  12579. return nil
  12580. }
  12581. return fmt.Errorf("unknown Label nullable field %s", name)
  12582. }
  12583. // ResetField resets all changes in the mutation for the field with the given name.
  12584. // It returns an error if the field is not defined in the schema.
  12585. func (m *LabelMutation) ResetField(name string) error {
  12586. switch name {
  12587. case label.FieldCreatedAt:
  12588. m.ResetCreatedAt()
  12589. return nil
  12590. case label.FieldUpdatedAt:
  12591. m.ResetUpdatedAt()
  12592. return nil
  12593. case label.FieldStatus:
  12594. m.ResetStatus()
  12595. return nil
  12596. case label.FieldType:
  12597. m.ResetType()
  12598. return nil
  12599. case label.FieldName:
  12600. m.ResetName()
  12601. return nil
  12602. case label.FieldFrom:
  12603. m.ResetFrom()
  12604. return nil
  12605. case label.FieldMode:
  12606. m.ResetMode()
  12607. return nil
  12608. case label.FieldConditions:
  12609. m.ResetConditions()
  12610. return nil
  12611. case label.FieldOrganizationID:
  12612. m.ResetOrganizationID()
  12613. return nil
  12614. }
  12615. return fmt.Errorf("unknown Label field %s", name)
  12616. }
  12617. // AddedEdges returns all edge names that were set/added in this mutation.
  12618. func (m *LabelMutation) AddedEdges() []string {
  12619. edges := make([]string, 0, 1)
  12620. if m.label_relationships != nil {
  12621. edges = append(edges, label.EdgeLabelRelationships)
  12622. }
  12623. return edges
  12624. }
  12625. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12626. // name in this mutation.
  12627. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  12628. switch name {
  12629. case label.EdgeLabelRelationships:
  12630. ids := make([]ent.Value, 0, len(m.label_relationships))
  12631. for id := range m.label_relationships {
  12632. ids = append(ids, id)
  12633. }
  12634. return ids
  12635. }
  12636. return nil
  12637. }
  12638. // RemovedEdges returns all edge names that were removed in this mutation.
  12639. func (m *LabelMutation) RemovedEdges() []string {
  12640. edges := make([]string, 0, 1)
  12641. if m.removedlabel_relationships != nil {
  12642. edges = append(edges, label.EdgeLabelRelationships)
  12643. }
  12644. return edges
  12645. }
  12646. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12647. // the given name in this mutation.
  12648. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  12649. switch name {
  12650. case label.EdgeLabelRelationships:
  12651. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  12652. for id := range m.removedlabel_relationships {
  12653. ids = append(ids, id)
  12654. }
  12655. return ids
  12656. }
  12657. return nil
  12658. }
  12659. // ClearedEdges returns all edge names that were cleared in this mutation.
  12660. func (m *LabelMutation) ClearedEdges() []string {
  12661. edges := make([]string, 0, 1)
  12662. if m.clearedlabel_relationships {
  12663. edges = append(edges, label.EdgeLabelRelationships)
  12664. }
  12665. return edges
  12666. }
  12667. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12668. // was cleared in this mutation.
  12669. func (m *LabelMutation) EdgeCleared(name string) bool {
  12670. switch name {
  12671. case label.EdgeLabelRelationships:
  12672. return m.clearedlabel_relationships
  12673. }
  12674. return false
  12675. }
  12676. // ClearEdge clears the value of the edge with the given name. It returns an error
  12677. // if that edge is not defined in the schema.
  12678. func (m *LabelMutation) ClearEdge(name string) error {
  12679. switch name {
  12680. }
  12681. return fmt.Errorf("unknown Label unique edge %s", name)
  12682. }
  12683. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12684. // It returns an error if the edge is not defined in the schema.
  12685. func (m *LabelMutation) ResetEdge(name string) error {
  12686. switch name {
  12687. case label.EdgeLabelRelationships:
  12688. m.ResetLabelRelationships()
  12689. return nil
  12690. }
  12691. return fmt.Errorf("unknown Label edge %s", name)
  12692. }
  12693. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  12694. type LabelRelationshipMutation struct {
  12695. config
  12696. op Op
  12697. typ string
  12698. id *uint64
  12699. created_at *time.Time
  12700. updated_at *time.Time
  12701. status *uint8
  12702. addstatus *int8
  12703. deleted_at *time.Time
  12704. organization_id *uint64
  12705. addorganization_id *int64
  12706. clearedFields map[string]struct{}
  12707. contacts *uint64
  12708. clearedcontacts bool
  12709. labels *uint64
  12710. clearedlabels bool
  12711. done bool
  12712. oldValue func(context.Context) (*LabelRelationship, error)
  12713. predicates []predicate.LabelRelationship
  12714. }
  12715. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  12716. // labelrelationshipOption allows management of the mutation configuration using functional options.
  12717. type labelrelationshipOption func(*LabelRelationshipMutation)
  12718. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  12719. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  12720. m := &LabelRelationshipMutation{
  12721. config: c,
  12722. op: op,
  12723. typ: TypeLabelRelationship,
  12724. clearedFields: make(map[string]struct{}),
  12725. }
  12726. for _, opt := range opts {
  12727. opt(m)
  12728. }
  12729. return m
  12730. }
  12731. // withLabelRelationshipID sets the ID field of the mutation.
  12732. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  12733. return func(m *LabelRelationshipMutation) {
  12734. var (
  12735. err error
  12736. once sync.Once
  12737. value *LabelRelationship
  12738. )
  12739. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  12740. once.Do(func() {
  12741. if m.done {
  12742. err = errors.New("querying old values post mutation is not allowed")
  12743. } else {
  12744. value, err = m.Client().LabelRelationship.Get(ctx, id)
  12745. }
  12746. })
  12747. return value, err
  12748. }
  12749. m.id = &id
  12750. }
  12751. }
  12752. // withLabelRelationship sets the old LabelRelationship of the mutation.
  12753. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  12754. return func(m *LabelRelationshipMutation) {
  12755. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  12756. return node, nil
  12757. }
  12758. m.id = &node.ID
  12759. }
  12760. }
  12761. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12762. // executed in a transaction (ent.Tx), a transactional client is returned.
  12763. func (m LabelRelationshipMutation) Client() *Client {
  12764. client := &Client{config: m.config}
  12765. client.init()
  12766. return client
  12767. }
  12768. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12769. // it returns an error otherwise.
  12770. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  12771. if _, ok := m.driver.(*txDriver); !ok {
  12772. return nil, errors.New("ent: mutation is not running in a transaction")
  12773. }
  12774. tx := &Tx{config: m.config}
  12775. tx.init()
  12776. return tx, nil
  12777. }
  12778. // SetID sets the value of the id field. Note that this
  12779. // operation is only accepted on creation of LabelRelationship entities.
  12780. func (m *LabelRelationshipMutation) SetID(id uint64) {
  12781. m.id = &id
  12782. }
  12783. // ID returns the ID value in the mutation. Note that the ID is only available
  12784. // if it was provided to the builder or after it was returned from the database.
  12785. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  12786. if m.id == nil {
  12787. return
  12788. }
  12789. return *m.id, true
  12790. }
  12791. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12792. // That means, if the mutation is applied within a transaction with an isolation level such
  12793. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12794. // or updated by the mutation.
  12795. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  12796. switch {
  12797. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12798. id, exists := m.ID()
  12799. if exists {
  12800. return []uint64{id}, nil
  12801. }
  12802. fallthrough
  12803. case m.op.Is(OpUpdate | OpDelete):
  12804. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  12805. default:
  12806. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12807. }
  12808. }
  12809. // SetCreatedAt sets the "created_at" field.
  12810. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  12811. m.created_at = &t
  12812. }
  12813. // CreatedAt returns the value of the "created_at" field in the mutation.
  12814. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  12815. v := m.created_at
  12816. if v == nil {
  12817. return
  12818. }
  12819. return *v, true
  12820. }
  12821. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  12822. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12824. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12825. if !m.op.Is(OpUpdateOne) {
  12826. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12827. }
  12828. if m.id == nil || m.oldValue == nil {
  12829. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12830. }
  12831. oldValue, err := m.oldValue(ctx)
  12832. if err != nil {
  12833. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12834. }
  12835. return oldValue.CreatedAt, nil
  12836. }
  12837. // ResetCreatedAt resets all changes to the "created_at" field.
  12838. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  12839. m.created_at = nil
  12840. }
  12841. // SetUpdatedAt sets the "updated_at" field.
  12842. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  12843. m.updated_at = &t
  12844. }
  12845. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12846. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  12847. v := m.updated_at
  12848. if v == nil {
  12849. return
  12850. }
  12851. return *v, true
  12852. }
  12853. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  12854. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12856. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12857. if !m.op.Is(OpUpdateOne) {
  12858. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12859. }
  12860. if m.id == nil || m.oldValue == nil {
  12861. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12862. }
  12863. oldValue, err := m.oldValue(ctx)
  12864. if err != nil {
  12865. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12866. }
  12867. return oldValue.UpdatedAt, nil
  12868. }
  12869. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12870. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  12871. m.updated_at = nil
  12872. }
  12873. // SetStatus sets the "status" field.
  12874. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  12875. m.status = &u
  12876. m.addstatus = nil
  12877. }
  12878. // Status returns the value of the "status" field in the mutation.
  12879. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  12880. v := m.status
  12881. if v == nil {
  12882. return
  12883. }
  12884. return *v, true
  12885. }
  12886. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  12887. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12889. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12890. if !m.op.Is(OpUpdateOne) {
  12891. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12892. }
  12893. if m.id == nil || m.oldValue == nil {
  12894. return v, errors.New("OldStatus requires an ID field in the mutation")
  12895. }
  12896. oldValue, err := m.oldValue(ctx)
  12897. if err != nil {
  12898. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12899. }
  12900. return oldValue.Status, nil
  12901. }
  12902. // AddStatus adds u to the "status" field.
  12903. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  12904. if m.addstatus != nil {
  12905. *m.addstatus += u
  12906. } else {
  12907. m.addstatus = &u
  12908. }
  12909. }
  12910. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12911. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  12912. v := m.addstatus
  12913. if v == nil {
  12914. return
  12915. }
  12916. return *v, true
  12917. }
  12918. // ClearStatus clears the value of the "status" field.
  12919. func (m *LabelRelationshipMutation) ClearStatus() {
  12920. m.status = nil
  12921. m.addstatus = nil
  12922. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  12923. }
  12924. // StatusCleared returns if the "status" field was cleared in this mutation.
  12925. func (m *LabelRelationshipMutation) StatusCleared() bool {
  12926. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  12927. return ok
  12928. }
  12929. // ResetStatus resets all changes to the "status" field.
  12930. func (m *LabelRelationshipMutation) ResetStatus() {
  12931. m.status = nil
  12932. m.addstatus = nil
  12933. delete(m.clearedFields, labelrelationship.FieldStatus)
  12934. }
  12935. // SetDeletedAt sets the "deleted_at" field.
  12936. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  12937. m.deleted_at = &t
  12938. }
  12939. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12940. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  12941. v := m.deleted_at
  12942. if v == nil {
  12943. return
  12944. }
  12945. return *v, true
  12946. }
  12947. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  12948. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12950. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12951. if !m.op.Is(OpUpdateOne) {
  12952. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12953. }
  12954. if m.id == nil || m.oldValue == nil {
  12955. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12956. }
  12957. oldValue, err := m.oldValue(ctx)
  12958. if err != nil {
  12959. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12960. }
  12961. return oldValue.DeletedAt, nil
  12962. }
  12963. // ClearDeletedAt clears the value of the "deleted_at" field.
  12964. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  12965. m.deleted_at = nil
  12966. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  12967. }
  12968. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12969. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  12970. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  12971. return ok
  12972. }
  12973. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12974. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  12975. m.deleted_at = nil
  12976. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  12977. }
  12978. // SetLabelID sets the "label_id" field.
  12979. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  12980. m.labels = &u
  12981. }
  12982. // LabelID returns the value of the "label_id" field in the mutation.
  12983. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  12984. v := m.labels
  12985. if v == nil {
  12986. return
  12987. }
  12988. return *v, true
  12989. }
  12990. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  12991. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12993. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  12994. if !m.op.Is(OpUpdateOne) {
  12995. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  12996. }
  12997. if m.id == nil || m.oldValue == nil {
  12998. return v, errors.New("OldLabelID requires an ID field in the mutation")
  12999. }
  13000. oldValue, err := m.oldValue(ctx)
  13001. if err != nil {
  13002. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  13003. }
  13004. return oldValue.LabelID, nil
  13005. }
  13006. // ResetLabelID resets all changes to the "label_id" field.
  13007. func (m *LabelRelationshipMutation) ResetLabelID() {
  13008. m.labels = nil
  13009. }
  13010. // SetContactID sets the "contact_id" field.
  13011. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  13012. m.contacts = &u
  13013. }
  13014. // ContactID returns the value of the "contact_id" field in the mutation.
  13015. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  13016. v := m.contacts
  13017. if v == nil {
  13018. return
  13019. }
  13020. return *v, true
  13021. }
  13022. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  13023. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  13024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13025. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13026. if !m.op.Is(OpUpdateOne) {
  13027. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13028. }
  13029. if m.id == nil || m.oldValue == nil {
  13030. return v, errors.New("OldContactID requires an ID field in the mutation")
  13031. }
  13032. oldValue, err := m.oldValue(ctx)
  13033. if err != nil {
  13034. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13035. }
  13036. return oldValue.ContactID, nil
  13037. }
  13038. // ResetContactID resets all changes to the "contact_id" field.
  13039. func (m *LabelRelationshipMutation) ResetContactID() {
  13040. m.contacts = nil
  13041. }
  13042. // SetOrganizationID sets the "organization_id" field.
  13043. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  13044. m.organization_id = &u
  13045. m.addorganization_id = nil
  13046. }
  13047. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13048. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  13049. v := m.organization_id
  13050. if v == nil {
  13051. return
  13052. }
  13053. return *v, true
  13054. }
  13055. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  13056. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  13057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13058. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13059. if !m.op.Is(OpUpdateOne) {
  13060. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13061. }
  13062. if m.id == nil || m.oldValue == nil {
  13063. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13064. }
  13065. oldValue, err := m.oldValue(ctx)
  13066. if err != nil {
  13067. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13068. }
  13069. return oldValue.OrganizationID, nil
  13070. }
  13071. // AddOrganizationID adds u to the "organization_id" field.
  13072. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  13073. if m.addorganization_id != nil {
  13074. *m.addorganization_id += u
  13075. } else {
  13076. m.addorganization_id = &u
  13077. }
  13078. }
  13079. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13080. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  13081. v := m.addorganization_id
  13082. if v == nil {
  13083. return
  13084. }
  13085. return *v, true
  13086. }
  13087. // ClearOrganizationID clears the value of the "organization_id" field.
  13088. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  13089. m.organization_id = nil
  13090. m.addorganization_id = nil
  13091. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  13092. }
  13093. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13094. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  13095. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  13096. return ok
  13097. }
  13098. // ResetOrganizationID resets all changes to the "organization_id" field.
  13099. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  13100. m.organization_id = nil
  13101. m.addorganization_id = nil
  13102. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  13103. }
  13104. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  13105. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  13106. m.contacts = &id
  13107. }
  13108. // ClearContacts clears the "contacts" edge to the Contact entity.
  13109. func (m *LabelRelationshipMutation) ClearContacts() {
  13110. m.clearedcontacts = true
  13111. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  13112. }
  13113. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  13114. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  13115. return m.clearedcontacts
  13116. }
  13117. // ContactsID returns the "contacts" edge ID in the mutation.
  13118. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  13119. if m.contacts != nil {
  13120. return *m.contacts, true
  13121. }
  13122. return
  13123. }
  13124. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  13125. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13126. // ContactsID instead. It exists only for internal usage by the builders.
  13127. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  13128. if id := m.contacts; id != nil {
  13129. ids = append(ids, *id)
  13130. }
  13131. return
  13132. }
  13133. // ResetContacts resets all changes to the "contacts" edge.
  13134. func (m *LabelRelationshipMutation) ResetContacts() {
  13135. m.contacts = nil
  13136. m.clearedcontacts = false
  13137. }
  13138. // SetLabelsID sets the "labels" edge to the Label entity by id.
  13139. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  13140. m.labels = &id
  13141. }
  13142. // ClearLabels clears the "labels" edge to the Label entity.
  13143. func (m *LabelRelationshipMutation) ClearLabels() {
  13144. m.clearedlabels = true
  13145. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  13146. }
  13147. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  13148. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  13149. return m.clearedlabels
  13150. }
  13151. // LabelsID returns the "labels" edge ID in the mutation.
  13152. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  13153. if m.labels != nil {
  13154. return *m.labels, true
  13155. }
  13156. return
  13157. }
  13158. // LabelsIDs returns the "labels" edge IDs in the mutation.
  13159. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13160. // LabelsID instead. It exists only for internal usage by the builders.
  13161. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  13162. if id := m.labels; id != nil {
  13163. ids = append(ids, *id)
  13164. }
  13165. return
  13166. }
  13167. // ResetLabels resets all changes to the "labels" edge.
  13168. func (m *LabelRelationshipMutation) ResetLabels() {
  13169. m.labels = nil
  13170. m.clearedlabels = false
  13171. }
  13172. // Where appends a list predicates to the LabelRelationshipMutation builder.
  13173. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  13174. m.predicates = append(m.predicates, ps...)
  13175. }
  13176. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  13177. // users can use type-assertion to append predicates that do not depend on any generated package.
  13178. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  13179. p := make([]predicate.LabelRelationship, len(ps))
  13180. for i := range ps {
  13181. p[i] = ps[i]
  13182. }
  13183. m.Where(p...)
  13184. }
  13185. // Op returns the operation name.
  13186. func (m *LabelRelationshipMutation) Op() Op {
  13187. return m.op
  13188. }
  13189. // SetOp allows setting the mutation operation.
  13190. func (m *LabelRelationshipMutation) SetOp(op Op) {
  13191. m.op = op
  13192. }
  13193. // Type returns the node type of this mutation (LabelRelationship).
  13194. func (m *LabelRelationshipMutation) Type() string {
  13195. return m.typ
  13196. }
  13197. // Fields returns all fields that were changed during this mutation. Note that in
  13198. // order to get all numeric fields that were incremented/decremented, call
  13199. // AddedFields().
  13200. func (m *LabelRelationshipMutation) Fields() []string {
  13201. fields := make([]string, 0, 7)
  13202. if m.created_at != nil {
  13203. fields = append(fields, labelrelationship.FieldCreatedAt)
  13204. }
  13205. if m.updated_at != nil {
  13206. fields = append(fields, labelrelationship.FieldUpdatedAt)
  13207. }
  13208. if m.status != nil {
  13209. fields = append(fields, labelrelationship.FieldStatus)
  13210. }
  13211. if m.deleted_at != nil {
  13212. fields = append(fields, labelrelationship.FieldDeletedAt)
  13213. }
  13214. if m.labels != nil {
  13215. fields = append(fields, labelrelationship.FieldLabelID)
  13216. }
  13217. if m.contacts != nil {
  13218. fields = append(fields, labelrelationship.FieldContactID)
  13219. }
  13220. if m.organization_id != nil {
  13221. fields = append(fields, labelrelationship.FieldOrganizationID)
  13222. }
  13223. return fields
  13224. }
  13225. // Field returns the value of a field with the given name. The second boolean
  13226. // return value indicates that this field was not set, or was not defined in the
  13227. // schema.
  13228. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  13229. switch name {
  13230. case labelrelationship.FieldCreatedAt:
  13231. return m.CreatedAt()
  13232. case labelrelationship.FieldUpdatedAt:
  13233. return m.UpdatedAt()
  13234. case labelrelationship.FieldStatus:
  13235. return m.Status()
  13236. case labelrelationship.FieldDeletedAt:
  13237. return m.DeletedAt()
  13238. case labelrelationship.FieldLabelID:
  13239. return m.LabelID()
  13240. case labelrelationship.FieldContactID:
  13241. return m.ContactID()
  13242. case labelrelationship.FieldOrganizationID:
  13243. return m.OrganizationID()
  13244. }
  13245. return nil, false
  13246. }
  13247. // OldField returns the old value of the field from the database. An error is
  13248. // returned if the mutation operation is not UpdateOne, or the query to the
  13249. // database failed.
  13250. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13251. switch name {
  13252. case labelrelationship.FieldCreatedAt:
  13253. return m.OldCreatedAt(ctx)
  13254. case labelrelationship.FieldUpdatedAt:
  13255. return m.OldUpdatedAt(ctx)
  13256. case labelrelationship.FieldStatus:
  13257. return m.OldStatus(ctx)
  13258. case labelrelationship.FieldDeletedAt:
  13259. return m.OldDeletedAt(ctx)
  13260. case labelrelationship.FieldLabelID:
  13261. return m.OldLabelID(ctx)
  13262. case labelrelationship.FieldContactID:
  13263. return m.OldContactID(ctx)
  13264. case labelrelationship.FieldOrganizationID:
  13265. return m.OldOrganizationID(ctx)
  13266. }
  13267. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  13268. }
  13269. // SetField sets the value of a field with the given name. It returns an error if
  13270. // the field is not defined in the schema, or if the type mismatched the field
  13271. // type.
  13272. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  13273. switch name {
  13274. case labelrelationship.FieldCreatedAt:
  13275. v, ok := value.(time.Time)
  13276. if !ok {
  13277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13278. }
  13279. m.SetCreatedAt(v)
  13280. return nil
  13281. case labelrelationship.FieldUpdatedAt:
  13282. v, ok := value.(time.Time)
  13283. if !ok {
  13284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13285. }
  13286. m.SetUpdatedAt(v)
  13287. return nil
  13288. case labelrelationship.FieldStatus:
  13289. v, ok := value.(uint8)
  13290. if !ok {
  13291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13292. }
  13293. m.SetStatus(v)
  13294. return nil
  13295. case labelrelationship.FieldDeletedAt:
  13296. v, ok := value.(time.Time)
  13297. if !ok {
  13298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13299. }
  13300. m.SetDeletedAt(v)
  13301. return nil
  13302. case labelrelationship.FieldLabelID:
  13303. v, ok := value.(uint64)
  13304. if !ok {
  13305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13306. }
  13307. m.SetLabelID(v)
  13308. return nil
  13309. case labelrelationship.FieldContactID:
  13310. v, ok := value.(uint64)
  13311. if !ok {
  13312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13313. }
  13314. m.SetContactID(v)
  13315. return nil
  13316. case labelrelationship.FieldOrganizationID:
  13317. v, ok := value.(uint64)
  13318. if !ok {
  13319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13320. }
  13321. m.SetOrganizationID(v)
  13322. return nil
  13323. }
  13324. return fmt.Errorf("unknown LabelRelationship field %s", name)
  13325. }
  13326. // AddedFields returns all numeric fields that were incremented/decremented during
  13327. // this mutation.
  13328. func (m *LabelRelationshipMutation) AddedFields() []string {
  13329. var fields []string
  13330. if m.addstatus != nil {
  13331. fields = append(fields, labelrelationship.FieldStatus)
  13332. }
  13333. if m.addorganization_id != nil {
  13334. fields = append(fields, labelrelationship.FieldOrganizationID)
  13335. }
  13336. return fields
  13337. }
  13338. // AddedField returns the numeric value that was incremented/decremented on a field
  13339. // with the given name. The second boolean return value indicates that this field
  13340. // was not set, or was not defined in the schema.
  13341. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  13342. switch name {
  13343. case labelrelationship.FieldStatus:
  13344. return m.AddedStatus()
  13345. case labelrelationship.FieldOrganizationID:
  13346. return m.AddedOrganizationID()
  13347. }
  13348. return nil, false
  13349. }
  13350. // AddField adds the value to the field with the given name. It returns an error if
  13351. // the field is not defined in the schema, or if the type mismatched the field
  13352. // type.
  13353. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  13354. switch name {
  13355. case labelrelationship.FieldStatus:
  13356. v, ok := value.(int8)
  13357. if !ok {
  13358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13359. }
  13360. m.AddStatus(v)
  13361. return nil
  13362. case labelrelationship.FieldOrganizationID:
  13363. v, ok := value.(int64)
  13364. if !ok {
  13365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13366. }
  13367. m.AddOrganizationID(v)
  13368. return nil
  13369. }
  13370. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  13371. }
  13372. // ClearedFields returns all nullable fields that were cleared during this
  13373. // mutation.
  13374. func (m *LabelRelationshipMutation) ClearedFields() []string {
  13375. var fields []string
  13376. if m.FieldCleared(labelrelationship.FieldStatus) {
  13377. fields = append(fields, labelrelationship.FieldStatus)
  13378. }
  13379. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  13380. fields = append(fields, labelrelationship.FieldDeletedAt)
  13381. }
  13382. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  13383. fields = append(fields, labelrelationship.FieldOrganizationID)
  13384. }
  13385. return fields
  13386. }
  13387. // FieldCleared returns a boolean indicating if a field with the given name was
  13388. // cleared in this mutation.
  13389. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  13390. _, ok := m.clearedFields[name]
  13391. return ok
  13392. }
  13393. // ClearField clears the value of the field with the given name. It returns an
  13394. // error if the field is not defined in the schema.
  13395. func (m *LabelRelationshipMutation) ClearField(name string) error {
  13396. switch name {
  13397. case labelrelationship.FieldStatus:
  13398. m.ClearStatus()
  13399. return nil
  13400. case labelrelationship.FieldDeletedAt:
  13401. m.ClearDeletedAt()
  13402. return nil
  13403. case labelrelationship.FieldOrganizationID:
  13404. m.ClearOrganizationID()
  13405. return nil
  13406. }
  13407. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  13408. }
  13409. // ResetField resets all changes in the mutation for the field with the given name.
  13410. // It returns an error if the field is not defined in the schema.
  13411. func (m *LabelRelationshipMutation) ResetField(name string) error {
  13412. switch name {
  13413. case labelrelationship.FieldCreatedAt:
  13414. m.ResetCreatedAt()
  13415. return nil
  13416. case labelrelationship.FieldUpdatedAt:
  13417. m.ResetUpdatedAt()
  13418. return nil
  13419. case labelrelationship.FieldStatus:
  13420. m.ResetStatus()
  13421. return nil
  13422. case labelrelationship.FieldDeletedAt:
  13423. m.ResetDeletedAt()
  13424. return nil
  13425. case labelrelationship.FieldLabelID:
  13426. m.ResetLabelID()
  13427. return nil
  13428. case labelrelationship.FieldContactID:
  13429. m.ResetContactID()
  13430. return nil
  13431. case labelrelationship.FieldOrganizationID:
  13432. m.ResetOrganizationID()
  13433. return nil
  13434. }
  13435. return fmt.Errorf("unknown LabelRelationship field %s", name)
  13436. }
  13437. // AddedEdges returns all edge names that were set/added in this mutation.
  13438. func (m *LabelRelationshipMutation) AddedEdges() []string {
  13439. edges := make([]string, 0, 2)
  13440. if m.contacts != nil {
  13441. edges = append(edges, labelrelationship.EdgeContacts)
  13442. }
  13443. if m.labels != nil {
  13444. edges = append(edges, labelrelationship.EdgeLabels)
  13445. }
  13446. return edges
  13447. }
  13448. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13449. // name in this mutation.
  13450. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  13451. switch name {
  13452. case labelrelationship.EdgeContacts:
  13453. if id := m.contacts; id != nil {
  13454. return []ent.Value{*id}
  13455. }
  13456. case labelrelationship.EdgeLabels:
  13457. if id := m.labels; id != nil {
  13458. return []ent.Value{*id}
  13459. }
  13460. }
  13461. return nil
  13462. }
  13463. // RemovedEdges returns all edge names that were removed in this mutation.
  13464. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  13465. edges := make([]string, 0, 2)
  13466. return edges
  13467. }
  13468. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13469. // the given name in this mutation.
  13470. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  13471. return nil
  13472. }
  13473. // ClearedEdges returns all edge names that were cleared in this mutation.
  13474. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  13475. edges := make([]string, 0, 2)
  13476. if m.clearedcontacts {
  13477. edges = append(edges, labelrelationship.EdgeContacts)
  13478. }
  13479. if m.clearedlabels {
  13480. edges = append(edges, labelrelationship.EdgeLabels)
  13481. }
  13482. return edges
  13483. }
  13484. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13485. // was cleared in this mutation.
  13486. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  13487. switch name {
  13488. case labelrelationship.EdgeContacts:
  13489. return m.clearedcontacts
  13490. case labelrelationship.EdgeLabels:
  13491. return m.clearedlabels
  13492. }
  13493. return false
  13494. }
  13495. // ClearEdge clears the value of the edge with the given name. It returns an error
  13496. // if that edge is not defined in the schema.
  13497. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  13498. switch name {
  13499. case labelrelationship.EdgeContacts:
  13500. m.ClearContacts()
  13501. return nil
  13502. case labelrelationship.EdgeLabels:
  13503. m.ClearLabels()
  13504. return nil
  13505. }
  13506. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  13507. }
  13508. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13509. // It returns an error if the edge is not defined in the schema.
  13510. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  13511. switch name {
  13512. case labelrelationship.EdgeContacts:
  13513. m.ResetContacts()
  13514. return nil
  13515. case labelrelationship.EdgeLabels:
  13516. m.ResetLabels()
  13517. return nil
  13518. }
  13519. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  13520. }
  13521. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  13522. type MessageMutation struct {
  13523. config
  13524. op Op
  13525. typ string
  13526. id *int
  13527. wx_wxid *string
  13528. wxid *string
  13529. content *string
  13530. clearedFields map[string]struct{}
  13531. done bool
  13532. oldValue func(context.Context) (*Message, error)
  13533. predicates []predicate.Message
  13534. }
  13535. var _ ent.Mutation = (*MessageMutation)(nil)
  13536. // messageOption allows management of the mutation configuration using functional options.
  13537. type messageOption func(*MessageMutation)
  13538. // newMessageMutation creates new mutation for the Message entity.
  13539. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  13540. m := &MessageMutation{
  13541. config: c,
  13542. op: op,
  13543. typ: TypeMessage,
  13544. clearedFields: make(map[string]struct{}),
  13545. }
  13546. for _, opt := range opts {
  13547. opt(m)
  13548. }
  13549. return m
  13550. }
  13551. // withMessageID sets the ID field of the mutation.
  13552. func withMessageID(id int) messageOption {
  13553. return func(m *MessageMutation) {
  13554. var (
  13555. err error
  13556. once sync.Once
  13557. value *Message
  13558. )
  13559. m.oldValue = func(ctx context.Context) (*Message, error) {
  13560. once.Do(func() {
  13561. if m.done {
  13562. err = errors.New("querying old values post mutation is not allowed")
  13563. } else {
  13564. value, err = m.Client().Message.Get(ctx, id)
  13565. }
  13566. })
  13567. return value, err
  13568. }
  13569. m.id = &id
  13570. }
  13571. }
  13572. // withMessage sets the old Message of the mutation.
  13573. func withMessage(node *Message) messageOption {
  13574. return func(m *MessageMutation) {
  13575. m.oldValue = func(context.Context) (*Message, error) {
  13576. return node, nil
  13577. }
  13578. m.id = &node.ID
  13579. }
  13580. }
  13581. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13582. // executed in a transaction (ent.Tx), a transactional client is returned.
  13583. func (m MessageMutation) Client() *Client {
  13584. client := &Client{config: m.config}
  13585. client.init()
  13586. return client
  13587. }
  13588. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13589. // it returns an error otherwise.
  13590. func (m MessageMutation) Tx() (*Tx, error) {
  13591. if _, ok := m.driver.(*txDriver); !ok {
  13592. return nil, errors.New("ent: mutation is not running in a transaction")
  13593. }
  13594. tx := &Tx{config: m.config}
  13595. tx.init()
  13596. return tx, nil
  13597. }
  13598. // ID returns the ID value in the mutation. Note that the ID is only available
  13599. // if it was provided to the builder or after it was returned from the database.
  13600. func (m *MessageMutation) ID() (id int, exists bool) {
  13601. if m.id == nil {
  13602. return
  13603. }
  13604. return *m.id, true
  13605. }
  13606. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13607. // That means, if the mutation is applied within a transaction with an isolation level such
  13608. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13609. // or updated by the mutation.
  13610. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  13611. switch {
  13612. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13613. id, exists := m.ID()
  13614. if exists {
  13615. return []int{id}, nil
  13616. }
  13617. fallthrough
  13618. case m.op.Is(OpUpdate | OpDelete):
  13619. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  13620. default:
  13621. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13622. }
  13623. }
  13624. // SetWxWxid sets the "wx_wxid" field.
  13625. func (m *MessageMutation) SetWxWxid(s string) {
  13626. m.wx_wxid = &s
  13627. }
  13628. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  13629. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  13630. v := m.wx_wxid
  13631. if v == nil {
  13632. return
  13633. }
  13634. return *v, true
  13635. }
  13636. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  13637. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13639. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  13640. if !m.op.Is(OpUpdateOne) {
  13641. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  13642. }
  13643. if m.id == nil || m.oldValue == nil {
  13644. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  13645. }
  13646. oldValue, err := m.oldValue(ctx)
  13647. if err != nil {
  13648. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  13649. }
  13650. return oldValue.WxWxid, nil
  13651. }
  13652. // ClearWxWxid clears the value of the "wx_wxid" field.
  13653. func (m *MessageMutation) ClearWxWxid() {
  13654. m.wx_wxid = nil
  13655. m.clearedFields[message.FieldWxWxid] = struct{}{}
  13656. }
  13657. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  13658. func (m *MessageMutation) WxWxidCleared() bool {
  13659. _, ok := m.clearedFields[message.FieldWxWxid]
  13660. return ok
  13661. }
  13662. // ResetWxWxid resets all changes to the "wx_wxid" field.
  13663. func (m *MessageMutation) ResetWxWxid() {
  13664. m.wx_wxid = nil
  13665. delete(m.clearedFields, message.FieldWxWxid)
  13666. }
  13667. // SetWxid sets the "wxid" field.
  13668. func (m *MessageMutation) SetWxid(s string) {
  13669. m.wxid = &s
  13670. }
  13671. // Wxid returns the value of the "wxid" field in the mutation.
  13672. func (m *MessageMutation) Wxid() (r string, exists bool) {
  13673. v := m.wxid
  13674. if v == nil {
  13675. return
  13676. }
  13677. return *v, true
  13678. }
  13679. // OldWxid returns the old "wxid" field's value of the Message entity.
  13680. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13682. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  13683. if !m.op.Is(OpUpdateOne) {
  13684. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  13685. }
  13686. if m.id == nil || m.oldValue == nil {
  13687. return v, errors.New("OldWxid requires an ID field in the mutation")
  13688. }
  13689. oldValue, err := m.oldValue(ctx)
  13690. if err != nil {
  13691. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  13692. }
  13693. return oldValue.Wxid, nil
  13694. }
  13695. // ResetWxid resets all changes to the "wxid" field.
  13696. func (m *MessageMutation) ResetWxid() {
  13697. m.wxid = nil
  13698. }
  13699. // SetContent sets the "content" field.
  13700. func (m *MessageMutation) SetContent(s string) {
  13701. m.content = &s
  13702. }
  13703. // Content returns the value of the "content" field in the mutation.
  13704. func (m *MessageMutation) Content() (r string, exists bool) {
  13705. v := m.content
  13706. if v == nil {
  13707. return
  13708. }
  13709. return *v, true
  13710. }
  13711. // OldContent returns the old "content" field's value of the Message entity.
  13712. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13714. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  13715. if !m.op.Is(OpUpdateOne) {
  13716. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  13717. }
  13718. if m.id == nil || m.oldValue == nil {
  13719. return v, errors.New("OldContent requires an ID field in the mutation")
  13720. }
  13721. oldValue, err := m.oldValue(ctx)
  13722. if err != nil {
  13723. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  13724. }
  13725. return oldValue.Content, nil
  13726. }
  13727. // ResetContent resets all changes to the "content" field.
  13728. func (m *MessageMutation) ResetContent() {
  13729. m.content = nil
  13730. }
  13731. // Where appends a list predicates to the MessageMutation builder.
  13732. func (m *MessageMutation) Where(ps ...predicate.Message) {
  13733. m.predicates = append(m.predicates, ps...)
  13734. }
  13735. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  13736. // users can use type-assertion to append predicates that do not depend on any generated package.
  13737. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  13738. p := make([]predicate.Message, len(ps))
  13739. for i := range ps {
  13740. p[i] = ps[i]
  13741. }
  13742. m.Where(p...)
  13743. }
  13744. // Op returns the operation name.
  13745. func (m *MessageMutation) Op() Op {
  13746. return m.op
  13747. }
  13748. // SetOp allows setting the mutation operation.
  13749. func (m *MessageMutation) SetOp(op Op) {
  13750. m.op = op
  13751. }
  13752. // Type returns the node type of this mutation (Message).
  13753. func (m *MessageMutation) Type() string {
  13754. return m.typ
  13755. }
  13756. // Fields returns all fields that were changed during this mutation. Note that in
  13757. // order to get all numeric fields that were incremented/decremented, call
  13758. // AddedFields().
  13759. func (m *MessageMutation) Fields() []string {
  13760. fields := make([]string, 0, 3)
  13761. if m.wx_wxid != nil {
  13762. fields = append(fields, message.FieldWxWxid)
  13763. }
  13764. if m.wxid != nil {
  13765. fields = append(fields, message.FieldWxid)
  13766. }
  13767. if m.content != nil {
  13768. fields = append(fields, message.FieldContent)
  13769. }
  13770. return fields
  13771. }
  13772. // Field returns the value of a field with the given name. The second boolean
  13773. // return value indicates that this field was not set, or was not defined in the
  13774. // schema.
  13775. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  13776. switch name {
  13777. case message.FieldWxWxid:
  13778. return m.WxWxid()
  13779. case message.FieldWxid:
  13780. return m.Wxid()
  13781. case message.FieldContent:
  13782. return m.Content()
  13783. }
  13784. return nil, false
  13785. }
  13786. // OldField returns the old value of the field from the database. An error is
  13787. // returned if the mutation operation is not UpdateOne, or the query to the
  13788. // database failed.
  13789. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13790. switch name {
  13791. case message.FieldWxWxid:
  13792. return m.OldWxWxid(ctx)
  13793. case message.FieldWxid:
  13794. return m.OldWxid(ctx)
  13795. case message.FieldContent:
  13796. return m.OldContent(ctx)
  13797. }
  13798. return nil, fmt.Errorf("unknown Message field %s", name)
  13799. }
  13800. // SetField sets the value of a field with the given name. It returns an error if
  13801. // the field is not defined in the schema, or if the type mismatched the field
  13802. // type.
  13803. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  13804. switch name {
  13805. case message.FieldWxWxid:
  13806. v, ok := value.(string)
  13807. if !ok {
  13808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13809. }
  13810. m.SetWxWxid(v)
  13811. return nil
  13812. case message.FieldWxid:
  13813. v, ok := value.(string)
  13814. if !ok {
  13815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13816. }
  13817. m.SetWxid(v)
  13818. return nil
  13819. case message.FieldContent:
  13820. v, ok := value.(string)
  13821. if !ok {
  13822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13823. }
  13824. m.SetContent(v)
  13825. return nil
  13826. }
  13827. return fmt.Errorf("unknown Message field %s", name)
  13828. }
  13829. // AddedFields returns all numeric fields that were incremented/decremented during
  13830. // this mutation.
  13831. func (m *MessageMutation) AddedFields() []string {
  13832. return nil
  13833. }
  13834. // AddedField returns the numeric value that was incremented/decremented on a field
  13835. // with the given name. The second boolean return value indicates that this field
  13836. // was not set, or was not defined in the schema.
  13837. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  13838. return nil, false
  13839. }
  13840. // AddField adds the value to the field with the given name. It returns an error if
  13841. // the field is not defined in the schema, or if the type mismatched the field
  13842. // type.
  13843. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  13844. switch name {
  13845. }
  13846. return fmt.Errorf("unknown Message numeric field %s", name)
  13847. }
  13848. // ClearedFields returns all nullable fields that were cleared during this
  13849. // mutation.
  13850. func (m *MessageMutation) ClearedFields() []string {
  13851. var fields []string
  13852. if m.FieldCleared(message.FieldWxWxid) {
  13853. fields = append(fields, message.FieldWxWxid)
  13854. }
  13855. return fields
  13856. }
  13857. // FieldCleared returns a boolean indicating if a field with the given name was
  13858. // cleared in this mutation.
  13859. func (m *MessageMutation) FieldCleared(name string) bool {
  13860. _, ok := m.clearedFields[name]
  13861. return ok
  13862. }
  13863. // ClearField clears the value of the field with the given name. It returns an
  13864. // error if the field is not defined in the schema.
  13865. func (m *MessageMutation) ClearField(name string) error {
  13866. switch name {
  13867. case message.FieldWxWxid:
  13868. m.ClearWxWxid()
  13869. return nil
  13870. }
  13871. return fmt.Errorf("unknown Message nullable field %s", name)
  13872. }
  13873. // ResetField resets all changes in the mutation for the field with the given name.
  13874. // It returns an error if the field is not defined in the schema.
  13875. func (m *MessageMutation) ResetField(name string) error {
  13876. switch name {
  13877. case message.FieldWxWxid:
  13878. m.ResetWxWxid()
  13879. return nil
  13880. case message.FieldWxid:
  13881. m.ResetWxid()
  13882. return nil
  13883. case message.FieldContent:
  13884. m.ResetContent()
  13885. return nil
  13886. }
  13887. return fmt.Errorf("unknown Message field %s", name)
  13888. }
  13889. // AddedEdges returns all edge names that were set/added in this mutation.
  13890. func (m *MessageMutation) AddedEdges() []string {
  13891. edges := make([]string, 0, 0)
  13892. return edges
  13893. }
  13894. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13895. // name in this mutation.
  13896. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  13897. return nil
  13898. }
  13899. // RemovedEdges returns all edge names that were removed in this mutation.
  13900. func (m *MessageMutation) RemovedEdges() []string {
  13901. edges := make([]string, 0, 0)
  13902. return edges
  13903. }
  13904. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13905. // the given name in this mutation.
  13906. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  13907. return nil
  13908. }
  13909. // ClearedEdges returns all edge names that were cleared in this mutation.
  13910. func (m *MessageMutation) ClearedEdges() []string {
  13911. edges := make([]string, 0, 0)
  13912. return edges
  13913. }
  13914. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13915. // was cleared in this mutation.
  13916. func (m *MessageMutation) EdgeCleared(name string) bool {
  13917. return false
  13918. }
  13919. // ClearEdge clears the value of the edge with the given name. It returns an error
  13920. // if that edge is not defined in the schema.
  13921. func (m *MessageMutation) ClearEdge(name string) error {
  13922. return fmt.Errorf("unknown Message unique edge %s", name)
  13923. }
  13924. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13925. // It returns an error if the edge is not defined in the schema.
  13926. func (m *MessageMutation) ResetEdge(name string) error {
  13927. return fmt.Errorf("unknown Message edge %s", name)
  13928. }
  13929. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  13930. type MessageRecordsMutation struct {
  13931. config
  13932. op Op
  13933. typ string
  13934. id *uint64
  13935. created_at *time.Time
  13936. updated_at *time.Time
  13937. status *uint8
  13938. addstatus *int8
  13939. bot_wxid *string
  13940. contact_type *int
  13941. addcontact_type *int
  13942. contact_wxid *string
  13943. content_type *int
  13944. addcontent_type *int
  13945. content *string
  13946. meta *custom_types.Meta
  13947. error_detail *string
  13948. send_time *time.Time
  13949. source_type *int
  13950. addsource_type *int
  13951. organization_id *uint64
  13952. addorganization_id *int64
  13953. clearedFields map[string]struct{}
  13954. sop_stage *uint64
  13955. clearedsop_stage bool
  13956. sop_node *uint64
  13957. clearedsop_node bool
  13958. message_contact *uint64
  13959. clearedmessage_contact bool
  13960. done bool
  13961. oldValue func(context.Context) (*MessageRecords, error)
  13962. predicates []predicate.MessageRecords
  13963. }
  13964. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  13965. // messagerecordsOption allows management of the mutation configuration using functional options.
  13966. type messagerecordsOption func(*MessageRecordsMutation)
  13967. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  13968. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  13969. m := &MessageRecordsMutation{
  13970. config: c,
  13971. op: op,
  13972. typ: TypeMessageRecords,
  13973. clearedFields: make(map[string]struct{}),
  13974. }
  13975. for _, opt := range opts {
  13976. opt(m)
  13977. }
  13978. return m
  13979. }
  13980. // withMessageRecordsID sets the ID field of the mutation.
  13981. func withMessageRecordsID(id uint64) messagerecordsOption {
  13982. return func(m *MessageRecordsMutation) {
  13983. var (
  13984. err error
  13985. once sync.Once
  13986. value *MessageRecords
  13987. )
  13988. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  13989. once.Do(func() {
  13990. if m.done {
  13991. err = errors.New("querying old values post mutation is not allowed")
  13992. } else {
  13993. value, err = m.Client().MessageRecords.Get(ctx, id)
  13994. }
  13995. })
  13996. return value, err
  13997. }
  13998. m.id = &id
  13999. }
  14000. }
  14001. // withMessageRecords sets the old MessageRecords of the mutation.
  14002. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  14003. return func(m *MessageRecordsMutation) {
  14004. m.oldValue = func(context.Context) (*MessageRecords, error) {
  14005. return node, nil
  14006. }
  14007. m.id = &node.ID
  14008. }
  14009. }
  14010. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14011. // executed in a transaction (ent.Tx), a transactional client is returned.
  14012. func (m MessageRecordsMutation) Client() *Client {
  14013. client := &Client{config: m.config}
  14014. client.init()
  14015. return client
  14016. }
  14017. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14018. // it returns an error otherwise.
  14019. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  14020. if _, ok := m.driver.(*txDriver); !ok {
  14021. return nil, errors.New("ent: mutation is not running in a transaction")
  14022. }
  14023. tx := &Tx{config: m.config}
  14024. tx.init()
  14025. return tx, nil
  14026. }
  14027. // SetID sets the value of the id field. Note that this
  14028. // operation is only accepted on creation of MessageRecords entities.
  14029. func (m *MessageRecordsMutation) SetID(id uint64) {
  14030. m.id = &id
  14031. }
  14032. // ID returns the ID value in the mutation. Note that the ID is only available
  14033. // if it was provided to the builder or after it was returned from the database.
  14034. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  14035. if m.id == nil {
  14036. return
  14037. }
  14038. return *m.id, true
  14039. }
  14040. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14041. // That means, if the mutation is applied within a transaction with an isolation level such
  14042. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14043. // or updated by the mutation.
  14044. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  14045. switch {
  14046. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14047. id, exists := m.ID()
  14048. if exists {
  14049. return []uint64{id}, nil
  14050. }
  14051. fallthrough
  14052. case m.op.Is(OpUpdate | OpDelete):
  14053. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  14054. default:
  14055. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14056. }
  14057. }
  14058. // SetCreatedAt sets the "created_at" field.
  14059. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  14060. m.created_at = &t
  14061. }
  14062. // CreatedAt returns the value of the "created_at" field in the mutation.
  14063. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  14064. v := m.created_at
  14065. if v == nil {
  14066. return
  14067. }
  14068. return *v, true
  14069. }
  14070. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  14071. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14073. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14074. if !m.op.Is(OpUpdateOne) {
  14075. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14076. }
  14077. if m.id == nil || m.oldValue == nil {
  14078. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14079. }
  14080. oldValue, err := m.oldValue(ctx)
  14081. if err != nil {
  14082. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14083. }
  14084. return oldValue.CreatedAt, nil
  14085. }
  14086. // ResetCreatedAt resets all changes to the "created_at" field.
  14087. func (m *MessageRecordsMutation) ResetCreatedAt() {
  14088. m.created_at = nil
  14089. }
  14090. // SetUpdatedAt sets the "updated_at" field.
  14091. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  14092. m.updated_at = &t
  14093. }
  14094. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14095. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  14096. v := m.updated_at
  14097. if v == nil {
  14098. return
  14099. }
  14100. return *v, true
  14101. }
  14102. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  14103. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14105. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14106. if !m.op.Is(OpUpdateOne) {
  14107. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14108. }
  14109. if m.id == nil || m.oldValue == nil {
  14110. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14111. }
  14112. oldValue, err := m.oldValue(ctx)
  14113. if err != nil {
  14114. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14115. }
  14116. return oldValue.UpdatedAt, nil
  14117. }
  14118. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14119. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  14120. m.updated_at = nil
  14121. }
  14122. // SetStatus sets the "status" field.
  14123. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  14124. m.status = &u
  14125. m.addstatus = nil
  14126. }
  14127. // Status returns the value of the "status" field in the mutation.
  14128. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  14129. v := m.status
  14130. if v == nil {
  14131. return
  14132. }
  14133. return *v, true
  14134. }
  14135. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  14136. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14138. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14139. if !m.op.Is(OpUpdateOne) {
  14140. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14141. }
  14142. if m.id == nil || m.oldValue == nil {
  14143. return v, errors.New("OldStatus requires an ID field in the mutation")
  14144. }
  14145. oldValue, err := m.oldValue(ctx)
  14146. if err != nil {
  14147. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14148. }
  14149. return oldValue.Status, nil
  14150. }
  14151. // AddStatus adds u to the "status" field.
  14152. func (m *MessageRecordsMutation) AddStatus(u int8) {
  14153. if m.addstatus != nil {
  14154. *m.addstatus += u
  14155. } else {
  14156. m.addstatus = &u
  14157. }
  14158. }
  14159. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14160. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  14161. v := m.addstatus
  14162. if v == nil {
  14163. return
  14164. }
  14165. return *v, true
  14166. }
  14167. // ClearStatus clears the value of the "status" field.
  14168. func (m *MessageRecordsMutation) ClearStatus() {
  14169. m.status = nil
  14170. m.addstatus = nil
  14171. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  14172. }
  14173. // StatusCleared returns if the "status" field was cleared in this mutation.
  14174. func (m *MessageRecordsMutation) StatusCleared() bool {
  14175. _, ok := m.clearedFields[messagerecords.FieldStatus]
  14176. return ok
  14177. }
  14178. // ResetStatus resets all changes to the "status" field.
  14179. func (m *MessageRecordsMutation) ResetStatus() {
  14180. m.status = nil
  14181. m.addstatus = nil
  14182. delete(m.clearedFields, messagerecords.FieldStatus)
  14183. }
  14184. // SetBotWxid sets the "bot_wxid" field.
  14185. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  14186. m.bot_wxid = &s
  14187. }
  14188. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  14189. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  14190. v := m.bot_wxid
  14191. if v == nil {
  14192. return
  14193. }
  14194. return *v, true
  14195. }
  14196. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  14197. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14199. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  14200. if !m.op.Is(OpUpdateOne) {
  14201. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  14202. }
  14203. if m.id == nil || m.oldValue == nil {
  14204. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  14205. }
  14206. oldValue, err := m.oldValue(ctx)
  14207. if err != nil {
  14208. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  14209. }
  14210. return oldValue.BotWxid, nil
  14211. }
  14212. // ResetBotWxid resets all changes to the "bot_wxid" field.
  14213. func (m *MessageRecordsMutation) ResetBotWxid() {
  14214. m.bot_wxid = nil
  14215. }
  14216. // SetContactID sets the "contact_id" field.
  14217. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  14218. m.message_contact = &u
  14219. }
  14220. // ContactID returns the value of the "contact_id" field in the mutation.
  14221. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  14222. v := m.message_contact
  14223. if v == nil {
  14224. return
  14225. }
  14226. return *v, true
  14227. }
  14228. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  14229. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14231. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14232. if !m.op.Is(OpUpdateOne) {
  14233. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14234. }
  14235. if m.id == nil || m.oldValue == nil {
  14236. return v, errors.New("OldContactID requires an ID field in the mutation")
  14237. }
  14238. oldValue, err := m.oldValue(ctx)
  14239. if err != nil {
  14240. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14241. }
  14242. return oldValue.ContactID, nil
  14243. }
  14244. // ClearContactID clears the value of the "contact_id" field.
  14245. func (m *MessageRecordsMutation) ClearContactID() {
  14246. m.message_contact = nil
  14247. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14248. }
  14249. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  14250. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  14251. _, ok := m.clearedFields[messagerecords.FieldContactID]
  14252. return ok
  14253. }
  14254. // ResetContactID resets all changes to the "contact_id" field.
  14255. func (m *MessageRecordsMutation) ResetContactID() {
  14256. m.message_contact = nil
  14257. delete(m.clearedFields, messagerecords.FieldContactID)
  14258. }
  14259. // SetContactType sets the "contact_type" field.
  14260. func (m *MessageRecordsMutation) SetContactType(i int) {
  14261. m.contact_type = &i
  14262. m.addcontact_type = nil
  14263. }
  14264. // ContactType returns the value of the "contact_type" field in the mutation.
  14265. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  14266. v := m.contact_type
  14267. if v == nil {
  14268. return
  14269. }
  14270. return *v, true
  14271. }
  14272. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  14273. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14275. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  14276. if !m.op.Is(OpUpdateOne) {
  14277. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  14278. }
  14279. if m.id == nil || m.oldValue == nil {
  14280. return v, errors.New("OldContactType requires an ID field in the mutation")
  14281. }
  14282. oldValue, err := m.oldValue(ctx)
  14283. if err != nil {
  14284. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  14285. }
  14286. return oldValue.ContactType, nil
  14287. }
  14288. // AddContactType adds i to the "contact_type" field.
  14289. func (m *MessageRecordsMutation) AddContactType(i int) {
  14290. if m.addcontact_type != nil {
  14291. *m.addcontact_type += i
  14292. } else {
  14293. m.addcontact_type = &i
  14294. }
  14295. }
  14296. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  14297. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  14298. v := m.addcontact_type
  14299. if v == nil {
  14300. return
  14301. }
  14302. return *v, true
  14303. }
  14304. // ResetContactType resets all changes to the "contact_type" field.
  14305. func (m *MessageRecordsMutation) ResetContactType() {
  14306. m.contact_type = nil
  14307. m.addcontact_type = nil
  14308. }
  14309. // SetContactWxid sets the "contact_wxid" field.
  14310. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  14311. m.contact_wxid = &s
  14312. }
  14313. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  14314. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  14315. v := m.contact_wxid
  14316. if v == nil {
  14317. return
  14318. }
  14319. return *v, true
  14320. }
  14321. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  14322. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14324. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  14325. if !m.op.Is(OpUpdateOne) {
  14326. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  14327. }
  14328. if m.id == nil || m.oldValue == nil {
  14329. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  14330. }
  14331. oldValue, err := m.oldValue(ctx)
  14332. if err != nil {
  14333. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  14334. }
  14335. return oldValue.ContactWxid, nil
  14336. }
  14337. // ResetContactWxid resets all changes to the "contact_wxid" field.
  14338. func (m *MessageRecordsMutation) ResetContactWxid() {
  14339. m.contact_wxid = nil
  14340. }
  14341. // SetContentType sets the "content_type" field.
  14342. func (m *MessageRecordsMutation) SetContentType(i int) {
  14343. m.content_type = &i
  14344. m.addcontent_type = nil
  14345. }
  14346. // ContentType returns the value of the "content_type" field in the mutation.
  14347. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  14348. v := m.content_type
  14349. if v == nil {
  14350. return
  14351. }
  14352. return *v, true
  14353. }
  14354. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  14355. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14357. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  14358. if !m.op.Is(OpUpdateOne) {
  14359. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  14360. }
  14361. if m.id == nil || m.oldValue == nil {
  14362. return v, errors.New("OldContentType requires an ID field in the mutation")
  14363. }
  14364. oldValue, err := m.oldValue(ctx)
  14365. if err != nil {
  14366. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  14367. }
  14368. return oldValue.ContentType, nil
  14369. }
  14370. // AddContentType adds i to the "content_type" field.
  14371. func (m *MessageRecordsMutation) AddContentType(i int) {
  14372. if m.addcontent_type != nil {
  14373. *m.addcontent_type += i
  14374. } else {
  14375. m.addcontent_type = &i
  14376. }
  14377. }
  14378. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  14379. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  14380. v := m.addcontent_type
  14381. if v == nil {
  14382. return
  14383. }
  14384. return *v, true
  14385. }
  14386. // ResetContentType resets all changes to the "content_type" field.
  14387. func (m *MessageRecordsMutation) ResetContentType() {
  14388. m.content_type = nil
  14389. m.addcontent_type = nil
  14390. }
  14391. // SetContent sets the "content" field.
  14392. func (m *MessageRecordsMutation) SetContent(s string) {
  14393. m.content = &s
  14394. }
  14395. // Content returns the value of the "content" field in the mutation.
  14396. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  14397. v := m.content
  14398. if v == nil {
  14399. return
  14400. }
  14401. return *v, true
  14402. }
  14403. // OldContent returns the old "content" field's value of the MessageRecords entity.
  14404. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14406. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  14407. if !m.op.Is(OpUpdateOne) {
  14408. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  14409. }
  14410. if m.id == nil || m.oldValue == nil {
  14411. return v, errors.New("OldContent requires an ID field in the mutation")
  14412. }
  14413. oldValue, err := m.oldValue(ctx)
  14414. if err != nil {
  14415. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  14416. }
  14417. return oldValue.Content, nil
  14418. }
  14419. // ResetContent resets all changes to the "content" field.
  14420. func (m *MessageRecordsMutation) ResetContent() {
  14421. m.content = nil
  14422. }
  14423. // SetMeta sets the "meta" field.
  14424. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  14425. m.meta = &ct
  14426. }
  14427. // Meta returns the value of the "meta" field in the mutation.
  14428. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  14429. v := m.meta
  14430. if v == nil {
  14431. return
  14432. }
  14433. return *v, true
  14434. }
  14435. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  14436. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14438. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  14439. if !m.op.Is(OpUpdateOne) {
  14440. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  14441. }
  14442. if m.id == nil || m.oldValue == nil {
  14443. return v, errors.New("OldMeta requires an ID field in the mutation")
  14444. }
  14445. oldValue, err := m.oldValue(ctx)
  14446. if err != nil {
  14447. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  14448. }
  14449. return oldValue.Meta, nil
  14450. }
  14451. // ClearMeta clears the value of the "meta" field.
  14452. func (m *MessageRecordsMutation) ClearMeta() {
  14453. m.meta = nil
  14454. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  14455. }
  14456. // MetaCleared returns if the "meta" field was cleared in this mutation.
  14457. func (m *MessageRecordsMutation) MetaCleared() bool {
  14458. _, ok := m.clearedFields[messagerecords.FieldMeta]
  14459. return ok
  14460. }
  14461. // ResetMeta resets all changes to the "meta" field.
  14462. func (m *MessageRecordsMutation) ResetMeta() {
  14463. m.meta = nil
  14464. delete(m.clearedFields, messagerecords.FieldMeta)
  14465. }
  14466. // SetErrorDetail sets the "error_detail" field.
  14467. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  14468. m.error_detail = &s
  14469. }
  14470. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  14471. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  14472. v := m.error_detail
  14473. if v == nil {
  14474. return
  14475. }
  14476. return *v, true
  14477. }
  14478. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  14479. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14481. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  14482. if !m.op.Is(OpUpdateOne) {
  14483. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  14484. }
  14485. if m.id == nil || m.oldValue == nil {
  14486. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  14487. }
  14488. oldValue, err := m.oldValue(ctx)
  14489. if err != nil {
  14490. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  14491. }
  14492. return oldValue.ErrorDetail, nil
  14493. }
  14494. // ResetErrorDetail resets all changes to the "error_detail" field.
  14495. func (m *MessageRecordsMutation) ResetErrorDetail() {
  14496. m.error_detail = nil
  14497. }
  14498. // SetSendTime sets the "send_time" field.
  14499. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  14500. m.send_time = &t
  14501. }
  14502. // SendTime returns the value of the "send_time" field in the mutation.
  14503. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  14504. v := m.send_time
  14505. if v == nil {
  14506. return
  14507. }
  14508. return *v, true
  14509. }
  14510. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  14511. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14513. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  14514. if !m.op.Is(OpUpdateOne) {
  14515. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  14516. }
  14517. if m.id == nil || m.oldValue == nil {
  14518. return v, errors.New("OldSendTime requires an ID field in the mutation")
  14519. }
  14520. oldValue, err := m.oldValue(ctx)
  14521. if err != nil {
  14522. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  14523. }
  14524. return oldValue.SendTime, nil
  14525. }
  14526. // ClearSendTime clears the value of the "send_time" field.
  14527. func (m *MessageRecordsMutation) ClearSendTime() {
  14528. m.send_time = nil
  14529. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  14530. }
  14531. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  14532. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  14533. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  14534. return ok
  14535. }
  14536. // ResetSendTime resets all changes to the "send_time" field.
  14537. func (m *MessageRecordsMutation) ResetSendTime() {
  14538. m.send_time = nil
  14539. delete(m.clearedFields, messagerecords.FieldSendTime)
  14540. }
  14541. // SetSourceType sets the "source_type" field.
  14542. func (m *MessageRecordsMutation) SetSourceType(i int) {
  14543. m.source_type = &i
  14544. m.addsource_type = nil
  14545. }
  14546. // SourceType returns the value of the "source_type" field in the mutation.
  14547. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  14548. v := m.source_type
  14549. if v == nil {
  14550. return
  14551. }
  14552. return *v, true
  14553. }
  14554. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  14555. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14557. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  14558. if !m.op.Is(OpUpdateOne) {
  14559. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  14560. }
  14561. if m.id == nil || m.oldValue == nil {
  14562. return v, errors.New("OldSourceType requires an ID field in the mutation")
  14563. }
  14564. oldValue, err := m.oldValue(ctx)
  14565. if err != nil {
  14566. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  14567. }
  14568. return oldValue.SourceType, nil
  14569. }
  14570. // AddSourceType adds i to the "source_type" field.
  14571. func (m *MessageRecordsMutation) AddSourceType(i int) {
  14572. if m.addsource_type != nil {
  14573. *m.addsource_type += i
  14574. } else {
  14575. m.addsource_type = &i
  14576. }
  14577. }
  14578. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  14579. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  14580. v := m.addsource_type
  14581. if v == nil {
  14582. return
  14583. }
  14584. return *v, true
  14585. }
  14586. // ResetSourceType resets all changes to the "source_type" field.
  14587. func (m *MessageRecordsMutation) ResetSourceType() {
  14588. m.source_type = nil
  14589. m.addsource_type = nil
  14590. }
  14591. // SetSourceID sets the "source_id" field.
  14592. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  14593. m.sop_stage = &u
  14594. }
  14595. // SourceID returns the value of the "source_id" field in the mutation.
  14596. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  14597. v := m.sop_stage
  14598. if v == nil {
  14599. return
  14600. }
  14601. return *v, true
  14602. }
  14603. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  14604. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14606. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  14607. if !m.op.Is(OpUpdateOne) {
  14608. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  14609. }
  14610. if m.id == nil || m.oldValue == nil {
  14611. return v, errors.New("OldSourceID requires an ID field in the mutation")
  14612. }
  14613. oldValue, err := m.oldValue(ctx)
  14614. if err != nil {
  14615. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  14616. }
  14617. return oldValue.SourceID, nil
  14618. }
  14619. // ClearSourceID clears the value of the "source_id" field.
  14620. func (m *MessageRecordsMutation) ClearSourceID() {
  14621. m.sop_stage = nil
  14622. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  14623. }
  14624. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  14625. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  14626. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  14627. return ok
  14628. }
  14629. // ResetSourceID resets all changes to the "source_id" field.
  14630. func (m *MessageRecordsMutation) ResetSourceID() {
  14631. m.sop_stage = nil
  14632. delete(m.clearedFields, messagerecords.FieldSourceID)
  14633. }
  14634. // SetSubSourceID sets the "sub_source_id" field.
  14635. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  14636. m.sop_node = &u
  14637. }
  14638. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  14639. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  14640. v := m.sop_node
  14641. if v == nil {
  14642. return
  14643. }
  14644. return *v, true
  14645. }
  14646. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  14647. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14649. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  14650. if !m.op.Is(OpUpdateOne) {
  14651. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  14652. }
  14653. if m.id == nil || m.oldValue == nil {
  14654. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  14655. }
  14656. oldValue, err := m.oldValue(ctx)
  14657. if err != nil {
  14658. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  14659. }
  14660. return oldValue.SubSourceID, nil
  14661. }
  14662. // ClearSubSourceID clears the value of the "sub_source_id" field.
  14663. func (m *MessageRecordsMutation) ClearSubSourceID() {
  14664. m.sop_node = nil
  14665. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14666. }
  14667. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  14668. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  14669. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  14670. return ok
  14671. }
  14672. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  14673. func (m *MessageRecordsMutation) ResetSubSourceID() {
  14674. m.sop_node = nil
  14675. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  14676. }
  14677. // SetOrganizationID sets the "organization_id" field.
  14678. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  14679. m.organization_id = &u
  14680. m.addorganization_id = nil
  14681. }
  14682. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14683. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  14684. v := m.organization_id
  14685. if v == nil {
  14686. return
  14687. }
  14688. return *v, true
  14689. }
  14690. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  14691. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14693. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14694. if !m.op.Is(OpUpdateOne) {
  14695. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14696. }
  14697. if m.id == nil || m.oldValue == nil {
  14698. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14699. }
  14700. oldValue, err := m.oldValue(ctx)
  14701. if err != nil {
  14702. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14703. }
  14704. return oldValue.OrganizationID, nil
  14705. }
  14706. // AddOrganizationID adds u to the "organization_id" field.
  14707. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  14708. if m.addorganization_id != nil {
  14709. *m.addorganization_id += u
  14710. } else {
  14711. m.addorganization_id = &u
  14712. }
  14713. }
  14714. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14715. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  14716. v := m.addorganization_id
  14717. if v == nil {
  14718. return
  14719. }
  14720. return *v, true
  14721. }
  14722. // ClearOrganizationID clears the value of the "organization_id" field.
  14723. func (m *MessageRecordsMutation) ClearOrganizationID() {
  14724. m.organization_id = nil
  14725. m.addorganization_id = nil
  14726. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  14727. }
  14728. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14729. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  14730. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  14731. return ok
  14732. }
  14733. // ResetOrganizationID resets all changes to the "organization_id" field.
  14734. func (m *MessageRecordsMutation) ResetOrganizationID() {
  14735. m.organization_id = nil
  14736. m.addorganization_id = nil
  14737. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  14738. }
  14739. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  14740. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  14741. m.sop_stage = &id
  14742. }
  14743. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  14744. func (m *MessageRecordsMutation) ClearSopStage() {
  14745. m.clearedsop_stage = true
  14746. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  14747. }
  14748. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  14749. func (m *MessageRecordsMutation) SopStageCleared() bool {
  14750. return m.SourceIDCleared() || m.clearedsop_stage
  14751. }
  14752. // SopStageID returns the "sop_stage" edge ID in the mutation.
  14753. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  14754. if m.sop_stage != nil {
  14755. return *m.sop_stage, true
  14756. }
  14757. return
  14758. }
  14759. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  14760. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14761. // SopStageID instead. It exists only for internal usage by the builders.
  14762. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  14763. if id := m.sop_stage; id != nil {
  14764. ids = append(ids, *id)
  14765. }
  14766. return
  14767. }
  14768. // ResetSopStage resets all changes to the "sop_stage" edge.
  14769. func (m *MessageRecordsMutation) ResetSopStage() {
  14770. m.sop_stage = nil
  14771. m.clearedsop_stage = false
  14772. }
  14773. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  14774. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  14775. m.sop_node = &id
  14776. }
  14777. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  14778. func (m *MessageRecordsMutation) ClearSopNode() {
  14779. m.clearedsop_node = true
  14780. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14781. }
  14782. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  14783. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  14784. return m.SubSourceIDCleared() || m.clearedsop_node
  14785. }
  14786. // SopNodeID returns the "sop_node" edge ID in the mutation.
  14787. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  14788. if m.sop_node != nil {
  14789. return *m.sop_node, true
  14790. }
  14791. return
  14792. }
  14793. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  14794. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14795. // SopNodeID instead. It exists only for internal usage by the builders.
  14796. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  14797. if id := m.sop_node; id != nil {
  14798. ids = append(ids, *id)
  14799. }
  14800. return
  14801. }
  14802. // ResetSopNode resets all changes to the "sop_node" edge.
  14803. func (m *MessageRecordsMutation) ResetSopNode() {
  14804. m.sop_node = nil
  14805. m.clearedsop_node = false
  14806. }
  14807. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  14808. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  14809. m.message_contact = &id
  14810. }
  14811. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  14812. func (m *MessageRecordsMutation) ClearMessageContact() {
  14813. m.clearedmessage_contact = true
  14814. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14815. }
  14816. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  14817. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  14818. return m.ContactIDCleared() || m.clearedmessage_contact
  14819. }
  14820. // MessageContactID returns the "message_contact" edge ID in the mutation.
  14821. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  14822. if m.message_contact != nil {
  14823. return *m.message_contact, true
  14824. }
  14825. return
  14826. }
  14827. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  14828. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14829. // MessageContactID instead. It exists only for internal usage by the builders.
  14830. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  14831. if id := m.message_contact; id != nil {
  14832. ids = append(ids, *id)
  14833. }
  14834. return
  14835. }
  14836. // ResetMessageContact resets all changes to the "message_contact" edge.
  14837. func (m *MessageRecordsMutation) ResetMessageContact() {
  14838. m.message_contact = nil
  14839. m.clearedmessage_contact = false
  14840. }
  14841. // Where appends a list predicates to the MessageRecordsMutation builder.
  14842. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  14843. m.predicates = append(m.predicates, ps...)
  14844. }
  14845. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  14846. // users can use type-assertion to append predicates that do not depend on any generated package.
  14847. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  14848. p := make([]predicate.MessageRecords, len(ps))
  14849. for i := range ps {
  14850. p[i] = ps[i]
  14851. }
  14852. m.Where(p...)
  14853. }
  14854. // Op returns the operation name.
  14855. func (m *MessageRecordsMutation) Op() Op {
  14856. return m.op
  14857. }
  14858. // SetOp allows setting the mutation operation.
  14859. func (m *MessageRecordsMutation) SetOp(op Op) {
  14860. m.op = op
  14861. }
  14862. // Type returns the node type of this mutation (MessageRecords).
  14863. func (m *MessageRecordsMutation) Type() string {
  14864. return m.typ
  14865. }
  14866. // Fields returns all fields that were changed during this mutation. Note that in
  14867. // order to get all numeric fields that were incremented/decremented, call
  14868. // AddedFields().
  14869. func (m *MessageRecordsMutation) Fields() []string {
  14870. fields := make([]string, 0, 16)
  14871. if m.created_at != nil {
  14872. fields = append(fields, messagerecords.FieldCreatedAt)
  14873. }
  14874. if m.updated_at != nil {
  14875. fields = append(fields, messagerecords.FieldUpdatedAt)
  14876. }
  14877. if m.status != nil {
  14878. fields = append(fields, messagerecords.FieldStatus)
  14879. }
  14880. if m.bot_wxid != nil {
  14881. fields = append(fields, messagerecords.FieldBotWxid)
  14882. }
  14883. if m.message_contact != nil {
  14884. fields = append(fields, messagerecords.FieldContactID)
  14885. }
  14886. if m.contact_type != nil {
  14887. fields = append(fields, messagerecords.FieldContactType)
  14888. }
  14889. if m.contact_wxid != nil {
  14890. fields = append(fields, messagerecords.FieldContactWxid)
  14891. }
  14892. if m.content_type != nil {
  14893. fields = append(fields, messagerecords.FieldContentType)
  14894. }
  14895. if m.content != nil {
  14896. fields = append(fields, messagerecords.FieldContent)
  14897. }
  14898. if m.meta != nil {
  14899. fields = append(fields, messagerecords.FieldMeta)
  14900. }
  14901. if m.error_detail != nil {
  14902. fields = append(fields, messagerecords.FieldErrorDetail)
  14903. }
  14904. if m.send_time != nil {
  14905. fields = append(fields, messagerecords.FieldSendTime)
  14906. }
  14907. if m.source_type != nil {
  14908. fields = append(fields, messagerecords.FieldSourceType)
  14909. }
  14910. if m.sop_stage != nil {
  14911. fields = append(fields, messagerecords.FieldSourceID)
  14912. }
  14913. if m.sop_node != nil {
  14914. fields = append(fields, messagerecords.FieldSubSourceID)
  14915. }
  14916. if m.organization_id != nil {
  14917. fields = append(fields, messagerecords.FieldOrganizationID)
  14918. }
  14919. return fields
  14920. }
  14921. // Field returns the value of a field with the given name. The second boolean
  14922. // return value indicates that this field was not set, or was not defined in the
  14923. // schema.
  14924. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  14925. switch name {
  14926. case messagerecords.FieldCreatedAt:
  14927. return m.CreatedAt()
  14928. case messagerecords.FieldUpdatedAt:
  14929. return m.UpdatedAt()
  14930. case messagerecords.FieldStatus:
  14931. return m.Status()
  14932. case messagerecords.FieldBotWxid:
  14933. return m.BotWxid()
  14934. case messagerecords.FieldContactID:
  14935. return m.ContactID()
  14936. case messagerecords.FieldContactType:
  14937. return m.ContactType()
  14938. case messagerecords.FieldContactWxid:
  14939. return m.ContactWxid()
  14940. case messagerecords.FieldContentType:
  14941. return m.ContentType()
  14942. case messagerecords.FieldContent:
  14943. return m.Content()
  14944. case messagerecords.FieldMeta:
  14945. return m.Meta()
  14946. case messagerecords.FieldErrorDetail:
  14947. return m.ErrorDetail()
  14948. case messagerecords.FieldSendTime:
  14949. return m.SendTime()
  14950. case messagerecords.FieldSourceType:
  14951. return m.SourceType()
  14952. case messagerecords.FieldSourceID:
  14953. return m.SourceID()
  14954. case messagerecords.FieldSubSourceID:
  14955. return m.SubSourceID()
  14956. case messagerecords.FieldOrganizationID:
  14957. return m.OrganizationID()
  14958. }
  14959. return nil, false
  14960. }
  14961. // OldField returns the old value of the field from the database. An error is
  14962. // returned if the mutation operation is not UpdateOne, or the query to the
  14963. // database failed.
  14964. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14965. switch name {
  14966. case messagerecords.FieldCreatedAt:
  14967. return m.OldCreatedAt(ctx)
  14968. case messagerecords.FieldUpdatedAt:
  14969. return m.OldUpdatedAt(ctx)
  14970. case messagerecords.FieldStatus:
  14971. return m.OldStatus(ctx)
  14972. case messagerecords.FieldBotWxid:
  14973. return m.OldBotWxid(ctx)
  14974. case messagerecords.FieldContactID:
  14975. return m.OldContactID(ctx)
  14976. case messagerecords.FieldContactType:
  14977. return m.OldContactType(ctx)
  14978. case messagerecords.FieldContactWxid:
  14979. return m.OldContactWxid(ctx)
  14980. case messagerecords.FieldContentType:
  14981. return m.OldContentType(ctx)
  14982. case messagerecords.FieldContent:
  14983. return m.OldContent(ctx)
  14984. case messagerecords.FieldMeta:
  14985. return m.OldMeta(ctx)
  14986. case messagerecords.FieldErrorDetail:
  14987. return m.OldErrorDetail(ctx)
  14988. case messagerecords.FieldSendTime:
  14989. return m.OldSendTime(ctx)
  14990. case messagerecords.FieldSourceType:
  14991. return m.OldSourceType(ctx)
  14992. case messagerecords.FieldSourceID:
  14993. return m.OldSourceID(ctx)
  14994. case messagerecords.FieldSubSourceID:
  14995. return m.OldSubSourceID(ctx)
  14996. case messagerecords.FieldOrganizationID:
  14997. return m.OldOrganizationID(ctx)
  14998. }
  14999. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  15000. }
  15001. // SetField sets the value of a field with the given name. It returns an error if
  15002. // the field is not defined in the schema, or if the type mismatched the field
  15003. // type.
  15004. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  15005. switch name {
  15006. case messagerecords.FieldCreatedAt:
  15007. v, ok := value.(time.Time)
  15008. if !ok {
  15009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15010. }
  15011. m.SetCreatedAt(v)
  15012. return nil
  15013. case messagerecords.FieldUpdatedAt:
  15014. v, ok := value.(time.Time)
  15015. if !ok {
  15016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15017. }
  15018. m.SetUpdatedAt(v)
  15019. return nil
  15020. case messagerecords.FieldStatus:
  15021. v, ok := value.(uint8)
  15022. if !ok {
  15023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15024. }
  15025. m.SetStatus(v)
  15026. return nil
  15027. case messagerecords.FieldBotWxid:
  15028. v, ok := value.(string)
  15029. if !ok {
  15030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15031. }
  15032. m.SetBotWxid(v)
  15033. return nil
  15034. case messagerecords.FieldContactID:
  15035. v, ok := value.(uint64)
  15036. if !ok {
  15037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15038. }
  15039. m.SetContactID(v)
  15040. return nil
  15041. case messagerecords.FieldContactType:
  15042. v, ok := value.(int)
  15043. if !ok {
  15044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15045. }
  15046. m.SetContactType(v)
  15047. return nil
  15048. case messagerecords.FieldContactWxid:
  15049. v, ok := value.(string)
  15050. if !ok {
  15051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15052. }
  15053. m.SetContactWxid(v)
  15054. return nil
  15055. case messagerecords.FieldContentType:
  15056. v, ok := value.(int)
  15057. if !ok {
  15058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15059. }
  15060. m.SetContentType(v)
  15061. return nil
  15062. case messagerecords.FieldContent:
  15063. v, ok := value.(string)
  15064. if !ok {
  15065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15066. }
  15067. m.SetContent(v)
  15068. return nil
  15069. case messagerecords.FieldMeta:
  15070. v, ok := value.(custom_types.Meta)
  15071. if !ok {
  15072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15073. }
  15074. m.SetMeta(v)
  15075. return nil
  15076. case messagerecords.FieldErrorDetail:
  15077. v, ok := value.(string)
  15078. if !ok {
  15079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15080. }
  15081. m.SetErrorDetail(v)
  15082. return nil
  15083. case messagerecords.FieldSendTime:
  15084. v, ok := value.(time.Time)
  15085. if !ok {
  15086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15087. }
  15088. m.SetSendTime(v)
  15089. return nil
  15090. case messagerecords.FieldSourceType:
  15091. v, ok := value.(int)
  15092. if !ok {
  15093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15094. }
  15095. m.SetSourceType(v)
  15096. return nil
  15097. case messagerecords.FieldSourceID:
  15098. v, ok := value.(uint64)
  15099. if !ok {
  15100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15101. }
  15102. m.SetSourceID(v)
  15103. return nil
  15104. case messagerecords.FieldSubSourceID:
  15105. v, ok := value.(uint64)
  15106. if !ok {
  15107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15108. }
  15109. m.SetSubSourceID(v)
  15110. return nil
  15111. case messagerecords.FieldOrganizationID:
  15112. v, ok := value.(uint64)
  15113. if !ok {
  15114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15115. }
  15116. m.SetOrganizationID(v)
  15117. return nil
  15118. }
  15119. return fmt.Errorf("unknown MessageRecords field %s", name)
  15120. }
  15121. // AddedFields returns all numeric fields that were incremented/decremented during
  15122. // this mutation.
  15123. func (m *MessageRecordsMutation) AddedFields() []string {
  15124. var fields []string
  15125. if m.addstatus != nil {
  15126. fields = append(fields, messagerecords.FieldStatus)
  15127. }
  15128. if m.addcontact_type != nil {
  15129. fields = append(fields, messagerecords.FieldContactType)
  15130. }
  15131. if m.addcontent_type != nil {
  15132. fields = append(fields, messagerecords.FieldContentType)
  15133. }
  15134. if m.addsource_type != nil {
  15135. fields = append(fields, messagerecords.FieldSourceType)
  15136. }
  15137. if m.addorganization_id != nil {
  15138. fields = append(fields, messagerecords.FieldOrganizationID)
  15139. }
  15140. return fields
  15141. }
  15142. // AddedField returns the numeric value that was incremented/decremented on a field
  15143. // with the given name. The second boolean return value indicates that this field
  15144. // was not set, or was not defined in the schema.
  15145. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  15146. switch name {
  15147. case messagerecords.FieldStatus:
  15148. return m.AddedStatus()
  15149. case messagerecords.FieldContactType:
  15150. return m.AddedContactType()
  15151. case messagerecords.FieldContentType:
  15152. return m.AddedContentType()
  15153. case messagerecords.FieldSourceType:
  15154. return m.AddedSourceType()
  15155. case messagerecords.FieldOrganizationID:
  15156. return m.AddedOrganizationID()
  15157. }
  15158. return nil, false
  15159. }
  15160. // AddField adds the value to the field with the given name. It returns an error if
  15161. // the field is not defined in the schema, or if the type mismatched the field
  15162. // type.
  15163. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  15164. switch name {
  15165. case messagerecords.FieldStatus:
  15166. v, ok := value.(int8)
  15167. if !ok {
  15168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15169. }
  15170. m.AddStatus(v)
  15171. return nil
  15172. case messagerecords.FieldContactType:
  15173. v, ok := value.(int)
  15174. if !ok {
  15175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15176. }
  15177. m.AddContactType(v)
  15178. return nil
  15179. case messagerecords.FieldContentType:
  15180. v, ok := value.(int)
  15181. if !ok {
  15182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15183. }
  15184. m.AddContentType(v)
  15185. return nil
  15186. case messagerecords.FieldSourceType:
  15187. v, ok := value.(int)
  15188. if !ok {
  15189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15190. }
  15191. m.AddSourceType(v)
  15192. return nil
  15193. case messagerecords.FieldOrganizationID:
  15194. v, ok := value.(int64)
  15195. if !ok {
  15196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15197. }
  15198. m.AddOrganizationID(v)
  15199. return nil
  15200. }
  15201. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  15202. }
  15203. // ClearedFields returns all nullable fields that were cleared during this
  15204. // mutation.
  15205. func (m *MessageRecordsMutation) ClearedFields() []string {
  15206. var fields []string
  15207. if m.FieldCleared(messagerecords.FieldStatus) {
  15208. fields = append(fields, messagerecords.FieldStatus)
  15209. }
  15210. if m.FieldCleared(messagerecords.FieldContactID) {
  15211. fields = append(fields, messagerecords.FieldContactID)
  15212. }
  15213. if m.FieldCleared(messagerecords.FieldMeta) {
  15214. fields = append(fields, messagerecords.FieldMeta)
  15215. }
  15216. if m.FieldCleared(messagerecords.FieldSendTime) {
  15217. fields = append(fields, messagerecords.FieldSendTime)
  15218. }
  15219. if m.FieldCleared(messagerecords.FieldSourceID) {
  15220. fields = append(fields, messagerecords.FieldSourceID)
  15221. }
  15222. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  15223. fields = append(fields, messagerecords.FieldSubSourceID)
  15224. }
  15225. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  15226. fields = append(fields, messagerecords.FieldOrganizationID)
  15227. }
  15228. return fields
  15229. }
  15230. // FieldCleared returns a boolean indicating if a field with the given name was
  15231. // cleared in this mutation.
  15232. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  15233. _, ok := m.clearedFields[name]
  15234. return ok
  15235. }
  15236. // ClearField clears the value of the field with the given name. It returns an
  15237. // error if the field is not defined in the schema.
  15238. func (m *MessageRecordsMutation) ClearField(name string) error {
  15239. switch name {
  15240. case messagerecords.FieldStatus:
  15241. m.ClearStatus()
  15242. return nil
  15243. case messagerecords.FieldContactID:
  15244. m.ClearContactID()
  15245. return nil
  15246. case messagerecords.FieldMeta:
  15247. m.ClearMeta()
  15248. return nil
  15249. case messagerecords.FieldSendTime:
  15250. m.ClearSendTime()
  15251. return nil
  15252. case messagerecords.FieldSourceID:
  15253. m.ClearSourceID()
  15254. return nil
  15255. case messagerecords.FieldSubSourceID:
  15256. m.ClearSubSourceID()
  15257. return nil
  15258. case messagerecords.FieldOrganizationID:
  15259. m.ClearOrganizationID()
  15260. return nil
  15261. }
  15262. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  15263. }
  15264. // ResetField resets all changes in the mutation for the field with the given name.
  15265. // It returns an error if the field is not defined in the schema.
  15266. func (m *MessageRecordsMutation) ResetField(name string) error {
  15267. switch name {
  15268. case messagerecords.FieldCreatedAt:
  15269. m.ResetCreatedAt()
  15270. return nil
  15271. case messagerecords.FieldUpdatedAt:
  15272. m.ResetUpdatedAt()
  15273. return nil
  15274. case messagerecords.FieldStatus:
  15275. m.ResetStatus()
  15276. return nil
  15277. case messagerecords.FieldBotWxid:
  15278. m.ResetBotWxid()
  15279. return nil
  15280. case messagerecords.FieldContactID:
  15281. m.ResetContactID()
  15282. return nil
  15283. case messagerecords.FieldContactType:
  15284. m.ResetContactType()
  15285. return nil
  15286. case messagerecords.FieldContactWxid:
  15287. m.ResetContactWxid()
  15288. return nil
  15289. case messagerecords.FieldContentType:
  15290. m.ResetContentType()
  15291. return nil
  15292. case messagerecords.FieldContent:
  15293. m.ResetContent()
  15294. return nil
  15295. case messagerecords.FieldMeta:
  15296. m.ResetMeta()
  15297. return nil
  15298. case messagerecords.FieldErrorDetail:
  15299. m.ResetErrorDetail()
  15300. return nil
  15301. case messagerecords.FieldSendTime:
  15302. m.ResetSendTime()
  15303. return nil
  15304. case messagerecords.FieldSourceType:
  15305. m.ResetSourceType()
  15306. return nil
  15307. case messagerecords.FieldSourceID:
  15308. m.ResetSourceID()
  15309. return nil
  15310. case messagerecords.FieldSubSourceID:
  15311. m.ResetSubSourceID()
  15312. return nil
  15313. case messagerecords.FieldOrganizationID:
  15314. m.ResetOrganizationID()
  15315. return nil
  15316. }
  15317. return fmt.Errorf("unknown MessageRecords field %s", name)
  15318. }
  15319. // AddedEdges returns all edge names that were set/added in this mutation.
  15320. func (m *MessageRecordsMutation) AddedEdges() []string {
  15321. edges := make([]string, 0, 3)
  15322. if m.sop_stage != nil {
  15323. edges = append(edges, messagerecords.EdgeSopStage)
  15324. }
  15325. if m.sop_node != nil {
  15326. edges = append(edges, messagerecords.EdgeSopNode)
  15327. }
  15328. if m.message_contact != nil {
  15329. edges = append(edges, messagerecords.EdgeMessageContact)
  15330. }
  15331. return edges
  15332. }
  15333. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15334. // name in this mutation.
  15335. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  15336. switch name {
  15337. case messagerecords.EdgeSopStage:
  15338. if id := m.sop_stage; id != nil {
  15339. return []ent.Value{*id}
  15340. }
  15341. case messagerecords.EdgeSopNode:
  15342. if id := m.sop_node; id != nil {
  15343. return []ent.Value{*id}
  15344. }
  15345. case messagerecords.EdgeMessageContact:
  15346. if id := m.message_contact; id != nil {
  15347. return []ent.Value{*id}
  15348. }
  15349. }
  15350. return nil
  15351. }
  15352. // RemovedEdges returns all edge names that were removed in this mutation.
  15353. func (m *MessageRecordsMutation) RemovedEdges() []string {
  15354. edges := make([]string, 0, 3)
  15355. return edges
  15356. }
  15357. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15358. // the given name in this mutation.
  15359. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  15360. return nil
  15361. }
  15362. // ClearedEdges returns all edge names that were cleared in this mutation.
  15363. func (m *MessageRecordsMutation) ClearedEdges() []string {
  15364. edges := make([]string, 0, 3)
  15365. if m.clearedsop_stage {
  15366. edges = append(edges, messagerecords.EdgeSopStage)
  15367. }
  15368. if m.clearedsop_node {
  15369. edges = append(edges, messagerecords.EdgeSopNode)
  15370. }
  15371. if m.clearedmessage_contact {
  15372. edges = append(edges, messagerecords.EdgeMessageContact)
  15373. }
  15374. return edges
  15375. }
  15376. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15377. // was cleared in this mutation.
  15378. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  15379. switch name {
  15380. case messagerecords.EdgeSopStage:
  15381. return m.clearedsop_stage
  15382. case messagerecords.EdgeSopNode:
  15383. return m.clearedsop_node
  15384. case messagerecords.EdgeMessageContact:
  15385. return m.clearedmessage_contact
  15386. }
  15387. return false
  15388. }
  15389. // ClearEdge clears the value of the edge with the given name. It returns an error
  15390. // if that edge is not defined in the schema.
  15391. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  15392. switch name {
  15393. case messagerecords.EdgeSopStage:
  15394. m.ClearSopStage()
  15395. return nil
  15396. case messagerecords.EdgeSopNode:
  15397. m.ClearSopNode()
  15398. return nil
  15399. case messagerecords.EdgeMessageContact:
  15400. m.ClearMessageContact()
  15401. return nil
  15402. }
  15403. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  15404. }
  15405. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15406. // It returns an error if the edge is not defined in the schema.
  15407. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  15408. switch name {
  15409. case messagerecords.EdgeSopStage:
  15410. m.ResetSopStage()
  15411. return nil
  15412. case messagerecords.EdgeSopNode:
  15413. m.ResetSopNode()
  15414. return nil
  15415. case messagerecords.EdgeMessageContact:
  15416. m.ResetMessageContact()
  15417. return nil
  15418. }
  15419. return fmt.Errorf("unknown MessageRecords edge %s", name)
  15420. }
  15421. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  15422. type MsgMutation struct {
  15423. config
  15424. op Op
  15425. typ string
  15426. id *uint64
  15427. created_at *time.Time
  15428. updated_at *time.Time
  15429. deleted_at *time.Time
  15430. status *uint8
  15431. addstatus *int8
  15432. fromwxid *string
  15433. toid *string
  15434. msgtype *int32
  15435. addmsgtype *int32
  15436. msg *string
  15437. batch_no *string
  15438. clearedFields map[string]struct{}
  15439. done bool
  15440. oldValue func(context.Context) (*Msg, error)
  15441. predicates []predicate.Msg
  15442. }
  15443. var _ ent.Mutation = (*MsgMutation)(nil)
  15444. // msgOption allows management of the mutation configuration using functional options.
  15445. type msgOption func(*MsgMutation)
  15446. // newMsgMutation creates new mutation for the Msg entity.
  15447. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  15448. m := &MsgMutation{
  15449. config: c,
  15450. op: op,
  15451. typ: TypeMsg,
  15452. clearedFields: make(map[string]struct{}),
  15453. }
  15454. for _, opt := range opts {
  15455. opt(m)
  15456. }
  15457. return m
  15458. }
  15459. // withMsgID sets the ID field of the mutation.
  15460. func withMsgID(id uint64) msgOption {
  15461. return func(m *MsgMutation) {
  15462. var (
  15463. err error
  15464. once sync.Once
  15465. value *Msg
  15466. )
  15467. m.oldValue = func(ctx context.Context) (*Msg, error) {
  15468. once.Do(func() {
  15469. if m.done {
  15470. err = errors.New("querying old values post mutation is not allowed")
  15471. } else {
  15472. value, err = m.Client().Msg.Get(ctx, id)
  15473. }
  15474. })
  15475. return value, err
  15476. }
  15477. m.id = &id
  15478. }
  15479. }
  15480. // withMsg sets the old Msg of the mutation.
  15481. func withMsg(node *Msg) msgOption {
  15482. return func(m *MsgMutation) {
  15483. m.oldValue = func(context.Context) (*Msg, error) {
  15484. return node, nil
  15485. }
  15486. m.id = &node.ID
  15487. }
  15488. }
  15489. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15490. // executed in a transaction (ent.Tx), a transactional client is returned.
  15491. func (m MsgMutation) Client() *Client {
  15492. client := &Client{config: m.config}
  15493. client.init()
  15494. return client
  15495. }
  15496. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15497. // it returns an error otherwise.
  15498. func (m MsgMutation) Tx() (*Tx, error) {
  15499. if _, ok := m.driver.(*txDriver); !ok {
  15500. return nil, errors.New("ent: mutation is not running in a transaction")
  15501. }
  15502. tx := &Tx{config: m.config}
  15503. tx.init()
  15504. return tx, nil
  15505. }
  15506. // SetID sets the value of the id field. Note that this
  15507. // operation is only accepted on creation of Msg entities.
  15508. func (m *MsgMutation) SetID(id uint64) {
  15509. m.id = &id
  15510. }
  15511. // ID returns the ID value in the mutation. Note that the ID is only available
  15512. // if it was provided to the builder or after it was returned from the database.
  15513. func (m *MsgMutation) ID() (id uint64, exists bool) {
  15514. if m.id == nil {
  15515. return
  15516. }
  15517. return *m.id, true
  15518. }
  15519. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15520. // That means, if the mutation is applied within a transaction with an isolation level such
  15521. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15522. // or updated by the mutation.
  15523. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  15524. switch {
  15525. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15526. id, exists := m.ID()
  15527. if exists {
  15528. return []uint64{id}, nil
  15529. }
  15530. fallthrough
  15531. case m.op.Is(OpUpdate | OpDelete):
  15532. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  15533. default:
  15534. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15535. }
  15536. }
  15537. // SetCreatedAt sets the "created_at" field.
  15538. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  15539. m.created_at = &t
  15540. }
  15541. // CreatedAt returns the value of the "created_at" field in the mutation.
  15542. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  15543. v := m.created_at
  15544. if v == nil {
  15545. return
  15546. }
  15547. return *v, true
  15548. }
  15549. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  15550. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15552. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15553. if !m.op.Is(OpUpdateOne) {
  15554. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15555. }
  15556. if m.id == nil || m.oldValue == nil {
  15557. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15558. }
  15559. oldValue, err := m.oldValue(ctx)
  15560. if err != nil {
  15561. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15562. }
  15563. return oldValue.CreatedAt, nil
  15564. }
  15565. // ResetCreatedAt resets all changes to the "created_at" field.
  15566. func (m *MsgMutation) ResetCreatedAt() {
  15567. m.created_at = nil
  15568. }
  15569. // SetUpdatedAt sets the "updated_at" field.
  15570. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  15571. m.updated_at = &t
  15572. }
  15573. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15574. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  15575. v := m.updated_at
  15576. if v == nil {
  15577. return
  15578. }
  15579. return *v, true
  15580. }
  15581. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  15582. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15584. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15585. if !m.op.Is(OpUpdateOne) {
  15586. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15587. }
  15588. if m.id == nil || m.oldValue == nil {
  15589. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15590. }
  15591. oldValue, err := m.oldValue(ctx)
  15592. if err != nil {
  15593. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15594. }
  15595. return oldValue.UpdatedAt, nil
  15596. }
  15597. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15598. func (m *MsgMutation) ResetUpdatedAt() {
  15599. m.updated_at = nil
  15600. }
  15601. // SetDeletedAt sets the "deleted_at" field.
  15602. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  15603. m.deleted_at = &t
  15604. }
  15605. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15606. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  15607. v := m.deleted_at
  15608. if v == nil {
  15609. return
  15610. }
  15611. return *v, true
  15612. }
  15613. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  15614. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15616. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15617. if !m.op.Is(OpUpdateOne) {
  15618. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15619. }
  15620. if m.id == nil || m.oldValue == nil {
  15621. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15622. }
  15623. oldValue, err := m.oldValue(ctx)
  15624. if err != nil {
  15625. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15626. }
  15627. return oldValue.DeletedAt, nil
  15628. }
  15629. // ClearDeletedAt clears the value of the "deleted_at" field.
  15630. func (m *MsgMutation) ClearDeletedAt() {
  15631. m.deleted_at = nil
  15632. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  15633. }
  15634. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15635. func (m *MsgMutation) DeletedAtCleared() bool {
  15636. _, ok := m.clearedFields[msg.FieldDeletedAt]
  15637. return ok
  15638. }
  15639. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15640. func (m *MsgMutation) ResetDeletedAt() {
  15641. m.deleted_at = nil
  15642. delete(m.clearedFields, msg.FieldDeletedAt)
  15643. }
  15644. // SetStatus sets the "status" field.
  15645. func (m *MsgMutation) SetStatus(u uint8) {
  15646. m.status = &u
  15647. m.addstatus = nil
  15648. }
  15649. // Status returns the value of the "status" field in the mutation.
  15650. func (m *MsgMutation) Status() (r uint8, exists bool) {
  15651. v := m.status
  15652. if v == nil {
  15653. return
  15654. }
  15655. return *v, true
  15656. }
  15657. // OldStatus returns the old "status" field's value of the Msg entity.
  15658. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15660. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15661. if !m.op.Is(OpUpdateOne) {
  15662. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15663. }
  15664. if m.id == nil || m.oldValue == nil {
  15665. return v, errors.New("OldStatus requires an ID field in the mutation")
  15666. }
  15667. oldValue, err := m.oldValue(ctx)
  15668. if err != nil {
  15669. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15670. }
  15671. return oldValue.Status, nil
  15672. }
  15673. // AddStatus adds u to the "status" field.
  15674. func (m *MsgMutation) AddStatus(u int8) {
  15675. if m.addstatus != nil {
  15676. *m.addstatus += u
  15677. } else {
  15678. m.addstatus = &u
  15679. }
  15680. }
  15681. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15682. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  15683. v := m.addstatus
  15684. if v == nil {
  15685. return
  15686. }
  15687. return *v, true
  15688. }
  15689. // ClearStatus clears the value of the "status" field.
  15690. func (m *MsgMutation) ClearStatus() {
  15691. m.status = nil
  15692. m.addstatus = nil
  15693. m.clearedFields[msg.FieldStatus] = struct{}{}
  15694. }
  15695. // StatusCleared returns if the "status" field was cleared in this mutation.
  15696. func (m *MsgMutation) StatusCleared() bool {
  15697. _, ok := m.clearedFields[msg.FieldStatus]
  15698. return ok
  15699. }
  15700. // ResetStatus resets all changes to the "status" field.
  15701. func (m *MsgMutation) ResetStatus() {
  15702. m.status = nil
  15703. m.addstatus = nil
  15704. delete(m.clearedFields, msg.FieldStatus)
  15705. }
  15706. // SetFromwxid sets the "fromwxid" field.
  15707. func (m *MsgMutation) SetFromwxid(s string) {
  15708. m.fromwxid = &s
  15709. }
  15710. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  15711. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  15712. v := m.fromwxid
  15713. if v == nil {
  15714. return
  15715. }
  15716. return *v, true
  15717. }
  15718. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  15719. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15721. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  15722. if !m.op.Is(OpUpdateOne) {
  15723. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  15724. }
  15725. if m.id == nil || m.oldValue == nil {
  15726. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  15727. }
  15728. oldValue, err := m.oldValue(ctx)
  15729. if err != nil {
  15730. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  15731. }
  15732. return oldValue.Fromwxid, nil
  15733. }
  15734. // ClearFromwxid clears the value of the "fromwxid" field.
  15735. func (m *MsgMutation) ClearFromwxid() {
  15736. m.fromwxid = nil
  15737. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  15738. }
  15739. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  15740. func (m *MsgMutation) FromwxidCleared() bool {
  15741. _, ok := m.clearedFields[msg.FieldFromwxid]
  15742. return ok
  15743. }
  15744. // ResetFromwxid resets all changes to the "fromwxid" field.
  15745. func (m *MsgMutation) ResetFromwxid() {
  15746. m.fromwxid = nil
  15747. delete(m.clearedFields, msg.FieldFromwxid)
  15748. }
  15749. // SetToid sets the "toid" field.
  15750. func (m *MsgMutation) SetToid(s string) {
  15751. m.toid = &s
  15752. }
  15753. // Toid returns the value of the "toid" field in the mutation.
  15754. func (m *MsgMutation) Toid() (r string, exists bool) {
  15755. v := m.toid
  15756. if v == nil {
  15757. return
  15758. }
  15759. return *v, true
  15760. }
  15761. // OldToid returns the old "toid" field's value of the Msg entity.
  15762. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15764. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  15765. if !m.op.Is(OpUpdateOne) {
  15766. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  15767. }
  15768. if m.id == nil || m.oldValue == nil {
  15769. return v, errors.New("OldToid requires an ID field in the mutation")
  15770. }
  15771. oldValue, err := m.oldValue(ctx)
  15772. if err != nil {
  15773. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  15774. }
  15775. return oldValue.Toid, nil
  15776. }
  15777. // ClearToid clears the value of the "toid" field.
  15778. func (m *MsgMutation) ClearToid() {
  15779. m.toid = nil
  15780. m.clearedFields[msg.FieldToid] = struct{}{}
  15781. }
  15782. // ToidCleared returns if the "toid" field was cleared in this mutation.
  15783. func (m *MsgMutation) ToidCleared() bool {
  15784. _, ok := m.clearedFields[msg.FieldToid]
  15785. return ok
  15786. }
  15787. // ResetToid resets all changes to the "toid" field.
  15788. func (m *MsgMutation) ResetToid() {
  15789. m.toid = nil
  15790. delete(m.clearedFields, msg.FieldToid)
  15791. }
  15792. // SetMsgtype sets the "msgtype" field.
  15793. func (m *MsgMutation) SetMsgtype(i int32) {
  15794. m.msgtype = &i
  15795. m.addmsgtype = nil
  15796. }
  15797. // Msgtype returns the value of the "msgtype" field in the mutation.
  15798. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  15799. v := m.msgtype
  15800. if v == nil {
  15801. return
  15802. }
  15803. return *v, true
  15804. }
  15805. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  15806. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15808. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  15809. if !m.op.Is(OpUpdateOne) {
  15810. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  15811. }
  15812. if m.id == nil || m.oldValue == nil {
  15813. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  15814. }
  15815. oldValue, err := m.oldValue(ctx)
  15816. if err != nil {
  15817. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  15818. }
  15819. return oldValue.Msgtype, nil
  15820. }
  15821. // AddMsgtype adds i to the "msgtype" field.
  15822. func (m *MsgMutation) AddMsgtype(i int32) {
  15823. if m.addmsgtype != nil {
  15824. *m.addmsgtype += i
  15825. } else {
  15826. m.addmsgtype = &i
  15827. }
  15828. }
  15829. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  15830. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  15831. v := m.addmsgtype
  15832. if v == nil {
  15833. return
  15834. }
  15835. return *v, true
  15836. }
  15837. // ClearMsgtype clears the value of the "msgtype" field.
  15838. func (m *MsgMutation) ClearMsgtype() {
  15839. m.msgtype = nil
  15840. m.addmsgtype = nil
  15841. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  15842. }
  15843. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  15844. func (m *MsgMutation) MsgtypeCleared() bool {
  15845. _, ok := m.clearedFields[msg.FieldMsgtype]
  15846. return ok
  15847. }
  15848. // ResetMsgtype resets all changes to the "msgtype" field.
  15849. func (m *MsgMutation) ResetMsgtype() {
  15850. m.msgtype = nil
  15851. m.addmsgtype = nil
  15852. delete(m.clearedFields, msg.FieldMsgtype)
  15853. }
  15854. // SetMsg sets the "msg" field.
  15855. func (m *MsgMutation) SetMsg(s string) {
  15856. m.msg = &s
  15857. }
  15858. // Msg returns the value of the "msg" field in the mutation.
  15859. func (m *MsgMutation) Msg() (r string, exists bool) {
  15860. v := m.msg
  15861. if v == nil {
  15862. return
  15863. }
  15864. return *v, true
  15865. }
  15866. // OldMsg returns the old "msg" field's value of the Msg entity.
  15867. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15869. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  15870. if !m.op.Is(OpUpdateOne) {
  15871. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  15872. }
  15873. if m.id == nil || m.oldValue == nil {
  15874. return v, errors.New("OldMsg requires an ID field in the mutation")
  15875. }
  15876. oldValue, err := m.oldValue(ctx)
  15877. if err != nil {
  15878. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  15879. }
  15880. return oldValue.Msg, nil
  15881. }
  15882. // ClearMsg clears the value of the "msg" field.
  15883. func (m *MsgMutation) ClearMsg() {
  15884. m.msg = nil
  15885. m.clearedFields[msg.FieldMsg] = struct{}{}
  15886. }
  15887. // MsgCleared returns if the "msg" field was cleared in this mutation.
  15888. func (m *MsgMutation) MsgCleared() bool {
  15889. _, ok := m.clearedFields[msg.FieldMsg]
  15890. return ok
  15891. }
  15892. // ResetMsg resets all changes to the "msg" field.
  15893. func (m *MsgMutation) ResetMsg() {
  15894. m.msg = nil
  15895. delete(m.clearedFields, msg.FieldMsg)
  15896. }
  15897. // SetBatchNo sets the "batch_no" field.
  15898. func (m *MsgMutation) SetBatchNo(s string) {
  15899. m.batch_no = &s
  15900. }
  15901. // BatchNo returns the value of the "batch_no" field in the mutation.
  15902. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  15903. v := m.batch_no
  15904. if v == nil {
  15905. return
  15906. }
  15907. return *v, true
  15908. }
  15909. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  15910. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15912. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  15913. if !m.op.Is(OpUpdateOne) {
  15914. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  15915. }
  15916. if m.id == nil || m.oldValue == nil {
  15917. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  15918. }
  15919. oldValue, err := m.oldValue(ctx)
  15920. if err != nil {
  15921. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  15922. }
  15923. return oldValue.BatchNo, nil
  15924. }
  15925. // ClearBatchNo clears the value of the "batch_no" field.
  15926. func (m *MsgMutation) ClearBatchNo() {
  15927. m.batch_no = nil
  15928. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  15929. }
  15930. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  15931. func (m *MsgMutation) BatchNoCleared() bool {
  15932. _, ok := m.clearedFields[msg.FieldBatchNo]
  15933. return ok
  15934. }
  15935. // ResetBatchNo resets all changes to the "batch_no" field.
  15936. func (m *MsgMutation) ResetBatchNo() {
  15937. m.batch_no = nil
  15938. delete(m.clearedFields, msg.FieldBatchNo)
  15939. }
  15940. // Where appends a list predicates to the MsgMutation builder.
  15941. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  15942. m.predicates = append(m.predicates, ps...)
  15943. }
  15944. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  15945. // users can use type-assertion to append predicates that do not depend on any generated package.
  15946. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  15947. p := make([]predicate.Msg, len(ps))
  15948. for i := range ps {
  15949. p[i] = ps[i]
  15950. }
  15951. m.Where(p...)
  15952. }
  15953. // Op returns the operation name.
  15954. func (m *MsgMutation) Op() Op {
  15955. return m.op
  15956. }
  15957. // SetOp allows setting the mutation operation.
  15958. func (m *MsgMutation) SetOp(op Op) {
  15959. m.op = op
  15960. }
  15961. // Type returns the node type of this mutation (Msg).
  15962. func (m *MsgMutation) Type() string {
  15963. return m.typ
  15964. }
  15965. // Fields returns all fields that were changed during this mutation. Note that in
  15966. // order to get all numeric fields that were incremented/decremented, call
  15967. // AddedFields().
  15968. func (m *MsgMutation) Fields() []string {
  15969. fields := make([]string, 0, 9)
  15970. if m.created_at != nil {
  15971. fields = append(fields, msg.FieldCreatedAt)
  15972. }
  15973. if m.updated_at != nil {
  15974. fields = append(fields, msg.FieldUpdatedAt)
  15975. }
  15976. if m.deleted_at != nil {
  15977. fields = append(fields, msg.FieldDeletedAt)
  15978. }
  15979. if m.status != nil {
  15980. fields = append(fields, msg.FieldStatus)
  15981. }
  15982. if m.fromwxid != nil {
  15983. fields = append(fields, msg.FieldFromwxid)
  15984. }
  15985. if m.toid != nil {
  15986. fields = append(fields, msg.FieldToid)
  15987. }
  15988. if m.msgtype != nil {
  15989. fields = append(fields, msg.FieldMsgtype)
  15990. }
  15991. if m.msg != nil {
  15992. fields = append(fields, msg.FieldMsg)
  15993. }
  15994. if m.batch_no != nil {
  15995. fields = append(fields, msg.FieldBatchNo)
  15996. }
  15997. return fields
  15998. }
  15999. // Field returns the value of a field with the given name. The second boolean
  16000. // return value indicates that this field was not set, or was not defined in the
  16001. // schema.
  16002. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  16003. switch name {
  16004. case msg.FieldCreatedAt:
  16005. return m.CreatedAt()
  16006. case msg.FieldUpdatedAt:
  16007. return m.UpdatedAt()
  16008. case msg.FieldDeletedAt:
  16009. return m.DeletedAt()
  16010. case msg.FieldStatus:
  16011. return m.Status()
  16012. case msg.FieldFromwxid:
  16013. return m.Fromwxid()
  16014. case msg.FieldToid:
  16015. return m.Toid()
  16016. case msg.FieldMsgtype:
  16017. return m.Msgtype()
  16018. case msg.FieldMsg:
  16019. return m.Msg()
  16020. case msg.FieldBatchNo:
  16021. return m.BatchNo()
  16022. }
  16023. return nil, false
  16024. }
  16025. // OldField returns the old value of the field from the database. An error is
  16026. // returned if the mutation operation is not UpdateOne, or the query to the
  16027. // database failed.
  16028. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16029. switch name {
  16030. case msg.FieldCreatedAt:
  16031. return m.OldCreatedAt(ctx)
  16032. case msg.FieldUpdatedAt:
  16033. return m.OldUpdatedAt(ctx)
  16034. case msg.FieldDeletedAt:
  16035. return m.OldDeletedAt(ctx)
  16036. case msg.FieldStatus:
  16037. return m.OldStatus(ctx)
  16038. case msg.FieldFromwxid:
  16039. return m.OldFromwxid(ctx)
  16040. case msg.FieldToid:
  16041. return m.OldToid(ctx)
  16042. case msg.FieldMsgtype:
  16043. return m.OldMsgtype(ctx)
  16044. case msg.FieldMsg:
  16045. return m.OldMsg(ctx)
  16046. case msg.FieldBatchNo:
  16047. return m.OldBatchNo(ctx)
  16048. }
  16049. return nil, fmt.Errorf("unknown Msg field %s", name)
  16050. }
  16051. // SetField sets the value of a field with the given name. It returns an error if
  16052. // the field is not defined in the schema, or if the type mismatched the field
  16053. // type.
  16054. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  16055. switch name {
  16056. case msg.FieldCreatedAt:
  16057. v, ok := value.(time.Time)
  16058. if !ok {
  16059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16060. }
  16061. m.SetCreatedAt(v)
  16062. return nil
  16063. case msg.FieldUpdatedAt:
  16064. v, ok := value.(time.Time)
  16065. if !ok {
  16066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16067. }
  16068. m.SetUpdatedAt(v)
  16069. return nil
  16070. case msg.FieldDeletedAt:
  16071. v, ok := value.(time.Time)
  16072. if !ok {
  16073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16074. }
  16075. m.SetDeletedAt(v)
  16076. return nil
  16077. case msg.FieldStatus:
  16078. v, ok := value.(uint8)
  16079. if !ok {
  16080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16081. }
  16082. m.SetStatus(v)
  16083. return nil
  16084. case msg.FieldFromwxid:
  16085. v, ok := value.(string)
  16086. if !ok {
  16087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16088. }
  16089. m.SetFromwxid(v)
  16090. return nil
  16091. case msg.FieldToid:
  16092. v, ok := value.(string)
  16093. if !ok {
  16094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16095. }
  16096. m.SetToid(v)
  16097. return nil
  16098. case msg.FieldMsgtype:
  16099. v, ok := value.(int32)
  16100. if !ok {
  16101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16102. }
  16103. m.SetMsgtype(v)
  16104. return nil
  16105. case msg.FieldMsg:
  16106. v, ok := value.(string)
  16107. if !ok {
  16108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16109. }
  16110. m.SetMsg(v)
  16111. return nil
  16112. case msg.FieldBatchNo:
  16113. v, ok := value.(string)
  16114. if !ok {
  16115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16116. }
  16117. m.SetBatchNo(v)
  16118. return nil
  16119. }
  16120. return fmt.Errorf("unknown Msg field %s", name)
  16121. }
  16122. // AddedFields returns all numeric fields that were incremented/decremented during
  16123. // this mutation.
  16124. func (m *MsgMutation) AddedFields() []string {
  16125. var fields []string
  16126. if m.addstatus != nil {
  16127. fields = append(fields, msg.FieldStatus)
  16128. }
  16129. if m.addmsgtype != nil {
  16130. fields = append(fields, msg.FieldMsgtype)
  16131. }
  16132. return fields
  16133. }
  16134. // AddedField returns the numeric value that was incremented/decremented on a field
  16135. // with the given name. The second boolean return value indicates that this field
  16136. // was not set, or was not defined in the schema.
  16137. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  16138. switch name {
  16139. case msg.FieldStatus:
  16140. return m.AddedStatus()
  16141. case msg.FieldMsgtype:
  16142. return m.AddedMsgtype()
  16143. }
  16144. return nil, false
  16145. }
  16146. // AddField adds the value to the field with the given name. It returns an error if
  16147. // the field is not defined in the schema, or if the type mismatched the field
  16148. // type.
  16149. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  16150. switch name {
  16151. case msg.FieldStatus:
  16152. v, ok := value.(int8)
  16153. if !ok {
  16154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16155. }
  16156. m.AddStatus(v)
  16157. return nil
  16158. case msg.FieldMsgtype:
  16159. v, ok := value.(int32)
  16160. if !ok {
  16161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16162. }
  16163. m.AddMsgtype(v)
  16164. return nil
  16165. }
  16166. return fmt.Errorf("unknown Msg numeric field %s", name)
  16167. }
  16168. // ClearedFields returns all nullable fields that were cleared during this
  16169. // mutation.
  16170. func (m *MsgMutation) ClearedFields() []string {
  16171. var fields []string
  16172. if m.FieldCleared(msg.FieldDeletedAt) {
  16173. fields = append(fields, msg.FieldDeletedAt)
  16174. }
  16175. if m.FieldCleared(msg.FieldStatus) {
  16176. fields = append(fields, msg.FieldStatus)
  16177. }
  16178. if m.FieldCleared(msg.FieldFromwxid) {
  16179. fields = append(fields, msg.FieldFromwxid)
  16180. }
  16181. if m.FieldCleared(msg.FieldToid) {
  16182. fields = append(fields, msg.FieldToid)
  16183. }
  16184. if m.FieldCleared(msg.FieldMsgtype) {
  16185. fields = append(fields, msg.FieldMsgtype)
  16186. }
  16187. if m.FieldCleared(msg.FieldMsg) {
  16188. fields = append(fields, msg.FieldMsg)
  16189. }
  16190. if m.FieldCleared(msg.FieldBatchNo) {
  16191. fields = append(fields, msg.FieldBatchNo)
  16192. }
  16193. return fields
  16194. }
  16195. // FieldCleared returns a boolean indicating if a field with the given name was
  16196. // cleared in this mutation.
  16197. func (m *MsgMutation) FieldCleared(name string) bool {
  16198. _, ok := m.clearedFields[name]
  16199. return ok
  16200. }
  16201. // ClearField clears the value of the field with the given name. It returns an
  16202. // error if the field is not defined in the schema.
  16203. func (m *MsgMutation) ClearField(name string) error {
  16204. switch name {
  16205. case msg.FieldDeletedAt:
  16206. m.ClearDeletedAt()
  16207. return nil
  16208. case msg.FieldStatus:
  16209. m.ClearStatus()
  16210. return nil
  16211. case msg.FieldFromwxid:
  16212. m.ClearFromwxid()
  16213. return nil
  16214. case msg.FieldToid:
  16215. m.ClearToid()
  16216. return nil
  16217. case msg.FieldMsgtype:
  16218. m.ClearMsgtype()
  16219. return nil
  16220. case msg.FieldMsg:
  16221. m.ClearMsg()
  16222. return nil
  16223. case msg.FieldBatchNo:
  16224. m.ClearBatchNo()
  16225. return nil
  16226. }
  16227. return fmt.Errorf("unknown Msg nullable field %s", name)
  16228. }
  16229. // ResetField resets all changes in the mutation for the field with the given name.
  16230. // It returns an error if the field is not defined in the schema.
  16231. func (m *MsgMutation) ResetField(name string) error {
  16232. switch name {
  16233. case msg.FieldCreatedAt:
  16234. m.ResetCreatedAt()
  16235. return nil
  16236. case msg.FieldUpdatedAt:
  16237. m.ResetUpdatedAt()
  16238. return nil
  16239. case msg.FieldDeletedAt:
  16240. m.ResetDeletedAt()
  16241. return nil
  16242. case msg.FieldStatus:
  16243. m.ResetStatus()
  16244. return nil
  16245. case msg.FieldFromwxid:
  16246. m.ResetFromwxid()
  16247. return nil
  16248. case msg.FieldToid:
  16249. m.ResetToid()
  16250. return nil
  16251. case msg.FieldMsgtype:
  16252. m.ResetMsgtype()
  16253. return nil
  16254. case msg.FieldMsg:
  16255. m.ResetMsg()
  16256. return nil
  16257. case msg.FieldBatchNo:
  16258. m.ResetBatchNo()
  16259. return nil
  16260. }
  16261. return fmt.Errorf("unknown Msg field %s", name)
  16262. }
  16263. // AddedEdges returns all edge names that were set/added in this mutation.
  16264. func (m *MsgMutation) AddedEdges() []string {
  16265. edges := make([]string, 0, 0)
  16266. return edges
  16267. }
  16268. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16269. // name in this mutation.
  16270. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  16271. return nil
  16272. }
  16273. // RemovedEdges returns all edge names that were removed in this mutation.
  16274. func (m *MsgMutation) RemovedEdges() []string {
  16275. edges := make([]string, 0, 0)
  16276. return edges
  16277. }
  16278. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16279. // the given name in this mutation.
  16280. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  16281. return nil
  16282. }
  16283. // ClearedEdges returns all edge names that were cleared in this mutation.
  16284. func (m *MsgMutation) ClearedEdges() []string {
  16285. edges := make([]string, 0, 0)
  16286. return edges
  16287. }
  16288. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16289. // was cleared in this mutation.
  16290. func (m *MsgMutation) EdgeCleared(name string) bool {
  16291. return false
  16292. }
  16293. // ClearEdge clears the value of the edge with the given name. It returns an error
  16294. // if that edge is not defined in the schema.
  16295. func (m *MsgMutation) ClearEdge(name string) error {
  16296. return fmt.Errorf("unknown Msg unique edge %s", name)
  16297. }
  16298. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16299. // It returns an error if the edge is not defined in the schema.
  16300. func (m *MsgMutation) ResetEdge(name string) error {
  16301. return fmt.Errorf("unknown Msg edge %s", name)
  16302. }
  16303. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  16304. type ServerMutation struct {
  16305. config
  16306. op Op
  16307. typ string
  16308. id *uint64
  16309. created_at *time.Time
  16310. updated_at *time.Time
  16311. status *uint8
  16312. addstatus *int8
  16313. deleted_at *time.Time
  16314. name *string
  16315. public_ip *string
  16316. private_ip *string
  16317. admin_port *string
  16318. clearedFields map[string]struct{}
  16319. wxs map[uint64]struct{}
  16320. removedwxs map[uint64]struct{}
  16321. clearedwxs bool
  16322. done bool
  16323. oldValue func(context.Context) (*Server, error)
  16324. predicates []predicate.Server
  16325. }
  16326. var _ ent.Mutation = (*ServerMutation)(nil)
  16327. // serverOption allows management of the mutation configuration using functional options.
  16328. type serverOption func(*ServerMutation)
  16329. // newServerMutation creates new mutation for the Server entity.
  16330. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  16331. m := &ServerMutation{
  16332. config: c,
  16333. op: op,
  16334. typ: TypeServer,
  16335. clearedFields: make(map[string]struct{}),
  16336. }
  16337. for _, opt := range opts {
  16338. opt(m)
  16339. }
  16340. return m
  16341. }
  16342. // withServerID sets the ID field of the mutation.
  16343. func withServerID(id uint64) serverOption {
  16344. return func(m *ServerMutation) {
  16345. var (
  16346. err error
  16347. once sync.Once
  16348. value *Server
  16349. )
  16350. m.oldValue = func(ctx context.Context) (*Server, error) {
  16351. once.Do(func() {
  16352. if m.done {
  16353. err = errors.New("querying old values post mutation is not allowed")
  16354. } else {
  16355. value, err = m.Client().Server.Get(ctx, id)
  16356. }
  16357. })
  16358. return value, err
  16359. }
  16360. m.id = &id
  16361. }
  16362. }
  16363. // withServer sets the old Server of the mutation.
  16364. func withServer(node *Server) serverOption {
  16365. return func(m *ServerMutation) {
  16366. m.oldValue = func(context.Context) (*Server, error) {
  16367. return node, nil
  16368. }
  16369. m.id = &node.ID
  16370. }
  16371. }
  16372. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16373. // executed in a transaction (ent.Tx), a transactional client is returned.
  16374. func (m ServerMutation) Client() *Client {
  16375. client := &Client{config: m.config}
  16376. client.init()
  16377. return client
  16378. }
  16379. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16380. // it returns an error otherwise.
  16381. func (m ServerMutation) Tx() (*Tx, error) {
  16382. if _, ok := m.driver.(*txDriver); !ok {
  16383. return nil, errors.New("ent: mutation is not running in a transaction")
  16384. }
  16385. tx := &Tx{config: m.config}
  16386. tx.init()
  16387. return tx, nil
  16388. }
  16389. // SetID sets the value of the id field. Note that this
  16390. // operation is only accepted on creation of Server entities.
  16391. func (m *ServerMutation) SetID(id uint64) {
  16392. m.id = &id
  16393. }
  16394. // ID returns the ID value in the mutation. Note that the ID is only available
  16395. // if it was provided to the builder or after it was returned from the database.
  16396. func (m *ServerMutation) ID() (id uint64, exists bool) {
  16397. if m.id == nil {
  16398. return
  16399. }
  16400. return *m.id, true
  16401. }
  16402. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16403. // That means, if the mutation is applied within a transaction with an isolation level such
  16404. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16405. // or updated by the mutation.
  16406. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  16407. switch {
  16408. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16409. id, exists := m.ID()
  16410. if exists {
  16411. return []uint64{id}, nil
  16412. }
  16413. fallthrough
  16414. case m.op.Is(OpUpdate | OpDelete):
  16415. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  16416. default:
  16417. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16418. }
  16419. }
  16420. // SetCreatedAt sets the "created_at" field.
  16421. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  16422. m.created_at = &t
  16423. }
  16424. // CreatedAt returns the value of the "created_at" field in the mutation.
  16425. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  16426. v := m.created_at
  16427. if v == nil {
  16428. return
  16429. }
  16430. return *v, true
  16431. }
  16432. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  16433. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16435. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16436. if !m.op.Is(OpUpdateOne) {
  16437. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16438. }
  16439. if m.id == nil || m.oldValue == nil {
  16440. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16441. }
  16442. oldValue, err := m.oldValue(ctx)
  16443. if err != nil {
  16444. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16445. }
  16446. return oldValue.CreatedAt, nil
  16447. }
  16448. // ResetCreatedAt resets all changes to the "created_at" field.
  16449. func (m *ServerMutation) ResetCreatedAt() {
  16450. m.created_at = nil
  16451. }
  16452. // SetUpdatedAt sets the "updated_at" field.
  16453. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  16454. m.updated_at = &t
  16455. }
  16456. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16457. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  16458. v := m.updated_at
  16459. if v == nil {
  16460. return
  16461. }
  16462. return *v, true
  16463. }
  16464. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  16465. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16467. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16468. if !m.op.Is(OpUpdateOne) {
  16469. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16470. }
  16471. if m.id == nil || m.oldValue == nil {
  16472. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16473. }
  16474. oldValue, err := m.oldValue(ctx)
  16475. if err != nil {
  16476. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16477. }
  16478. return oldValue.UpdatedAt, nil
  16479. }
  16480. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16481. func (m *ServerMutation) ResetUpdatedAt() {
  16482. m.updated_at = nil
  16483. }
  16484. // SetStatus sets the "status" field.
  16485. func (m *ServerMutation) SetStatus(u uint8) {
  16486. m.status = &u
  16487. m.addstatus = nil
  16488. }
  16489. // Status returns the value of the "status" field in the mutation.
  16490. func (m *ServerMutation) Status() (r uint8, exists bool) {
  16491. v := m.status
  16492. if v == nil {
  16493. return
  16494. }
  16495. return *v, true
  16496. }
  16497. // OldStatus returns the old "status" field's value of the Server entity.
  16498. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16500. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16501. if !m.op.Is(OpUpdateOne) {
  16502. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16503. }
  16504. if m.id == nil || m.oldValue == nil {
  16505. return v, errors.New("OldStatus requires an ID field in the mutation")
  16506. }
  16507. oldValue, err := m.oldValue(ctx)
  16508. if err != nil {
  16509. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16510. }
  16511. return oldValue.Status, nil
  16512. }
  16513. // AddStatus adds u to the "status" field.
  16514. func (m *ServerMutation) AddStatus(u int8) {
  16515. if m.addstatus != nil {
  16516. *m.addstatus += u
  16517. } else {
  16518. m.addstatus = &u
  16519. }
  16520. }
  16521. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16522. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  16523. v := m.addstatus
  16524. if v == nil {
  16525. return
  16526. }
  16527. return *v, true
  16528. }
  16529. // ClearStatus clears the value of the "status" field.
  16530. func (m *ServerMutation) ClearStatus() {
  16531. m.status = nil
  16532. m.addstatus = nil
  16533. m.clearedFields[server.FieldStatus] = struct{}{}
  16534. }
  16535. // StatusCleared returns if the "status" field was cleared in this mutation.
  16536. func (m *ServerMutation) StatusCleared() bool {
  16537. _, ok := m.clearedFields[server.FieldStatus]
  16538. return ok
  16539. }
  16540. // ResetStatus resets all changes to the "status" field.
  16541. func (m *ServerMutation) ResetStatus() {
  16542. m.status = nil
  16543. m.addstatus = nil
  16544. delete(m.clearedFields, server.FieldStatus)
  16545. }
  16546. // SetDeletedAt sets the "deleted_at" field.
  16547. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  16548. m.deleted_at = &t
  16549. }
  16550. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16551. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  16552. v := m.deleted_at
  16553. if v == nil {
  16554. return
  16555. }
  16556. return *v, true
  16557. }
  16558. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  16559. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16561. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16562. if !m.op.Is(OpUpdateOne) {
  16563. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16564. }
  16565. if m.id == nil || m.oldValue == nil {
  16566. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16567. }
  16568. oldValue, err := m.oldValue(ctx)
  16569. if err != nil {
  16570. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16571. }
  16572. return oldValue.DeletedAt, nil
  16573. }
  16574. // ClearDeletedAt clears the value of the "deleted_at" field.
  16575. func (m *ServerMutation) ClearDeletedAt() {
  16576. m.deleted_at = nil
  16577. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  16578. }
  16579. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16580. func (m *ServerMutation) DeletedAtCleared() bool {
  16581. _, ok := m.clearedFields[server.FieldDeletedAt]
  16582. return ok
  16583. }
  16584. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16585. func (m *ServerMutation) ResetDeletedAt() {
  16586. m.deleted_at = nil
  16587. delete(m.clearedFields, server.FieldDeletedAt)
  16588. }
  16589. // SetName sets the "name" field.
  16590. func (m *ServerMutation) SetName(s string) {
  16591. m.name = &s
  16592. }
  16593. // Name returns the value of the "name" field in the mutation.
  16594. func (m *ServerMutation) Name() (r string, exists bool) {
  16595. v := m.name
  16596. if v == nil {
  16597. return
  16598. }
  16599. return *v, true
  16600. }
  16601. // OldName returns the old "name" field's value of the Server entity.
  16602. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16604. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  16605. if !m.op.Is(OpUpdateOne) {
  16606. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16607. }
  16608. if m.id == nil || m.oldValue == nil {
  16609. return v, errors.New("OldName requires an ID field in the mutation")
  16610. }
  16611. oldValue, err := m.oldValue(ctx)
  16612. if err != nil {
  16613. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16614. }
  16615. return oldValue.Name, nil
  16616. }
  16617. // ResetName resets all changes to the "name" field.
  16618. func (m *ServerMutation) ResetName() {
  16619. m.name = nil
  16620. }
  16621. // SetPublicIP sets the "public_ip" field.
  16622. func (m *ServerMutation) SetPublicIP(s string) {
  16623. m.public_ip = &s
  16624. }
  16625. // PublicIP returns the value of the "public_ip" field in the mutation.
  16626. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  16627. v := m.public_ip
  16628. if v == nil {
  16629. return
  16630. }
  16631. return *v, true
  16632. }
  16633. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  16634. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16636. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  16637. if !m.op.Is(OpUpdateOne) {
  16638. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  16639. }
  16640. if m.id == nil || m.oldValue == nil {
  16641. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  16642. }
  16643. oldValue, err := m.oldValue(ctx)
  16644. if err != nil {
  16645. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  16646. }
  16647. return oldValue.PublicIP, nil
  16648. }
  16649. // ResetPublicIP resets all changes to the "public_ip" field.
  16650. func (m *ServerMutation) ResetPublicIP() {
  16651. m.public_ip = nil
  16652. }
  16653. // SetPrivateIP sets the "private_ip" field.
  16654. func (m *ServerMutation) SetPrivateIP(s string) {
  16655. m.private_ip = &s
  16656. }
  16657. // PrivateIP returns the value of the "private_ip" field in the mutation.
  16658. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  16659. v := m.private_ip
  16660. if v == nil {
  16661. return
  16662. }
  16663. return *v, true
  16664. }
  16665. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  16666. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16668. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  16669. if !m.op.Is(OpUpdateOne) {
  16670. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  16671. }
  16672. if m.id == nil || m.oldValue == nil {
  16673. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  16674. }
  16675. oldValue, err := m.oldValue(ctx)
  16676. if err != nil {
  16677. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  16678. }
  16679. return oldValue.PrivateIP, nil
  16680. }
  16681. // ResetPrivateIP resets all changes to the "private_ip" field.
  16682. func (m *ServerMutation) ResetPrivateIP() {
  16683. m.private_ip = nil
  16684. }
  16685. // SetAdminPort sets the "admin_port" field.
  16686. func (m *ServerMutation) SetAdminPort(s string) {
  16687. m.admin_port = &s
  16688. }
  16689. // AdminPort returns the value of the "admin_port" field in the mutation.
  16690. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  16691. v := m.admin_port
  16692. if v == nil {
  16693. return
  16694. }
  16695. return *v, true
  16696. }
  16697. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  16698. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16700. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  16701. if !m.op.Is(OpUpdateOne) {
  16702. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  16703. }
  16704. if m.id == nil || m.oldValue == nil {
  16705. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  16706. }
  16707. oldValue, err := m.oldValue(ctx)
  16708. if err != nil {
  16709. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  16710. }
  16711. return oldValue.AdminPort, nil
  16712. }
  16713. // ResetAdminPort resets all changes to the "admin_port" field.
  16714. func (m *ServerMutation) ResetAdminPort() {
  16715. m.admin_port = nil
  16716. }
  16717. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  16718. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  16719. if m.wxs == nil {
  16720. m.wxs = make(map[uint64]struct{})
  16721. }
  16722. for i := range ids {
  16723. m.wxs[ids[i]] = struct{}{}
  16724. }
  16725. }
  16726. // ClearWxs clears the "wxs" edge to the Wx entity.
  16727. func (m *ServerMutation) ClearWxs() {
  16728. m.clearedwxs = true
  16729. }
  16730. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  16731. func (m *ServerMutation) WxsCleared() bool {
  16732. return m.clearedwxs
  16733. }
  16734. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  16735. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  16736. if m.removedwxs == nil {
  16737. m.removedwxs = make(map[uint64]struct{})
  16738. }
  16739. for i := range ids {
  16740. delete(m.wxs, ids[i])
  16741. m.removedwxs[ids[i]] = struct{}{}
  16742. }
  16743. }
  16744. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  16745. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  16746. for id := range m.removedwxs {
  16747. ids = append(ids, id)
  16748. }
  16749. return
  16750. }
  16751. // WxsIDs returns the "wxs" edge IDs in the mutation.
  16752. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  16753. for id := range m.wxs {
  16754. ids = append(ids, id)
  16755. }
  16756. return
  16757. }
  16758. // ResetWxs resets all changes to the "wxs" edge.
  16759. func (m *ServerMutation) ResetWxs() {
  16760. m.wxs = nil
  16761. m.clearedwxs = false
  16762. m.removedwxs = nil
  16763. }
  16764. // Where appends a list predicates to the ServerMutation builder.
  16765. func (m *ServerMutation) Where(ps ...predicate.Server) {
  16766. m.predicates = append(m.predicates, ps...)
  16767. }
  16768. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  16769. // users can use type-assertion to append predicates that do not depend on any generated package.
  16770. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  16771. p := make([]predicate.Server, len(ps))
  16772. for i := range ps {
  16773. p[i] = ps[i]
  16774. }
  16775. m.Where(p...)
  16776. }
  16777. // Op returns the operation name.
  16778. func (m *ServerMutation) Op() Op {
  16779. return m.op
  16780. }
  16781. // SetOp allows setting the mutation operation.
  16782. func (m *ServerMutation) SetOp(op Op) {
  16783. m.op = op
  16784. }
  16785. // Type returns the node type of this mutation (Server).
  16786. func (m *ServerMutation) Type() string {
  16787. return m.typ
  16788. }
  16789. // Fields returns all fields that were changed during this mutation. Note that in
  16790. // order to get all numeric fields that were incremented/decremented, call
  16791. // AddedFields().
  16792. func (m *ServerMutation) Fields() []string {
  16793. fields := make([]string, 0, 8)
  16794. if m.created_at != nil {
  16795. fields = append(fields, server.FieldCreatedAt)
  16796. }
  16797. if m.updated_at != nil {
  16798. fields = append(fields, server.FieldUpdatedAt)
  16799. }
  16800. if m.status != nil {
  16801. fields = append(fields, server.FieldStatus)
  16802. }
  16803. if m.deleted_at != nil {
  16804. fields = append(fields, server.FieldDeletedAt)
  16805. }
  16806. if m.name != nil {
  16807. fields = append(fields, server.FieldName)
  16808. }
  16809. if m.public_ip != nil {
  16810. fields = append(fields, server.FieldPublicIP)
  16811. }
  16812. if m.private_ip != nil {
  16813. fields = append(fields, server.FieldPrivateIP)
  16814. }
  16815. if m.admin_port != nil {
  16816. fields = append(fields, server.FieldAdminPort)
  16817. }
  16818. return fields
  16819. }
  16820. // Field returns the value of a field with the given name. The second boolean
  16821. // return value indicates that this field was not set, or was not defined in the
  16822. // schema.
  16823. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  16824. switch name {
  16825. case server.FieldCreatedAt:
  16826. return m.CreatedAt()
  16827. case server.FieldUpdatedAt:
  16828. return m.UpdatedAt()
  16829. case server.FieldStatus:
  16830. return m.Status()
  16831. case server.FieldDeletedAt:
  16832. return m.DeletedAt()
  16833. case server.FieldName:
  16834. return m.Name()
  16835. case server.FieldPublicIP:
  16836. return m.PublicIP()
  16837. case server.FieldPrivateIP:
  16838. return m.PrivateIP()
  16839. case server.FieldAdminPort:
  16840. return m.AdminPort()
  16841. }
  16842. return nil, false
  16843. }
  16844. // OldField returns the old value of the field from the database. An error is
  16845. // returned if the mutation operation is not UpdateOne, or the query to the
  16846. // database failed.
  16847. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16848. switch name {
  16849. case server.FieldCreatedAt:
  16850. return m.OldCreatedAt(ctx)
  16851. case server.FieldUpdatedAt:
  16852. return m.OldUpdatedAt(ctx)
  16853. case server.FieldStatus:
  16854. return m.OldStatus(ctx)
  16855. case server.FieldDeletedAt:
  16856. return m.OldDeletedAt(ctx)
  16857. case server.FieldName:
  16858. return m.OldName(ctx)
  16859. case server.FieldPublicIP:
  16860. return m.OldPublicIP(ctx)
  16861. case server.FieldPrivateIP:
  16862. return m.OldPrivateIP(ctx)
  16863. case server.FieldAdminPort:
  16864. return m.OldAdminPort(ctx)
  16865. }
  16866. return nil, fmt.Errorf("unknown Server field %s", name)
  16867. }
  16868. // SetField sets the value of a field with the given name. It returns an error if
  16869. // the field is not defined in the schema, or if the type mismatched the field
  16870. // type.
  16871. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  16872. switch name {
  16873. case server.FieldCreatedAt:
  16874. v, ok := value.(time.Time)
  16875. if !ok {
  16876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16877. }
  16878. m.SetCreatedAt(v)
  16879. return nil
  16880. case server.FieldUpdatedAt:
  16881. v, ok := value.(time.Time)
  16882. if !ok {
  16883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16884. }
  16885. m.SetUpdatedAt(v)
  16886. return nil
  16887. case server.FieldStatus:
  16888. v, ok := value.(uint8)
  16889. if !ok {
  16890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16891. }
  16892. m.SetStatus(v)
  16893. return nil
  16894. case server.FieldDeletedAt:
  16895. v, ok := value.(time.Time)
  16896. if !ok {
  16897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16898. }
  16899. m.SetDeletedAt(v)
  16900. return nil
  16901. case server.FieldName:
  16902. v, ok := value.(string)
  16903. if !ok {
  16904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16905. }
  16906. m.SetName(v)
  16907. return nil
  16908. case server.FieldPublicIP:
  16909. v, ok := value.(string)
  16910. if !ok {
  16911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16912. }
  16913. m.SetPublicIP(v)
  16914. return nil
  16915. case server.FieldPrivateIP:
  16916. v, ok := value.(string)
  16917. if !ok {
  16918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16919. }
  16920. m.SetPrivateIP(v)
  16921. return nil
  16922. case server.FieldAdminPort:
  16923. v, ok := value.(string)
  16924. if !ok {
  16925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16926. }
  16927. m.SetAdminPort(v)
  16928. return nil
  16929. }
  16930. return fmt.Errorf("unknown Server field %s", name)
  16931. }
  16932. // AddedFields returns all numeric fields that were incremented/decremented during
  16933. // this mutation.
  16934. func (m *ServerMutation) AddedFields() []string {
  16935. var fields []string
  16936. if m.addstatus != nil {
  16937. fields = append(fields, server.FieldStatus)
  16938. }
  16939. return fields
  16940. }
  16941. // AddedField returns the numeric value that was incremented/decremented on a field
  16942. // with the given name. The second boolean return value indicates that this field
  16943. // was not set, or was not defined in the schema.
  16944. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  16945. switch name {
  16946. case server.FieldStatus:
  16947. return m.AddedStatus()
  16948. }
  16949. return nil, false
  16950. }
  16951. // AddField adds the value to the field with the given name. It returns an error if
  16952. // the field is not defined in the schema, or if the type mismatched the field
  16953. // type.
  16954. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  16955. switch name {
  16956. case server.FieldStatus:
  16957. v, ok := value.(int8)
  16958. if !ok {
  16959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16960. }
  16961. m.AddStatus(v)
  16962. return nil
  16963. }
  16964. return fmt.Errorf("unknown Server numeric field %s", name)
  16965. }
  16966. // ClearedFields returns all nullable fields that were cleared during this
  16967. // mutation.
  16968. func (m *ServerMutation) ClearedFields() []string {
  16969. var fields []string
  16970. if m.FieldCleared(server.FieldStatus) {
  16971. fields = append(fields, server.FieldStatus)
  16972. }
  16973. if m.FieldCleared(server.FieldDeletedAt) {
  16974. fields = append(fields, server.FieldDeletedAt)
  16975. }
  16976. return fields
  16977. }
  16978. // FieldCleared returns a boolean indicating if a field with the given name was
  16979. // cleared in this mutation.
  16980. func (m *ServerMutation) FieldCleared(name string) bool {
  16981. _, ok := m.clearedFields[name]
  16982. return ok
  16983. }
  16984. // ClearField clears the value of the field with the given name. It returns an
  16985. // error if the field is not defined in the schema.
  16986. func (m *ServerMutation) ClearField(name string) error {
  16987. switch name {
  16988. case server.FieldStatus:
  16989. m.ClearStatus()
  16990. return nil
  16991. case server.FieldDeletedAt:
  16992. m.ClearDeletedAt()
  16993. return nil
  16994. }
  16995. return fmt.Errorf("unknown Server nullable field %s", name)
  16996. }
  16997. // ResetField resets all changes in the mutation for the field with the given name.
  16998. // It returns an error if the field is not defined in the schema.
  16999. func (m *ServerMutation) ResetField(name string) error {
  17000. switch name {
  17001. case server.FieldCreatedAt:
  17002. m.ResetCreatedAt()
  17003. return nil
  17004. case server.FieldUpdatedAt:
  17005. m.ResetUpdatedAt()
  17006. return nil
  17007. case server.FieldStatus:
  17008. m.ResetStatus()
  17009. return nil
  17010. case server.FieldDeletedAt:
  17011. m.ResetDeletedAt()
  17012. return nil
  17013. case server.FieldName:
  17014. m.ResetName()
  17015. return nil
  17016. case server.FieldPublicIP:
  17017. m.ResetPublicIP()
  17018. return nil
  17019. case server.FieldPrivateIP:
  17020. m.ResetPrivateIP()
  17021. return nil
  17022. case server.FieldAdminPort:
  17023. m.ResetAdminPort()
  17024. return nil
  17025. }
  17026. return fmt.Errorf("unknown Server field %s", name)
  17027. }
  17028. // AddedEdges returns all edge names that were set/added in this mutation.
  17029. func (m *ServerMutation) AddedEdges() []string {
  17030. edges := make([]string, 0, 1)
  17031. if m.wxs != nil {
  17032. edges = append(edges, server.EdgeWxs)
  17033. }
  17034. return edges
  17035. }
  17036. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17037. // name in this mutation.
  17038. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  17039. switch name {
  17040. case server.EdgeWxs:
  17041. ids := make([]ent.Value, 0, len(m.wxs))
  17042. for id := range m.wxs {
  17043. ids = append(ids, id)
  17044. }
  17045. return ids
  17046. }
  17047. return nil
  17048. }
  17049. // RemovedEdges returns all edge names that were removed in this mutation.
  17050. func (m *ServerMutation) RemovedEdges() []string {
  17051. edges := make([]string, 0, 1)
  17052. if m.removedwxs != nil {
  17053. edges = append(edges, server.EdgeWxs)
  17054. }
  17055. return edges
  17056. }
  17057. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17058. // the given name in this mutation.
  17059. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  17060. switch name {
  17061. case server.EdgeWxs:
  17062. ids := make([]ent.Value, 0, len(m.removedwxs))
  17063. for id := range m.removedwxs {
  17064. ids = append(ids, id)
  17065. }
  17066. return ids
  17067. }
  17068. return nil
  17069. }
  17070. // ClearedEdges returns all edge names that were cleared in this mutation.
  17071. func (m *ServerMutation) ClearedEdges() []string {
  17072. edges := make([]string, 0, 1)
  17073. if m.clearedwxs {
  17074. edges = append(edges, server.EdgeWxs)
  17075. }
  17076. return edges
  17077. }
  17078. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17079. // was cleared in this mutation.
  17080. func (m *ServerMutation) EdgeCleared(name string) bool {
  17081. switch name {
  17082. case server.EdgeWxs:
  17083. return m.clearedwxs
  17084. }
  17085. return false
  17086. }
  17087. // ClearEdge clears the value of the edge with the given name. It returns an error
  17088. // if that edge is not defined in the schema.
  17089. func (m *ServerMutation) ClearEdge(name string) error {
  17090. switch name {
  17091. }
  17092. return fmt.Errorf("unknown Server unique edge %s", name)
  17093. }
  17094. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17095. // It returns an error if the edge is not defined in the schema.
  17096. func (m *ServerMutation) ResetEdge(name string) error {
  17097. switch name {
  17098. case server.EdgeWxs:
  17099. m.ResetWxs()
  17100. return nil
  17101. }
  17102. return fmt.Errorf("unknown Server edge %s", name)
  17103. }
  17104. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  17105. type SopNodeMutation struct {
  17106. config
  17107. op Op
  17108. typ string
  17109. id *uint64
  17110. created_at *time.Time
  17111. updated_at *time.Time
  17112. status *uint8
  17113. addstatus *int8
  17114. deleted_at *time.Time
  17115. parent_id *uint64
  17116. addparent_id *int64
  17117. name *string
  17118. condition_type *int
  17119. addcondition_type *int
  17120. condition_list *[]string
  17121. appendcondition_list []string
  17122. no_reply_condition *uint64
  17123. addno_reply_condition *int64
  17124. no_reply_unit *string
  17125. action_message *[]custom_types.Action
  17126. appendaction_message []custom_types.Action
  17127. action_label_add *[]uint64
  17128. appendaction_label_add []uint64
  17129. action_label_del *[]uint64
  17130. appendaction_label_del []uint64
  17131. action_forward **custom_types.ActionForward
  17132. clearedFields map[string]struct{}
  17133. sop_stage *uint64
  17134. clearedsop_stage bool
  17135. node_messages map[uint64]struct{}
  17136. removednode_messages map[uint64]struct{}
  17137. clearednode_messages bool
  17138. done bool
  17139. oldValue func(context.Context) (*SopNode, error)
  17140. predicates []predicate.SopNode
  17141. }
  17142. var _ ent.Mutation = (*SopNodeMutation)(nil)
  17143. // sopnodeOption allows management of the mutation configuration using functional options.
  17144. type sopnodeOption func(*SopNodeMutation)
  17145. // newSopNodeMutation creates new mutation for the SopNode entity.
  17146. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  17147. m := &SopNodeMutation{
  17148. config: c,
  17149. op: op,
  17150. typ: TypeSopNode,
  17151. clearedFields: make(map[string]struct{}),
  17152. }
  17153. for _, opt := range opts {
  17154. opt(m)
  17155. }
  17156. return m
  17157. }
  17158. // withSopNodeID sets the ID field of the mutation.
  17159. func withSopNodeID(id uint64) sopnodeOption {
  17160. return func(m *SopNodeMutation) {
  17161. var (
  17162. err error
  17163. once sync.Once
  17164. value *SopNode
  17165. )
  17166. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  17167. once.Do(func() {
  17168. if m.done {
  17169. err = errors.New("querying old values post mutation is not allowed")
  17170. } else {
  17171. value, err = m.Client().SopNode.Get(ctx, id)
  17172. }
  17173. })
  17174. return value, err
  17175. }
  17176. m.id = &id
  17177. }
  17178. }
  17179. // withSopNode sets the old SopNode of the mutation.
  17180. func withSopNode(node *SopNode) sopnodeOption {
  17181. return func(m *SopNodeMutation) {
  17182. m.oldValue = func(context.Context) (*SopNode, error) {
  17183. return node, nil
  17184. }
  17185. m.id = &node.ID
  17186. }
  17187. }
  17188. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17189. // executed in a transaction (ent.Tx), a transactional client is returned.
  17190. func (m SopNodeMutation) Client() *Client {
  17191. client := &Client{config: m.config}
  17192. client.init()
  17193. return client
  17194. }
  17195. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17196. // it returns an error otherwise.
  17197. func (m SopNodeMutation) Tx() (*Tx, error) {
  17198. if _, ok := m.driver.(*txDriver); !ok {
  17199. return nil, errors.New("ent: mutation is not running in a transaction")
  17200. }
  17201. tx := &Tx{config: m.config}
  17202. tx.init()
  17203. return tx, nil
  17204. }
  17205. // SetID sets the value of the id field. Note that this
  17206. // operation is only accepted on creation of SopNode entities.
  17207. func (m *SopNodeMutation) SetID(id uint64) {
  17208. m.id = &id
  17209. }
  17210. // ID returns the ID value in the mutation. Note that the ID is only available
  17211. // if it was provided to the builder or after it was returned from the database.
  17212. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  17213. if m.id == nil {
  17214. return
  17215. }
  17216. return *m.id, true
  17217. }
  17218. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17219. // That means, if the mutation is applied within a transaction with an isolation level such
  17220. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17221. // or updated by the mutation.
  17222. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  17223. switch {
  17224. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17225. id, exists := m.ID()
  17226. if exists {
  17227. return []uint64{id}, nil
  17228. }
  17229. fallthrough
  17230. case m.op.Is(OpUpdate | OpDelete):
  17231. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  17232. default:
  17233. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17234. }
  17235. }
  17236. // SetCreatedAt sets the "created_at" field.
  17237. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  17238. m.created_at = &t
  17239. }
  17240. // CreatedAt returns the value of the "created_at" field in the mutation.
  17241. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  17242. v := m.created_at
  17243. if v == nil {
  17244. return
  17245. }
  17246. return *v, true
  17247. }
  17248. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  17249. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17251. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17252. if !m.op.Is(OpUpdateOne) {
  17253. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17254. }
  17255. if m.id == nil || m.oldValue == nil {
  17256. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17257. }
  17258. oldValue, err := m.oldValue(ctx)
  17259. if err != nil {
  17260. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17261. }
  17262. return oldValue.CreatedAt, nil
  17263. }
  17264. // ResetCreatedAt resets all changes to the "created_at" field.
  17265. func (m *SopNodeMutation) ResetCreatedAt() {
  17266. m.created_at = nil
  17267. }
  17268. // SetUpdatedAt sets the "updated_at" field.
  17269. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  17270. m.updated_at = &t
  17271. }
  17272. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17273. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  17274. v := m.updated_at
  17275. if v == nil {
  17276. return
  17277. }
  17278. return *v, true
  17279. }
  17280. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  17281. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17283. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17284. if !m.op.Is(OpUpdateOne) {
  17285. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17286. }
  17287. if m.id == nil || m.oldValue == nil {
  17288. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17289. }
  17290. oldValue, err := m.oldValue(ctx)
  17291. if err != nil {
  17292. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17293. }
  17294. return oldValue.UpdatedAt, nil
  17295. }
  17296. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17297. func (m *SopNodeMutation) ResetUpdatedAt() {
  17298. m.updated_at = nil
  17299. }
  17300. // SetStatus sets the "status" field.
  17301. func (m *SopNodeMutation) SetStatus(u uint8) {
  17302. m.status = &u
  17303. m.addstatus = nil
  17304. }
  17305. // Status returns the value of the "status" field in the mutation.
  17306. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  17307. v := m.status
  17308. if v == nil {
  17309. return
  17310. }
  17311. return *v, true
  17312. }
  17313. // OldStatus returns the old "status" field's value of the SopNode entity.
  17314. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17316. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17317. if !m.op.Is(OpUpdateOne) {
  17318. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17319. }
  17320. if m.id == nil || m.oldValue == nil {
  17321. return v, errors.New("OldStatus requires an ID field in the mutation")
  17322. }
  17323. oldValue, err := m.oldValue(ctx)
  17324. if err != nil {
  17325. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17326. }
  17327. return oldValue.Status, nil
  17328. }
  17329. // AddStatus adds u to the "status" field.
  17330. func (m *SopNodeMutation) AddStatus(u int8) {
  17331. if m.addstatus != nil {
  17332. *m.addstatus += u
  17333. } else {
  17334. m.addstatus = &u
  17335. }
  17336. }
  17337. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17338. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  17339. v := m.addstatus
  17340. if v == nil {
  17341. return
  17342. }
  17343. return *v, true
  17344. }
  17345. // ClearStatus clears the value of the "status" field.
  17346. func (m *SopNodeMutation) ClearStatus() {
  17347. m.status = nil
  17348. m.addstatus = nil
  17349. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  17350. }
  17351. // StatusCleared returns if the "status" field was cleared in this mutation.
  17352. func (m *SopNodeMutation) StatusCleared() bool {
  17353. _, ok := m.clearedFields[sopnode.FieldStatus]
  17354. return ok
  17355. }
  17356. // ResetStatus resets all changes to the "status" field.
  17357. func (m *SopNodeMutation) ResetStatus() {
  17358. m.status = nil
  17359. m.addstatus = nil
  17360. delete(m.clearedFields, sopnode.FieldStatus)
  17361. }
  17362. // SetDeletedAt sets the "deleted_at" field.
  17363. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  17364. m.deleted_at = &t
  17365. }
  17366. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17367. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  17368. v := m.deleted_at
  17369. if v == nil {
  17370. return
  17371. }
  17372. return *v, true
  17373. }
  17374. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  17375. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17377. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17378. if !m.op.Is(OpUpdateOne) {
  17379. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17380. }
  17381. if m.id == nil || m.oldValue == nil {
  17382. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17383. }
  17384. oldValue, err := m.oldValue(ctx)
  17385. if err != nil {
  17386. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17387. }
  17388. return oldValue.DeletedAt, nil
  17389. }
  17390. // ClearDeletedAt clears the value of the "deleted_at" field.
  17391. func (m *SopNodeMutation) ClearDeletedAt() {
  17392. m.deleted_at = nil
  17393. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  17394. }
  17395. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17396. func (m *SopNodeMutation) DeletedAtCleared() bool {
  17397. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  17398. return ok
  17399. }
  17400. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17401. func (m *SopNodeMutation) ResetDeletedAt() {
  17402. m.deleted_at = nil
  17403. delete(m.clearedFields, sopnode.FieldDeletedAt)
  17404. }
  17405. // SetStageID sets the "stage_id" field.
  17406. func (m *SopNodeMutation) SetStageID(u uint64) {
  17407. m.sop_stage = &u
  17408. }
  17409. // StageID returns the value of the "stage_id" field in the mutation.
  17410. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  17411. v := m.sop_stage
  17412. if v == nil {
  17413. return
  17414. }
  17415. return *v, true
  17416. }
  17417. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  17418. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17420. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  17421. if !m.op.Is(OpUpdateOne) {
  17422. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  17423. }
  17424. if m.id == nil || m.oldValue == nil {
  17425. return v, errors.New("OldStageID requires an ID field in the mutation")
  17426. }
  17427. oldValue, err := m.oldValue(ctx)
  17428. if err != nil {
  17429. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  17430. }
  17431. return oldValue.StageID, nil
  17432. }
  17433. // ResetStageID resets all changes to the "stage_id" field.
  17434. func (m *SopNodeMutation) ResetStageID() {
  17435. m.sop_stage = nil
  17436. }
  17437. // SetParentID sets the "parent_id" field.
  17438. func (m *SopNodeMutation) SetParentID(u uint64) {
  17439. m.parent_id = &u
  17440. m.addparent_id = nil
  17441. }
  17442. // ParentID returns the value of the "parent_id" field in the mutation.
  17443. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  17444. v := m.parent_id
  17445. if v == nil {
  17446. return
  17447. }
  17448. return *v, true
  17449. }
  17450. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  17451. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17453. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  17454. if !m.op.Is(OpUpdateOne) {
  17455. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  17456. }
  17457. if m.id == nil || m.oldValue == nil {
  17458. return v, errors.New("OldParentID requires an ID field in the mutation")
  17459. }
  17460. oldValue, err := m.oldValue(ctx)
  17461. if err != nil {
  17462. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  17463. }
  17464. return oldValue.ParentID, nil
  17465. }
  17466. // AddParentID adds u to the "parent_id" field.
  17467. func (m *SopNodeMutation) AddParentID(u int64) {
  17468. if m.addparent_id != nil {
  17469. *m.addparent_id += u
  17470. } else {
  17471. m.addparent_id = &u
  17472. }
  17473. }
  17474. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  17475. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  17476. v := m.addparent_id
  17477. if v == nil {
  17478. return
  17479. }
  17480. return *v, true
  17481. }
  17482. // ResetParentID resets all changes to the "parent_id" field.
  17483. func (m *SopNodeMutation) ResetParentID() {
  17484. m.parent_id = nil
  17485. m.addparent_id = nil
  17486. }
  17487. // SetName sets the "name" field.
  17488. func (m *SopNodeMutation) SetName(s string) {
  17489. m.name = &s
  17490. }
  17491. // Name returns the value of the "name" field in the mutation.
  17492. func (m *SopNodeMutation) Name() (r string, exists bool) {
  17493. v := m.name
  17494. if v == nil {
  17495. return
  17496. }
  17497. return *v, true
  17498. }
  17499. // OldName returns the old "name" field's value of the SopNode entity.
  17500. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17502. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  17503. if !m.op.Is(OpUpdateOne) {
  17504. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17505. }
  17506. if m.id == nil || m.oldValue == nil {
  17507. return v, errors.New("OldName requires an ID field in the mutation")
  17508. }
  17509. oldValue, err := m.oldValue(ctx)
  17510. if err != nil {
  17511. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17512. }
  17513. return oldValue.Name, nil
  17514. }
  17515. // ResetName resets all changes to the "name" field.
  17516. func (m *SopNodeMutation) ResetName() {
  17517. m.name = nil
  17518. }
  17519. // SetConditionType sets the "condition_type" field.
  17520. func (m *SopNodeMutation) SetConditionType(i int) {
  17521. m.condition_type = &i
  17522. m.addcondition_type = nil
  17523. }
  17524. // ConditionType returns the value of the "condition_type" field in the mutation.
  17525. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  17526. v := m.condition_type
  17527. if v == nil {
  17528. return
  17529. }
  17530. return *v, true
  17531. }
  17532. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  17533. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17535. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  17536. if !m.op.Is(OpUpdateOne) {
  17537. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  17538. }
  17539. if m.id == nil || m.oldValue == nil {
  17540. return v, errors.New("OldConditionType requires an ID field in the mutation")
  17541. }
  17542. oldValue, err := m.oldValue(ctx)
  17543. if err != nil {
  17544. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  17545. }
  17546. return oldValue.ConditionType, nil
  17547. }
  17548. // AddConditionType adds i to the "condition_type" field.
  17549. func (m *SopNodeMutation) AddConditionType(i int) {
  17550. if m.addcondition_type != nil {
  17551. *m.addcondition_type += i
  17552. } else {
  17553. m.addcondition_type = &i
  17554. }
  17555. }
  17556. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  17557. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  17558. v := m.addcondition_type
  17559. if v == nil {
  17560. return
  17561. }
  17562. return *v, true
  17563. }
  17564. // ResetConditionType resets all changes to the "condition_type" field.
  17565. func (m *SopNodeMutation) ResetConditionType() {
  17566. m.condition_type = nil
  17567. m.addcondition_type = nil
  17568. }
  17569. // SetConditionList sets the "condition_list" field.
  17570. func (m *SopNodeMutation) SetConditionList(s []string) {
  17571. m.condition_list = &s
  17572. m.appendcondition_list = nil
  17573. }
  17574. // ConditionList returns the value of the "condition_list" field in the mutation.
  17575. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  17576. v := m.condition_list
  17577. if v == nil {
  17578. return
  17579. }
  17580. return *v, true
  17581. }
  17582. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  17583. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17585. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  17586. if !m.op.Is(OpUpdateOne) {
  17587. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  17588. }
  17589. if m.id == nil || m.oldValue == nil {
  17590. return v, errors.New("OldConditionList requires an ID field in the mutation")
  17591. }
  17592. oldValue, err := m.oldValue(ctx)
  17593. if err != nil {
  17594. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  17595. }
  17596. return oldValue.ConditionList, nil
  17597. }
  17598. // AppendConditionList adds s to the "condition_list" field.
  17599. func (m *SopNodeMutation) AppendConditionList(s []string) {
  17600. m.appendcondition_list = append(m.appendcondition_list, s...)
  17601. }
  17602. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  17603. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  17604. if len(m.appendcondition_list) == 0 {
  17605. return nil, false
  17606. }
  17607. return m.appendcondition_list, true
  17608. }
  17609. // ClearConditionList clears the value of the "condition_list" field.
  17610. func (m *SopNodeMutation) ClearConditionList() {
  17611. m.condition_list = nil
  17612. m.appendcondition_list = nil
  17613. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  17614. }
  17615. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  17616. func (m *SopNodeMutation) ConditionListCleared() bool {
  17617. _, ok := m.clearedFields[sopnode.FieldConditionList]
  17618. return ok
  17619. }
  17620. // ResetConditionList resets all changes to the "condition_list" field.
  17621. func (m *SopNodeMutation) ResetConditionList() {
  17622. m.condition_list = nil
  17623. m.appendcondition_list = nil
  17624. delete(m.clearedFields, sopnode.FieldConditionList)
  17625. }
  17626. // SetNoReplyCondition sets the "no_reply_condition" field.
  17627. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  17628. m.no_reply_condition = &u
  17629. m.addno_reply_condition = nil
  17630. }
  17631. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  17632. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  17633. v := m.no_reply_condition
  17634. if v == nil {
  17635. return
  17636. }
  17637. return *v, true
  17638. }
  17639. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  17640. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17642. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  17643. if !m.op.Is(OpUpdateOne) {
  17644. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  17645. }
  17646. if m.id == nil || m.oldValue == nil {
  17647. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  17648. }
  17649. oldValue, err := m.oldValue(ctx)
  17650. if err != nil {
  17651. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  17652. }
  17653. return oldValue.NoReplyCondition, nil
  17654. }
  17655. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  17656. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  17657. if m.addno_reply_condition != nil {
  17658. *m.addno_reply_condition += u
  17659. } else {
  17660. m.addno_reply_condition = &u
  17661. }
  17662. }
  17663. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  17664. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  17665. v := m.addno_reply_condition
  17666. if v == nil {
  17667. return
  17668. }
  17669. return *v, true
  17670. }
  17671. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  17672. func (m *SopNodeMutation) ResetNoReplyCondition() {
  17673. m.no_reply_condition = nil
  17674. m.addno_reply_condition = nil
  17675. }
  17676. // SetNoReplyUnit sets the "no_reply_unit" field.
  17677. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  17678. m.no_reply_unit = &s
  17679. }
  17680. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  17681. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  17682. v := m.no_reply_unit
  17683. if v == nil {
  17684. return
  17685. }
  17686. return *v, true
  17687. }
  17688. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  17689. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17691. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  17692. if !m.op.Is(OpUpdateOne) {
  17693. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  17694. }
  17695. if m.id == nil || m.oldValue == nil {
  17696. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  17697. }
  17698. oldValue, err := m.oldValue(ctx)
  17699. if err != nil {
  17700. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  17701. }
  17702. return oldValue.NoReplyUnit, nil
  17703. }
  17704. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  17705. func (m *SopNodeMutation) ResetNoReplyUnit() {
  17706. m.no_reply_unit = nil
  17707. }
  17708. // SetActionMessage sets the "action_message" field.
  17709. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  17710. m.action_message = &ct
  17711. m.appendaction_message = nil
  17712. }
  17713. // ActionMessage returns the value of the "action_message" field in the mutation.
  17714. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  17715. v := m.action_message
  17716. if v == nil {
  17717. return
  17718. }
  17719. return *v, true
  17720. }
  17721. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  17722. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17724. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  17725. if !m.op.Is(OpUpdateOne) {
  17726. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  17727. }
  17728. if m.id == nil || m.oldValue == nil {
  17729. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  17730. }
  17731. oldValue, err := m.oldValue(ctx)
  17732. if err != nil {
  17733. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  17734. }
  17735. return oldValue.ActionMessage, nil
  17736. }
  17737. // AppendActionMessage adds ct to the "action_message" field.
  17738. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  17739. m.appendaction_message = append(m.appendaction_message, ct...)
  17740. }
  17741. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  17742. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  17743. if len(m.appendaction_message) == 0 {
  17744. return nil, false
  17745. }
  17746. return m.appendaction_message, true
  17747. }
  17748. // ClearActionMessage clears the value of the "action_message" field.
  17749. func (m *SopNodeMutation) ClearActionMessage() {
  17750. m.action_message = nil
  17751. m.appendaction_message = nil
  17752. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  17753. }
  17754. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  17755. func (m *SopNodeMutation) ActionMessageCleared() bool {
  17756. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  17757. return ok
  17758. }
  17759. // ResetActionMessage resets all changes to the "action_message" field.
  17760. func (m *SopNodeMutation) ResetActionMessage() {
  17761. m.action_message = nil
  17762. m.appendaction_message = nil
  17763. delete(m.clearedFields, sopnode.FieldActionMessage)
  17764. }
  17765. // SetActionLabelAdd sets the "action_label_add" field.
  17766. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  17767. m.action_label_add = &u
  17768. m.appendaction_label_add = nil
  17769. }
  17770. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17771. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17772. v := m.action_label_add
  17773. if v == nil {
  17774. return
  17775. }
  17776. return *v, true
  17777. }
  17778. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  17779. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17781. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17782. if !m.op.Is(OpUpdateOne) {
  17783. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17784. }
  17785. if m.id == nil || m.oldValue == nil {
  17786. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17787. }
  17788. oldValue, err := m.oldValue(ctx)
  17789. if err != nil {
  17790. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17791. }
  17792. return oldValue.ActionLabelAdd, nil
  17793. }
  17794. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17795. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  17796. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17797. }
  17798. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17799. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17800. if len(m.appendaction_label_add) == 0 {
  17801. return nil, false
  17802. }
  17803. return m.appendaction_label_add, true
  17804. }
  17805. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17806. func (m *SopNodeMutation) ClearActionLabelAdd() {
  17807. m.action_label_add = nil
  17808. m.appendaction_label_add = nil
  17809. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  17810. }
  17811. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17812. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  17813. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  17814. return ok
  17815. }
  17816. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17817. func (m *SopNodeMutation) ResetActionLabelAdd() {
  17818. m.action_label_add = nil
  17819. m.appendaction_label_add = nil
  17820. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  17821. }
  17822. // SetActionLabelDel sets the "action_label_del" field.
  17823. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  17824. m.action_label_del = &u
  17825. m.appendaction_label_del = nil
  17826. }
  17827. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17828. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  17829. v := m.action_label_del
  17830. if v == nil {
  17831. return
  17832. }
  17833. return *v, true
  17834. }
  17835. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  17836. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17838. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17839. if !m.op.Is(OpUpdateOne) {
  17840. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17841. }
  17842. if m.id == nil || m.oldValue == nil {
  17843. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17844. }
  17845. oldValue, err := m.oldValue(ctx)
  17846. if err != nil {
  17847. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  17848. }
  17849. return oldValue.ActionLabelDel, nil
  17850. }
  17851. // AppendActionLabelDel adds u to the "action_label_del" field.
  17852. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  17853. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  17854. }
  17855. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  17856. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  17857. if len(m.appendaction_label_del) == 0 {
  17858. return nil, false
  17859. }
  17860. return m.appendaction_label_del, true
  17861. }
  17862. // ClearActionLabelDel clears the value of the "action_label_del" field.
  17863. func (m *SopNodeMutation) ClearActionLabelDel() {
  17864. m.action_label_del = nil
  17865. m.appendaction_label_del = nil
  17866. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  17867. }
  17868. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  17869. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  17870. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  17871. return ok
  17872. }
  17873. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  17874. func (m *SopNodeMutation) ResetActionLabelDel() {
  17875. m.action_label_del = nil
  17876. m.appendaction_label_del = nil
  17877. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  17878. }
  17879. // SetActionForward sets the "action_forward" field.
  17880. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  17881. m.action_forward = &ctf
  17882. }
  17883. // ActionForward returns the value of the "action_forward" field in the mutation.
  17884. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  17885. v := m.action_forward
  17886. if v == nil {
  17887. return
  17888. }
  17889. return *v, true
  17890. }
  17891. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  17892. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17894. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  17895. if !m.op.Is(OpUpdateOne) {
  17896. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  17897. }
  17898. if m.id == nil || m.oldValue == nil {
  17899. return v, errors.New("OldActionForward requires an ID field in the mutation")
  17900. }
  17901. oldValue, err := m.oldValue(ctx)
  17902. if err != nil {
  17903. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  17904. }
  17905. return oldValue.ActionForward, nil
  17906. }
  17907. // ClearActionForward clears the value of the "action_forward" field.
  17908. func (m *SopNodeMutation) ClearActionForward() {
  17909. m.action_forward = nil
  17910. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  17911. }
  17912. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  17913. func (m *SopNodeMutation) ActionForwardCleared() bool {
  17914. _, ok := m.clearedFields[sopnode.FieldActionForward]
  17915. return ok
  17916. }
  17917. // ResetActionForward resets all changes to the "action_forward" field.
  17918. func (m *SopNodeMutation) ResetActionForward() {
  17919. m.action_forward = nil
  17920. delete(m.clearedFields, sopnode.FieldActionForward)
  17921. }
  17922. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17923. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  17924. m.sop_stage = &id
  17925. }
  17926. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17927. func (m *SopNodeMutation) ClearSopStage() {
  17928. m.clearedsop_stage = true
  17929. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  17930. }
  17931. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17932. func (m *SopNodeMutation) SopStageCleared() bool {
  17933. return m.clearedsop_stage
  17934. }
  17935. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17936. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  17937. if m.sop_stage != nil {
  17938. return *m.sop_stage, true
  17939. }
  17940. return
  17941. }
  17942. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17943. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17944. // SopStageID instead. It exists only for internal usage by the builders.
  17945. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  17946. if id := m.sop_stage; id != nil {
  17947. ids = append(ids, *id)
  17948. }
  17949. return
  17950. }
  17951. // ResetSopStage resets all changes to the "sop_stage" edge.
  17952. func (m *SopNodeMutation) ResetSopStage() {
  17953. m.sop_stage = nil
  17954. m.clearedsop_stage = false
  17955. }
  17956. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  17957. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  17958. if m.node_messages == nil {
  17959. m.node_messages = make(map[uint64]struct{})
  17960. }
  17961. for i := range ids {
  17962. m.node_messages[ids[i]] = struct{}{}
  17963. }
  17964. }
  17965. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  17966. func (m *SopNodeMutation) ClearNodeMessages() {
  17967. m.clearednode_messages = true
  17968. }
  17969. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  17970. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  17971. return m.clearednode_messages
  17972. }
  17973. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  17974. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  17975. if m.removednode_messages == nil {
  17976. m.removednode_messages = make(map[uint64]struct{})
  17977. }
  17978. for i := range ids {
  17979. delete(m.node_messages, ids[i])
  17980. m.removednode_messages[ids[i]] = struct{}{}
  17981. }
  17982. }
  17983. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  17984. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  17985. for id := range m.removednode_messages {
  17986. ids = append(ids, id)
  17987. }
  17988. return
  17989. }
  17990. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  17991. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  17992. for id := range m.node_messages {
  17993. ids = append(ids, id)
  17994. }
  17995. return
  17996. }
  17997. // ResetNodeMessages resets all changes to the "node_messages" edge.
  17998. func (m *SopNodeMutation) ResetNodeMessages() {
  17999. m.node_messages = nil
  18000. m.clearednode_messages = false
  18001. m.removednode_messages = nil
  18002. }
  18003. // Where appends a list predicates to the SopNodeMutation builder.
  18004. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  18005. m.predicates = append(m.predicates, ps...)
  18006. }
  18007. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  18008. // users can use type-assertion to append predicates that do not depend on any generated package.
  18009. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  18010. p := make([]predicate.SopNode, len(ps))
  18011. for i := range ps {
  18012. p[i] = ps[i]
  18013. }
  18014. m.Where(p...)
  18015. }
  18016. // Op returns the operation name.
  18017. func (m *SopNodeMutation) Op() Op {
  18018. return m.op
  18019. }
  18020. // SetOp allows setting the mutation operation.
  18021. func (m *SopNodeMutation) SetOp(op Op) {
  18022. m.op = op
  18023. }
  18024. // Type returns the node type of this mutation (SopNode).
  18025. func (m *SopNodeMutation) Type() string {
  18026. return m.typ
  18027. }
  18028. // Fields returns all fields that were changed during this mutation. Note that in
  18029. // order to get all numeric fields that were incremented/decremented, call
  18030. // AddedFields().
  18031. func (m *SopNodeMutation) Fields() []string {
  18032. fields := make([]string, 0, 15)
  18033. if m.created_at != nil {
  18034. fields = append(fields, sopnode.FieldCreatedAt)
  18035. }
  18036. if m.updated_at != nil {
  18037. fields = append(fields, sopnode.FieldUpdatedAt)
  18038. }
  18039. if m.status != nil {
  18040. fields = append(fields, sopnode.FieldStatus)
  18041. }
  18042. if m.deleted_at != nil {
  18043. fields = append(fields, sopnode.FieldDeletedAt)
  18044. }
  18045. if m.sop_stage != nil {
  18046. fields = append(fields, sopnode.FieldStageID)
  18047. }
  18048. if m.parent_id != nil {
  18049. fields = append(fields, sopnode.FieldParentID)
  18050. }
  18051. if m.name != nil {
  18052. fields = append(fields, sopnode.FieldName)
  18053. }
  18054. if m.condition_type != nil {
  18055. fields = append(fields, sopnode.FieldConditionType)
  18056. }
  18057. if m.condition_list != nil {
  18058. fields = append(fields, sopnode.FieldConditionList)
  18059. }
  18060. if m.no_reply_condition != nil {
  18061. fields = append(fields, sopnode.FieldNoReplyCondition)
  18062. }
  18063. if m.no_reply_unit != nil {
  18064. fields = append(fields, sopnode.FieldNoReplyUnit)
  18065. }
  18066. if m.action_message != nil {
  18067. fields = append(fields, sopnode.FieldActionMessage)
  18068. }
  18069. if m.action_label_add != nil {
  18070. fields = append(fields, sopnode.FieldActionLabelAdd)
  18071. }
  18072. if m.action_label_del != nil {
  18073. fields = append(fields, sopnode.FieldActionLabelDel)
  18074. }
  18075. if m.action_forward != nil {
  18076. fields = append(fields, sopnode.FieldActionForward)
  18077. }
  18078. return fields
  18079. }
  18080. // Field returns the value of a field with the given name. The second boolean
  18081. // return value indicates that this field was not set, or was not defined in the
  18082. // schema.
  18083. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  18084. switch name {
  18085. case sopnode.FieldCreatedAt:
  18086. return m.CreatedAt()
  18087. case sopnode.FieldUpdatedAt:
  18088. return m.UpdatedAt()
  18089. case sopnode.FieldStatus:
  18090. return m.Status()
  18091. case sopnode.FieldDeletedAt:
  18092. return m.DeletedAt()
  18093. case sopnode.FieldStageID:
  18094. return m.StageID()
  18095. case sopnode.FieldParentID:
  18096. return m.ParentID()
  18097. case sopnode.FieldName:
  18098. return m.Name()
  18099. case sopnode.FieldConditionType:
  18100. return m.ConditionType()
  18101. case sopnode.FieldConditionList:
  18102. return m.ConditionList()
  18103. case sopnode.FieldNoReplyCondition:
  18104. return m.NoReplyCondition()
  18105. case sopnode.FieldNoReplyUnit:
  18106. return m.NoReplyUnit()
  18107. case sopnode.FieldActionMessage:
  18108. return m.ActionMessage()
  18109. case sopnode.FieldActionLabelAdd:
  18110. return m.ActionLabelAdd()
  18111. case sopnode.FieldActionLabelDel:
  18112. return m.ActionLabelDel()
  18113. case sopnode.FieldActionForward:
  18114. return m.ActionForward()
  18115. }
  18116. return nil, false
  18117. }
  18118. // OldField returns the old value of the field from the database. An error is
  18119. // returned if the mutation operation is not UpdateOne, or the query to the
  18120. // database failed.
  18121. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18122. switch name {
  18123. case sopnode.FieldCreatedAt:
  18124. return m.OldCreatedAt(ctx)
  18125. case sopnode.FieldUpdatedAt:
  18126. return m.OldUpdatedAt(ctx)
  18127. case sopnode.FieldStatus:
  18128. return m.OldStatus(ctx)
  18129. case sopnode.FieldDeletedAt:
  18130. return m.OldDeletedAt(ctx)
  18131. case sopnode.FieldStageID:
  18132. return m.OldStageID(ctx)
  18133. case sopnode.FieldParentID:
  18134. return m.OldParentID(ctx)
  18135. case sopnode.FieldName:
  18136. return m.OldName(ctx)
  18137. case sopnode.FieldConditionType:
  18138. return m.OldConditionType(ctx)
  18139. case sopnode.FieldConditionList:
  18140. return m.OldConditionList(ctx)
  18141. case sopnode.FieldNoReplyCondition:
  18142. return m.OldNoReplyCondition(ctx)
  18143. case sopnode.FieldNoReplyUnit:
  18144. return m.OldNoReplyUnit(ctx)
  18145. case sopnode.FieldActionMessage:
  18146. return m.OldActionMessage(ctx)
  18147. case sopnode.FieldActionLabelAdd:
  18148. return m.OldActionLabelAdd(ctx)
  18149. case sopnode.FieldActionLabelDel:
  18150. return m.OldActionLabelDel(ctx)
  18151. case sopnode.FieldActionForward:
  18152. return m.OldActionForward(ctx)
  18153. }
  18154. return nil, fmt.Errorf("unknown SopNode field %s", name)
  18155. }
  18156. // SetField sets the value of a field with the given name. It returns an error if
  18157. // the field is not defined in the schema, or if the type mismatched the field
  18158. // type.
  18159. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  18160. switch name {
  18161. case sopnode.FieldCreatedAt:
  18162. v, ok := value.(time.Time)
  18163. if !ok {
  18164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18165. }
  18166. m.SetCreatedAt(v)
  18167. return nil
  18168. case sopnode.FieldUpdatedAt:
  18169. v, ok := value.(time.Time)
  18170. if !ok {
  18171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18172. }
  18173. m.SetUpdatedAt(v)
  18174. return nil
  18175. case sopnode.FieldStatus:
  18176. v, ok := value.(uint8)
  18177. if !ok {
  18178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18179. }
  18180. m.SetStatus(v)
  18181. return nil
  18182. case sopnode.FieldDeletedAt:
  18183. v, ok := value.(time.Time)
  18184. if !ok {
  18185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18186. }
  18187. m.SetDeletedAt(v)
  18188. return nil
  18189. case sopnode.FieldStageID:
  18190. v, ok := value.(uint64)
  18191. if !ok {
  18192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18193. }
  18194. m.SetStageID(v)
  18195. return nil
  18196. case sopnode.FieldParentID:
  18197. v, ok := value.(uint64)
  18198. if !ok {
  18199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18200. }
  18201. m.SetParentID(v)
  18202. return nil
  18203. case sopnode.FieldName:
  18204. v, ok := value.(string)
  18205. if !ok {
  18206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18207. }
  18208. m.SetName(v)
  18209. return nil
  18210. case sopnode.FieldConditionType:
  18211. v, ok := value.(int)
  18212. if !ok {
  18213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18214. }
  18215. m.SetConditionType(v)
  18216. return nil
  18217. case sopnode.FieldConditionList:
  18218. v, ok := value.([]string)
  18219. if !ok {
  18220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18221. }
  18222. m.SetConditionList(v)
  18223. return nil
  18224. case sopnode.FieldNoReplyCondition:
  18225. v, ok := value.(uint64)
  18226. if !ok {
  18227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18228. }
  18229. m.SetNoReplyCondition(v)
  18230. return nil
  18231. case sopnode.FieldNoReplyUnit:
  18232. v, ok := value.(string)
  18233. if !ok {
  18234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18235. }
  18236. m.SetNoReplyUnit(v)
  18237. return nil
  18238. case sopnode.FieldActionMessage:
  18239. v, ok := value.([]custom_types.Action)
  18240. if !ok {
  18241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18242. }
  18243. m.SetActionMessage(v)
  18244. return nil
  18245. case sopnode.FieldActionLabelAdd:
  18246. v, ok := value.([]uint64)
  18247. if !ok {
  18248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18249. }
  18250. m.SetActionLabelAdd(v)
  18251. return nil
  18252. case sopnode.FieldActionLabelDel:
  18253. v, ok := value.([]uint64)
  18254. if !ok {
  18255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18256. }
  18257. m.SetActionLabelDel(v)
  18258. return nil
  18259. case sopnode.FieldActionForward:
  18260. v, ok := value.(*custom_types.ActionForward)
  18261. if !ok {
  18262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18263. }
  18264. m.SetActionForward(v)
  18265. return nil
  18266. }
  18267. return fmt.Errorf("unknown SopNode field %s", name)
  18268. }
  18269. // AddedFields returns all numeric fields that were incremented/decremented during
  18270. // this mutation.
  18271. func (m *SopNodeMutation) AddedFields() []string {
  18272. var fields []string
  18273. if m.addstatus != nil {
  18274. fields = append(fields, sopnode.FieldStatus)
  18275. }
  18276. if m.addparent_id != nil {
  18277. fields = append(fields, sopnode.FieldParentID)
  18278. }
  18279. if m.addcondition_type != nil {
  18280. fields = append(fields, sopnode.FieldConditionType)
  18281. }
  18282. if m.addno_reply_condition != nil {
  18283. fields = append(fields, sopnode.FieldNoReplyCondition)
  18284. }
  18285. return fields
  18286. }
  18287. // AddedField returns the numeric value that was incremented/decremented on a field
  18288. // with the given name. The second boolean return value indicates that this field
  18289. // was not set, or was not defined in the schema.
  18290. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  18291. switch name {
  18292. case sopnode.FieldStatus:
  18293. return m.AddedStatus()
  18294. case sopnode.FieldParentID:
  18295. return m.AddedParentID()
  18296. case sopnode.FieldConditionType:
  18297. return m.AddedConditionType()
  18298. case sopnode.FieldNoReplyCondition:
  18299. return m.AddedNoReplyCondition()
  18300. }
  18301. return nil, false
  18302. }
  18303. // AddField adds the value to the field with the given name. It returns an error if
  18304. // the field is not defined in the schema, or if the type mismatched the field
  18305. // type.
  18306. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  18307. switch name {
  18308. case sopnode.FieldStatus:
  18309. v, ok := value.(int8)
  18310. if !ok {
  18311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18312. }
  18313. m.AddStatus(v)
  18314. return nil
  18315. case sopnode.FieldParentID:
  18316. v, ok := value.(int64)
  18317. if !ok {
  18318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18319. }
  18320. m.AddParentID(v)
  18321. return nil
  18322. case sopnode.FieldConditionType:
  18323. v, ok := value.(int)
  18324. if !ok {
  18325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18326. }
  18327. m.AddConditionType(v)
  18328. return nil
  18329. case sopnode.FieldNoReplyCondition:
  18330. v, ok := value.(int64)
  18331. if !ok {
  18332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18333. }
  18334. m.AddNoReplyCondition(v)
  18335. return nil
  18336. }
  18337. return fmt.Errorf("unknown SopNode numeric field %s", name)
  18338. }
  18339. // ClearedFields returns all nullable fields that were cleared during this
  18340. // mutation.
  18341. func (m *SopNodeMutation) ClearedFields() []string {
  18342. var fields []string
  18343. if m.FieldCleared(sopnode.FieldStatus) {
  18344. fields = append(fields, sopnode.FieldStatus)
  18345. }
  18346. if m.FieldCleared(sopnode.FieldDeletedAt) {
  18347. fields = append(fields, sopnode.FieldDeletedAt)
  18348. }
  18349. if m.FieldCleared(sopnode.FieldConditionList) {
  18350. fields = append(fields, sopnode.FieldConditionList)
  18351. }
  18352. if m.FieldCleared(sopnode.FieldActionMessage) {
  18353. fields = append(fields, sopnode.FieldActionMessage)
  18354. }
  18355. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  18356. fields = append(fields, sopnode.FieldActionLabelAdd)
  18357. }
  18358. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  18359. fields = append(fields, sopnode.FieldActionLabelDel)
  18360. }
  18361. if m.FieldCleared(sopnode.FieldActionForward) {
  18362. fields = append(fields, sopnode.FieldActionForward)
  18363. }
  18364. return fields
  18365. }
  18366. // FieldCleared returns a boolean indicating if a field with the given name was
  18367. // cleared in this mutation.
  18368. func (m *SopNodeMutation) FieldCleared(name string) bool {
  18369. _, ok := m.clearedFields[name]
  18370. return ok
  18371. }
  18372. // ClearField clears the value of the field with the given name. It returns an
  18373. // error if the field is not defined in the schema.
  18374. func (m *SopNodeMutation) ClearField(name string) error {
  18375. switch name {
  18376. case sopnode.FieldStatus:
  18377. m.ClearStatus()
  18378. return nil
  18379. case sopnode.FieldDeletedAt:
  18380. m.ClearDeletedAt()
  18381. return nil
  18382. case sopnode.FieldConditionList:
  18383. m.ClearConditionList()
  18384. return nil
  18385. case sopnode.FieldActionMessage:
  18386. m.ClearActionMessage()
  18387. return nil
  18388. case sopnode.FieldActionLabelAdd:
  18389. m.ClearActionLabelAdd()
  18390. return nil
  18391. case sopnode.FieldActionLabelDel:
  18392. m.ClearActionLabelDel()
  18393. return nil
  18394. case sopnode.FieldActionForward:
  18395. m.ClearActionForward()
  18396. return nil
  18397. }
  18398. return fmt.Errorf("unknown SopNode nullable field %s", name)
  18399. }
  18400. // ResetField resets all changes in the mutation for the field with the given name.
  18401. // It returns an error if the field is not defined in the schema.
  18402. func (m *SopNodeMutation) ResetField(name string) error {
  18403. switch name {
  18404. case sopnode.FieldCreatedAt:
  18405. m.ResetCreatedAt()
  18406. return nil
  18407. case sopnode.FieldUpdatedAt:
  18408. m.ResetUpdatedAt()
  18409. return nil
  18410. case sopnode.FieldStatus:
  18411. m.ResetStatus()
  18412. return nil
  18413. case sopnode.FieldDeletedAt:
  18414. m.ResetDeletedAt()
  18415. return nil
  18416. case sopnode.FieldStageID:
  18417. m.ResetStageID()
  18418. return nil
  18419. case sopnode.FieldParentID:
  18420. m.ResetParentID()
  18421. return nil
  18422. case sopnode.FieldName:
  18423. m.ResetName()
  18424. return nil
  18425. case sopnode.FieldConditionType:
  18426. m.ResetConditionType()
  18427. return nil
  18428. case sopnode.FieldConditionList:
  18429. m.ResetConditionList()
  18430. return nil
  18431. case sopnode.FieldNoReplyCondition:
  18432. m.ResetNoReplyCondition()
  18433. return nil
  18434. case sopnode.FieldNoReplyUnit:
  18435. m.ResetNoReplyUnit()
  18436. return nil
  18437. case sopnode.FieldActionMessage:
  18438. m.ResetActionMessage()
  18439. return nil
  18440. case sopnode.FieldActionLabelAdd:
  18441. m.ResetActionLabelAdd()
  18442. return nil
  18443. case sopnode.FieldActionLabelDel:
  18444. m.ResetActionLabelDel()
  18445. return nil
  18446. case sopnode.FieldActionForward:
  18447. m.ResetActionForward()
  18448. return nil
  18449. }
  18450. return fmt.Errorf("unknown SopNode field %s", name)
  18451. }
  18452. // AddedEdges returns all edge names that were set/added in this mutation.
  18453. func (m *SopNodeMutation) AddedEdges() []string {
  18454. edges := make([]string, 0, 2)
  18455. if m.sop_stage != nil {
  18456. edges = append(edges, sopnode.EdgeSopStage)
  18457. }
  18458. if m.node_messages != nil {
  18459. edges = append(edges, sopnode.EdgeNodeMessages)
  18460. }
  18461. return edges
  18462. }
  18463. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18464. // name in this mutation.
  18465. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  18466. switch name {
  18467. case sopnode.EdgeSopStage:
  18468. if id := m.sop_stage; id != nil {
  18469. return []ent.Value{*id}
  18470. }
  18471. case sopnode.EdgeNodeMessages:
  18472. ids := make([]ent.Value, 0, len(m.node_messages))
  18473. for id := range m.node_messages {
  18474. ids = append(ids, id)
  18475. }
  18476. return ids
  18477. }
  18478. return nil
  18479. }
  18480. // RemovedEdges returns all edge names that were removed in this mutation.
  18481. func (m *SopNodeMutation) RemovedEdges() []string {
  18482. edges := make([]string, 0, 2)
  18483. if m.removednode_messages != nil {
  18484. edges = append(edges, sopnode.EdgeNodeMessages)
  18485. }
  18486. return edges
  18487. }
  18488. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18489. // the given name in this mutation.
  18490. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  18491. switch name {
  18492. case sopnode.EdgeNodeMessages:
  18493. ids := make([]ent.Value, 0, len(m.removednode_messages))
  18494. for id := range m.removednode_messages {
  18495. ids = append(ids, id)
  18496. }
  18497. return ids
  18498. }
  18499. return nil
  18500. }
  18501. // ClearedEdges returns all edge names that were cleared in this mutation.
  18502. func (m *SopNodeMutation) ClearedEdges() []string {
  18503. edges := make([]string, 0, 2)
  18504. if m.clearedsop_stage {
  18505. edges = append(edges, sopnode.EdgeSopStage)
  18506. }
  18507. if m.clearednode_messages {
  18508. edges = append(edges, sopnode.EdgeNodeMessages)
  18509. }
  18510. return edges
  18511. }
  18512. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18513. // was cleared in this mutation.
  18514. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  18515. switch name {
  18516. case sopnode.EdgeSopStage:
  18517. return m.clearedsop_stage
  18518. case sopnode.EdgeNodeMessages:
  18519. return m.clearednode_messages
  18520. }
  18521. return false
  18522. }
  18523. // ClearEdge clears the value of the edge with the given name. It returns an error
  18524. // if that edge is not defined in the schema.
  18525. func (m *SopNodeMutation) ClearEdge(name string) error {
  18526. switch name {
  18527. case sopnode.EdgeSopStage:
  18528. m.ClearSopStage()
  18529. return nil
  18530. }
  18531. return fmt.Errorf("unknown SopNode unique edge %s", name)
  18532. }
  18533. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18534. // It returns an error if the edge is not defined in the schema.
  18535. func (m *SopNodeMutation) ResetEdge(name string) error {
  18536. switch name {
  18537. case sopnode.EdgeSopStage:
  18538. m.ResetSopStage()
  18539. return nil
  18540. case sopnode.EdgeNodeMessages:
  18541. m.ResetNodeMessages()
  18542. return nil
  18543. }
  18544. return fmt.Errorf("unknown SopNode edge %s", name)
  18545. }
  18546. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  18547. type SopStageMutation struct {
  18548. config
  18549. op Op
  18550. typ string
  18551. id *uint64
  18552. created_at *time.Time
  18553. updated_at *time.Time
  18554. status *uint8
  18555. addstatus *int8
  18556. deleted_at *time.Time
  18557. name *string
  18558. condition_type *int
  18559. addcondition_type *int
  18560. condition_operator *int
  18561. addcondition_operator *int
  18562. condition_list *[]custom_types.Condition
  18563. appendcondition_list []custom_types.Condition
  18564. action_message *[]custom_types.Action
  18565. appendaction_message []custom_types.Action
  18566. action_label_add *[]uint64
  18567. appendaction_label_add []uint64
  18568. action_label_del *[]uint64
  18569. appendaction_label_del []uint64
  18570. action_forward **custom_types.ActionForward
  18571. index_sort *int
  18572. addindex_sort *int
  18573. clearedFields map[string]struct{}
  18574. sop_task *uint64
  18575. clearedsop_task bool
  18576. stage_nodes map[uint64]struct{}
  18577. removedstage_nodes map[uint64]struct{}
  18578. clearedstage_nodes bool
  18579. stage_messages map[uint64]struct{}
  18580. removedstage_messages map[uint64]struct{}
  18581. clearedstage_messages bool
  18582. done bool
  18583. oldValue func(context.Context) (*SopStage, error)
  18584. predicates []predicate.SopStage
  18585. }
  18586. var _ ent.Mutation = (*SopStageMutation)(nil)
  18587. // sopstageOption allows management of the mutation configuration using functional options.
  18588. type sopstageOption func(*SopStageMutation)
  18589. // newSopStageMutation creates new mutation for the SopStage entity.
  18590. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  18591. m := &SopStageMutation{
  18592. config: c,
  18593. op: op,
  18594. typ: TypeSopStage,
  18595. clearedFields: make(map[string]struct{}),
  18596. }
  18597. for _, opt := range opts {
  18598. opt(m)
  18599. }
  18600. return m
  18601. }
  18602. // withSopStageID sets the ID field of the mutation.
  18603. func withSopStageID(id uint64) sopstageOption {
  18604. return func(m *SopStageMutation) {
  18605. var (
  18606. err error
  18607. once sync.Once
  18608. value *SopStage
  18609. )
  18610. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  18611. once.Do(func() {
  18612. if m.done {
  18613. err = errors.New("querying old values post mutation is not allowed")
  18614. } else {
  18615. value, err = m.Client().SopStage.Get(ctx, id)
  18616. }
  18617. })
  18618. return value, err
  18619. }
  18620. m.id = &id
  18621. }
  18622. }
  18623. // withSopStage sets the old SopStage of the mutation.
  18624. func withSopStage(node *SopStage) sopstageOption {
  18625. return func(m *SopStageMutation) {
  18626. m.oldValue = func(context.Context) (*SopStage, error) {
  18627. return node, nil
  18628. }
  18629. m.id = &node.ID
  18630. }
  18631. }
  18632. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18633. // executed in a transaction (ent.Tx), a transactional client is returned.
  18634. func (m SopStageMutation) Client() *Client {
  18635. client := &Client{config: m.config}
  18636. client.init()
  18637. return client
  18638. }
  18639. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18640. // it returns an error otherwise.
  18641. func (m SopStageMutation) Tx() (*Tx, error) {
  18642. if _, ok := m.driver.(*txDriver); !ok {
  18643. return nil, errors.New("ent: mutation is not running in a transaction")
  18644. }
  18645. tx := &Tx{config: m.config}
  18646. tx.init()
  18647. return tx, nil
  18648. }
  18649. // SetID sets the value of the id field. Note that this
  18650. // operation is only accepted on creation of SopStage entities.
  18651. func (m *SopStageMutation) SetID(id uint64) {
  18652. m.id = &id
  18653. }
  18654. // ID returns the ID value in the mutation. Note that the ID is only available
  18655. // if it was provided to the builder or after it was returned from the database.
  18656. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  18657. if m.id == nil {
  18658. return
  18659. }
  18660. return *m.id, true
  18661. }
  18662. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18663. // That means, if the mutation is applied within a transaction with an isolation level such
  18664. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18665. // or updated by the mutation.
  18666. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  18667. switch {
  18668. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18669. id, exists := m.ID()
  18670. if exists {
  18671. return []uint64{id}, nil
  18672. }
  18673. fallthrough
  18674. case m.op.Is(OpUpdate | OpDelete):
  18675. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  18676. default:
  18677. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18678. }
  18679. }
  18680. // SetCreatedAt sets the "created_at" field.
  18681. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  18682. m.created_at = &t
  18683. }
  18684. // CreatedAt returns the value of the "created_at" field in the mutation.
  18685. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  18686. v := m.created_at
  18687. if v == nil {
  18688. return
  18689. }
  18690. return *v, true
  18691. }
  18692. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  18693. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18695. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18696. if !m.op.Is(OpUpdateOne) {
  18697. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18698. }
  18699. if m.id == nil || m.oldValue == nil {
  18700. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18701. }
  18702. oldValue, err := m.oldValue(ctx)
  18703. if err != nil {
  18704. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18705. }
  18706. return oldValue.CreatedAt, nil
  18707. }
  18708. // ResetCreatedAt resets all changes to the "created_at" field.
  18709. func (m *SopStageMutation) ResetCreatedAt() {
  18710. m.created_at = nil
  18711. }
  18712. // SetUpdatedAt sets the "updated_at" field.
  18713. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  18714. m.updated_at = &t
  18715. }
  18716. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18717. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  18718. v := m.updated_at
  18719. if v == nil {
  18720. return
  18721. }
  18722. return *v, true
  18723. }
  18724. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  18725. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18727. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18728. if !m.op.Is(OpUpdateOne) {
  18729. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18730. }
  18731. if m.id == nil || m.oldValue == nil {
  18732. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18733. }
  18734. oldValue, err := m.oldValue(ctx)
  18735. if err != nil {
  18736. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18737. }
  18738. return oldValue.UpdatedAt, nil
  18739. }
  18740. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18741. func (m *SopStageMutation) ResetUpdatedAt() {
  18742. m.updated_at = nil
  18743. }
  18744. // SetStatus sets the "status" field.
  18745. func (m *SopStageMutation) SetStatus(u uint8) {
  18746. m.status = &u
  18747. m.addstatus = nil
  18748. }
  18749. // Status returns the value of the "status" field in the mutation.
  18750. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  18751. v := m.status
  18752. if v == nil {
  18753. return
  18754. }
  18755. return *v, true
  18756. }
  18757. // OldStatus returns the old "status" field's value of the SopStage entity.
  18758. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18760. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18761. if !m.op.Is(OpUpdateOne) {
  18762. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18763. }
  18764. if m.id == nil || m.oldValue == nil {
  18765. return v, errors.New("OldStatus requires an ID field in the mutation")
  18766. }
  18767. oldValue, err := m.oldValue(ctx)
  18768. if err != nil {
  18769. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18770. }
  18771. return oldValue.Status, nil
  18772. }
  18773. // AddStatus adds u to the "status" field.
  18774. func (m *SopStageMutation) AddStatus(u int8) {
  18775. if m.addstatus != nil {
  18776. *m.addstatus += u
  18777. } else {
  18778. m.addstatus = &u
  18779. }
  18780. }
  18781. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18782. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  18783. v := m.addstatus
  18784. if v == nil {
  18785. return
  18786. }
  18787. return *v, true
  18788. }
  18789. // ClearStatus clears the value of the "status" field.
  18790. func (m *SopStageMutation) ClearStatus() {
  18791. m.status = nil
  18792. m.addstatus = nil
  18793. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  18794. }
  18795. // StatusCleared returns if the "status" field was cleared in this mutation.
  18796. func (m *SopStageMutation) StatusCleared() bool {
  18797. _, ok := m.clearedFields[sopstage.FieldStatus]
  18798. return ok
  18799. }
  18800. // ResetStatus resets all changes to the "status" field.
  18801. func (m *SopStageMutation) ResetStatus() {
  18802. m.status = nil
  18803. m.addstatus = nil
  18804. delete(m.clearedFields, sopstage.FieldStatus)
  18805. }
  18806. // SetDeletedAt sets the "deleted_at" field.
  18807. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  18808. m.deleted_at = &t
  18809. }
  18810. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18811. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  18812. v := m.deleted_at
  18813. if v == nil {
  18814. return
  18815. }
  18816. return *v, true
  18817. }
  18818. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  18819. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18821. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18822. if !m.op.Is(OpUpdateOne) {
  18823. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18824. }
  18825. if m.id == nil || m.oldValue == nil {
  18826. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18827. }
  18828. oldValue, err := m.oldValue(ctx)
  18829. if err != nil {
  18830. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18831. }
  18832. return oldValue.DeletedAt, nil
  18833. }
  18834. // ClearDeletedAt clears the value of the "deleted_at" field.
  18835. func (m *SopStageMutation) ClearDeletedAt() {
  18836. m.deleted_at = nil
  18837. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  18838. }
  18839. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18840. func (m *SopStageMutation) DeletedAtCleared() bool {
  18841. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  18842. return ok
  18843. }
  18844. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18845. func (m *SopStageMutation) ResetDeletedAt() {
  18846. m.deleted_at = nil
  18847. delete(m.clearedFields, sopstage.FieldDeletedAt)
  18848. }
  18849. // SetTaskID sets the "task_id" field.
  18850. func (m *SopStageMutation) SetTaskID(u uint64) {
  18851. m.sop_task = &u
  18852. }
  18853. // TaskID returns the value of the "task_id" field in the mutation.
  18854. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  18855. v := m.sop_task
  18856. if v == nil {
  18857. return
  18858. }
  18859. return *v, true
  18860. }
  18861. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  18862. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18864. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  18865. if !m.op.Is(OpUpdateOne) {
  18866. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  18867. }
  18868. if m.id == nil || m.oldValue == nil {
  18869. return v, errors.New("OldTaskID requires an ID field in the mutation")
  18870. }
  18871. oldValue, err := m.oldValue(ctx)
  18872. if err != nil {
  18873. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  18874. }
  18875. return oldValue.TaskID, nil
  18876. }
  18877. // ResetTaskID resets all changes to the "task_id" field.
  18878. func (m *SopStageMutation) ResetTaskID() {
  18879. m.sop_task = nil
  18880. }
  18881. // SetName sets the "name" field.
  18882. func (m *SopStageMutation) SetName(s string) {
  18883. m.name = &s
  18884. }
  18885. // Name returns the value of the "name" field in the mutation.
  18886. func (m *SopStageMutation) Name() (r string, exists bool) {
  18887. v := m.name
  18888. if v == nil {
  18889. return
  18890. }
  18891. return *v, true
  18892. }
  18893. // OldName returns the old "name" field's value of the SopStage entity.
  18894. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18896. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  18897. if !m.op.Is(OpUpdateOne) {
  18898. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18899. }
  18900. if m.id == nil || m.oldValue == nil {
  18901. return v, errors.New("OldName requires an ID field in the mutation")
  18902. }
  18903. oldValue, err := m.oldValue(ctx)
  18904. if err != nil {
  18905. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18906. }
  18907. return oldValue.Name, nil
  18908. }
  18909. // ResetName resets all changes to the "name" field.
  18910. func (m *SopStageMutation) ResetName() {
  18911. m.name = nil
  18912. }
  18913. // SetConditionType sets the "condition_type" field.
  18914. func (m *SopStageMutation) SetConditionType(i int) {
  18915. m.condition_type = &i
  18916. m.addcondition_type = nil
  18917. }
  18918. // ConditionType returns the value of the "condition_type" field in the mutation.
  18919. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  18920. v := m.condition_type
  18921. if v == nil {
  18922. return
  18923. }
  18924. return *v, true
  18925. }
  18926. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  18927. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18929. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  18930. if !m.op.Is(OpUpdateOne) {
  18931. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  18932. }
  18933. if m.id == nil || m.oldValue == nil {
  18934. return v, errors.New("OldConditionType requires an ID field in the mutation")
  18935. }
  18936. oldValue, err := m.oldValue(ctx)
  18937. if err != nil {
  18938. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  18939. }
  18940. return oldValue.ConditionType, nil
  18941. }
  18942. // AddConditionType adds i to the "condition_type" field.
  18943. func (m *SopStageMutation) AddConditionType(i int) {
  18944. if m.addcondition_type != nil {
  18945. *m.addcondition_type += i
  18946. } else {
  18947. m.addcondition_type = &i
  18948. }
  18949. }
  18950. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  18951. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  18952. v := m.addcondition_type
  18953. if v == nil {
  18954. return
  18955. }
  18956. return *v, true
  18957. }
  18958. // ResetConditionType resets all changes to the "condition_type" field.
  18959. func (m *SopStageMutation) ResetConditionType() {
  18960. m.condition_type = nil
  18961. m.addcondition_type = nil
  18962. }
  18963. // SetConditionOperator sets the "condition_operator" field.
  18964. func (m *SopStageMutation) SetConditionOperator(i int) {
  18965. m.condition_operator = &i
  18966. m.addcondition_operator = nil
  18967. }
  18968. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  18969. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  18970. v := m.condition_operator
  18971. if v == nil {
  18972. return
  18973. }
  18974. return *v, true
  18975. }
  18976. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  18977. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18979. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  18980. if !m.op.Is(OpUpdateOne) {
  18981. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  18982. }
  18983. if m.id == nil || m.oldValue == nil {
  18984. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  18985. }
  18986. oldValue, err := m.oldValue(ctx)
  18987. if err != nil {
  18988. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  18989. }
  18990. return oldValue.ConditionOperator, nil
  18991. }
  18992. // AddConditionOperator adds i to the "condition_operator" field.
  18993. func (m *SopStageMutation) AddConditionOperator(i int) {
  18994. if m.addcondition_operator != nil {
  18995. *m.addcondition_operator += i
  18996. } else {
  18997. m.addcondition_operator = &i
  18998. }
  18999. }
  19000. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  19001. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  19002. v := m.addcondition_operator
  19003. if v == nil {
  19004. return
  19005. }
  19006. return *v, true
  19007. }
  19008. // ResetConditionOperator resets all changes to the "condition_operator" field.
  19009. func (m *SopStageMutation) ResetConditionOperator() {
  19010. m.condition_operator = nil
  19011. m.addcondition_operator = nil
  19012. }
  19013. // SetConditionList sets the "condition_list" field.
  19014. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  19015. m.condition_list = &ct
  19016. m.appendcondition_list = nil
  19017. }
  19018. // ConditionList returns the value of the "condition_list" field in the mutation.
  19019. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  19020. v := m.condition_list
  19021. if v == nil {
  19022. return
  19023. }
  19024. return *v, true
  19025. }
  19026. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  19027. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19029. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  19030. if !m.op.Is(OpUpdateOne) {
  19031. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  19032. }
  19033. if m.id == nil || m.oldValue == nil {
  19034. return v, errors.New("OldConditionList requires an ID field in the mutation")
  19035. }
  19036. oldValue, err := m.oldValue(ctx)
  19037. if err != nil {
  19038. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  19039. }
  19040. return oldValue.ConditionList, nil
  19041. }
  19042. // AppendConditionList adds ct to the "condition_list" field.
  19043. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  19044. m.appendcondition_list = append(m.appendcondition_list, ct...)
  19045. }
  19046. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  19047. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  19048. if len(m.appendcondition_list) == 0 {
  19049. return nil, false
  19050. }
  19051. return m.appendcondition_list, true
  19052. }
  19053. // ResetConditionList resets all changes to the "condition_list" field.
  19054. func (m *SopStageMutation) ResetConditionList() {
  19055. m.condition_list = nil
  19056. m.appendcondition_list = nil
  19057. }
  19058. // SetActionMessage sets the "action_message" field.
  19059. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  19060. m.action_message = &ct
  19061. m.appendaction_message = nil
  19062. }
  19063. // ActionMessage returns the value of the "action_message" field in the mutation.
  19064. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  19065. v := m.action_message
  19066. if v == nil {
  19067. return
  19068. }
  19069. return *v, true
  19070. }
  19071. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  19072. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19074. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  19075. if !m.op.Is(OpUpdateOne) {
  19076. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  19077. }
  19078. if m.id == nil || m.oldValue == nil {
  19079. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  19080. }
  19081. oldValue, err := m.oldValue(ctx)
  19082. if err != nil {
  19083. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  19084. }
  19085. return oldValue.ActionMessage, nil
  19086. }
  19087. // AppendActionMessage adds ct to the "action_message" field.
  19088. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  19089. m.appendaction_message = append(m.appendaction_message, ct...)
  19090. }
  19091. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  19092. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  19093. if len(m.appendaction_message) == 0 {
  19094. return nil, false
  19095. }
  19096. return m.appendaction_message, true
  19097. }
  19098. // ClearActionMessage clears the value of the "action_message" field.
  19099. func (m *SopStageMutation) ClearActionMessage() {
  19100. m.action_message = nil
  19101. m.appendaction_message = nil
  19102. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  19103. }
  19104. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  19105. func (m *SopStageMutation) ActionMessageCleared() bool {
  19106. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  19107. return ok
  19108. }
  19109. // ResetActionMessage resets all changes to the "action_message" field.
  19110. func (m *SopStageMutation) ResetActionMessage() {
  19111. m.action_message = nil
  19112. m.appendaction_message = nil
  19113. delete(m.clearedFields, sopstage.FieldActionMessage)
  19114. }
  19115. // SetActionLabelAdd sets the "action_label_add" field.
  19116. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  19117. m.action_label_add = &u
  19118. m.appendaction_label_add = nil
  19119. }
  19120. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  19121. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  19122. v := m.action_label_add
  19123. if v == nil {
  19124. return
  19125. }
  19126. return *v, true
  19127. }
  19128. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  19129. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19131. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  19132. if !m.op.Is(OpUpdateOne) {
  19133. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  19134. }
  19135. if m.id == nil || m.oldValue == nil {
  19136. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  19137. }
  19138. oldValue, err := m.oldValue(ctx)
  19139. if err != nil {
  19140. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  19141. }
  19142. return oldValue.ActionLabelAdd, nil
  19143. }
  19144. // AppendActionLabelAdd adds u to the "action_label_add" field.
  19145. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  19146. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  19147. }
  19148. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  19149. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  19150. if len(m.appendaction_label_add) == 0 {
  19151. return nil, false
  19152. }
  19153. return m.appendaction_label_add, true
  19154. }
  19155. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  19156. func (m *SopStageMutation) ClearActionLabelAdd() {
  19157. m.action_label_add = nil
  19158. m.appendaction_label_add = nil
  19159. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  19160. }
  19161. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  19162. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  19163. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  19164. return ok
  19165. }
  19166. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  19167. func (m *SopStageMutation) ResetActionLabelAdd() {
  19168. m.action_label_add = nil
  19169. m.appendaction_label_add = nil
  19170. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  19171. }
  19172. // SetActionLabelDel sets the "action_label_del" field.
  19173. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  19174. m.action_label_del = &u
  19175. m.appendaction_label_del = nil
  19176. }
  19177. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  19178. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  19179. v := m.action_label_del
  19180. if v == nil {
  19181. return
  19182. }
  19183. return *v, true
  19184. }
  19185. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  19186. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19188. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  19189. if !m.op.Is(OpUpdateOne) {
  19190. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  19191. }
  19192. if m.id == nil || m.oldValue == nil {
  19193. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  19194. }
  19195. oldValue, err := m.oldValue(ctx)
  19196. if err != nil {
  19197. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  19198. }
  19199. return oldValue.ActionLabelDel, nil
  19200. }
  19201. // AppendActionLabelDel adds u to the "action_label_del" field.
  19202. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  19203. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  19204. }
  19205. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  19206. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  19207. if len(m.appendaction_label_del) == 0 {
  19208. return nil, false
  19209. }
  19210. return m.appendaction_label_del, true
  19211. }
  19212. // ClearActionLabelDel clears the value of the "action_label_del" field.
  19213. func (m *SopStageMutation) ClearActionLabelDel() {
  19214. m.action_label_del = nil
  19215. m.appendaction_label_del = nil
  19216. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  19217. }
  19218. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  19219. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  19220. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  19221. return ok
  19222. }
  19223. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  19224. func (m *SopStageMutation) ResetActionLabelDel() {
  19225. m.action_label_del = nil
  19226. m.appendaction_label_del = nil
  19227. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  19228. }
  19229. // SetActionForward sets the "action_forward" field.
  19230. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  19231. m.action_forward = &ctf
  19232. }
  19233. // ActionForward returns the value of the "action_forward" field in the mutation.
  19234. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  19235. v := m.action_forward
  19236. if v == nil {
  19237. return
  19238. }
  19239. return *v, true
  19240. }
  19241. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  19242. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19244. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  19245. if !m.op.Is(OpUpdateOne) {
  19246. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  19247. }
  19248. if m.id == nil || m.oldValue == nil {
  19249. return v, errors.New("OldActionForward requires an ID field in the mutation")
  19250. }
  19251. oldValue, err := m.oldValue(ctx)
  19252. if err != nil {
  19253. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  19254. }
  19255. return oldValue.ActionForward, nil
  19256. }
  19257. // ClearActionForward clears the value of the "action_forward" field.
  19258. func (m *SopStageMutation) ClearActionForward() {
  19259. m.action_forward = nil
  19260. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  19261. }
  19262. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  19263. func (m *SopStageMutation) ActionForwardCleared() bool {
  19264. _, ok := m.clearedFields[sopstage.FieldActionForward]
  19265. return ok
  19266. }
  19267. // ResetActionForward resets all changes to the "action_forward" field.
  19268. func (m *SopStageMutation) ResetActionForward() {
  19269. m.action_forward = nil
  19270. delete(m.clearedFields, sopstage.FieldActionForward)
  19271. }
  19272. // SetIndexSort sets the "index_sort" field.
  19273. func (m *SopStageMutation) SetIndexSort(i int) {
  19274. m.index_sort = &i
  19275. m.addindex_sort = nil
  19276. }
  19277. // IndexSort returns the value of the "index_sort" field in the mutation.
  19278. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  19279. v := m.index_sort
  19280. if v == nil {
  19281. return
  19282. }
  19283. return *v, true
  19284. }
  19285. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  19286. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19288. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  19289. if !m.op.Is(OpUpdateOne) {
  19290. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  19291. }
  19292. if m.id == nil || m.oldValue == nil {
  19293. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  19294. }
  19295. oldValue, err := m.oldValue(ctx)
  19296. if err != nil {
  19297. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  19298. }
  19299. return oldValue.IndexSort, nil
  19300. }
  19301. // AddIndexSort adds i to the "index_sort" field.
  19302. func (m *SopStageMutation) AddIndexSort(i int) {
  19303. if m.addindex_sort != nil {
  19304. *m.addindex_sort += i
  19305. } else {
  19306. m.addindex_sort = &i
  19307. }
  19308. }
  19309. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  19310. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  19311. v := m.addindex_sort
  19312. if v == nil {
  19313. return
  19314. }
  19315. return *v, true
  19316. }
  19317. // ClearIndexSort clears the value of the "index_sort" field.
  19318. func (m *SopStageMutation) ClearIndexSort() {
  19319. m.index_sort = nil
  19320. m.addindex_sort = nil
  19321. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  19322. }
  19323. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  19324. func (m *SopStageMutation) IndexSortCleared() bool {
  19325. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  19326. return ok
  19327. }
  19328. // ResetIndexSort resets all changes to the "index_sort" field.
  19329. func (m *SopStageMutation) ResetIndexSort() {
  19330. m.index_sort = nil
  19331. m.addindex_sort = nil
  19332. delete(m.clearedFields, sopstage.FieldIndexSort)
  19333. }
  19334. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  19335. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  19336. m.sop_task = &id
  19337. }
  19338. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  19339. func (m *SopStageMutation) ClearSopTask() {
  19340. m.clearedsop_task = true
  19341. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  19342. }
  19343. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  19344. func (m *SopStageMutation) SopTaskCleared() bool {
  19345. return m.clearedsop_task
  19346. }
  19347. // SopTaskID returns the "sop_task" edge ID in the mutation.
  19348. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  19349. if m.sop_task != nil {
  19350. return *m.sop_task, true
  19351. }
  19352. return
  19353. }
  19354. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  19355. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19356. // SopTaskID instead. It exists only for internal usage by the builders.
  19357. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  19358. if id := m.sop_task; id != nil {
  19359. ids = append(ids, *id)
  19360. }
  19361. return
  19362. }
  19363. // ResetSopTask resets all changes to the "sop_task" edge.
  19364. func (m *SopStageMutation) ResetSopTask() {
  19365. m.sop_task = nil
  19366. m.clearedsop_task = false
  19367. }
  19368. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  19369. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  19370. if m.stage_nodes == nil {
  19371. m.stage_nodes = make(map[uint64]struct{})
  19372. }
  19373. for i := range ids {
  19374. m.stage_nodes[ids[i]] = struct{}{}
  19375. }
  19376. }
  19377. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  19378. func (m *SopStageMutation) ClearStageNodes() {
  19379. m.clearedstage_nodes = true
  19380. }
  19381. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  19382. func (m *SopStageMutation) StageNodesCleared() bool {
  19383. return m.clearedstage_nodes
  19384. }
  19385. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  19386. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  19387. if m.removedstage_nodes == nil {
  19388. m.removedstage_nodes = make(map[uint64]struct{})
  19389. }
  19390. for i := range ids {
  19391. delete(m.stage_nodes, ids[i])
  19392. m.removedstage_nodes[ids[i]] = struct{}{}
  19393. }
  19394. }
  19395. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  19396. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  19397. for id := range m.removedstage_nodes {
  19398. ids = append(ids, id)
  19399. }
  19400. return
  19401. }
  19402. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  19403. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  19404. for id := range m.stage_nodes {
  19405. ids = append(ids, id)
  19406. }
  19407. return
  19408. }
  19409. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  19410. func (m *SopStageMutation) ResetStageNodes() {
  19411. m.stage_nodes = nil
  19412. m.clearedstage_nodes = false
  19413. m.removedstage_nodes = nil
  19414. }
  19415. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  19416. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  19417. if m.stage_messages == nil {
  19418. m.stage_messages = make(map[uint64]struct{})
  19419. }
  19420. for i := range ids {
  19421. m.stage_messages[ids[i]] = struct{}{}
  19422. }
  19423. }
  19424. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  19425. func (m *SopStageMutation) ClearStageMessages() {
  19426. m.clearedstage_messages = true
  19427. }
  19428. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  19429. func (m *SopStageMutation) StageMessagesCleared() bool {
  19430. return m.clearedstage_messages
  19431. }
  19432. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  19433. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  19434. if m.removedstage_messages == nil {
  19435. m.removedstage_messages = make(map[uint64]struct{})
  19436. }
  19437. for i := range ids {
  19438. delete(m.stage_messages, ids[i])
  19439. m.removedstage_messages[ids[i]] = struct{}{}
  19440. }
  19441. }
  19442. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  19443. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  19444. for id := range m.removedstage_messages {
  19445. ids = append(ids, id)
  19446. }
  19447. return
  19448. }
  19449. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  19450. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  19451. for id := range m.stage_messages {
  19452. ids = append(ids, id)
  19453. }
  19454. return
  19455. }
  19456. // ResetStageMessages resets all changes to the "stage_messages" edge.
  19457. func (m *SopStageMutation) ResetStageMessages() {
  19458. m.stage_messages = nil
  19459. m.clearedstage_messages = false
  19460. m.removedstage_messages = nil
  19461. }
  19462. // Where appends a list predicates to the SopStageMutation builder.
  19463. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  19464. m.predicates = append(m.predicates, ps...)
  19465. }
  19466. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  19467. // users can use type-assertion to append predicates that do not depend on any generated package.
  19468. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  19469. p := make([]predicate.SopStage, len(ps))
  19470. for i := range ps {
  19471. p[i] = ps[i]
  19472. }
  19473. m.Where(p...)
  19474. }
  19475. // Op returns the operation name.
  19476. func (m *SopStageMutation) Op() Op {
  19477. return m.op
  19478. }
  19479. // SetOp allows setting the mutation operation.
  19480. func (m *SopStageMutation) SetOp(op Op) {
  19481. m.op = op
  19482. }
  19483. // Type returns the node type of this mutation (SopStage).
  19484. func (m *SopStageMutation) Type() string {
  19485. return m.typ
  19486. }
  19487. // Fields returns all fields that were changed during this mutation. Note that in
  19488. // order to get all numeric fields that were incremented/decremented, call
  19489. // AddedFields().
  19490. func (m *SopStageMutation) Fields() []string {
  19491. fields := make([]string, 0, 14)
  19492. if m.created_at != nil {
  19493. fields = append(fields, sopstage.FieldCreatedAt)
  19494. }
  19495. if m.updated_at != nil {
  19496. fields = append(fields, sopstage.FieldUpdatedAt)
  19497. }
  19498. if m.status != nil {
  19499. fields = append(fields, sopstage.FieldStatus)
  19500. }
  19501. if m.deleted_at != nil {
  19502. fields = append(fields, sopstage.FieldDeletedAt)
  19503. }
  19504. if m.sop_task != nil {
  19505. fields = append(fields, sopstage.FieldTaskID)
  19506. }
  19507. if m.name != nil {
  19508. fields = append(fields, sopstage.FieldName)
  19509. }
  19510. if m.condition_type != nil {
  19511. fields = append(fields, sopstage.FieldConditionType)
  19512. }
  19513. if m.condition_operator != nil {
  19514. fields = append(fields, sopstage.FieldConditionOperator)
  19515. }
  19516. if m.condition_list != nil {
  19517. fields = append(fields, sopstage.FieldConditionList)
  19518. }
  19519. if m.action_message != nil {
  19520. fields = append(fields, sopstage.FieldActionMessage)
  19521. }
  19522. if m.action_label_add != nil {
  19523. fields = append(fields, sopstage.FieldActionLabelAdd)
  19524. }
  19525. if m.action_label_del != nil {
  19526. fields = append(fields, sopstage.FieldActionLabelDel)
  19527. }
  19528. if m.action_forward != nil {
  19529. fields = append(fields, sopstage.FieldActionForward)
  19530. }
  19531. if m.index_sort != nil {
  19532. fields = append(fields, sopstage.FieldIndexSort)
  19533. }
  19534. return fields
  19535. }
  19536. // Field returns the value of a field with the given name. The second boolean
  19537. // return value indicates that this field was not set, or was not defined in the
  19538. // schema.
  19539. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  19540. switch name {
  19541. case sopstage.FieldCreatedAt:
  19542. return m.CreatedAt()
  19543. case sopstage.FieldUpdatedAt:
  19544. return m.UpdatedAt()
  19545. case sopstage.FieldStatus:
  19546. return m.Status()
  19547. case sopstage.FieldDeletedAt:
  19548. return m.DeletedAt()
  19549. case sopstage.FieldTaskID:
  19550. return m.TaskID()
  19551. case sopstage.FieldName:
  19552. return m.Name()
  19553. case sopstage.FieldConditionType:
  19554. return m.ConditionType()
  19555. case sopstage.FieldConditionOperator:
  19556. return m.ConditionOperator()
  19557. case sopstage.FieldConditionList:
  19558. return m.ConditionList()
  19559. case sopstage.FieldActionMessage:
  19560. return m.ActionMessage()
  19561. case sopstage.FieldActionLabelAdd:
  19562. return m.ActionLabelAdd()
  19563. case sopstage.FieldActionLabelDel:
  19564. return m.ActionLabelDel()
  19565. case sopstage.FieldActionForward:
  19566. return m.ActionForward()
  19567. case sopstage.FieldIndexSort:
  19568. return m.IndexSort()
  19569. }
  19570. return nil, false
  19571. }
  19572. // OldField returns the old value of the field from the database. An error is
  19573. // returned if the mutation operation is not UpdateOne, or the query to the
  19574. // database failed.
  19575. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19576. switch name {
  19577. case sopstage.FieldCreatedAt:
  19578. return m.OldCreatedAt(ctx)
  19579. case sopstage.FieldUpdatedAt:
  19580. return m.OldUpdatedAt(ctx)
  19581. case sopstage.FieldStatus:
  19582. return m.OldStatus(ctx)
  19583. case sopstage.FieldDeletedAt:
  19584. return m.OldDeletedAt(ctx)
  19585. case sopstage.FieldTaskID:
  19586. return m.OldTaskID(ctx)
  19587. case sopstage.FieldName:
  19588. return m.OldName(ctx)
  19589. case sopstage.FieldConditionType:
  19590. return m.OldConditionType(ctx)
  19591. case sopstage.FieldConditionOperator:
  19592. return m.OldConditionOperator(ctx)
  19593. case sopstage.FieldConditionList:
  19594. return m.OldConditionList(ctx)
  19595. case sopstage.FieldActionMessage:
  19596. return m.OldActionMessage(ctx)
  19597. case sopstage.FieldActionLabelAdd:
  19598. return m.OldActionLabelAdd(ctx)
  19599. case sopstage.FieldActionLabelDel:
  19600. return m.OldActionLabelDel(ctx)
  19601. case sopstage.FieldActionForward:
  19602. return m.OldActionForward(ctx)
  19603. case sopstage.FieldIndexSort:
  19604. return m.OldIndexSort(ctx)
  19605. }
  19606. return nil, fmt.Errorf("unknown SopStage field %s", name)
  19607. }
  19608. // SetField sets the value of a field with the given name. It returns an error if
  19609. // the field is not defined in the schema, or if the type mismatched the field
  19610. // type.
  19611. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  19612. switch name {
  19613. case sopstage.FieldCreatedAt:
  19614. v, ok := value.(time.Time)
  19615. if !ok {
  19616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19617. }
  19618. m.SetCreatedAt(v)
  19619. return nil
  19620. case sopstage.FieldUpdatedAt:
  19621. v, ok := value.(time.Time)
  19622. if !ok {
  19623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19624. }
  19625. m.SetUpdatedAt(v)
  19626. return nil
  19627. case sopstage.FieldStatus:
  19628. v, ok := value.(uint8)
  19629. if !ok {
  19630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19631. }
  19632. m.SetStatus(v)
  19633. return nil
  19634. case sopstage.FieldDeletedAt:
  19635. v, ok := value.(time.Time)
  19636. if !ok {
  19637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19638. }
  19639. m.SetDeletedAt(v)
  19640. return nil
  19641. case sopstage.FieldTaskID:
  19642. v, ok := value.(uint64)
  19643. if !ok {
  19644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19645. }
  19646. m.SetTaskID(v)
  19647. return nil
  19648. case sopstage.FieldName:
  19649. v, ok := value.(string)
  19650. if !ok {
  19651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19652. }
  19653. m.SetName(v)
  19654. return nil
  19655. case sopstage.FieldConditionType:
  19656. v, ok := value.(int)
  19657. if !ok {
  19658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19659. }
  19660. m.SetConditionType(v)
  19661. return nil
  19662. case sopstage.FieldConditionOperator:
  19663. v, ok := value.(int)
  19664. if !ok {
  19665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19666. }
  19667. m.SetConditionOperator(v)
  19668. return nil
  19669. case sopstage.FieldConditionList:
  19670. v, ok := value.([]custom_types.Condition)
  19671. if !ok {
  19672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19673. }
  19674. m.SetConditionList(v)
  19675. return nil
  19676. case sopstage.FieldActionMessage:
  19677. v, ok := value.([]custom_types.Action)
  19678. if !ok {
  19679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19680. }
  19681. m.SetActionMessage(v)
  19682. return nil
  19683. case sopstage.FieldActionLabelAdd:
  19684. v, ok := value.([]uint64)
  19685. if !ok {
  19686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19687. }
  19688. m.SetActionLabelAdd(v)
  19689. return nil
  19690. case sopstage.FieldActionLabelDel:
  19691. v, ok := value.([]uint64)
  19692. if !ok {
  19693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19694. }
  19695. m.SetActionLabelDel(v)
  19696. return nil
  19697. case sopstage.FieldActionForward:
  19698. v, ok := value.(*custom_types.ActionForward)
  19699. if !ok {
  19700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19701. }
  19702. m.SetActionForward(v)
  19703. return nil
  19704. case sopstage.FieldIndexSort:
  19705. v, ok := value.(int)
  19706. if !ok {
  19707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19708. }
  19709. m.SetIndexSort(v)
  19710. return nil
  19711. }
  19712. return fmt.Errorf("unknown SopStage field %s", name)
  19713. }
  19714. // AddedFields returns all numeric fields that were incremented/decremented during
  19715. // this mutation.
  19716. func (m *SopStageMutation) AddedFields() []string {
  19717. var fields []string
  19718. if m.addstatus != nil {
  19719. fields = append(fields, sopstage.FieldStatus)
  19720. }
  19721. if m.addcondition_type != nil {
  19722. fields = append(fields, sopstage.FieldConditionType)
  19723. }
  19724. if m.addcondition_operator != nil {
  19725. fields = append(fields, sopstage.FieldConditionOperator)
  19726. }
  19727. if m.addindex_sort != nil {
  19728. fields = append(fields, sopstage.FieldIndexSort)
  19729. }
  19730. return fields
  19731. }
  19732. // AddedField returns the numeric value that was incremented/decremented on a field
  19733. // with the given name. The second boolean return value indicates that this field
  19734. // was not set, or was not defined in the schema.
  19735. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  19736. switch name {
  19737. case sopstage.FieldStatus:
  19738. return m.AddedStatus()
  19739. case sopstage.FieldConditionType:
  19740. return m.AddedConditionType()
  19741. case sopstage.FieldConditionOperator:
  19742. return m.AddedConditionOperator()
  19743. case sopstage.FieldIndexSort:
  19744. return m.AddedIndexSort()
  19745. }
  19746. return nil, false
  19747. }
  19748. // AddField adds the value to the field with the given name. It returns an error if
  19749. // the field is not defined in the schema, or if the type mismatched the field
  19750. // type.
  19751. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  19752. switch name {
  19753. case sopstage.FieldStatus:
  19754. v, ok := value.(int8)
  19755. if !ok {
  19756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19757. }
  19758. m.AddStatus(v)
  19759. return nil
  19760. case sopstage.FieldConditionType:
  19761. v, ok := value.(int)
  19762. if !ok {
  19763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19764. }
  19765. m.AddConditionType(v)
  19766. return nil
  19767. case sopstage.FieldConditionOperator:
  19768. v, ok := value.(int)
  19769. if !ok {
  19770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19771. }
  19772. m.AddConditionOperator(v)
  19773. return nil
  19774. case sopstage.FieldIndexSort:
  19775. v, ok := value.(int)
  19776. if !ok {
  19777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19778. }
  19779. m.AddIndexSort(v)
  19780. return nil
  19781. }
  19782. return fmt.Errorf("unknown SopStage numeric field %s", name)
  19783. }
  19784. // ClearedFields returns all nullable fields that were cleared during this
  19785. // mutation.
  19786. func (m *SopStageMutation) ClearedFields() []string {
  19787. var fields []string
  19788. if m.FieldCleared(sopstage.FieldStatus) {
  19789. fields = append(fields, sopstage.FieldStatus)
  19790. }
  19791. if m.FieldCleared(sopstage.FieldDeletedAt) {
  19792. fields = append(fields, sopstage.FieldDeletedAt)
  19793. }
  19794. if m.FieldCleared(sopstage.FieldActionMessage) {
  19795. fields = append(fields, sopstage.FieldActionMessage)
  19796. }
  19797. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  19798. fields = append(fields, sopstage.FieldActionLabelAdd)
  19799. }
  19800. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  19801. fields = append(fields, sopstage.FieldActionLabelDel)
  19802. }
  19803. if m.FieldCleared(sopstage.FieldActionForward) {
  19804. fields = append(fields, sopstage.FieldActionForward)
  19805. }
  19806. if m.FieldCleared(sopstage.FieldIndexSort) {
  19807. fields = append(fields, sopstage.FieldIndexSort)
  19808. }
  19809. return fields
  19810. }
  19811. // FieldCleared returns a boolean indicating if a field with the given name was
  19812. // cleared in this mutation.
  19813. func (m *SopStageMutation) FieldCleared(name string) bool {
  19814. _, ok := m.clearedFields[name]
  19815. return ok
  19816. }
  19817. // ClearField clears the value of the field with the given name. It returns an
  19818. // error if the field is not defined in the schema.
  19819. func (m *SopStageMutation) ClearField(name string) error {
  19820. switch name {
  19821. case sopstage.FieldStatus:
  19822. m.ClearStatus()
  19823. return nil
  19824. case sopstage.FieldDeletedAt:
  19825. m.ClearDeletedAt()
  19826. return nil
  19827. case sopstage.FieldActionMessage:
  19828. m.ClearActionMessage()
  19829. return nil
  19830. case sopstage.FieldActionLabelAdd:
  19831. m.ClearActionLabelAdd()
  19832. return nil
  19833. case sopstage.FieldActionLabelDel:
  19834. m.ClearActionLabelDel()
  19835. return nil
  19836. case sopstage.FieldActionForward:
  19837. m.ClearActionForward()
  19838. return nil
  19839. case sopstage.FieldIndexSort:
  19840. m.ClearIndexSort()
  19841. return nil
  19842. }
  19843. return fmt.Errorf("unknown SopStage nullable field %s", name)
  19844. }
  19845. // ResetField resets all changes in the mutation for the field with the given name.
  19846. // It returns an error if the field is not defined in the schema.
  19847. func (m *SopStageMutation) ResetField(name string) error {
  19848. switch name {
  19849. case sopstage.FieldCreatedAt:
  19850. m.ResetCreatedAt()
  19851. return nil
  19852. case sopstage.FieldUpdatedAt:
  19853. m.ResetUpdatedAt()
  19854. return nil
  19855. case sopstage.FieldStatus:
  19856. m.ResetStatus()
  19857. return nil
  19858. case sopstage.FieldDeletedAt:
  19859. m.ResetDeletedAt()
  19860. return nil
  19861. case sopstage.FieldTaskID:
  19862. m.ResetTaskID()
  19863. return nil
  19864. case sopstage.FieldName:
  19865. m.ResetName()
  19866. return nil
  19867. case sopstage.FieldConditionType:
  19868. m.ResetConditionType()
  19869. return nil
  19870. case sopstage.FieldConditionOperator:
  19871. m.ResetConditionOperator()
  19872. return nil
  19873. case sopstage.FieldConditionList:
  19874. m.ResetConditionList()
  19875. return nil
  19876. case sopstage.FieldActionMessage:
  19877. m.ResetActionMessage()
  19878. return nil
  19879. case sopstage.FieldActionLabelAdd:
  19880. m.ResetActionLabelAdd()
  19881. return nil
  19882. case sopstage.FieldActionLabelDel:
  19883. m.ResetActionLabelDel()
  19884. return nil
  19885. case sopstage.FieldActionForward:
  19886. m.ResetActionForward()
  19887. return nil
  19888. case sopstage.FieldIndexSort:
  19889. m.ResetIndexSort()
  19890. return nil
  19891. }
  19892. return fmt.Errorf("unknown SopStage field %s", name)
  19893. }
  19894. // AddedEdges returns all edge names that were set/added in this mutation.
  19895. func (m *SopStageMutation) AddedEdges() []string {
  19896. edges := make([]string, 0, 3)
  19897. if m.sop_task != nil {
  19898. edges = append(edges, sopstage.EdgeSopTask)
  19899. }
  19900. if m.stage_nodes != nil {
  19901. edges = append(edges, sopstage.EdgeStageNodes)
  19902. }
  19903. if m.stage_messages != nil {
  19904. edges = append(edges, sopstage.EdgeStageMessages)
  19905. }
  19906. return edges
  19907. }
  19908. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19909. // name in this mutation.
  19910. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  19911. switch name {
  19912. case sopstage.EdgeSopTask:
  19913. if id := m.sop_task; id != nil {
  19914. return []ent.Value{*id}
  19915. }
  19916. case sopstage.EdgeStageNodes:
  19917. ids := make([]ent.Value, 0, len(m.stage_nodes))
  19918. for id := range m.stage_nodes {
  19919. ids = append(ids, id)
  19920. }
  19921. return ids
  19922. case sopstage.EdgeStageMessages:
  19923. ids := make([]ent.Value, 0, len(m.stage_messages))
  19924. for id := range m.stage_messages {
  19925. ids = append(ids, id)
  19926. }
  19927. return ids
  19928. }
  19929. return nil
  19930. }
  19931. // RemovedEdges returns all edge names that were removed in this mutation.
  19932. func (m *SopStageMutation) RemovedEdges() []string {
  19933. edges := make([]string, 0, 3)
  19934. if m.removedstage_nodes != nil {
  19935. edges = append(edges, sopstage.EdgeStageNodes)
  19936. }
  19937. if m.removedstage_messages != nil {
  19938. edges = append(edges, sopstage.EdgeStageMessages)
  19939. }
  19940. return edges
  19941. }
  19942. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19943. // the given name in this mutation.
  19944. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  19945. switch name {
  19946. case sopstage.EdgeStageNodes:
  19947. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  19948. for id := range m.removedstage_nodes {
  19949. ids = append(ids, id)
  19950. }
  19951. return ids
  19952. case sopstage.EdgeStageMessages:
  19953. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  19954. for id := range m.removedstage_messages {
  19955. ids = append(ids, id)
  19956. }
  19957. return ids
  19958. }
  19959. return nil
  19960. }
  19961. // ClearedEdges returns all edge names that were cleared in this mutation.
  19962. func (m *SopStageMutation) ClearedEdges() []string {
  19963. edges := make([]string, 0, 3)
  19964. if m.clearedsop_task {
  19965. edges = append(edges, sopstage.EdgeSopTask)
  19966. }
  19967. if m.clearedstage_nodes {
  19968. edges = append(edges, sopstage.EdgeStageNodes)
  19969. }
  19970. if m.clearedstage_messages {
  19971. edges = append(edges, sopstage.EdgeStageMessages)
  19972. }
  19973. return edges
  19974. }
  19975. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19976. // was cleared in this mutation.
  19977. func (m *SopStageMutation) EdgeCleared(name string) bool {
  19978. switch name {
  19979. case sopstage.EdgeSopTask:
  19980. return m.clearedsop_task
  19981. case sopstage.EdgeStageNodes:
  19982. return m.clearedstage_nodes
  19983. case sopstage.EdgeStageMessages:
  19984. return m.clearedstage_messages
  19985. }
  19986. return false
  19987. }
  19988. // ClearEdge clears the value of the edge with the given name. It returns an error
  19989. // if that edge is not defined in the schema.
  19990. func (m *SopStageMutation) ClearEdge(name string) error {
  19991. switch name {
  19992. case sopstage.EdgeSopTask:
  19993. m.ClearSopTask()
  19994. return nil
  19995. }
  19996. return fmt.Errorf("unknown SopStage unique edge %s", name)
  19997. }
  19998. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19999. // It returns an error if the edge is not defined in the schema.
  20000. func (m *SopStageMutation) ResetEdge(name string) error {
  20001. switch name {
  20002. case sopstage.EdgeSopTask:
  20003. m.ResetSopTask()
  20004. return nil
  20005. case sopstage.EdgeStageNodes:
  20006. m.ResetStageNodes()
  20007. return nil
  20008. case sopstage.EdgeStageMessages:
  20009. m.ResetStageMessages()
  20010. return nil
  20011. }
  20012. return fmt.Errorf("unknown SopStage edge %s", name)
  20013. }
  20014. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  20015. type SopTaskMutation struct {
  20016. config
  20017. op Op
  20018. typ string
  20019. id *uint64
  20020. created_at *time.Time
  20021. updated_at *time.Time
  20022. status *uint8
  20023. addstatus *int8
  20024. deleted_at *time.Time
  20025. name *string
  20026. bot_wxid_list *[]string
  20027. appendbot_wxid_list []string
  20028. _type *int
  20029. add_type *int
  20030. plan_start_time *time.Time
  20031. plan_end_time *time.Time
  20032. creator_id *string
  20033. organization_id *uint64
  20034. addorganization_id *int64
  20035. token *[]string
  20036. appendtoken []string
  20037. clearedFields map[string]struct{}
  20038. task_stages map[uint64]struct{}
  20039. removedtask_stages map[uint64]struct{}
  20040. clearedtask_stages bool
  20041. done bool
  20042. oldValue func(context.Context) (*SopTask, error)
  20043. predicates []predicate.SopTask
  20044. }
  20045. var _ ent.Mutation = (*SopTaskMutation)(nil)
  20046. // soptaskOption allows management of the mutation configuration using functional options.
  20047. type soptaskOption func(*SopTaskMutation)
  20048. // newSopTaskMutation creates new mutation for the SopTask entity.
  20049. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  20050. m := &SopTaskMutation{
  20051. config: c,
  20052. op: op,
  20053. typ: TypeSopTask,
  20054. clearedFields: make(map[string]struct{}),
  20055. }
  20056. for _, opt := range opts {
  20057. opt(m)
  20058. }
  20059. return m
  20060. }
  20061. // withSopTaskID sets the ID field of the mutation.
  20062. func withSopTaskID(id uint64) soptaskOption {
  20063. return func(m *SopTaskMutation) {
  20064. var (
  20065. err error
  20066. once sync.Once
  20067. value *SopTask
  20068. )
  20069. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  20070. once.Do(func() {
  20071. if m.done {
  20072. err = errors.New("querying old values post mutation is not allowed")
  20073. } else {
  20074. value, err = m.Client().SopTask.Get(ctx, id)
  20075. }
  20076. })
  20077. return value, err
  20078. }
  20079. m.id = &id
  20080. }
  20081. }
  20082. // withSopTask sets the old SopTask of the mutation.
  20083. func withSopTask(node *SopTask) soptaskOption {
  20084. return func(m *SopTaskMutation) {
  20085. m.oldValue = func(context.Context) (*SopTask, error) {
  20086. return node, nil
  20087. }
  20088. m.id = &node.ID
  20089. }
  20090. }
  20091. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20092. // executed in a transaction (ent.Tx), a transactional client is returned.
  20093. func (m SopTaskMutation) Client() *Client {
  20094. client := &Client{config: m.config}
  20095. client.init()
  20096. return client
  20097. }
  20098. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20099. // it returns an error otherwise.
  20100. func (m SopTaskMutation) Tx() (*Tx, error) {
  20101. if _, ok := m.driver.(*txDriver); !ok {
  20102. return nil, errors.New("ent: mutation is not running in a transaction")
  20103. }
  20104. tx := &Tx{config: m.config}
  20105. tx.init()
  20106. return tx, nil
  20107. }
  20108. // SetID sets the value of the id field. Note that this
  20109. // operation is only accepted on creation of SopTask entities.
  20110. func (m *SopTaskMutation) SetID(id uint64) {
  20111. m.id = &id
  20112. }
  20113. // ID returns the ID value in the mutation. Note that the ID is only available
  20114. // if it was provided to the builder or after it was returned from the database.
  20115. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  20116. if m.id == nil {
  20117. return
  20118. }
  20119. return *m.id, true
  20120. }
  20121. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20122. // That means, if the mutation is applied within a transaction with an isolation level such
  20123. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20124. // or updated by the mutation.
  20125. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  20126. switch {
  20127. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20128. id, exists := m.ID()
  20129. if exists {
  20130. return []uint64{id}, nil
  20131. }
  20132. fallthrough
  20133. case m.op.Is(OpUpdate | OpDelete):
  20134. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  20135. default:
  20136. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20137. }
  20138. }
  20139. // SetCreatedAt sets the "created_at" field.
  20140. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  20141. m.created_at = &t
  20142. }
  20143. // CreatedAt returns the value of the "created_at" field in the mutation.
  20144. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  20145. v := m.created_at
  20146. if v == nil {
  20147. return
  20148. }
  20149. return *v, true
  20150. }
  20151. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  20152. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20154. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20155. if !m.op.Is(OpUpdateOne) {
  20156. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20157. }
  20158. if m.id == nil || m.oldValue == nil {
  20159. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20160. }
  20161. oldValue, err := m.oldValue(ctx)
  20162. if err != nil {
  20163. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20164. }
  20165. return oldValue.CreatedAt, nil
  20166. }
  20167. // ResetCreatedAt resets all changes to the "created_at" field.
  20168. func (m *SopTaskMutation) ResetCreatedAt() {
  20169. m.created_at = nil
  20170. }
  20171. // SetUpdatedAt sets the "updated_at" field.
  20172. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  20173. m.updated_at = &t
  20174. }
  20175. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20176. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  20177. v := m.updated_at
  20178. if v == nil {
  20179. return
  20180. }
  20181. return *v, true
  20182. }
  20183. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  20184. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20186. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20187. if !m.op.Is(OpUpdateOne) {
  20188. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20189. }
  20190. if m.id == nil || m.oldValue == nil {
  20191. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20192. }
  20193. oldValue, err := m.oldValue(ctx)
  20194. if err != nil {
  20195. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20196. }
  20197. return oldValue.UpdatedAt, nil
  20198. }
  20199. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20200. func (m *SopTaskMutation) ResetUpdatedAt() {
  20201. m.updated_at = nil
  20202. }
  20203. // SetStatus sets the "status" field.
  20204. func (m *SopTaskMutation) SetStatus(u uint8) {
  20205. m.status = &u
  20206. m.addstatus = nil
  20207. }
  20208. // Status returns the value of the "status" field in the mutation.
  20209. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  20210. v := m.status
  20211. if v == nil {
  20212. return
  20213. }
  20214. return *v, true
  20215. }
  20216. // OldStatus returns the old "status" field's value of the SopTask entity.
  20217. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20219. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20220. if !m.op.Is(OpUpdateOne) {
  20221. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20222. }
  20223. if m.id == nil || m.oldValue == nil {
  20224. return v, errors.New("OldStatus requires an ID field in the mutation")
  20225. }
  20226. oldValue, err := m.oldValue(ctx)
  20227. if err != nil {
  20228. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20229. }
  20230. return oldValue.Status, nil
  20231. }
  20232. // AddStatus adds u to the "status" field.
  20233. func (m *SopTaskMutation) AddStatus(u int8) {
  20234. if m.addstatus != nil {
  20235. *m.addstatus += u
  20236. } else {
  20237. m.addstatus = &u
  20238. }
  20239. }
  20240. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20241. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  20242. v := m.addstatus
  20243. if v == nil {
  20244. return
  20245. }
  20246. return *v, true
  20247. }
  20248. // ClearStatus clears the value of the "status" field.
  20249. func (m *SopTaskMutation) ClearStatus() {
  20250. m.status = nil
  20251. m.addstatus = nil
  20252. m.clearedFields[soptask.FieldStatus] = struct{}{}
  20253. }
  20254. // StatusCleared returns if the "status" field was cleared in this mutation.
  20255. func (m *SopTaskMutation) StatusCleared() bool {
  20256. _, ok := m.clearedFields[soptask.FieldStatus]
  20257. return ok
  20258. }
  20259. // ResetStatus resets all changes to the "status" field.
  20260. func (m *SopTaskMutation) ResetStatus() {
  20261. m.status = nil
  20262. m.addstatus = nil
  20263. delete(m.clearedFields, soptask.FieldStatus)
  20264. }
  20265. // SetDeletedAt sets the "deleted_at" field.
  20266. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  20267. m.deleted_at = &t
  20268. }
  20269. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20270. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  20271. v := m.deleted_at
  20272. if v == nil {
  20273. return
  20274. }
  20275. return *v, true
  20276. }
  20277. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  20278. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20280. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20281. if !m.op.Is(OpUpdateOne) {
  20282. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20283. }
  20284. if m.id == nil || m.oldValue == nil {
  20285. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20286. }
  20287. oldValue, err := m.oldValue(ctx)
  20288. if err != nil {
  20289. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20290. }
  20291. return oldValue.DeletedAt, nil
  20292. }
  20293. // ClearDeletedAt clears the value of the "deleted_at" field.
  20294. func (m *SopTaskMutation) ClearDeletedAt() {
  20295. m.deleted_at = nil
  20296. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  20297. }
  20298. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20299. func (m *SopTaskMutation) DeletedAtCleared() bool {
  20300. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  20301. return ok
  20302. }
  20303. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20304. func (m *SopTaskMutation) ResetDeletedAt() {
  20305. m.deleted_at = nil
  20306. delete(m.clearedFields, soptask.FieldDeletedAt)
  20307. }
  20308. // SetName sets the "name" field.
  20309. func (m *SopTaskMutation) SetName(s string) {
  20310. m.name = &s
  20311. }
  20312. // Name returns the value of the "name" field in the mutation.
  20313. func (m *SopTaskMutation) Name() (r string, exists bool) {
  20314. v := m.name
  20315. if v == nil {
  20316. return
  20317. }
  20318. return *v, true
  20319. }
  20320. // OldName returns the old "name" field's value of the SopTask entity.
  20321. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20323. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  20324. if !m.op.Is(OpUpdateOne) {
  20325. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20326. }
  20327. if m.id == nil || m.oldValue == nil {
  20328. return v, errors.New("OldName requires an ID field in the mutation")
  20329. }
  20330. oldValue, err := m.oldValue(ctx)
  20331. if err != nil {
  20332. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20333. }
  20334. return oldValue.Name, nil
  20335. }
  20336. // ResetName resets all changes to the "name" field.
  20337. func (m *SopTaskMutation) ResetName() {
  20338. m.name = nil
  20339. }
  20340. // SetBotWxidList sets the "bot_wxid_list" field.
  20341. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  20342. m.bot_wxid_list = &s
  20343. m.appendbot_wxid_list = nil
  20344. }
  20345. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  20346. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  20347. v := m.bot_wxid_list
  20348. if v == nil {
  20349. return
  20350. }
  20351. return *v, true
  20352. }
  20353. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  20354. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20356. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  20357. if !m.op.Is(OpUpdateOne) {
  20358. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  20359. }
  20360. if m.id == nil || m.oldValue == nil {
  20361. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  20362. }
  20363. oldValue, err := m.oldValue(ctx)
  20364. if err != nil {
  20365. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  20366. }
  20367. return oldValue.BotWxidList, nil
  20368. }
  20369. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  20370. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  20371. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  20372. }
  20373. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  20374. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  20375. if len(m.appendbot_wxid_list) == 0 {
  20376. return nil, false
  20377. }
  20378. return m.appendbot_wxid_list, true
  20379. }
  20380. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  20381. func (m *SopTaskMutation) ClearBotWxidList() {
  20382. m.bot_wxid_list = nil
  20383. m.appendbot_wxid_list = nil
  20384. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  20385. }
  20386. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  20387. func (m *SopTaskMutation) BotWxidListCleared() bool {
  20388. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  20389. return ok
  20390. }
  20391. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  20392. func (m *SopTaskMutation) ResetBotWxidList() {
  20393. m.bot_wxid_list = nil
  20394. m.appendbot_wxid_list = nil
  20395. delete(m.clearedFields, soptask.FieldBotWxidList)
  20396. }
  20397. // SetType sets the "type" field.
  20398. func (m *SopTaskMutation) SetType(i int) {
  20399. m._type = &i
  20400. m.add_type = nil
  20401. }
  20402. // GetType returns the value of the "type" field in the mutation.
  20403. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  20404. v := m._type
  20405. if v == nil {
  20406. return
  20407. }
  20408. return *v, true
  20409. }
  20410. // OldType returns the old "type" field's value of the SopTask entity.
  20411. // If the SopTask 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 *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  20414. if !m.op.Is(OpUpdateOne) {
  20415. return v, errors.New("OldType is only allowed on UpdateOne operations")
  20416. }
  20417. if m.id == nil || m.oldValue == nil {
  20418. return v, errors.New("OldType 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 OldType: %w", err)
  20423. }
  20424. return oldValue.Type, nil
  20425. }
  20426. // AddType adds i to the "type" field.
  20427. func (m *SopTaskMutation) AddType(i int) {
  20428. if m.add_type != nil {
  20429. *m.add_type += i
  20430. } else {
  20431. m.add_type = &i
  20432. }
  20433. }
  20434. // AddedType returns the value that was added to the "type" field in this mutation.
  20435. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  20436. v := m.add_type
  20437. if v == nil {
  20438. return
  20439. }
  20440. return *v, true
  20441. }
  20442. // ResetType resets all changes to the "type" field.
  20443. func (m *SopTaskMutation) ResetType() {
  20444. m._type = nil
  20445. m.add_type = nil
  20446. }
  20447. // SetPlanStartTime sets the "plan_start_time" field.
  20448. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  20449. m.plan_start_time = &t
  20450. }
  20451. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  20452. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  20453. v := m.plan_start_time
  20454. if v == nil {
  20455. return
  20456. }
  20457. return *v, true
  20458. }
  20459. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  20460. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20462. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  20463. if !m.op.Is(OpUpdateOne) {
  20464. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  20465. }
  20466. if m.id == nil || m.oldValue == nil {
  20467. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  20468. }
  20469. oldValue, err := m.oldValue(ctx)
  20470. if err != nil {
  20471. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  20472. }
  20473. return oldValue.PlanStartTime, nil
  20474. }
  20475. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  20476. func (m *SopTaskMutation) ClearPlanStartTime() {
  20477. m.plan_start_time = nil
  20478. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  20479. }
  20480. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  20481. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  20482. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  20483. return ok
  20484. }
  20485. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  20486. func (m *SopTaskMutation) ResetPlanStartTime() {
  20487. m.plan_start_time = nil
  20488. delete(m.clearedFields, soptask.FieldPlanStartTime)
  20489. }
  20490. // SetPlanEndTime sets the "plan_end_time" field.
  20491. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  20492. m.plan_end_time = &t
  20493. }
  20494. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  20495. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  20496. v := m.plan_end_time
  20497. if v == nil {
  20498. return
  20499. }
  20500. return *v, true
  20501. }
  20502. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  20503. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20505. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  20506. if !m.op.Is(OpUpdateOne) {
  20507. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  20508. }
  20509. if m.id == nil || m.oldValue == nil {
  20510. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  20511. }
  20512. oldValue, err := m.oldValue(ctx)
  20513. if err != nil {
  20514. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  20515. }
  20516. return oldValue.PlanEndTime, nil
  20517. }
  20518. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  20519. func (m *SopTaskMutation) ClearPlanEndTime() {
  20520. m.plan_end_time = nil
  20521. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  20522. }
  20523. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  20524. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  20525. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  20526. return ok
  20527. }
  20528. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  20529. func (m *SopTaskMutation) ResetPlanEndTime() {
  20530. m.plan_end_time = nil
  20531. delete(m.clearedFields, soptask.FieldPlanEndTime)
  20532. }
  20533. // SetCreatorID sets the "creator_id" field.
  20534. func (m *SopTaskMutation) SetCreatorID(s string) {
  20535. m.creator_id = &s
  20536. }
  20537. // CreatorID returns the value of the "creator_id" field in the mutation.
  20538. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  20539. v := m.creator_id
  20540. if v == nil {
  20541. return
  20542. }
  20543. return *v, true
  20544. }
  20545. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  20546. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20548. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  20549. if !m.op.Is(OpUpdateOne) {
  20550. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  20551. }
  20552. if m.id == nil || m.oldValue == nil {
  20553. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  20554. }
  20555. oldValue, err := m.oldValue(ctx)
  20556. if err != nil {
  20557. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  20558. }
  20559. return oldValue.CreatorID, nil
  20560. }
  20561. // ClearCreatorID clears the value of the "creator_id" field.
  20562. func (m *SopTaskMutation) ClearCreatorID() {
  20563. m.creator_id = nil
  20564. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  20565. }
  20566. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  20567. func (m *SopTaskMutation) CreatorIDCleared() bool {
  20568. _, ok := m.clearedFields[soptask.FieldCreatorID]
  20569. return ok
  20570. }
  20571. // ResetCreatorID resets all changes to the "creator_id" field.
  20572. func (m *SopTaskMutation) ResetCreatorID() {
  20573. m.creator_id = nil
  20574. delete(m.clearedFields, soptask.FieldCreatorID)
  20575. }
  20576. // SetOrganizationID sets the "organization_id" field.
  20577. func (m *SopTaskMutation) 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 *SopTaskMutation) 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 SopTask entity.
  20590. // If the SopTask 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 *SopTaskMutation) 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 *SopTaskMutation) 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 *SopTaskMutation) 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 *SopTaskMutation) ClearOrganizationID() {
  20623. m.organization_id = nil
  20624. m.addorganization_id = nil
  20625. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  20626. }
  20627. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20628. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  20629. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  20630. return ok
  20631. }
  20632. // ResetOrganizationID resets all changes to the "organization_id" field.
  20633. func (m *SopTaskMutation) ResetOrganizationID() {
  20634. m.organization_id = nil
  20635. m.addorganization_id = nil
  20636. delete(m.clearedFields, soptask.FieldOrganizationID)
  20637. }
  20638. // SetToken sets the "token" field.
  20639. func (m *SopTaskMutation) SetToken(s []string) {
  20640. m.token = &s
  20641. m.appendtoken = nil
  20642. }
  20643. // Token returns the value of the "token" field in the mutation.
  20644. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  20645. v := m.token
  20646. if v == nil {
  20647. return
  20648. }
  20649. return *v, true
  20650. }
  20651. // OldToken returns the old "token" field's value of the SopTask entity.
  20652. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20654. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  20655. if !m.op.Is(OpUpdateOne) {
  20656. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  20657. }
  20658. if m.id == nil || m.oldValue == nil {
  20659. return v, errors.New("OldToken requires an ID field in the mutation")
  20660. }
  20661. oldValue, err := m.oldValue(ctx)
  20662. if err != nil {
  20663. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  20664. }
  20665. return oldValue.Token, nil
  20666. }
  20667. // AppendToken adds s to the "token" field.
  20668. func (m *SopTaskMutation) AppendToken(s []string) {
  20669. m.appendtoken = append(m.appendtoken, s...)
  20670. }
  20671. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  20672. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  20673. if len(m.appendtoken) == 0 {
  20674. return nil, false
  20675. }
  20676. return m.appendtoken, true
  20677. }
  20678. // ClearToken clears the value of the "token" field.
  20679. func (m *SopTaskMutation) ClearToken() {
  20680. m.token = nil
  20681. m.appendtoken = nil
  20682. m.clearedFields[soptask.FieldToken] = struct{}{}
  20683. }
  20684. // TokenCleared returns if the "token" field was cleared in this mutation.
  20685. func (m *SopTaskMutation) TokenCleared() bool {
  20686. _, ok := m.clearedFields[soptask.FieldToken]
  20687. return ok
  20688. }
  20689. // ResetToken resets all changes to the "token" field.
  20690. func (m *SopTaskMutation) ResetToken() {
  20691. m.token = nil
  20692. m.appendtoken = nil
  20693. delete(m.clearedFields, soptask.FieldToken)
  20694. }
  20695. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  20696. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  20697. if m.task_stages == nil {
  20698. m.task_stages = make(map[uint64]struct{})
  20699. }
  20700. for i := range ids {
  20701. m.task_stages[ids[i]] = struct{}{}
  20702. }
  20703. }
  20704. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  20705. func (m *SopTaskMutation) ClearTaskStages() {
  20706. m.clearedtask_stages = true
  20707. }
  20708. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  20709. func (m *SopTaskMutation) TaskStagesCleared() bool {
  20710. return m.clearedtask_stages
  20711. }
  20712. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  20713. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  20714. if m.removedtask_stages == nil {
  20715. m.removedtask_stages = make(map[uint64]struct{})
  20716. }
  20717. for i := range ids {
  20718. delete(m.task_stages, ids[i])
  20719. m.removedtask_stages[ids[i]] = struct{}{}
  20720. }
  20721. }
  20722. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  20723. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  20724. for id := range m.removedtask_stages {
  20725. ids = append(ids, id)
  20726. }
  20727. return
  20728. }
  20729. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  20730. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  20731. for id := range m.task_stages {
  20732. ids = append(ids, id)
  20733. }
  20734. return
  20735. }
  20736. // ResetTaskStages resets all changes to the "task_stages" edge.
  20737. func (m *SopTaskMutation) ResetTaskStages() {
  20738. m.task_stages = nil
  20739. m.clearedtask_stages = false
  20740. m.removedtask_stages = nil
  20741. }
  20742. // Where appends a list predicates to the SopTaskMutation builder.
  20743. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  20744. m.predicates = append(m.predicates, ps...)
  20745. }
  20746. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  20747. // users can use type-assertion to append predicates that do not depend on any generated package.
  20748. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  20749. p := make([]predicate.SopTask, len(ps))
  20750. for i := range ps {
  20751. p[i] = ps[i]
  20752. }
  20753. m.Where(p...)
  20754. }
  20755. // Op returns the operation name.
  20756. func (m *SopTaskMutation) Op() Op {
  20757. return m.op
  20758. }
  20759. // SetOp allows setting the mutation operation.
  20760. func (m *SopTaskMutation) SetOp(op Op) {
  20761. m.op = op
  20762. }
  20763. // Type returns the node type of this mutation (SopTask).
  20764. func (m *SopTaskMutation) Type() string {
  20765. return m.typ
  20766. }
  20767. // Fields returns all fields that were changed during this mutation. Note that in
  20768. // order to get all numeric fields that were incremented/decremented, call
  20769. // AddedFields().
  20770. func (m *SopTaskMutation) Fields() []string {
  20771. fields := make([]string, 0, 12)
  20772. if m.created_at != nil {
  20773. fields = append(fields, soptask.FieldCreatedAt)
  20774. }
  20775. if m.updated_at != nil {
  20776. fields = append(fields, soptask.FieldUpdatedAt)
  20777. }
  20778. if m.status != nil {
  20779. fields = append(fields, soptask.FieldStatus)
  20780. }
  20781. if m.deleted_at != nil {
  20782. fields = append(fields, soptask.FieldDeletedAt)
  20783. }
  20784. if m.name != nil {
  20785. fields = append(fields, soptask.FieldName)
  20786. }
  20787. if m.bot_wxid_list != nil {
  20788. fields = append(fields, soptask.FieldBotWxidList)
  20789. }
  20790. if m._type != nil {
  20791. fields = append(fields, soptask.FieldType)
  20792. }
  20793. if m.plan_start_time != nil {
  20794. fields = append(fields, soptask.FieldPlanStartTime)
  20795. }
  20796. if m.plan_end_time != nil {
  20797. fields = append(fields, soptask.FieldPlanEndTime)
  20798. }
  20799. if m.creator_id != nil {
  20800. fields = append(fields, soptask.FieldCreatorID)
  20801. }
  20802. if m.organization_id != nil {
  20803. fields = append(fields, soptask.FieldOrganizationID)
  20804. }
  20805. if m.token != nil {
  20806. fields = append(fields, soptask.FieldToken)
  20807. }
  20808. return fields
  20809. }
  20810. // Field returns the value of a field with the given name. The second boolean
  20811. // return value indicates that this field was not set, or was not defined in the
  20812. // schema.
  20813. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  20814. switch name {
  20815. case soptask.FieldCreatedAt:
  20816. return m.CreatedAt()
  20817. case soptask.FieldUpdatedAt:
  20818. return m.UpdatedAt()
  20819. case soptask.FieldStatus:
  20820. return m.Status()
  20821. case soptask.FieldDeletedAt:
  20822. return m.DeletedAt()
  20823. case soptask.FieldName:
  20824. return m.Name()
  20825. case soptask.FieldBotWxidList:
  20826. return m.BotWxidList()
  20827. case soptask.FieldType:
  20828. return m.GetType()
  20829. case soptask.FieldPlanStartTime:
  20830. return m.PlanStartTime()
  20831. case soptask.FieldPlanEndTime:
  20832. return m.PlanEndTime()
  20833. case soptask.FieldCreatorID:
  20834. return m.CreatorID()
  20835. case soptask.FieldOrganizationID:
  20836. return m.OrganizationID()
  20837. case soptask.FieldToken:
  20838. return m.Token()
  20839. }
  20840. return nil, false
  20841. }
  20842. // OldField returns the old value of the field from the database. An error is
  20843. // returned if the mutation operation is not UpdateOne, or the query to the
  20844. // database failed.
  20845. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20846. switch name {
  20847. case soptask.FieldCreatedAt:
  20848. return m.OldCreatedAt(ctx)
  20849. case soptask.FieldUpdatedAt:
  20850. return m.OldUpdatedAt(ctx)
  20851. case soptask.FieldStatus:
  20852. return m.OldStatus(ctx)
  20853. case soptask.FieldDeletedAt:
  20854. return m.OldDeletedAt(ctx)
  20855. case soptask.FieldName:
  20856. return m.OldName(ctx)
  20857. case soptask.FieldBotWxidList:
  20858. return m.OldBotWxidList(ctx)
  20859. case soptask.FieldType:
  20860. return m.OldType(ctx)
  20861. case soptask.FieldPlanStartTime:
  20862. return m.OldPlanStartTime(ctx)
  20863. case soptask.FieldPlanEndTime:
  20864. return m.OldPlanEndTime(ctx)
  20865. case soptask.FieldCreatorID:
  20866. return m.OldCreatorID(ctx)
  20867. case soptask.FieldOrganizationID:
  20868. return m.OldOrganizationID(ctx)
  20869. case soptask.FieldToken:
  20870. return m.OldToken(ctx)
  20871. }
  20872. return nil, fmt.Errorf("unknown SopTask field %s", name)
  20873. }
  20874. // SetField sets the value of a field with the given name. It returns an error if
  20875. // the field is not defined in the schema, or if the type mismatched the field
  20876. // type.
  20877. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  20878. switch name {
  20879. case soptask.FieldCreatedAt:
  20880. v, ok := value.(time.Time)
  20881. if !ok {
  20882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20883. }
  20884. m.SetCreatedAt(v)
  20885. return nil
  20886. case soptask.FieldUpdatedAt:
  20887. v, ok := value.(time.Time)
  20888. if !ok {
  20889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20890. }
  20891. m.SetUpdatedAt(v)
  20892. return nil
  20893. case soptask.FieldStatus:
  20894. v, ok := value.(uint8)
  20895. if !ok {
  20896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20897. }
  20898. m.SetStatus(v)
  20899. return nil
  20900. case soptask.FieldDeletedAt:
  20901. v, ok := value.(time.Time)
  20902. if !ok {
  20903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20904. }
  20905. m.SetDeletedAt(v)
  20906. return nil
  20907. case soptask.FieldName:
  20908. v, ok := value.(string)
  20909. if !ok {
  20910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20911. }
  20912. m.SetName(v)
  20913. return nil
  20914. case soptask.FieldBotWxidList:
  20915. v, ok := value.([]string)
  20916. if !ok {
  20917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20918. }
  20919. m.SetBotWxidList(v)
  20920. return nil
  20921. case soptask.FieldType:
  20922. v, ok := value.(int)
  20923. if !ok {
  20924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20925. }
  20926. m.SetType(v)
  20927. return nil
  20928. case soptask.FieldPlanStartTime:
  20929. v, ok := value.(time.Time)
  20930. if !ok {
  20931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20932. }
  20933. m.SetPlanStartTime(v)
  20934. return nil
  20935. case soptask.FieldPlanEndTime:
  20936. v, ok := value.(time.Time)
  20937. if !ok {
  20938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20939. }
  20940. m.SetPlanEndTime(v)
  20941. return nil
  20942. case soptask.FieldCreatorID:
  20943. v, ok := value.(string)
  20944. if !ok {
  20945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20946. }
  20947. m.SetCreatorID(v)
  20948. return nil
  20949. case soptask.FieldOrganizationID:
  20950. v, ok := value.(uint64)
  20951. if !ok {
  20952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20953. }
  20954. m.SetOrganizationID(v)
  20955. return nil
  20956. case soptask.FieldToken:
  20957. v, ok := value.([]string)
  20958. if !ok {
  20959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20960. }
  20961. m.SetToken(v)
  20962. return nil
  20963. }
  20964. return fmt.Errorf("unknown SopTask field %s", name)
  20965. }
  20966. // AddedFields returns all numeric fields that were incremented/decremented during
  20967. // this mutation.
  20968. func (m *SopTaskMutation) AddedFields() []string {
  20969. var fields []string
  20970. if m.addstatus != nil {
  20971. fields = append(fields, soptask.FieldStatus)
  20972. }
  20973. if m.add_type != nil {
  20974. fields = append(fields, soptask.FieldType)
  20975. }
  20976. if m.addorganization_id != nil {
  20977. fields = append(fields, soptask.FieldOrganizationID)
  20978. }
  20979. return fields
  20980. }
  20981. // AddedField returns the numeric value that was incremented/decremented on a field
  20982. // with the given name. The second boolean return value indicates that this field
  20983. // was not set, or was not defined in the schema.
  20984. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  20985. switch name {
  20986. case soptask.FieldStatus:
  20987. return m.AddedStatus()
  20988. case soptask.FieldType:
  20989. return m.AddedType()
  20990. case soptask.FieldOrganizationID:
  20991. return m.AddedOrganizationID()
  20992. }
  20993. return nil, false
  20994. }
  20995. // AddField adds the value to the field with the given name. It returns an error if
  20996. // the field is not defined in the schema, or if the type mismatched the field
  20997. // type.
  20998. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  20999. switch name {
  21000. case soptask.FieldStatus:
  21001. v, ok := value.(int8)
  21002. if !ok {
  21003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21004. }
  21005. m.AddStatus(v)
  21006. return nil
  21007. case soptask.FieldType:
  21008. v, ok := value.(int)
  21009. if !ok {
  21010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21011. }
  21012. m.AddType(v)
  21013. return nil
  21014. case soptask.FieldOrganizationID:
  21015. v, ok := value.(int64)
  21016. if !ok {
  21017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21018. }
  21019. m.AddOrganizationID(v)
  21020. return nil
  21021. }
  21022. return fmt.Errorf("unknown SopTask numeric field %s", name)
  21023. }
  21024. // ClearedFields returns all nullable fields that were cleared during this
  21025. // mutation.
  21026. func (m *SopTaskMutation) ClearedFields() []string {
  21027. var fields []string
  21028. if m.FieldCleared(soptask.FieldStatus) {
  21029. fields = append(fields, soptask.FieldStatus)
  21030. }
  21031. if m.FieldCleared(soptask.FieldDeletedAt) {
  21032. fields = append(fields, soptask.FieldDeletedAt)
  21033. }
  21034. if m.FieldCleared(soptask.FieldBotWxidList) {
  21035. fields = append(fields, soptask.FieldBotWxidList)
  21036. }
  21037. if m.FieldCleared(soptask.FieldPlanStartTime) {
  21038. fields = append(fields, soptask.FieldPlanStartTime)
  21039. }
  21040. if m.FieldCleared(soptask.FieldPlanEndTime) {
  21041. fields = append(fields, soptask.FieldPlanEndTime)
  21042. }
  21043. if m.FieldCleared(soptask.FieldCreatorID) {
  21044. fields = append(fields, soptask.FieldCreatorID)
  21045. }
  21046. if m.FieldCleared(soptask.FieldOrganizationID) {
  21047. fields = append(fields, soptask.FieldOrganizationID)
  21048. }
  21049. if m.FieldCleared(soptask.FieldToken) {
  21050. fields = append(fields, soptask.FieldToken)
  21051. }
  21052. return fields
  21053. }
  21054. // FieldCleared returns a boolean indicating if a field with the given name was
  21055. // cleared in this mutation.
  21056. func (m *SopTaskMutation) FieldCleared(name string) bool {
  21057. _, ok := m.clearedFields[name]
  21058. return ok
  21059. }
  21060. // ClearField clears the value of the field with the given name. It returns an
  21061. // error if the field is not defined in the schema.
  21062. func (m *SopTaskMutation) ClearField(name string) error {
  21063. switch name {
  21064. case soptask.FieldStatus:
  21065. m.ClearStatus()
  21066. return nil
  21067. case soptask.FieldDeletedAt:
  21068. m.ClearDeletedAt()
  21069. return nil
  21070. case soptask.FieldBotWxidList:
  21071. m.ClearBotWxidList()
  21072. return nil
  21073. case soptask.FieldPlanStartTime:
  21074. m.ClearPlanStartTime()
  21075. return nil
  21076. case soptask.FieldPlanEndTime:
  21077. m.ClearPlanEndTime()
  21078. return nil
  21079. case soptask.FieldCreatorID:
  21080. m.ClearCreatorID()
  21081. return nil
  21082. case soptask.FieldOrganizationID:
  21083. m.ClearOrganizationID()
  21084. return nil
  21085. case soptask.FieldToken:
  21086. m.ClearToken()
  21087. return nil
  21088. }
  21089. return fmt.Errorf("unknown SopTask nullable field %s", name)
  21090. }
  21091. // ResetField resets all changes in the mutation for the field with the given name.
  21092. // It returns an error if the field is not defined in the schema.
  21093. func (m *SopTaskMutation) ResetField(name string) error {
  21094. switch name {
  21095. case soptask.FieldCreatedAt:
  21096. m.ResetCreatedAt()
  21097. return nil
  21098. case soptask.FieldUpdatedAt:
  21099. m.ResetUpdatedAt()
  21100. return nil
  21101. case soptask.FieldStatus:
  21102. m.ResetStatus()
  21103. return nil
  21104. case soptask.FieldDeletedAt:
  21105. m.ResetDeletedAt()
  21106. return nil
  21107. case soptask.FieldName:
  21108. m.ResetName()
  21109. return nil
  21110. case soptask.FieldBotWxidList:
  21111. m.ResetBotWxidList()
  21112. return nil
  21113. case soptask.FieldType:
  21114. m.ResetType()
  21115. return nil
  21116. case soptask.FieldPlanStartTime:
  21117. m.ResetPlanStartTime()
  21118. return nil
  21119. case soptask.FieldPlanEndTime:
  21120. m.ResetPlanEndTime()
  21121. return nil
  21122. case soptask.FieldCreatorID:
  21123. m.ResetCreatorID()
  21124. return nil
  21125. case soptask.FieldOrganizationID:
  21126. m.ResetOrganizationID()
  21127. return nil
  21128. case soptask.FieldToken:
  21129. m.ResetToken()
  21130. return nil
  21131. }
  21132. return fmt.Errorf("unknown SopTask field %s", name)
  21133. }
  21134. // AddedEdges returns all edge names that were set/added in this mutation.
  21135. func (m *SopTaskMutation) AddedEdges() []string {
  21136. edges := make([]string, 0, 1)
  21137. if m.task_stages != nil {
  21138. edges = append(edges, soptask.EdgeTaskStages)
  21139. }
  21140. return edges
  21141. }
  21142. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21143. // name in this mutation.
  21144. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  21145. switch name {
  21146. case soptask.EdgeTaskStages:
  21147. ids := make([]ent.Value, 0, len(m.task_stages))
  21148. for id := range m.task_stages {
  21149. ids = append(ids, id)
  21150. }
  21151. return ids
  21152. }
  21153. return nil
  21154. }
  21155. // RemovedEdges returns all edge names that were removed in this mutation.
  21156. func (m *SopTaskMutation) RemovedEdges() []string {
  21157. edges := make([]string, 0, 1)
  21158. if m.removedtask_stages != nil {
  21159. edges = append(edges, soptask.EdgeTaskStages)
  21160. }
  21161. return edges
  21162. }
  21163. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21164. // the given name in this mutation.
  21165. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  21166. switch name {
  21167. case soptask.EdgeTaskStages:
  21168. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  21169. for id := range m.removedtask_stages {
  21170. ids = append(ids, id)
  21171. }
  21172. return ids
  21173. }
  21174. return nil
  21175. }
  21176. // ClearedEdges returns all edge names that were cleared in this mutation.
  21177. func (m *SopTaskMutation) ClearedEdges() []string {
  21178. edges := make([]string, 0, 1)
  21179. if m.clearedtask_stages {
  21180. edges = append(edges, soptask.EdgeTaskStages)
  21181. }
  21182. return edges
  21183. }
  21184. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21185. // was cleared in this mutation.
  21186. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  21187. switch name {
  21188. case soptask.EdgeTaskStages:
  21189. return m.clearedtask_stages
  21190. }
  21191. return false
  21192. }
  21193. // ClearEdge clears the value of the edge with the given name. It returns an error
  21194. // if that edge is not defined in the schema.
  21195. func (m *SopTaskMutation) ClearEdge(name string) error {
  21196. switch name {
  21197. }
  21198. return fmt.Errorf("unknown SopTask unique edge %s", name)
  21199. }
  21200. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21201. // It returns an error if the edge is not defined in the schema.
  21202. func (m *SopTaskMutation) ResetEdge(name string) error {
  21203. switch name {
  21204. case soptask.EdgeTaskStages:
  21205. m.ResetTaskStages()
  21206. return nil
  21207. }
  21208. return fmt.Errorf("unknown SopTask edge %s", name)
  21209. }
  21210. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  21211. type TokenMutation struct {
  21212. config
  21213. op Op
  21214. typ string
  21215. id *uint64
  21216. created_at *time.Time
  21217. updated_at *time.Time
  21218. deleted_at *time.Time
  21219. expire_at *time.Time
  21220. token *string
  21221. mac *string
  21222. organization_id *uint64
  21223. addorganization_id *int64
  21224. custom_agent_base *string
  21225. custom_agent_key *string
  21226. openai_base *string
  21227. openai_key *string
  21228. clearedFields map[string]struct{}
  21229. agent *uint64
  21230. clearedagent bool
  21231. done bool
  21232. oldValue func(context.Context) (*Token, error)
  21233. predicates []predicate.Token
  21234. }
  21235. var _ ent.Mutation = (*TokenMutation)(nil)
  21236. // tokenOption allows management of the mutation configuration using functional options.
  21237. type tokenOption func(*TokenMutation)
  21238. // newTokenMutation creates new mutation for the Token entity.
  21239. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  21240. m := &TokenMutation{
  21241. config: c,
  21242. op: op,
  21243. typ: TypeToken,
  21244. clearedFields: make(map[string]struct{}),
  21245. }
  21246. for _, opt := range opts {
  21247. opt(m)
  21248. }
  21249. return m
  21250. }
  21251. // withTokenID sets the ID field of the mutation.
  21252. func withTokenID(id uint64) tokenOption {
  21253. return func(m *TokenMutation) {
  21254. var (
  21255. err error
  21256. once sync.Once
  21257. value *Token
  21258. )
  21259. m.oldValue = func(ctx context.Context) (*Token, error) {
  21260. once.Do(func() {
  21261. if m.done {
  21262. err = errors.New("querying old values post mutation is not allowed")
  21263. } else {
  21264. value, err = m.Client().Token.Get(ctx, id)
  21265. }
  21266. })
  21267. return value, err
  21268. }
  21269. m.id = &id
  21270. }
  21271. }
  21272. // withToken sets the old Token of the mutation.
  21273. func withToken(node *Token) tokenOption {
  21274. return func(m *TokenMutation) {
  21275. m.oldValue = func(context.Context) (*Token, error) {
  21276. return node, nil
  21277. }
  21278. m.id = &node.ID
  21279. }
  21280. }
  21281. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21282. // executed in a transaction (ent.Tx), a transactional client is returned.
  21283. func (m TokenMutation) Client() *Client {
  21284. client := &Client{config: m.config}
  21285. client.init()
  21286. return client
  21287. }
  21288. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21289. // it returns an error otherwise.
  21290. func (m TokenMutation) Tx() (*Tx, error) {
  21291. if _, ok := m.driver.(*txDriver); !ok {
  21292. return nil, errors.New("ent: mutation is not running in a transaction")
  21293. }
  21294. tx := &Tx{config: m.config}
  21295. tx.init()
  21296. return tx, nil
  21297. }
  21298. // SetID sets the value of the id field. Note that this
  21299. // operation is only accepted on creation of Token entities.
  21300. func (m *TokenMutation) SetID(id uint64) {
  21301. m.id = &id
  21302. }
  21303. // ID returns the ID value in the mutation. Note that the ID is only available
  21304. // if it was provided to the builder or after it was returned from the database.
  21305. func (m *TokenMutation) ID() (id uint64, exists bool) {
  21306. if m.id == nil {
  21307. return
  21308. }
  21309. return *m.id, true
  21310. }
  21311. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21312. // That means, if the mutation is applied within a transaction with an isolation level such
  21313. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21314. // or updated by the mutation.
  21315. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  21316. switch {
  21317. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21318. id, exists := m.ID()
  21319. if exists {
  21320. return []uint64{id}, nil
  21321. }
  21322. fallthrough
  21323. case m.op.Is(OpUpdate | OpDelete):
  21324. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  21325. default:
  21326. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21327. }
  21328. }
  21329. // SetCreatedAt sets the "created_at" field.
  21330. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  21331. m.created_at = &t
  21332. }
  21333. // CreatedAt returns the value of the "created_at" field in the mutation.
  21334. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  21335. v := m.created_at
  21336. if v == nil {
  21337. return
  21338. }
  21339. return *v, true
  21340. }
  21341. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  21342. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21344. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21345. if !m.op.Is(OpUpdateOne) {
  21346. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21347. }
  21348. if m.id == nil || m.oldValue == nil {
  21349. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21350. }
  21351. oldValue, err := m.oldValue(ctx)
  21352. if err != nil {
  21353. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21354. }
  21355. return oldValue.CreatedAt, nil
  21356. }
  21357. // ResetCreatedAt resets all changes to the "created_at" field.
  21358. func (m *TokenMutation) ResetCreatedAt() {
  21359. m.created_at = nil
  21360. }
  21361. // SetUpdatedAt sets the "updated_at" field.
  21362. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  21363. m.updated_at = &t
  21364. }
  21365. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21366. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  21367. v := m.updated_at
  21368. if v == nil {
  21369. return
  21370. }
  21371. return *v, true
  21372. }
  21373. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  21374. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21376. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21377. if !m.op.Is(OpUpdateOne) {
  21378. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21379. }
  21380. if m.id == nil || m.oldValue == nil {
  21381. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21382. }
  21383. oldValue, err := m.oldValue(ctx)
  21384. if err != nil {
  21385. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21386. }
  21387. return oldValue.UpdatedAt, nil
  21388. }
  21389. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21390. func (m *TokenMutation) ResetUpdatedAt() {
  21391. m.updated_at = nil
  21392. }
  21393. // SetDeletedAt sets the "deleted_at" field.
  21394. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  21395. m.deleted_at = &t
  21396. }
  21397. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21398. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  21399. v := m.deleted_at
  21400. if v == nil {
  21401. return
  21402. }
  21403. return *v, true
  21404. }
  21405. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  21406. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21408. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21409. if !m.op.Is(OpUpdateOne) {
  21410. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21411. }
  21412. if m.id == nil || m.oldValue == nil {
  21413. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21414. }
  21415. oldValue, err := m.oldValue(ctx)
  21416. if err != nil {
  21417. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21418. }
  21419. return oldValue.DeletedAt, nil
  21420. }
  21421. // ClearDeletedAt clears the value of the "deleted_at" field.
  21422. func (m *TokenMutation) ClearDeletedAt() {
  21423. m.deleted_at = nil
  21424. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  21425. }
  21426. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21427. func (m *TokenMutation) DeletedAtCleared() bool {
  21428. _, ok := m.clearedFields[token.FieldDeletedAt]
  21429. return ok
  21430. }
  21431. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21432. func (m *TokenMutation) ResetDeletedAt() {
  21433. m.deleted_at = nil
  21434. delete(m.clearedFields, token.FieldDeletedAt)
  21435. }
  21436. // SetExpireAt sets the "expire_at" field.
  21437. func (m *TokenMutation) SetExpireAt(t time.Time) {
  21438. m.expire_at = &t
  21439. }
  21440. // ExpireAt returns the value of the "expire_at" field in the mutation.
  21441. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  21442. v := m.expire_at
  21443. if v == nil {
  21444. return
  21445. }
  21446. return *v, true
  21447. }
  21448. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  21449. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21451. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  21452. if !m.op.Is(OpUpdateOne) {
  21453. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  21454. }
  21455. if m.id == nil || m.oldValue == nil {
  21456. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  21457. }
  21458. oldValue, err := m.oldValue(ctx)
  21459. if err != nil {
  21460. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  21461. }
  21462. return oldValue.ExpireAt, nil
  21463. }
  21464. // ClearExpireAt clears the value of the "expire_at" field.
  21465. func (m *TokenMutation) ClearExpireAt() {
  21466. m.expire_at = nil
  21467. m.clearedFields[token.FieldExpireAt] = struct{}{}
  21468. }
  21469. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  21470. func (m *TokenMutation) ExpireAtCleared() bool {
  21471. _, ok := m.clearedFields[token.FieldExpireAt]
  21472. return ok
  21473. }
  21474. // ResetExpireAt resets all changes to the "expire_at" field.
  21475. func (m *TokenMutation) ResetExpireAt() {
  21476. m.expire_at = nil
  21477. delete(m.clearedFields, token.FieldExpireAt)
  21478. }
  21479. // SetToken sets the "token" field.
  21480. func (m *TokenMutation) SetToken(s string) {
  21481. m.token = &s
  21482. }
  21483. // Token returns the value of the "token" field in the mutation.
  21484. func (m *TokenMutation) Token() (r string, exists bool) {
  21485. v := m.token
  21486. if v == nil {
  21487. return
  21488. }
  21489. return *v, true
  21490. }
  21491. // OldToken returns the old "token" field's value of the Token entity.
  21492. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21494. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  21495. if !m.op.Is(OpUpdateOne) {
  21496. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  21497. }
  21498. if m.id == nil || m.oldValue == nil {
  21499. return v, errors.New("OldToken requires an ID field in the mutation")
  21500. }
  21501. oldValue, err := m.oldValue(ctx)
  21502. if err != nil {
  21503. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  21504. }
  21505. return oldValue.Token, nil
  21506. }
  21507. // ClearToken clears the value of the "token" field.
  21508. func (m *TokenMutation) ClearToken() {
  21509. m.token = nil
  21510. m.clearedFields[token.FieldToken] = struct{}{}
  21511. }
  21512. // TokenCleared returns if the "token" field was cleared in this mutation.
  21513. func (m *TokenMutation) TokenCleared() bool {
  21514. _, ok := m.clearedFields[token.FieldToken]
  21515. return ok
  21516. }
  21517. // ResetToken resets all changes to the "token" field.
  21518. func (m *TokenMutation) ResetToken() {
  21519. m.token = nil
  21520. delete(m.clearedFields, token.FieldToken)
  21521. }
  21522. // SetMAC sets the "mac" field.
  21523. func (m *TokenMutation) SetMAC(s string) {
  21524. m.mac = &s
  21525. }
  21526. // MAC returns the value of the "mac" field in the mutation.
  21527. func (m *TokenMutation) MAC() (r string, exists bool) {
  21528. v := m.mac
  21529. if v == nil {
  21530. return
  21531. }
  21532. return *v, true
  21533. }
  21534. // OldMAC returns the old "mac" field's value of the Token entity.
  21535. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21537. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  21538. if !m.op.Is(OpUpdateOne) {
  21539. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  21540. }
  21541. if m.id == nil || m.oldValue == nil {
  21542. return v, errors.New("OldMAC requires an ID field in the mutation")
  21543. }
  21544. oldValue, err := m.oldValue(ctx)
  21545. if err != nil {
  21546. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  21547. }
  21548. return oldValue.MAC, nil
  21549. }
  21550. // ClearMAC clears the value of the "mac" field.
  21551. func (m *TokenMutation) ClearMAC() {
  21552. m.mac = nil
  21553. m.clearedFields[token.FieldMAC] = struct{}{}
  21554. }
  21555. // MACCleared returns if the "mac" field was cleared in this mutation.
  21556. func (m *TokenMutation) MACCleared() bool {
  21557. _, ok := m.clearedFields[token.FieldMAC]
  21558. return ok
  21559. }
  21560. // ResetMAC resets all changes to the "mac" field.
  21561. func (m *TokenMutation) ResetMAC() {
  21562. m.mac = nil
  21563. delete(m.clearedFields, token.FieldMAC)
  21564. }
  21565. // SetOrganizationID sets the "organization_id" field.
  21566. func (m *TokenMutation) SetOrganizationID(u uint64) {
  21567. m.organization_id = &u
  21568. m.addorganization_id = nil
  21569. }
  21570. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21571. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  21572. v := m.organization_id
  21573. if v == nil {
  21574. return
  21575. }
  21576. return *v, true
  21577. }
  21578. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  21579. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21581. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21582. if !m.op.Is(OpUpdateOne) {
  21583. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21584. }
  21585. if m.id == nil || m.oldValue == nil {
  21586. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21587. }
  21588. oldValue, err := m.oldValue(ctx)
  21589. if err != nil {
  21590. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21591. }
  21592. return oldValue.OrganizationID, nil
  21593. }
  21594. // AddOrganizationID adds u to the "organization_id" field.
  21595. func (m *TokenMutation) AddOrganizationID(u int64) {
  21596. if m.addorganization_id != nil {
  21597. *m.addorganization_id += u
  21598. } else {
  21599. m.addorganization_id = &u
  21600. }
  21601. }
  21602. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21603. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  21604. v := m.addorganization_id
  21605. if v == nil {
  21606. return
  21607. }
  21608. return *v, true
  21609. }
  21610. // ResetOrganizationID resets all changes to the "organization_id" field.
  21611. func (m *TokenMutation) ResetOrganizationID() {
  21612. m.organization_id = nil
  21613. m.addorganization_id = nil
  21614. }
  21615. // SetAgentID sets the "agent_id" field.
  21616. func (m *TokenMutation) SetAgentID(u uint64) {
  21617. m.agent = &u
  21618. }
  21619. // AgentID returns the value of the "agent_id" field in the mutation.
  21620. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  21621. v := m.agent
  21622. if v == nil {
  21623. return
  21624. }
  21625. return *v, true
  21626. }
  21627. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  21628. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21630. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  21631. if !m.op.Is(OpUpdateOne) {
  21632. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  21633. }
  21634. if m.id == nil || m.oldValue == nil {
  21635. return v, errors.New("OldAgentID requires an ID field in the mutation")
  21636. }
  21637. oldValue, err := m.oldValue(ctx)
  21638. if err != nil {
  21639. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  21640. }
  21641. return oldValue.AgentID, nil
  21642. }
  21643. // ResetAgentID resets all changes to the "agent_id" field.
  21644. func (m *TokenMutation) ResetAgentID() {
  21645. m.agent = nil
  21646. }
  21647. // SetCustomAgentBase sets the "custom_agent_base" field.
  21648. func (m *TokenMutation) SetCustomAgentBase(s string) {
  21649. m.custom_agent_base = &s
  21650. }
  21651. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  21652. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  21653. v := m.custom_agent_base
  21654. if v == nil {
  21655. return
  21656. }
  21657. return *v, true
  21658. }
  21659. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  21660. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21662. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  21663. if !m.op.Is(OpUpdateOne) {
  21664. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  21665. }
  21666. if m.id == nil || m.oldValue == nil {
  21667. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  21668. }
  21669. oldValue, err := m.oldValue(ctx)
  21670. if err != nil {
  21671. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  21672. }
  21673. return oldValue.CustomAgentBase, nil
  21674. }
  21675. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  21676. func (m *TokenMutation) ClearCustomAgentBase() {
  21677. m.custom_agent_base = nil
  21678. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  21679. }
  21680. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  21681. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  21682. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  21683. return ok
  21684. }
  21685. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  21686. func (m *TokenMutation) ResetCustomAgentBase() {
  21687. m.custom_agent_base = nil
  21688. delete(m.clearedFields, token.FieldCustomAgentBase)
  21689. }
  21690. // SetCustomAgentKey sets the "custom_agent_key" field.
  21691. func (m *TokenMutation) SetCustomAgentKey(s string) {
  21692. m.custom_agent_key = &s
  21693. }
  21694. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  21695. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  21696. v := m.custom_agent_key
  21697. if v == nil {
  21698. return
  21699. }
  21700. return *v, true
  21701. }
  21702. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  21703. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21705. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  21706. if !m.op.Is(OpUpdateOne) {
  21707. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  21708. }
  21709. if m.id == nil || m.oldValue == nil {
  21710. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  21711. }
  21712. oldValue, err := m.oldValue(ctx)
  21713. if err != nil {
  21714. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  21715. }
  21716. return oldValue.CustomAgentKey, nil
  21717. }
  21718. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  21719. func (m *TokenMutation) ClearCustomAgentKey() {
  21720. m.custom_agent_key = nil
  21721. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  21722. }
  21723. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  21724. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  21725. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  21726. return ok
  21727. }
  21728. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  21729. func (m *TokenMutation) ResetCustomAgentKey() {
  21730. m.custom_agent_key = nil
  21731. delete(m.clearedFields, token.FieldCustomAgentKey)
  21732. }
  21733. // SetOpenaiBase sets the "openai_base" field.
  21734. func (m *TokenMutation) SetOpenaiBase(s string) {
  21735. m.openai_base = &s
  21736. }
  21737. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  21738. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  21739. v := m.openai_base
  21740. if v == nil {
  21741. return
  21742. }
  21743. return *v, true
  21744. }
  21745. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  21746. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21748. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  21749. if !m.op.Is(OpUpdateOne) {
  21750. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  21751. }
  21752. if m.id == nil || m.oldValue == nil {
  21753. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  21754. }
  21755. oldValue, err := m.oldValue(ctx)
  21756. if err != nil {
  21757. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  21758. }
  21759. return oldValue.OpenaiBase, nil
  21760. }
  21761. // ClearOpenaiBase clears the value of the "openai_base" field.
  21762. func (m *TokenMutation) ClearOpenaiBase() {
  21763. m.openai_base = nil
  21764. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  21765. }
  21766. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  21767. func (m *TokenMutation) OpenaiBaseCleared() bool {
  21768. _, ok := m.clearedFields[token.FieldOpenaiBase]
  21769. return ok
  21770. }
  21771. // ResetOpenaiBase resets all changes to the "openai_base" field.
  21772. func (m *TokenMutation) ResetOpenaiBase() {
  21773. m.openai_base = nil
  21774. delete(m.clearedFields, token.FieldOpenaiBase)
  21775. }
  21776. // SetOpenaiKey sets the "openai_key" field.
  21777. func (m *TokenMutation) SetOpenaiKey(s string) {
  21778. m.openai_key = &s
  21779. }
  21780. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  21781. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  21782. v := m.openai_key
  21783. if v == nil {
  21784. return
  21785. }
  21786. return *v, true
  21787. }
  21788. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  21789. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21791. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  21792. if !m.op.Is(OpUpdateOne) {
  21793. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  21794. }
  21795. if m.id == nil || m.oldValue == nil {
  21796. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  21797. }
  21798. oldValue, err := m.oldValue(ctx)
  21799. if err != nil {
  21800. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  21801. }
  21802. return oldValue.OpenaiKey, nil
  21803. }
  21804. // ClearOpenaiKey clears the value of the "openai_key" field.
  21805. func (m *TokenMutation) ClearOpenaiKey() {
  21806. m.openai_key = nil
  21807. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  21808. }
  21809. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  21810. func (m *TokenMutation) OpenaiKeyCleared() bool {
  21811. _, ok := m.clearedFields[token.FieldOpenaiKey]
  21812. return ok
  21813. }
  21814. // ResetOpenaiKey resets all changes to the "openai_key" field.
  21815. func (m *TokenMutation) ResetOpenaiKey() {
  21816. m.openai_key = nil
  21817. delete(m.clearedFields, token.FieldOpenaiKey)
  21818. }
  21819. // ClearAgent clears the "agent" edge to the Agent entity.
  21820. func (m *TokenMutation) ClearAgent() {
  21821. m.clearedagent = true
  21822. m.clearedFields[token.FieldAgentID] = struct{}{}
  21823. }
  21824. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  21825. func (m *TokenMutation) AgentCleared() bool {
  21826. return m.clearedagent
  21827. }
  21828. // AgentIDs returns the "agent" edge IDs in the mutation.
  21829. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21830. // AgentID instead. It exists only for internal usage by the builders.
  21831. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  21832. if id := m.agent; id != nil {
  21833. ids = append(ids, *id)
  21834. }
  21835. return
  21836. }
  21837. // ResetAgent resets all changes to the "agent" edge.
  21838. func (m *TokenMutation) ResetAgent() {
  21839. m.agent = nil
  21840. m.clearedagent = false
  21841. }
  21842. // Where appends a list predicates to the TokenMutation builder.
  21843. func (m *TokenMutation) Where(ps ...predicate.Token) {
  21844. m.predicates = append(m.predicates, ps...)
  21845. }
  21846. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  21847. // users can use type-assertion to append predicates that do not depend on any generated package.
  21848. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  21849. p := make([]predicate.Token, len(ps))
  21850. for i := range ps {
  21851. p[i] = ps[i]
  21852. }
  21853. m.Where(p...)
  21854. }
  21855. // Op returns the operation name.
  21856. func (m *TokenMutation) Op() Op {
  21857. return m.op
  21858. }
  21859. // SetOp allows setting the mutation operation.
  21860. func (m *TokenMutation) SetOp(op Op) {
  21861. m.op = op
  21862. }
  21863. // Type returns the node type of this mutation (Token).
  21864. func (m *TokenMutation) Type() string {
  21865. return m.typ
  21866. }
  21867. // Fields returns all fields that were changed during this mutation. Note that in
  21868. // order to get all numeric fields that were incremented/decremented, call
  21869. // AddedFields().
  21870. func (m *TokenMutation) Fields() []string {
  21871. fields := make([]string, 0, 12)
  21872. if m.created_at != nil {
  21873. fields = append(fields, token.FieldCreatedAt)
  21874. }
  21875. if m.updated_at != nil {
  21876. fields = append(fields, token.FieldUpdatedAt)
  21877. }
  21878. if m.deleted_at != nil {
  21879. fields = append(fields, token.FieldDeletedAt)
  21880. }
  21881. if m.expire_at != nil {
  21882. fields = append(fields, token.FieldExpireAt)
  21883. }
  21884. if m.token != nil {
  21885. fields = append(fields, token.FieldToken)
  21886. }
  21887. if m.mac != nil {
  21888. fields = append(fields, token.FieldMAC)
  21889. }
  21890. if m.organization_id != nil {
  21891. fields = append(fields, token.FieldOrganizationID)
  21892. }
  21893. if m.agent != nil {
  21894. fields = append(fields, token.FieldAgentID)
  21895. }
  21896. if m.custom_agent_base != nil {
  21897. fields = append(fields, token.FieldCustomAgentBase)
  21898. }
  21899. if m.custom_agent_key != nil {
  21900. fields = append(fields, token.FieldCustomAgentKey)
  21901. }
  21902. if m.openai_base != nil {
  21903. fields = append(fields, token.FieldOpenaiBase)
  21904. }
  21905. if m.openai_key != nil {
  21906. fields = append(fields, token.FieldOpenaiKey)
  21907. }
  21908. return fields
  21909. }
  21910. // Field returns the value of a field with the given name. The second boolean
  21911. // return value indicates that this field was not set, or was not defined in the
  21912. // schema.
  21913. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  21914. switch name {
  21915. case token.FieldCreatedAt:
  21916. return m.CreatedAt()
  21917. case token.FieldUpdatedAt:
  21918. return m.UpdatedAt()
  21919. case token.FieldDeletedAt:
  21920. return m.DeletedAt()
  21921. case token.FieldExpireAt:
  21922. return m.ExpireAt()
  21923. case token.FieldToken:
  21924. return m.Token()
  21925. case token.FieldMAC:
  21926. return m.MAC()
  21927. case token.FieldOrganizationID:
  21928. return m.OrganizationID()
  21929. case token.FieldAgentID:
  21930. return m.AgentID()
  21931. case token.FieldCustomAgentBase:
  21932. return m.CustomAgentBase()
  21933. case token.FieldCustomAgentKey:
  21934. return m.CustomAgentKey()
  21935. case token.FieldOpenaiBase:
  21936. return m.OpenaiBase()
  21937. case token.FieldOpenaiKey:
  21938. return m.OpenaiKey()
  21939. }
  21940. return nil, false
  21941. }
  21942. // OldField returns the old value of the field from the database. An error is
  21943. // returned if the mutation operation is not UpdateOne, or the query to the
  21944. // database failed.
  21945. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21946. switch name {
  21947. case token.FieldCreatedAt:
  21948. return m.OldCreatedAt(ctx)
  21949. case token.FieldUpdatedAt:
  21950. return m.OldUpdatedAt(ctx)
  21951. case token.FieldDeletedAt:
  21952. return m.OldDeletedAt(ctx)
  21953. case token.FieldExpireAt:
  21954. return m.OldExpireAt(ctx)
  21955. case token.FieldToken:
  21956. return m.OldToken(ctx)
  21957. case token.FieldMAC:
  21958. return m.OldMAC(ctx)
  21959. case token.FieldOrganizationID:
  21960. return m.OldOrganizationID(ctx)
  21961. case token.FieldAgentID:
  21962. return m.OldAgentID(ctx)
  21963. case token.FieldCustomAgentBase:
  21964. return m.OldCustomAgentBase(ctx)
  21965. case token.FieldCustomAgentKey:
  21966. return m.OldCustomAgentKey(ctx)
  21967. case token.FieldOpenaiBase:
  21968. return m.OldOpenaiBase(ctx)
  21969. case token.FieldOpenaiKey:
  21970. return m.OldOpenaiKey(ctx)
  21971. }
  21972. return nil, fmt.Errorf("unknown Token field %s", name)
  21973. }
  21974. // SetField sets the value of a field with the given name. It returns an error if
  21975. // the field is not defined in the schema, or if the type mismatched the field
  21976. // type.
  21977. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  21978. switch name {
  21979. case token.FieldCreatedAt:
  21980. v, ok := value.(time.Time)
  21981. if !ok {
  21982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21983. }
  21984. m.SetCreatedAt(v)
  21985. return nil
  21986. case token.FieldUpdatedAt:
  21987. v, ok := value.(time.Time)
  21988. if !ok {
  21989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21990. }
  21991. m.SetUpdatedAt(v)
  21992. return nil
  21993. case token.FieldDeletedAt:
  21994. v, ok := value.(time.Time)
  21995. if !ok {
  21996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21997. }
  21998. m.SetDeletedAt(v)
  21999. return nil
  22000. case token.FieldExpireAt:
  22001. v, ok := value.(time.Time)
  22002. if !ok {
  22003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22004. }
  22005. m.SetExpireAt(v)
  22006. return nil
  22007. case token.FieldToken:
  22008. v, ok := value.(string)
  22009. if !ok {
  22010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22011. }
  22012. m.SetToken(v)
  22013. return nil
  22014. case token.FieldMAC:
  22015. v, ok := value.(string)
  22016. if !ok {
  22017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22018. }
  22019. m.SetMAC(v)
  22020. return nil
  22021. case token.FieldOrganizationID:
  22022. v, ok := value.(uint64)
  22023. if !ok {
  22024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22025. }
  22026. m.SetOrganizationID(v)
  22027. return nil
  22028. case token.FieldAgentID:
  22029. v, ok := value.(uint64)
  22030. if !ok {
  22031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22032. }
  22033. m.SetAgentID(v)
  22034. return nil
  22035. case token.FieldCustomAgentBase:
  22036. v, ok := value.(string)
  22037. if !ok {
  22038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22039. }
  22040. m.SetCustomAgentBase(v)
  22041. return nil
  22042. case token.FieldCustomAgentKey:
  22043. v, ok := value.(string)
  22044. if !ok {
  22045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22046. }
  22047. m.SetCustomAgentKey(v)
  22048. return nil
  22049. case token.FieldOpenaiBase:
  22050. v, ok := value.(string)
  22051. if !ok {
  22052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22053. }
  22054. m.SetOpenaiBase(v)
  22055. return nil
  22056. case token.FieldOpenaiKey:
  22057. v, ok := value.(string)
  22058. if !ok {
  22059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22060. }
  22061. m.SetOpenaiKey(v)
  22062. return nil
  22063. }
  22064. return fmt.Errorf("unknown Token field %s", name)
  22065. }
  22066. // AddedFields returns all numeric fields that were incremented/decremented during
  22067. // this mutation.
  22068. func (m *TokenMutation) AddedFields() []string {
  22069. var fields []string
  22070. if m.addorganization_id != nil {
  22071. fields = append(fields, token.FieldOrganizationID)
  22072. }
  22073. return fields
  22074. }
  22075. // AddedField returns the numeric value that was incremented/decremented on a field
  22076. // with the given name. The second boolean return value indicates that this field
  22077. // was not set, or was not defined in the schema.
  22078. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  22079. switch name {
  22080. case token.FieldOrganizationID:
  22081. return m.AddedOrganizationID()
  22082. }
  22083. return nil, false
  22084. }
  22085. // AddField adds the value to the field with the given name. It returns an error if
  22086. // the field is not defined in the schema, or if the type mismatched the field
  22087. // type.
  22088. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  22089. switch name {
  22090. case token.FieldOrganizationID:
  22091. v, ok := value.(int64)
  22092. if !ok {
  22093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22094. }
  22095. m.AddOrganizationID(v)
  22096. return nil
  22097. }
  22098. return fmt.Errorf("unknown Token numeric field %s", name)
  22099. }
  22100. // ClearedFields returns all nullable fields that were cleared during this
  22101. // mutation.
  22102. func (m *TokenMutation) ClearedFields() []string {
  22103. var fields []string
  22104. if m.FieldCleared(token.FieldDeletedAt) {
  22105. fields = append(fields, token.FieldDeletedAt)
  22106. }
  22107. if m.FieldCleared(token.FieldExpireAt) {
  22108. fields = append(fields, token.FieldExpireAt)
  22109. }
  22110. if m.FieldCleared(token.FieldToken) {
  22111. fields = append(fields, token.FieldToken)
  22112. }
  22113. if m.FieldCleared(token.FieldMAC) {
  22114. fields = append(fields, token.FieldMAC)
  22115. }
  22116. if m.FieldCleared(token.FieldCustomAgentBase) {
  22117. fields = append(fields, token.FieldCustomAgentBase)
  22118. }
  22119. if m.FieldCleared(token.FieldCustomAgentKey) {
  22120. fields = append(fields, token.FieldCustomAgentKey)
  22121. }
  22122. if m.FieldCleared(token.FieldOpenaiBase) {
  22123. fields = append(fields, token.FieldOpenaiBase)
  22124. }
  22125. if m.FieldCleared(token.FieldOpenaiKey) {
  22126. fields = append(fields, token.FieldOpenaiKey)
  22127. }
  22128. return fields
  22129. }
  22130. // FieldCleared returns a boolean indicating if a field with the given name was
  22131. // cleared in this mutation.
  22132. func (m *TokenMutation) FieldCleared(name string) bool {
  22133. _, ok := m.clearedFields[name]
  22134. return ok
  22135. }
  22136. // ClearField clears the value of the field with the given name. It returns an
  22137. // error if the field is not defined in the schema.
  22138. func (m *TokenMutation) ClearField(name string) error {
  22139. switch name {
  22140. case token.FieldDeletedAt:
  22141. m.ClearDeletedAt()
  22142. return nil
  22143. case token.FieldExpireAt:
  22144. m.ClearExpireAt()
  22145. return nil
  22146. case token.FieldToken:
  22147. m.ClearToken()
  22148. return nil
  22149. case token.FieldMAC:
  22150. m.ClearMAC()
  22151. return nil
  22152. case token.FieldCustomAgentBase:
  22153. m.ClearCustomAgentBase()
  22154. return nil
  22155. case token.FieldCustomAgentKey:
  22156. m.ClearCustomAgentKey()
  22157. return nil
  22158. case token.FieldOpenaiBase:
  22159. m.ClearOpenaiBase()
  22160. return nil
  22161. case token.FieldOpenaiKey:
  22162. m.ClearOpenaiKey()
  22163. return nil
  22164. }
  22165. return fmt.Errorf("unknown Token nullable field %s", name)
  22166. }
  22167. // ResetField resets all changes in the mutation for the field with the given name.
  22168. // It returns an error if the field is not defined in the schema.
  22169. func (m *TokenMutation) ResetField(name string) error {
  22170. switch name {
  22171. case token.FieldCreatedAt:
  22172. m.ResetCreatedAt()
  22173. return nil
  22174. case token.FieldUpdatedAt:
  22175. m.ResetUpdatedAt()
  22176. return nil
  22177. case token.FieldDeletedAt:
  22178. m.ResetDeletedAt()
  22179. return nil
  22180. case token.FieldExpireAt:
  22181. m.ResetExpireAt()
  22182. return nil
  22183. case token.FieldToken:
  22184. m.ResetToken()
  22185. return nil
  22186. case token.FieldMAC:
  22187. m.ResetMAC()
  22188. return nil
  22189. case token.FieldOrganizationID:
  22190. m.ResetOrganizationID()
  22191. return nil
  22192. case token.FieldAgentID:
  22193. m.ResetAgentID()
  22194. return nil
  22195. case token.FieldCustomAgentBase:
  22196. m.ResetCustomAgentBase()
  22197. return nil
  22198. case token.FieldCustomAgentKey:
  22199. m.ResetCustomAgentKey()
  22200. return nil
  22201. case token.FieldOpenaiBase:
  22202. m.ResetOpenaiBase()
  22203. return nil
  22204. case token.FieldOpenaiKey:
  22205. m.ResetOpenaiKey()
  22206. return nil
  22207. }
  22208. return fmt.Errorf("unknown Token field %s", name)
  22209. }
  22210. // AddedEdges returns all edge names that were set/added in this mutation.
  22211. func (m *TokenMutation) AddedEdges() []string {
  22212. edges := make([]string, 0, 1)
  22213. if m.agent != nil {
  22214. edges = append(edges, token.EdgeAgent)
  22215. }
  22216. return edges
  22217. }
  22218. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22219. // name in this mutation.
  22220. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  22221. switch name {
  22222. case token.EdgeAgent:
  22223. if id := m.agent; id != nil {
  22224. return []ent.Value{*id}
  22225. }
  22226. }
  22227. return nil
  22228. }
  22229. // RemovedEdges returns all edge names that were removed in this mutation.
  22230. func (m *TokenMutation) RemovedEdges() []string {
  22231. edges := make([]string, 0, 1)
  22232. return edges
  22233. }
  22234. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22235. // the given name in this mutation.
  22236. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  22237. return nil
  22238. }
  22239. // ClearedEdges returns all edge names that were cleared in this mutation.
  22240. func (m *TokenMutation) ClearedEdges() []string {
  22241. edges := make([]string, 0, 1)
  22242. if m.clearedagent {
  22243. edges = append(edges, token.EdgeAgent)
  22244. }
  22245. return edges
  22246. }
  22247. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22248. // was cleared in this mutation.
  22249. func (m *TokenMutation) EdgeCleared(name string) bool {
  22250. switch name {
  22251. case token.EdgeAgent:
  22252. return m.clearedagent
  22253. }
  22254. return false
  22255. }
  22256. // ClearEdge clears the value of the edge with the given name. It returns an error
  22257. // if that edge is not defined in the schema.
  22258. func (m *TokenMutation) ClearEdge(name string) error {
  22259. switch name {
  22260. case token.EdgeAgent:
  22261. m.ClearAgent()
  22262. return nil
  22263. }
  22264. return fmt.Errorf("unknown Token unique edge %s", name)
  22265. }
  22266. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22267. // It returns an error if the edge is not defined in the schema.
  22268. func (m *TokenMutation) ResetEdge(name string) error {
  22269. switch name {
  22270. case token.EdgeAgent:
  22271. m.ResetAgent()
  22272. return nil
  22273. }
  22274. return fmt.Errorf("unknown Token edge %s", name)
  22275. }
  22276. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  22277. type TutorialMutation struct {
  22278. config
  22279. op Op
  22280. typ string
  22281. id *uint64
  22282. created_at *time.Time
  22283. updated_at *time.Time
  22284. deleted_at *time.Time
  22285. index *int
  22286. addindex *int
  22287. title *string
  22288. content *string
  22289. organization_id *uint64
  22290. addorganization_id *int64
  22291. clearedFields map[string]struct{}
  22292. employee *uint64
  22293. clearedemployee bool
  22294. done bool
  22295. oldValue func(context.Context) (*Tutorial, error)
  22296. predicates []predicate.Tutorial
  22297. }
  22298. var _ ent.Mutation = (*TutorialMutation)(nil)
  22299. // tutorialOption allows management of the mutation configuration using functional options.
  22300. type tutorialOption func(*TutorialMutation)
  22301. // newTutorialMutation creates new mutation for the Tutorial entity.
  22302. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  22303. m := &TutorialMutation{
  22304. config: c,
  22305. op: op,
  22306. typ: TypeTutorial,
  22307. clearedFields: make(map[string]struct{}),
  22308. }
  22309. for _, opt := range opts {
  22310. opt(m)
  22311. }
  22312. return m
  22313. }
  22314. // withTutorialID sets the ID field of the mutation.
  22315. func withTutorialID(id uint64) tutorialOption {
  22316. return func(m *TutorialMutation) {
  22317. var (
  22318. err error
  22319. once sync.Once
  22320. value *Tutorial
  22321. )
  22322. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  22323. once.Do(func() {
  22324. if m.done {
  22325. err = errors.New("querying old values post mutation is not allowed")
  22326. } else {
  22327. value, err = m.Client().Tutorial.Get(ctx, id)
  22328. }
  22329. })
  22330. return value, err
  22331. }
  22332. m.id = &id
  22333. }
  22334. }
  22335. // withTutorial sets the old Tutorial of the mutation.
  22336. func withTutorial(node *Tutorial) tutorialOption {
  22337. return func(m *TutorialMutation) {
  22338. m.oldValue = func(context.Context) (*Tutorial, error) {
  22339. return node, nil
  22340. }
  22341. m.id = &node.ID
  22342. }
  22343. }
  22344. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22345. // executed in a transaction (ent.Tx), a transactional client is returned.
  22346. func (m TutorialMutation) Client() *Client {
  22347. client := &Client{config: m.config}
  22348. client.init()
  22349. return client
  22350. }
  22351. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22352. // it returns an error otherwise.
  22353. func (m TutorialMutation) Tx() (*Tx, error) {
  22354. if _, ok := m.driver.(*txDriver); !ok {
  22355. return nil, errors.New("ent: mutation is not running in a transaction")
  22356. }
  22357. tx := &Tx{config: m.config}
  22358. tx.init()
  22359. return tx, nil
  22360. }
  22361. // SetID sets the value of the id field. Note that this
  22362. // operation is only accepted on creation of Tutorial entities.
  22363. func (m *TutorialMutation) SetID(id uint64) {
  22364. m.id = &id
  22365. }
  22366. // ID returns the ID value in the mutation. Note that the ID is only available
  22367. // if it was provided to the builder or after it was returned from the database.
  22368. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  22369. if m.id == nil {
  22370. return
  22371. }
  22372. return *m.id, true
  22373. }
  22374. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22375. // That means, if the mutation is applied within a transaction with an isolation level such
  22376. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22377. // or updated by the mutation.
  22378. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  22379. switch {
  22380. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22381. id, exists := m.ID()
  22382. if exists {
  22383. return []uint64{id}, nil
  22384. }
  22385. fallthrough
  22386. case m.op.Is(OpUpdate | OpDelete):
  22387. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  22388. default:
  22389. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22390. }
  22391. }
  22392. // SetCreatedAt sets the "created_at" field.
  22393. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  22394. m.created_at = &t
  22395. }
  22396. // CreatedAt returns the value of the "created_at" field in the mutation.
  22397. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  22398. v := m.created_at
  22399. if v == nil {
  22400. return
  22401. }
  22402. return *v, true
  22403. }
  22404. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  22405. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22407. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22408. if !m.op.Is(OpUpdateOne) {
  22409. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22410. }
  22411. if m.id == nil || m.oldValue == nil {
  22412. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22413. }
  22414. oldValue, err := m.oldValue(ctx)
  22415. if err != nil {
  22416. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22417. }
  22418. return oldValue.CreatedAt, nil
  22419. }
  22420. // ResetCreatedAt resets all changes to the "created_at" field.
  22421. func (m *TutorialMutation) ResetCreatedAt() {
  22422. m.created_at = nil
  22423. }
  22424. // SetUpdatedAt sets the "updated_at" field.
  22425. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  22426. m.updated_at = &t
  22427. }
  22428. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22429. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  22430. v := m.updated_at
  22431. if v == nil {
  22432. return
  22433. }
  22434. return *v, true
  22435. }
  22436. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  22437. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22439. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22440. if !m.op.Is(OpUpdateOne) {
  22441. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22442. }
  22443. if m.id == nil || m.oldValue == nil {
  22444. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22445. }
  22446. oldValue, err := m.oldValue(ctx)
  22447. if err != nil {
  22448. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22449. }
  22450. return oldValue.UpdatedAt, nil
  22451. }
  22452. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22453. func (m *TutorialMutation) ResetUpdatedAt() {
  22454. m.updated_at = nil
  22455. }
  22456. // SetDeletedAt sets the "deleted_at" field.
  22457. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  22458. m.deleted_at = &t
  22459. }
  22460. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22461. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  22462. v := m.deleted_at
  22463. if v == nil {
  22464. return
  22465. }
  22466. return *v, true
  22467. }
  22468. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  22469. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22471. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22472. if !m.op.Is(OpUpdateOne) {
  22473. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22474. }
  22475. if m.id == nil || m.oldValue == nil {
  22476. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22477. }
  22478. oldValue, err := m.oldValue(ctx)
  22479. if err != nil {
  22480. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22481. }
  22482. return oldValue.DeletedAt, nil
  22483. }
  22484. // ClearDeletedAt clears the value of the "deleted_at" field.
  22485. func (m *TutorialMutation) ClearDeletedAt() {
  22486. m.deleted_at = nil
  22487. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  22488. }
  22489. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22490. func (m *TutorialMutation) DeletedAtCleared() bool {
  22491. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  22492. return ok
  22493. }
  22494. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22495. func (m *TutorialMutation) ResetDeletedAt() {
  22496. m.deleted_at = nil
  22497. delete(m.clearedFields, tutorial.FieldDeletedAt)
  22498. }
  22499. // SetEmployeeID sets the "employee_id" field.
  22500. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  22501. m.employee = &u
  22502. }
  22503. // EmployeeID returns the value of the "employee_id" field in the mutation.
  22504. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  22505. v := m.employee
  22506. if v == nil {
  22507. return
  22508. }
  22509. return *v, true
  22510. }
  22511. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  22512. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22514. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  22515. if !m.op.Is(OpUpdateOne) {
  22516. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  22517. }
  22518. if m.id == nil || m.oldValue == nil {
  22519. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  22520. }
  22521. oldValue, err := m.oldValue(ctx)
  22522. if err != nil {
  22523. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  22524. }
  22525. return oldValue.EmployeeID, nil
  22526. }
  22527. // ResetEmployeeID resets all changes to the "employee_id" field.
  22528. func (m *TutorialMutation) ResetEmployeeID() {
  22529. m.employee = nil
  22530. }
  22531. // SetIndex sets the "index" field.
  22532. func (m *TutorialMutation) SetIndex(i int) {
  22533. m.index = &i
  22534. m.addindex = nil
  22535. }
  22536. // Index returns the value of the "index" field in the mutation.
  22537. func (m *TutorialMutation) Index() (r int, exists bool) {
  22538. v := m.index
  22539. if v == nil {
  22540. return
  22541. }
  22542. return *v, true
  22543. }
  22544. // OldIndex returns the old "index" field's value of the Tutorial entity.
  22545. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22547. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  22548. if !m.op.Is(OpUpdateOne) {
  22549. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  22550. }
  22551. if m.id == nil || m.oldValue == nil {
  22552. return v, errors.New("OldIndex requires an ID field in the mutation")
  22553. }
  22554. oldValue, err := m.oldValue(ctx)
  22555. if err != nil {
  22556. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  22557. }
  22558. return oldValue.Index, nil
  22559. }
  22560. // AddIndex adds i to the "index" field.
  22561. func (m *TutorialMutation) AddIndex(i int) {
  22562. if m.addindex != nil {
  22563. *m.addindex += i
  22564. } else {
  22565. m.addindex = &i
  22566. }
  22567. }
  22568. // AddedIndex returns the value that was added to the "index" field in this mutation.
  22569. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  22570. v := m.addindex
  22571. if v == nil {
  22572. return
  22573. }
  22574. return *v, true
  22575. }
  22576. // ResetIndex resets all changes to the "index" field.
  22577. func (m *TutorialMutation) ResetIndex() {
  22578. m.index = nil
  22579. m.addindex = nil
  22580. }
  22581. // SetTitle sets the "title" field.
  22582. func (m *TutorialMutation) SetTitle(s string) {
  22583. m.title = &s
  22584. }
  22585. // Title returns the value of the "title" field in the mutation.
  22586. func (m *TutorialMutation) Title() (r string, exists bool) {
  22587. v := m.title
  22588. if v == nil {
  22589. return
  22590. }
  22591. return *v, true
  22592. }
  22593. // OldTitle returns the old "title" field's value of the Tutorial entity.
  22594. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22596. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  22597. if !m.op.Is(OpUpdateOne) {
  22598. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  22599. }
  22600. if m.id == nil || m.oldValue == nil {
  22601. return v, errors.New("OldTitle requires an ID field in the mutation")
  22602. }
  22603. oldValue, err := m.oldValue(ctx)
  22604. if err != nil {
  22605. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  22606. }
  22607. return oldValue.Title, nil
  22608. }
  22609. // ResetTitle resets all changes to the "title" field.
  22610. func (m *TutorialMutation) ResetTitle() {
  22611. m.title = nil
  22612. }
  22613. // SetContent sets the "content" field.
  22614. func (m *TutorialMutation) SetContent(s string) {
  22615. m.content = &s
  22616. }
  22617. // Content returns the value of the "content" field in the mutation.
  22618. func (m *TutorialMutation) Content() (r string, exists bool) {
  22619. v := m.content
  22620. if v == nil {
  22621. return
  22622. }
  22623. return *v, true
  22624. }
  22625. // OldContent returns the old "content" field's value of the Tutorial entity.
  22626. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22628. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  22629. if !m.op.Is(OpUpdateOne) {
  22630. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  22631. }
  22632. if m.id == nil || m.oldValue == nil {
  22633. return v, errors.New("OldContent requires an ID field in the mutation")
  22634. }
  22635. oldValue, err := m.oldValue(ctx)
  22636. if err != nil {
  22637. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  22638. }
  22639. return oldValue.Content, nil
  22640. }
  22641. // ResetContent resets all changes to the "content" field.
  22642. func (m *TutorialMutation) ResetContent() {
  22643. m.content = nil
  22644. }
  22645. // SetOrganizationID sets the "organization_id" field.
  22646. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  22647. m.organization_id = &u
  22648. m.addorganization_id = nil
  22649. }
  22650. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22651. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  22652. v := m.organization_id
  22653. if v == nil {
  22654. return
  22655. }
  22656. return *v, true
  22657. }
  22658. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  22659. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22661. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22662. if !m.op.Is(OpUpdateOne) {
  22663. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22664. }
  22665. if m.id == nil || m.oldValue == nil {
  22666. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22667. }
  22668. oldValue, err := m.oldValue(ctx)
  22669. if err != nil {
  22670. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22671. }
  22672. return oldValue.OrganizationID, nil
  22673. }
  22674. // AddOrganizationID adds u to the "organization_id" field.
  22675. func (m *TutorialMutation) AddOrganizationID(u int64) {
  22676. if m.addorganization_id != nil {
  22677. *m.addorganization_id += u
  22678. } else {
  22679. m.addorganization_id = &u
  22680. }
  22681. }
  22682. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22683. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  22684. v := m.addorganization_id
  22685. if v == nil {
  22686. return
  22687. }
  22688. return *v, true
  22689. }
  22690. // ResetOrganizationID resets all changes to the "organization_id" field.
  22691. func (m *TutorialMutation) ResetOrganizationID() {
  22692. m.organization_id = nil
  22693. m.addorganization_id = nil
  22694. }
  22695. // ClearEmployee clears the "employee" edge to the Employee entity.
  22696. func (m *TutorialMutation) ClearEmployee() {
  22697. m.clearedemployee = true
  22698. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  22699. }
  22700. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  22701. func (m *TutorialMutation) EmployeeCleared() bool {
  22702. return m.clearedemployee
  22703. }
  22704. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  22705. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22706. // EmployeeID instead. It exists only for internal usage by the builders.
  22707. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  22708. if id := m.employee; id != nil {
  22709. ids = append(ids, *id)
  22710. }
  22711. return
  22712. }
  22713. // ResetEmployee resets all changes to the "employee" edge.
  22714. func (m *TutorialMutation) ResetEmployee() {
  22715. m.employee = nil
  22716. m.clearedemployee = false
  22717. }
  22718. // Where appends a list predicates to the TutorialMutation builder.
  22719. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  22720. m.predicates = append(m.predicates, ps...)
  22721. }
  22722. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  22723. // users can use type-assertion to append predicates that do not depend on any generated package.
  22724. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  22725. p := make([]predicate.Tutorial, len(ps))
  22726. for i := range ps {
  22727. p[i] = ps[i]
  22728. }
  22729. m.Where(p...)
  22730. }
  22731. // Op returns the operation name.
  22732. func (m *TutorialMutation) Op() Op {
  22733. return m.op
  22734. }
  22735. // SetOp allows setting the mutation operation.
  22736. func (m *TutorialMutation) SetOp(op Op) {
  22737. m.op = op
  22738. }
  22739. // Type returns the node type of this mutation (Tutorial).
  22740. func (m *TutorialMutation) Type() string {
  22741. return m.typ
  22742. }
  22743. // Fields returns all fields that were changed during this mutation. Note that in
  22744. // order to get all numeric fields that were incremented/decremented, call
  22745. // AddedFields().
  22746. func (m *TutorialMutation) Fields() []string {
  22747. fields := make([]string, 0, 8)
  22748. if m.created_at != nil {
  22749. fields = append(fields, tutorial.FieldCreatedAt)
  22750. }
  22751. if m.updated_at != nil {
  22752. fields = append(fields, tutorial.FieldUpdatedAt)
  22753. }
  22754. if m.deleted_at != nil {
  22755. fields = append(fields, tutorial.FieldDeletedAt)
  22756. }
  22757. if m.employee != nil {
  22758. fields = append(fields, tutorial.FieldEmployeeID)
  22759. }
  22760. if m.index != nil {
  22761. fields = append(fields, tutorial.FieldIndex)
  22762. }
  22763. if m.title != nil {
  22764. fields = append(fields, tutorial.FieldTitle)
  22765. }
  22766. if m.content != nil {
  22767. fields = append(fields, tutorial.FieldContent)
  22768. }
  22769. if m.organization_id != nil {
  22770. fields = append(fields, tutorial.FieldOrganizationID)
  22771. }
  22772. return fields
  22773. }
  22774. // Field returns the value of a field with the given name. The second boolean
  22775. // return value indicates that this field was not set, or was not defined in the
  22776. // schema.
  22777. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  22778. switch name {
  22779. case tutorial.FieldCreatedAt:
  22780. return m.CreatedAt()
  22781. case tutorial.FieldUpdatedAt:
  22782. return m.UpdatedAt()
  22783. case tutorial.FieldDeletedAt:
  22784. return m.DeletedAt()
  22785. case tutorial.FieldEmployeeID:
  22786. return m.EmployeeID()
  22787. case tutorial.FieldIndex:
  22788. return m.Index()
  22789. case tutorial.FieldTitle:
  22790. return m.Title()
  22791. case tutorial.FieldContent:
  22792. return m.Content()
  22793. case tutorial.FieldOrganizationID:
  22794. return m.OrganizationID()
  22795. }
  22796. return nil, false
  22797. }
  22798. // OldField returns the old value of the field from the database. An error is
  22799. // returned if the mutation operation is not UpdateOne, or the query to the
  22800. // database failed.
  22801. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22802. switch name {
  22803. case tutorial.FieldCreatedAt:
  22804. return m.OldCreatedAt(ctx)
  22805. case tutorial.FieldUpdatedAt:
  22806. return m.OldUpdatedAt(ctx)
  22807. case tutorial.FieldDeletedAt:
  22808. return m.OldDeletedAt(ctx)
  22809. case tutorial.FieldEmployeeID:
  22810. return m.OldEmployeeID(ctx)
  22811. case tutorial.FieldIndex:
  22812. return m.OldIndex(ctx)
  22813. case tutorial.FieldTitle:
  22814. return m.OldTitle(ctx)
  22815. case tutorial.FieldContent:
  22816. return m.OldContent(ctx)
  22817. case tutorial.FieldOrganizationID:
  22818. return m.OldOrganizationID(ctx)
  22819. }
  22820. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  22821. }
  22822. // SetField sets the value of a field with the given name. It returns an error if
  22823. // the field is not defined in the schema, or if the type mismatched the field
  22824. // type.
  22825. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  22826. switch name {
  22827. case tutorial.FieldCreatedAt:
  22828. v, ok := value.(time.Time)
  22829. if !ok {
  22830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22831. }
  22832. m.SetCreatedAt(v)
  22833. return nil
  22834. case tutorial.FieldUpdatedAt:
  22835. v, ok := value.(time.Time)
  22836. if !ok {
  22837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22838. }
  22839. m.SetUpdatedAt(v)
  22840. return nil
  22841. case tutorial.FieldDeletedAt:
  22842. v, ok := value.(time.Time)
  22843. if !ok {
  22844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22845. }
  22846. m.SetDeletedAt(v)
  22847. return nil
  22848. case tutorial.FieldEmployeeID:
  22849. v, ok := value.(uint64)
  22850. if !ok {
  22851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22852. }
  22853. m.SetEmployeeID(v)
  22854. return nil
  22855. case tutorial.FieldIndex:
  22856. v, ok := value.(int)
  22857. if !ok {
  22858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22859. }
  22860. m.SetIndex(v)
  22861. return nil
  22862. case tutorial.FieldTitle:
  22863. v, ok := value.(string)
  22864. if !ok {
  22865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22866. }
  22867. m.SetTitle(v)
  22868. return nil
  22869. case tutorial.FieldContent:
  22870. v, ok := value.(string)
  22871. if !ok {
  22872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22873. }
  22874. m.SetContent(v)
  22875. return nil
  22876. case tutorial.FieldOrganizationID:
  22877. v, ok := value.(uint64)
  22878. if !ok {
  22879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22880. }
  22881. m.SetOrganizationID(v)
  22882. return nil
  22883. }
  22884. return fmt.Errorf("unknown Tutorial field %s", name)
  22885. }
  22886. // AddedFields returns all numeric fields that were incremented/decremented during
  22887. // this mutation.
  22888. func (m *TutorialMutation) AddedFields() []string {
  22889. var fields []string
  22890. if m.addindex != nil {
  22891. fields = append(fields, tutorial.FieldIndex)
  22892. }
  22893. if m.addorganization_id != nil {
  22894. fields = append(fields, tutorial.FieldOrganizationID)
  22895. }
  22896. return fields
  22897. }
  22898. // AddedField returns the numeric value that was incremented/decremented on a field
  22899. // with the given name. The second boolean return value indicates that this field
  22900. // was not set, or was not defined in the schema.
  22901. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  22902. switch name {
  22903. case tutorial.FieldIndex:
  22904. return m.AddedIndex()
  22905. case tutorial.FieldOrganizationID:
  22906. return m.AddedOrganizationID()
  22907. }
  22908. return nil, false
  22909. }
  22910. // AddField adds the value to the field with the given name. It returns an error if
  22911. // the field is not defined in the schema, or if the type mismatched the field
  22912. // type.
  22913. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  22914. switch name {
  22915. case tutorial.FieldIndex:
  22916. v, ok := value.(int)
  22917. if !ok {
  22918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22919. }
  22920. m.AddIndex(v)
  22921. return nil
  22922. case tutorial.FieldOrganizationID:
  22923. v, ok := value.(int64)
  22924. if !ok {
  22925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22926. }
  22927. m.AddOrganizationID(v)
  22928. return nil
  22929. }
  22930. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  22931. }
  22932. // ClearedFields returns all nullable fields that were cleared during this
  22933. // mutation.
  22934. func (m *TutorialMutation) ClearedFields() []string {
  22935. var fields []string
  22936. if m.FieldCleared(tutorial.FieldDeletedAt) {
  22937. fields = append(fields, tutorial.FieldDeletedAt)
  22938. }
  22939. return fields
  22940. }
  22941. // FieldCleared returns a boolean indicating if a field with the given name was
  22942. // cleared in this mutation.
  22943. func (m *TutorialMutation) FieldCleared(name string) bool {
  22944. _, ok := m.clearedFields[name]
  22945. return ok
  22946. }
  22947. // ClearField clears the value of the field with the given name. It returns an
  22948. // error if the field is not defined in the schema.
  22949. func (m *TutorialMutation) ClearField(name string) error {
  22950. switch name {
  22951. case tutorial.FieldDeletedAt:
  22952. m.ClearDeletedAt()
  22953. return nil
  22954. }
  22955. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  22956. }
  22957. // ResetField resets all changes in the mutation for the field with the given name.
  22958. // It returns an error if the field is not defined in the schema.
  22959. func (m *TutorialMutation) ResetField(name string) error {
  22960. switch name {
  22961. case tutorial.FieldCreatedAt:
  22962. m.ResetCreatedAt()
  22963. return nil
  22964. case tutorial.FieldUpdatedAt:
  22965. m.ResetUpdatedAt()
  22966. return nil
  22967. case tutorial.FieldDeletedAt:
  22968. m.ResetDeletedAt()
  22969. return nil
  22970. case tutorial.FieldEmployeeID:
  22971. m.ResetEmployeeID()
  22972. return nil
  22973. case tutorial.FieldIndex:
  22974. m.ResetIndex()
  22975. return nil
  22976. case tutorial.FieldTitle:
  22977. m.ResetTitle()
  22978. return nil
  22979. case tutorial.FieldContent:
  22980. m.ResetContent()
  22981. return nil
  22982. case tutorial.FieldOrganizationID:
  22983. m.ResetOrganizationID()
  22984. return nil
  22985. }
  22986. return fmt.Errorf("unknown Tutorial field %s", name)
  22987. }
  22988. // AddedEdges returns all edge names that were set/added in this mutation.
  22989. func (m *TutorialMutation) AddedEdges() []string {
  22990. edges := make([]string, 0, 1)
  22991. if m.employee != nil {
  22992. edges = append(edges, tutorial.EdgeEmployee)
  22993. }
  22994. return edges
  22995. }
  22996. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22997. // name in this mutation.
  22998. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  22999. switch name {
  23000. case tutorial.EdgeEmployee:
  23001. if id := m.employee; id != nil {
  23002. return []ent.Value{*id}
  23003. }
  23004. }
  23005. return nil
  23006. }
  23007. // RemovedEdges returns all edge names that were removed in this mutation.
  23008. func (m *TutorialMutation) RemovedEdges() []string {
  23009. edges := make([]string, 0, 1)
  23010. return edges
  23011. }
  23012. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23013. // the given name in this mutation.
  23014. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  23015. return nil
  23016. }
  23017. // ClearedEdges returns all edge names that were cleared in this mutation.
  23018. func (m *TutorialMutation) ClearedEdges() []string {
  23019. edges := make([]string, 0, 1)
  23020. if m.clearedemployee {
  23021. edges = append(edges, tutorial.EdgeEmployee)
  23022. }
  23023. return edges
  23024. }
  23025. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23026. // was cleared in this mutation.
  23027. func (m *TutorialMutation) EdgeCleared(name string) bool {
  23028. switch name {
  23029. case tutorial.EdgeEmployee:
  23030. return m.clearedemployee
  23031. }
  23032. return false
  23033. }
  23034. // ClearEdge clears the value of the edge with the given name. It returns an error
  23035. // if that edge is not defined in the schema.
  23036. func (m *TutorialMutation) ClearEdge(name string) error {
  23037. switch name {
  23038. case tutorial.EdgeEmployee:
  23039. m.ClearEmployee()
  23040. return nil
  23041. }
  23042. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  23043. }
  23044. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23045. // It returns an error if the edge is not defined in the schema.
  23046. func (m *TutorialMutation) ResetEdge(name string) error {
  23047. switch name {
  23048. case tutorial.EdgeEmployee:
  23049. m.ResetEmployee()
  23050. return nil
  23051. }
  23052. return fmt.Errorf("unknown Tutorial edge %s", name)
  23053. }
  23054. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  23055. type UsageDetailMutation struct {
  23056. config
  23057. op Op
  23058. typ string
  23059. id *uint64
  23060. created_at *time.Time
  23061. updated_at *time.Time
  23062. status *uint8
  23063. addstatus *int8
  23064. _type *int
  23065. add_type *int
  23066. bot_id *string
  23067. receiver_id *string
  23068. app *int
  23069. addapp *int
  23070. session_id *uint64
  23071. addsession_id *int64
  23072. request *string
  23073. response *string
  23074. total_tokens *uint64
  23075. addtotal_tokens *int64
  23076. prompt_tokens *uint64
  23077. addprompt_tokens *int64
  23078. completion_tokens *uint64
  23079. addcompletion_tokens *int64
  23080. organization_id *uint64
  23081. addorganization_id *int64
  23082. clearedFields map[string]struct{}
  23083. done bool
  23084. oldValue func(context.Context) (*UsageDetail, error)
  23085. predicates []predicate.UsageDetail
  23086. }
  23087. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  23088. // usagedetailOption allows management of the mutation configuration using functional options.
  23089. type usagedetailOption func(*UsageDetailMutation)
  23090. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  23091. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  23092. m := &UsageDetailMutation{
  23093. config: c,
  23094. op: op,
  23095. typ: TypeUsageDetail,
  23096. clearedFields: make(map[string]struct{}),
  23097. }
  23098. for _, opt := range opts {
  23099. opt(m)
  23100. }
  23101. return m
  23102. }
  23103. // withUsageDetailID sets the ID field of the mutation.
  23104. func withUsageDetailID(id uint64) usagedetailOption {
  23105. return func(m *UsageDetailMutation) {
  23106. var (
  23107. err error
  23108. once sync.Once
  23109. value *UsageDetail
  23110. )
  23111. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  23112. once.Do(func() {
  23113. if m.done {
  23114. err = errors.New("querying old values post mutation is not allowed")
  23115. } else {
  23116. value, err = m.Client().UsageDetail.Get(ctx, id)
  23117. }
  23118. })
  23119. return value, err
  23120. }
  23121. m.id = &id
  23122. }
  23123. }
  23124. // withUsageDetail sets the old UsageDetail of the mutation.
  23125. func withUsageDetail(node *UsageDetail) usagedetailOption {
  23126. return func(m *UsageDetailMutation) {
  23127. m.oldValue = func(context.Context) (*UsageDetail, error) {
  23128. return node, nil
  23129. }
  23130. m.id = &node.ID
  23131. }
  23132. }
  23133. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23134. // executed in a transaction (ent.Tx), a transactional client is returned.
  23135. func (m UsageDetailMutation) Client() *Client {
  23136. client := &Client{config: m.config}
  23137. client.init()
  23138. return client
  23139. }
  23140. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23141. // it returns an error otherwise.
  23142. func (m UsageDetailMutation) Tx() (*Tx, error) {
  23143. if _, ok := m.driver.(*txDriver); !ok {
  23144. return nil, errors.New("ent: mutation is not running in a transaction")
  23145. }
  23146. tx := &Tx{config: m.config}
  23147. tx.init()
  23148. return tx, nil
  23149. }
  23150. // SetID sets the value of the id field. Note that this
  23151. // operation is only accepted on creation of UsageDetail entities.
  23152. func (m *UsageDetailMutation) SetID(id uint64) {
  23153. m.id = &id
  23154. }
  23155. // ID returns the ID value in the mutation. Note that the ID is only available
  23156. // if it was provided to the builder or after it was returned from the database.
  23157. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  23158. if m.id == nil {
  23159. return
  23160. }
  23161. return *m.id, true
  23162. }
  23163. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23164. // That means, if the mutation is applied within a transaction with an isolation level such
  23165. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23166. // or updated by the mutation.
  23167. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  23168. switch {
  23169. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23170. id, exists := m.ID()
  23171. if exists {
  23172. return []uint64{id}, nil
  23173. }
  23174. fallthrough
  23175. case m.op.Is(OpUpdate | OpDelete):
  23176. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  23177. default:
  23178. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23179. }
  23180. }
  23181. // SetCreatedAt sets the "created_at" field.
  23182. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  23183. m.created_at = &t
  23184. }
  23185. // CreatedAt returns the value of the "created_at" field in the mutation.
  23186. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  23187. v := m.created_at
  23188. if v == nil {
  23189. return
  23190. }
  23191. return *v, true
  23192. }
  23193. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  23194. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23196. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23197. if !m.op.Is(OpUpdateOne) {
  23198. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23199. }
  23200. if m.id == nil || m.oldValue == nil {
  23201. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23202. }
  23203. oldValue, err := m.oldValue(ctx)
  23204. if err != nil {
  23205. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23206. }
  23207. return oldValue.CreatedAt, nil
  23208. }
  23209. // ResetCreatedAt resets all changes to the "created_at" field.
  23210. func (m *UsageDetailMutation) ResetCreatedAt() {
  23211. m.created_at = nil
  23212. }
  23213. // SetUpdatedAt sets the "updated_at" field.
  23214. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  23215. m.updated_at = &t
  23216. }
  23217. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23218. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  23219. v := m.updated_at
  23220. if v == nil {
  23221. return
  23222. }
  23223. return *v, true
  23224. }
  23225. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  23226. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23228. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23229. if !m.op.Is(OpUpdateOne) {
  23230. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23231. }
  23232. if m.id == nil || m.oldValue == nil {
  23233. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23234. }
  23235. oldValue, err := m.oldValue(ctx)
  23236. if err != nil {
  23237. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23238. }
  23239. return oldValue.UpdatedAt, nil
  23240. }
  23241. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23242. func (m *UsageDetailMutation) ResetUpdatedAt() {
  23243. m.updated_at = nil
  23244. }
  23245. // SetStatus sets the "status" field.
  23246. func (m *UsageDetailMutation) SetStatus(u uint8) {
  23247. m.status = &u
  23248. m.addstatus = nil
  23249. }
  23250. // Status returns the value of the "status" field in the mutation.
  23251. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  23252. v := m.status
  23253. if v == nil {
  23254. return
  23255. }
  23256. return *v, true
  23257. }
  23258. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  23259. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23261. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23262. if !m.op.Is(OpUpdateOne) {
  23263. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23264. }
  23265. if m.id == nil || m.oldValue == nil {
  23266. return v, errors.New("OldStatus requires an ID field in the mutation")
  23267. }
  23268. oldValue, err := m.oldValue(ctx)
  23269. if err != nil {
  23270. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23271. }
  23272. return oldValue.Status, nil
  23273. }
  23274. // AddStatus adds u to the "status" field.
  23275. func (m *UsageDetailMutation) AddStatus(u int8) {
  23276. if m.addstatus != nil {
  23277. *m.addstatus += u
  23278. } else {
  23279. m.addstatus = &u
  23280. }
  23281. }
  23282. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23283. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  23284. v := m.addstatus
  23285. if v == nil {
  23286. return
  23287. }
  23288. return *v, true
  23289. }
  23290. // ClearStatus clears the value of the "status" field.
  23291. func (m *UsageDetailMutation) ClearStatus() {
  23292. m.status = nil
  23293. m.addstatus = nil
  23294. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  23295. }
  23296. // StatusCleared returns if the "status" field was cleared in this mutation.
  23297. func (m *UsageDetailMutation) StatusCleared() bool {
  23298. _, ok := m.clearedFields[usagedetail.FieldStatus]
  23299. return ok
  23300. }
  23301. // ResetStatus resets all changes to the "status" field.
  23302. func (m *UsageDetailMutation) ResetStatus() {
  23303. m.status = nil
  23304. m.addstatus = nil
  23305. delete(m.clearedFields, usagedetail.FieldStatus)
  23306. }
  23307. // SetType sets the "type" field.
  23308. func (m *UsageDetailMutation) SetType(i int) {
  23309. m._type = &i
  23310. m.add_type = nil
  23311. }
  23312. // GetType returns the value of the "type" field in the mutation.
  23313. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  23314. v := m._type
  23315. if v == nil {
  23316. return
  23317. }
  23318. return *v, true
  23319. }
  23320. // OldType returns the old "type" field's value of the UsageDetail entity.
  23321. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23323. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  23324. if !m.op.Is(OpUpdateOne) {
  23325. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23326. }
  23327. if m.id == nil || m.oldValue == nil {
  23328. return v, errors.New("OldType requires an ID field in the mutation")
  23329. }
  23330. oldValue, err := m.oldValue(ctx)
  23331. if err != nil {
  23332. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23333. }
  23334. return oldValue.Type, nil
  23335. }
  23336. // AddType adds i to the "type" field.
  23337. func (m *UsageDetailMutation) AddType(i int) {
  23338. if m.add_type != nil {
  23339. *m.add_type += i
  23340. } else {
  23341. m.add_type = &i
  23342. }
  23343. }
  23344. // AddedType returns the value that was added to the "type" field in this mutation.
  23345. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  23346. v := m.add_type
  23347. if v == nil {
  23348. return
  23349. }
  23350. return *v, true
  23351. }
  23352. // ClearType clears the value of the "type" field.
  23353. func (m *UsageDetailMutation) ClearType() {
  23354. m._type = nil
  23355. m.add_type = nil
  23356. m.clearedFields[usagedetail.FieldType] = struct{}{}
  23357. }
  23358. // TypeCleared returns if the "type" field was cleared in this mutation.
  23359. func (m *UsageDetailMutation) TypeCleared() bool {
  23360. _, ok := m.clearedFields[usagedetail.FieldType]
  23361. return ok
  23362. }
  23363. // ResetType resets all changes to the "type" field.
  23364. func (m *UsageDetailMutation) ResetType() {
  23365. m._type = nil
  23366. m.add_type = nil
  23367. delete(m.clearedFields, usagedetail.FieldType)
  23368. }
  23369. // SetBotID sets the "bot_id" field.
  23370. func (m *UsageDetailMutation) SetBotID(s string) {
  23371. m.bot_id = &s
  23372. }
  23373. // BotID returns the value of the "bot_id" field in the mutation.
  23374. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  23375. v := m.bot_id
  23376. if v == nil {
  23377. return
  23378. }
  23379. return *v, true
  23380. }
  23381. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  23382. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23384. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  23385. if !m.op.Is(OpUpdateOne) {
  23386. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  23387. }
  23388. if m.id == nil || m.oldValue == nil {
  23389. return v, errors.New("OldBotID requires an ID field in the mutation")
  23390. }
  23391. oldValue, err := m.oldValue(ctx)
  23392. if err != nil {
  23393. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  23394. }
  23395. return oldValue.BotID, nil
  23396. }
  23397. // ResetBotID resets all changes to the "bot_id" field.
  23398. func (m *UsageDetailMutation) ResetBotID() {
  23399. m.bot_id = nil
  23400. }
  23401. // SetReceiverID sets the "receiver_id" field.
  23402. func (m *UsageDetailMutation) SetReceiverID(s string) {
  23403. m.receiver_id = &s
  23404. }
  23405. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  23406. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  23407. v := m.receiver_id
  23408. if v == nil {
  23409. return
  23410. }
  23411. return *v, true
  23412. }
  23413. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  23414. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23416. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  23417. if !m.op.Is(OpUpdateOne) {
  23418. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  23419. }
  23420. if m.id == nil || m.oldValue == nil {
  23421. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  23422. }
  23423. oldValue, err := m.oldValue(ctx)
  23424. if err != nil {
  23425. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  23426. }
  23427. return oldValue.ReceiverID, nil
  23428. }
  23429. // ResetReceiverID resets all changes to the "receiver_id" field.
  23430. func (m *UsageDetailMutation) ResetReceiverID() {
  23431. m.receiver_id = nil
  23432. }
  23433. // SetApp sets the "app" field.
  23434. func (m *UsageDetailMutation) SetApp(i int) {
  23435. m.app = &i
  23436. m.addapp = nil
  23437. }
  23438. // App returns the value of the "app" field in the mutation.
  23439. func (m *UsageDetailMutation) App() (r int, exists bool) {
  23440. v := m.app
  23441. if v == nil {
  23442. return
  23443. }
  23444. return *v, true
  23445. }
  23446. // OldApp returns the old "app" field's value of the UsageDetail entity.
  23447. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23449. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  23450. if !m.op.Is(OpUpdateOne) {
  23451. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  23452. }
  23453. if m.id == nil || m.oldValue == nil {
  23454. return v, errors.New("OldApp requires an ID field in the mutation")
  23455. }
  23456. oldValue, err := m.oldValue(ctx)
  23457. if err != nil {
  23458. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  23459. }
  23460. return oldValue.App, nil
  23461. }
  23462. // AddApp adds i to the "app" field.
  23463. func (m *UsageDetailMutation) AddApp(i int) {
  23464. if m.addapp != nil {
  23465. *m.addapp += i
  23466. } else {
  23467. m.addapp = &i
  23468. }
  23469. }
  23470. // AddedApp returns the value that was added to the "app" field in this mutation.
  23471. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  23472. v := m.addapp
  23473. if v == nil {
  23474. return
  23475. }
  23476. return *v, true
  23477. }
  23478. // ClearApp clears the value of the "app" field.
  23479. func (m *UsageDetailMutation) ClearApp() {
  23480. m.app = nil
  23481. m.addapp = nil
  23482. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  23483. }
  23484. // AppCleared returns if the "app" field was cleared in this mutation.
  23485. func (m *UsageDetailMutation) AppCleared() bool {
  23486. _, ok := m.clearedFields[usagedetail.FieldApp]
  23487. return ok
  23488. }
  23489. // ResetApp resets all changes to the "app" field.
  23490. func (m *UsageDetailMutation) ResetApp() {
  23491. m.app = nil
  23492. m.addapp = nil
  23493. delete(m.clearedFields, usagedetail.FieldApp)
  23494. }
  23495. // SetSessionID sets the "session_id" field.
  23496. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  23497. m.session_id = &u
  23498. m.addsession_id = nil
  23499. }
  23500. // SessionID returns the value of the "session_id" field in the mutation.
  23501. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  23502. v := m.session_id
  23503. if v == nil {
  23504. return
  23505. }
  23506. return *v, true
  23507. }
  23508. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  23509. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23511. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  23512. if !m.op.Is(OpUpdateOne) {
  23513. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  23514. }
  23515. if m.id == nil || m.oldValue == nil {
  23516. return v, errors.New("OldSessionID requires an ID field in the mutation")
  23517. }
  23518. oldValue, err := m.oldValue(ctx)
  23519. if err != nil {
  23520. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  23521. }
  23522. return oldValue.SessionID, nil
  23523. }
  23524. // AddSessionID adds u to the "session_id" field.
  23525. func (m *UsageDetailMutation) AddSessionID(u int64) {
  23526. if m.addsession_id != nil {
  23527. *m.addsession_id += u
  23528. } else {
  23529. m.addsession_id = &u
  23530. }
  23531. }
  23532. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  23533. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  23534. v := m.addsession_id
  23535. if v == nil {
  23536. return
  23537. }
  23538. return *v, true
  23539. }
  23540. // ClearSessionID clears the value of the "session_id" field.
  23541. func (m *UsageDetailMutation) ClearSessionID() {
  23542. m.session_id = nil
  23543. m.addsession_id = nil
  23544. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  23545. }
  23546. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  23547. func (m *UsageDetailMutation) SessionIDCleared() bool {
  23548. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  23549. return ok
  23550. }
  23551. // ResetSessionID resets all changes to the "session_id" field.
  23552. func (m *UsageDetailMutation) ResetSessionID() {
  23553. m.session_id = nil
  23554. m.addsession_id = nil
  23555. delete(m.clearedFields, usagedetail.FieldSessionID)
  23556. }
  23557. // SetRequest sets the "request" field.
  23558. func (m *UsageDetailMutation) SetRequest(s string) {
  23559. m.request = &s
  23560. }
  23561. // Request returns the value of the "request" field in the mutation.
  23562. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  23563. v := m.request
  23564. if v == nil {
  23565. return
  23566. }
  23567. return *v, true
  23568. }
  23569. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  23570. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23572. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  23573. if !m.op.Is(OpUpdateOne) {
  23574. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  23575. }
  23576. if m.id == nil || m.oldValue == nil {
  23577. return v, errors.New("OldRequest requires an ID field in the mutation")
  23578. }
  23579. oldValue, err := m.oldValue(ctx)
  23580. if err != nil {
  23581. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  23582. }
  23583. return oldValue.Request, nil
  23584. }
  23585. // ResetRequest resets all changes to the "request" field.
  23586. func (m *UsageDetailMutation) ResetRequest() {
  23587. m.request = nil
  23588. }
  23589. // SetResponse sets the "response" field.
  23590. func (m *UsageDetailMutation) SetResponse(s string) {
  23591. m.response = &s
  23592. }
  23593. // Response returns the value of the "response" field in the mutation.
  23594. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  23595. v := m.response
  23596. if v == nil {
  23597. return
  23598. }
  23599. return *v, true
  23600. }
  23601. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  23602. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23604. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  23605. if !m.op.Is(OpUpdateOne) {
  23606. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  23607. }
  23608. if m.id == nil || m.oldValue == nil {
  23609. return v, errors.New("OldResponse requires an ID field in the mutation")
  23610. }
  23611. oldValue, err := m.oldValue(ctx)
  23612. if err != nil {
  23613. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  23614. }
  23615. return oldValue.Response, nil
  23616. }
  23617. // ResetResponse resets all changes to the "response" field.
  23618. func (m *UsageDetailMutation) ResetResponse() {
  23619. m.response = nil
  23620. }
  23621. // SetTotalTokens sets the "total_tokens" field.
  23622. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  23623. m.total_tokens = &u
  23624. m.addtotal_tokens = nil
  23625. }
  23626. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  23627. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  23628. v := m.total_tokens
  23629. if v == nil {
  23630. return
  23631. }
  23632. return *v, true
  23633. }
  23634. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  23635. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23637. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  23638. if !m.op.Is(OpUpdateOne) {
  23639. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  23640. }
  23641. if m.id == nil || m.oldValue == nil {
  23642. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  23643. }
  23644. oldValue, err := m.oldValue(ctx)
  23645. if err != nil {
  23646. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  23647. }
  23648. return oldValue.TotalTokens, nil
  23649. }
  23650. // AddTotalTokens adds u to the "total_tokens" field.
  23651. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  23652. if m.addtotal_tokens != nil {
  23653. *m.addtotal_tokens += u
  23654. } else {
  23655. m.addtotal_tokens = &u
  23656. }
  23657. }
  23658. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  23659. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  23660. v := m.addtotal_tokens
  23661. if v == nil {
  23662. return
  23663. }
  23664. return *v, true
  23665. }
  23666. // ClearTotalTokens clears the value of the "total_tokens" field.
  23667. func (m *UsageDetailMutation) ClearTotalTokens() {
  23668. m.total_tokens = nil
  23669. m.addtotal_tokens = nil
  23670. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  23671. }
  23672. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  23673. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  23674. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  23675. return ok
  23676. }
  23677. // ResetTotalTokens resets all changes to the "total_tokens" field.
  23678. func (m *UsageDetailMutation) ResetTotalTokens() {
  23679. m.total_tokens = nil
  23680. m.addtotal_tokens = nil
  23681. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  23682. }
  23683. // SetPromptTokens sets the "prompt_tokens" field.
  23684. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  23685. m.prompt_tokens = &u
  23686. m.addprompt_tokens = nil
  23687. }
  23688. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  23689. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  23690. v := m.prompt_tokens
  23691. if v == nil {
  23692. return
  23693. }
  23694. return *v, true
  23695. }
  23696. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  23697. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23699. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  23700. if !m.op.Is(OpUpdateOne) {
  23701. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  23702. }
  23703. if m.id == nil || m.oldValue == nil {
  23704. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  23705. }
  23706. oldValue, err := m.oldValue(ctx)
  23707. if err != nil {
  23708. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  23709. }
  23710. return oldValue.PromptTokens, nil
  23711. }
  23712. // AddPromptTokens adds u to the "prompt_tokens" field.
  23713. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  23714. if m.addprompt_tokens != nil {
  23715. *m.addprompt_tokens += u
  23716. } else {
  23717. m.addprompt_tokens = &u
  23718. }
  23719. }
  23720. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  23721. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  23722. v := m.addprompt_tokens
  23723. if v == nil {
  23724. return
  23725. }
  23726. return *v, true
  23727. }
  23728. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  23729. func (m *UsageDetailMutation) ClearPromptTokens() {
  23730. m.prompt_tokens = nil
  23731. m.addprompt_tokens = nil
  23732. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  23733. }
  23734. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  23735. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  23736. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  23737. return ok
  23738. }
  23739. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  23740. func (m *UsageDetailMutation) ResetPromptTokens() {
  23741. m.prompt_tokens = nil
  23742. m.addprompt_tokens = nil
  23743. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  23744. }
  23745. // SetCompletionTokens sets the "completion_tokens" field.
  23746. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  23747. m.completion_tokens = &u
  23748. m.addcompletion_tokens = nil
  23749. }
  23750. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  23751. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  23752. v := m.completion_tokens
  23753. if v == nil {
  23754. return
  23755. }
  23756. return *v, true
  23757. }
  23758. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  23759. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23761. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  23762. if !m.op.Is(OpUpdateOne) {
  23763. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  23764. }
  23765. if m.id == nil || m.oldValue == nil {
  23766. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  23767. }
  23768. oldValue, err := m.oldValue(ctx)
  23769. if err != nil {
  23770. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  23771. }
  23772. return oldValue.CompletionTokens, nil
  23773. }
  23774. // AddCompletionTokens adds u to the "completion_tokens" field.
  23775. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  23776. if m.addcompletion_tokens != nil {
  23777. *m.addcompletion_tokens += u
  23778. } else {
  23779. m.addcompletion_tokens = &u
  23780. }
  23781. }
  23782. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  23783. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  23784. v := m.addcompletion_tokens
  23785. if v == nil {
  23786. return
  23787. }
  23788. return *v, true
  23789. }
  23790. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  23791. func (m *UsageDetailMutation) ClearCompletionTokens() {
  23792. m.completion_tokens = nil
  23793. m.addcompletion_tokens = nil
  23794. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  23795. }
  23796. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  23797. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  23798. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  23799. return ok
  23800. }
  23801. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  23802. func (m *UsageDetailMutation) ResetCompletionTokens() {
  23803. m.completion_tokens = nil
  23804. m.addcompletion_tokens = nil
  23805. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  23806. }
  23807. // SetOrganizationID sets the "organization_id" field.
  23808. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  23809. m.organization_id = &u
  23810. m.addorganization_id = nil
  23811. }
  23812. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23813. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  23814. v := m.organization_id
  23815. if v == nil {
  23816. return
  23817. }
  23818. return *v, true
  23819. }
  23820. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  23821. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23823. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23824. if !m.op.Is(OpUpdateOne) {
  23825. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23826. }
  23827. if m.id == nil || m.oldValue == nil {
  23828. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23829. }
  23830. oldValue, err := m.oldValue(ctx)
  23831. if err != nil {
  23832. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23833. }
  23834. return oldValue.OrganizationID, nil
  23835. }
  23836. // AddOrganizationID adds u to the "organization_id" field.
  23837. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  23838. if m.addorganization_id != nil {
  23839. *m.addorganization_id += u
  23840. } else {
  23841. m.addorganization_id = &u
  23842. }
  23843. }
  23844. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23845. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  23846. v := m.addorganization_id
  23847. if v == nil {
  23848. return
  23849. }
  23850. return *v, true
  23851. }
  23852. // ClearOrganizationID clears the value of the "organization_id" field.
  23853. func (m *UsageDetailMutation) ClearOrganizationID() {
  23854. m.organization_id = nil
  23855. m.addorganization_id = nil
  23856. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  23857. }
  23858. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23859. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  23860. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  23861. return ok
  23862. }
  23863. // ResetOrganizationID resets all changes to the "organization_id" field.
  23864. func (m *UsageDetailMutation) ResetOrganizationID() {
  23865. m.organization_id = nil
  23866. m.addorganization_id = nil
  23867. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  23868. }
  23869. // Where appends a list predicates to the UsageDetailMutation builder.
  23870. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  23871. m.predicates = append(m.predicates, ps...)
  23872. }
  23873. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  23874. // users can use type-assertion to append predicates that do not depend on any generated package.
  23875. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  23876. p := make([]predicate.UsageDetail, len(ps))
  23877. for i := range ps {
  23878. p[i] = ps[i]
  23879. }
  23880. m.Where(p...)
  23881. }
  23882. // Op returns the operation name.
  23883. func (m *UsageDetailMutation) Op() Op {
  23884. return m.op
  23885. }
  23886. // SetOp allows setting the mutation operation.
  23887. func (m *UsageDetailMutation) SetOp(op Op) {
  23888. m.op = op
  23889. }
  23890. // Type returns the node type of this mutation (UsageDetail).
  23891. func (m *UsageDetailMutation) Type() string {
  23892. return m.typ
  23893. }
  23894. // Fields returns all fields that were changed during this mutation. Note that in
  23895. // order to get all numeric fields that were incremented/decremented, call
  23896. // AddedFields().
  23897. func (m *UsageDetailMutation) Fields() []string {
  23898. fields := make([]string, 0, 14)
  23899. if m.created_at != nil {
  23900. fields = append(fields, usagedetail.FieldCreatedAt)
  23901. }
  23902. if m.updated_at != nil {
  23903. fields = append(fields, usagedetail.FieldUpdatedAt)
  23904. }
  23905. if m.status != nil {
  23906. fields = append(fields, usagedetail.FieldStatus)
  23907. }
  23908. if m._type != nil {
  23909. fields = append(fields, usagedetail.FieldType)
  23910. }
  23911. if m.bot_id != nil {
  23912. fields = append(fields, usagedetail.FieldBotID)
  23913. }
  23914. if m.receiver_id != nil {
  23915. fields = append(fields, usagedetail.FieldReceiverID)
  23916. }
  23917. if m.app != nil {
  23918. fields = append(fields, usagedetail.FieldApp)
  23919. }
  23920. if m.session_id != nil {
  23921. fields = append(fields, usagedetail.FieldSessionID)
  23922. }
  23923. if m.request != nil {
  23924. fields = append(fields, usagedetail.FieldRequest)
  23925. }
  23926. if m.response != nil {
  23927. fields = append(fields, usagedetail.FieldResponse)
  23928. }
  23929. if m.total_tokens != nil {
  23930. fields = append(fields, usagedetail.FieldTotalTokens)
  23931. }
  23932. if m.prompt_tokens != nil {
  23933. fields = append(fields, usagedetail.FieldPromptTokens)
  23934. }
  23935. if m.completion_tokens != nil {
  23936. fields = append(fields, usagedetail.FieldCompletionTokens)
  23937. }
  23938. if m.organization_id != nil {
  23939. fields = append(fields, usagedetail.FieldOrganizationID)
  23940. }
  23941. return fields
  23942. }
  23943. // Field returns the value of a field with the given name. The second boolean
  23944. // return value indicates that this field was not set, or was not defined in the
  23945. // schema.
  23946. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  23947. switch name {
  23948. case usagedetail.FieldCreatedAt:
  23949. return m.CreatedAt()
  23950. case usagedetail.FieldUpdatedAt:
  23951. return m.UpdatedAt()
  23952. case usagedetail.FieldStatus:
  23953. return m.Status()
  23954. case usagedetail.FieldType:
  23955. return m.GetType()
  23956. case usagedetail.FieldBotID:
  23957. return m.BotID()
  23958. case usagedetail.FieldReceiverID:
  23959. return m.ReceiverID()
  23960. case usagedetail.FieldApp:
  23961. return m.App()
  23962. case usagedetail.FieldSessionID:
  23963. return m.SessionID()
  23964. case usagedetail.FieldRequest:
  23965. return m.Request()
  23966. case usagedetail.FieldResponse:
  23967. return m.Response()
  23968. case usagedetail.FieldTotalTokens:
  23969. return m.TotalTokens()
  23970. case usagedetail.FieldPromptTokens:
  23971. return m.PromptTokens()
  23972. case usagedetail.FieldCompletionTokens:
  23973. return m.CompletionTokens()
  23974. case usagedetail.FieldOrganizationID:
  23975. return m.OrganizationID()
  23976. }
  23977. return nil, false
  23978. }
  23979. // OldField returns the old value of the field from the database. An error is
  23980. // returned if the mutation operation is not UpdateOne, or the query to the
  23981. // database failed.
  23982. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23983. switch name {
  23984. case usagedetail.FieldCreatedAt:
  23985. return m.OldCreatedAt(ctx)
  23986. case usagedetail.FieldUpdatedAt:
  23987. return m.OldUpdatedAt(ctx)
  23988. case usagedetail.FieldStatus:
  23989. return m.OldStatus(ctx)
  23990. case usagedetail.FieldType:
  23991. return m.OldType(ctx)
  23992. case usagedetail.FieldBotID:
  23993. return m.OldBotID(ctx)
  23994. case usagedetail.FieldReceiverID:
  23995. return m.OldReceiverID(ctx)
  23996. case usagedetail.FieldApp:
  23997. return m.OldApp(ctx)
  23998. case usagedetail.FieldSessionID:
  23999. return m.OldSessionID(ctx)
  24000. case usagedetail.FieldRequest:
  24001. return m.OldRequest(ctx)
  24002. case usagedetail.FieldResponse:
  24003. return m.OldResponse(ctx)
  24004. case usagedetail.FieldTotalTokens:
  24005. return m.OldTotalTokens(ctx)
  24006. case usagedetail.FieldPromptTokens:
  24007. return m.OldPromptTokens(ctx)
  24008. case usagedetail.FieldCompletionTokens:
  24009. return m.OldCompletionTokens(ctx)
  24010. case usagedetail.FieldOrganizationID:
  24011. return m.OldOrganizationID(ctx)
  24012. }
  24013. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  24014. }
  24015. // SetField sets the value of a field with the given name. It returns an error if
  24016. // the field is not defined in the schema, or if the type mismatched the field
  24017. // type.
  24018. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  24019. switch name {
  24020. case usagedetail.FieldCreatedAt:
  24021. v, ok := value.(time.Time)
  24022. if !ok {
  24023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24024. }
  24025. m.SetCreatedAt(v)
  24026. return nil
  24027. case usagedetail.FieldUpdatedAt:
  24028. v, ok := value.(time.Time)
  24029. if !ok {
  24030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24031. }
  24032. m.SetUpdatedAt(v)
  24033. return nil
  24034. case usagedetail.FieldStatus:
  24035. v, ok := value.(uint8)
  24036. if !ok {
  24037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24038. }
  24039. m.SetStatus(v)
  24040. return nil
  24041. case usagedetail.FieldType:
  24042. v, ok := value.(int)
  24043. if !ok {
  24044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24045. }
  24046. m.SetType(v)
  24047. return nil
  24048. case usagedetail.FieldBotID:
  24049. v, ok := value.(string)
  24050. if !ok {
  24051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24052. }
  24053. m.SetBotID(v)
  24054. return nil
  24055. case usagedetail.FieldReceiverID:
  24056. v, ok := value.(string)
  24057. if !ok {
  24058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24059. }
  24060. m.SetReceiverID(v)
  24061. return nil
  24062. case usagedetail.FieldApp:
  24063. v, ok := value.(int)
  24064. if !ok {
  24065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24066. }
  24067. m.SetApp(v)
  24068. return nil
  24069. case usagedetail.FieldSessionID:
  24070. v, ok := value.(uint64)
  24071. if !ok {
  24072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24073. }
  24074. m.SetSessionID(v)
  24075. return nil
  24076. case usagedetail.FieldRequest:
  24077. v, ok := value.(string)
  24078. if !ok {
  24079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24080. }
  24081. m.SetRequest(v)
  24082. return nil
  24083. case usagedetail.FieldResponse:
  24084. v, ok := value.(string)
  24085. if !ok {
  24086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24087. }
  24088. m.SetResponse(v)
  24089. return nil
  24090. case usagedetail.FieldTotalTokens:
  24091. v, ok := value.(uint64)
  24092. if !ok {
  24093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24094. }
  24095. m.SetTotalTokens(v)
  24096. return nil
  24097. case usagedetail.FieldPromptTokens:
  24098. v, ok := value.(uint64)
  24099. if !ok {
  24100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24101. }
  24102. m.SetPromptTokens(v)
  24103. return nil
  24104. case usagedetail.FieldCompletionTokens:
  24105. v, ok := value.(uint64)
  24106. if !ok {
  24107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24108. }
  24109. m.SetCompletionTokens(v)
  24110. return nil
  24111. case usagedetail.FieldOrganizationID:
  24112. v, ok := value.(uint64)
  24113. if !ok {
  24114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24115. }
  24116. m.SetOrganizationID(v)
  24117. return nil
  24118. }
  24119. return fmt.Errorf("unknown UsageDetail field %s", name)
  24120. }
  24121. // AddedFields returns all numeric fields that were incremented/decremented during
  24122. // this mutation.
  24123. func (m *UsageDetailMutation) AddedFields() []string {
  24124. var fields []string
  24125. if m.addstatus != nil {
  24126. fields = append(fields, usagedetail.FieldStatus)
  24127. }
  24128. if m.add_type != nil {
  24129. fields = append(fields, usagedetail.FieldType)
  24130. }
  24131. if m.addapp != nil {
  24132. fields = append(fields, usagedetail.FieldApp)
  24133. }
  24134. if m.addsession_id != nil {
  24135. fields = append(fields, usagedetail.FieldSessionID)
  24136. }
  24137. if m.addtotal_tokens != nil {
  24138. fields = append(fields, usagedetail.FieldTotalTokens)
  24139. }
  24140. if m.addprompt_tokens != nil {
  24141. fields = append(fields, usagedetail.FieldPromptTokens)
  24142. }
  24143. if m.addcompletion_tokens != nil {
  24144. fields = append(fields, usagedetail.FieldCompletionTokens)
  24145. }
  24146. if m.addorganization_id != nil {
  24147. fields = append(fields, usagedetail.FieldOrganizationID)
  24148. }
  24149. return fields
  24150. }
  24151. // AddedField returns the numeric value that was incremented/decremented on a field
  24152. // with the given name. The second boolean return value indicates that this field
  24153. // was not set, or was not defined in the schema.
  24154. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  24155. switch name {
  24156. case usagedetail.FieldStatus:
  24157. return m.AddedStatus()
  24158. case usagedetail.FieldType:
  24159. return m.AddedType()
  24160. case usagedetail.FieldApp:
  24161. return m.AddedApp()
  24162. case usagedetail.FieldSessionID:
  24163. return m.AddedSessionID()
  24164. case usagedetail.FieldTotalTokens:
  24165. return m.AddedTotalTokens()
  24166. case usagedetail.FieldPromptTokens:
  24167. return m.AddedPromptTokens()
  24168. case usagedetail.FieldCompletionTokens:
  24169. return m.AddedCompletionTokens()
  24170. case usagedetail.FieldOrganizationID:
  24171. return m.AddedOrganizationID()
  24172. }
  24173. return nil, false
  24174. }
  24175. // AddField adds the value to the field with the given name. It returns an error if
  24176. // the field is not defined in the schema, or if the type mismatched the field
  24177. // type.
  24178. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  24179. switch name {
  24180. case usagedetail.FieldStatus:
  24181. v, ok := value.(int8)
  24182. if !ok {
  24183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24184. }
  24185. m.AddStatus(v)
  24186. return nil
  24187. case usagedetail.FieldType:
  24188. v, ok := value.(int)
  24189. if !ok {
  24190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24191. }
  24192. m.AddType(v)
  24193. return nil
  24194. case usagedetail.FieldApp:
  24195. v, ok := value.(int)
  24196. if !ok {
  24197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24198. }
  24199. m.AddApp(v)
  24200. return nil
  24201. case usagedetail.FieldSessionID:
  24202. v, ok := value.(int64)
  24203. if !ok {
  24204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24205. }
  24206. m.AddSessionID(v)
  24207. return nil
  24208. case usagedetail.FieldTotalTokens:
  24209. v, ok := value.(int64)
  24210. if !ok {
  24211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24212. }
  24213. m.AddTotalTokens(v)
  24214. return nil
  24215. case usagedetail.FieldPromptTokens:
  24216. v, ok := value.(int64)
  24217. if !ok {
  24218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24219. }
  24220. m.AddPromptTokens(v)
  24221. return nil
  24222. case usagedetail.FieldCompletionTokens:
  24223. v, ok := value.(int64)
  24224. if !ok {
  24225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24226. }
  24227. m.AddCompletionTokens(v)
  24228. return nil
  24229. case usagedetail.FieldOrganizationID:
  24230. v, ok := value.(int64)
  24231. if !ok {
  24232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24233. }
  24234. m.AddOrganizationID(v)
  24235. return nil
  24236. }
  24237. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  24238. }
  24239. // ClearedFields returns all nullable fields that were cleared during this
  24240. // mutation.
  24241. func (m *UsageDetailMutation) ClearedFields() []string {
  24242. var fields []string
  24243. if m.FieldCleared(usagedetail.FieldStatus) {
  24244. fields = append(fields, usagedetail.FieldStatus)
  24245. }
  24246. if m.FieldCleared(usagedetail.FieldType) {
  24247. fields = append(fields, usagedetail.FieldType)
  24248. }
  24249. if m.FieldCleared(usagedetail.FieldApp) {
  24250. fields = append(fields, usagedetail.FieldApp)
  24251. }
  24252. if m.FieldCleared(usagedetail.FieldSessionID) {
  24253. fields = append(fields, usagedetail.FieldSessionID)
  24254. }
  24255. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  24256. fields = append(fields, usagedetail.FieldTotalTokens)
  24257. }
  24258. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  24259. fields = append(fields, usagedetail.FieldPromptTokens)
  24260. }
  24261. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  24262. fields = append(fields, usagedetail.FieldCompletionTokens)
  24263. }
  24264. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  24265. fields = append(fields, usagedetail.FieldOrganizationID)
  24266. }
  24267. return fields
  24268. }
  24269. // FieldCleared returns a boolean indicating if a field with the given name was
  24270. // cleared in this mutation.
  24271. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  24272. _, ok := m.clearedFields[name]
  24273. return ok
  24274. }
  24275. // ClearField clears the value of the field with the given name. It returns an
  24276. // error if the field is not defined in the schema.
  24277. func (m *UsageDetailMutation) ClearField(name string) error {
  24278. switch name {
  24279. case usagedetail.FieldStatus:
  24280. m.ClearStatus()
  24281. return nil
  24282. case usagedetail.FieldType:
  24283. m.ClearType()
  24284. return nil
  24285. case usagedetail.FieldApp:
  24286. m.ClearApp()
  24287. return nil
  24288. case usagedetail.FieldSessionID:
  24289. m.ClearSessionID()
  24290. return nil
  24291. case usagedetail.FieldTotalTokens:
  24292. m.ClearTotalTokens()
  24293. return nil
  24294. case usagedetail.FieldPromptTokens:
  24295. m.ClearPromptTokens()
  24296. return nil
  24297. case usagedetail.FieldCompletionTokens:
  24298. m.ClearCompletionTokens()
  24299. return nil
  24300. case usagedetail.FieldOrganizationID:
  24301. m.ClearOrganizationID()
  24302. return nil
  24303. }
  24304. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  24305. }
  24306. // ResetField resets all changes in the mutation for the field with the given name.
  24307. // It returns an error if the field is not defined in the schema.
  24308. func (m *UsageDetailMutation) ResetField(name string) error {
  24309. switch name {
  24310. case usagedetail.FieldCreatedAt:
  24311. m.ResetCreatedAt()
  24312. return nil
  24313. case usagedetail.FieldUpdatedAt:
  24314. m.ResetUpdatedAt()
  24315. return nil
  24316. case usagedetail.FieldStatus:
  24317. m.ResetStatus()
  24318. return nil
  24319. case usagedetail.FieldType:
  24320. m.ResetType()
  24321. return nil
  24322. case usagedetail.FieldBotID:
  24323. m.ResetBotID()
  24324. return nil
  24325. case usagedetail.FieldReceiverID:
  24326. m.ResetReceiverID()
  24327. return nil
  24328. case usagedetail.FieldApp:
  24329. m.ResetApp()
  24330. return nil
  24331. case usagedetail.FieldSessionID:
  24332. m.ResetSessionID()
  24333. return nil
  24334. case usagedetail.FieldRequest:
  24335. m.ResetRequest()
  24336. return nil
  24337. case usagedetail.FieldResponse:
  24338. m.ResetResponse()
  24339. return nil
  24340. case usagedetail.FieldTotalTokens:
  24341. m.ResetTotalTokens()
  24342. return nil
  24343. case usagedetail.FieldPromptTokens:
  24344. m.ResetPromptTokens()
  24345. return nil
  24346. case usagedetail.FieldCompletionTokens:
  24347. m.ResetCompletionTokens()
  24348. return nil
  24349. case usagedetail.FieldOrganizationID:
  24350. m.ResetOrganizationID()
  24351. return nil
  24352. }
  24353. return fmt.Errorf("unknown UsageDetail field %s", name)
  24354. }
  24355. // AddedEdges returns all edge names that were set/added in this mutation.
  24356. func (m *UsageDetailMutation) AddedEdges() []string {
  24357. edges := make([]string, 0, 0)
  24358. return edges
  24359. }
  24360. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24361. // name in this mutation.
  24362. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  24363. return nil
  24364. }
  24365. // RemovedEdges returns all edge names that were removed in this mutation.
  24366. func (m *UsageDetailMutation) RemovedEdges() []string {
  24367. edges := make([]string, 0, 0)
  24368. return edges
  24369. }
  24370. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24371. // the given name in this mutation.
  24372. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  24373. return nil
  24374. }
  24375. // ClearedEdges returns all edge names that were cleared in this mutation.
  24376. func (m *UsageDetailMutation) ClearedEdges() []string {
  24377. edges := make([]string, 0, 0)
  24378. return edges
  24379. }
  24380. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24381. // was cleared in this mutation.
  24382. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  24383. return false
  24384. }
  24385. // ClearEdge clears the value of the edge with the given name. It returns an error
  24386. // if that edge is not defined in the schema.
  24387. func (m *UsageDetailMutation) ClearEdge(name string) error {
  24388. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  24389. }
  24390. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24391. // It returns an error if the edge is not defined in the schema.
  24392. func (m *UsageDetailMutation) ResetEdge(name string) error {
  24393. return fmt.Errorf("unknown UsageDetail edge %s", name)
  24394. }
  24395. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  24396. type UsageTotalMutation struct {
  24397. config
  24398. op Op
  24399. typ string
  24400. id *uint64
  24401. created_at *time.Time
  24402. updated_at *time.Time
  24403. status *uint8
  24404. addstatus *int8
  24405. _type *int
  24406. add_type *int
  24407. bot_id *string
  24408. total_tokens *uint64
  24409. addtotal_tokens *int64
  24410. start_index *uint64
  24411. addstart_index *int64
  24412. end_index *uint64
  24413. addend_index *int64
  24414. organization_id *uint64
  24415. addorganization_id *int64
  24416. clearedFields map[string]struct{}
  24417. done bool
  24418. oldValue func(context.Context) (*UsageTotal, error)
  24419. predicates []predicate.UsageTotal
  24420. }
  24421. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  24422. // usagetotalOption allows management of the mutation configuration using functional options.
  24423. type usagetotalOption func(*UsageTotalMutation)
  24424. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  24425. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  24426. m := &UsageTotalMutation{
  24427. config: c,
  24428. op: op,
  24429. typ: TypeUsageTotal,
  24430. clearedFields: make(map[string]struct{}),
  24431. }
  24432. for _, opt := range opts {
  24433. opt(m)
  24434. }
  24435. return m
  24436. }
  24437. // withUsageTotalID sets the ID field of the mutation.
  24438. func withUsageTotalID(id uint64) usagetotalOption {
  24439. return func(m *UsageTotalMutation) {
  24440. var (
  24441. err error
  24442. once sync.Once
  24443. value *UsageTotal
  24444. )
  24445. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  24446. once.Do(func() {
  24447. if m.done {
  24448. err = errors.New("querying old values post mutation is not allowed")
  24449. } else {
  24450. value, err = m.Client().UsageTotal.Get(ctx, id)
  24451. }
  24452. })
  24453. return value, err
  24454. }
  24455. m.id = &id
  24456. }
  24457. }
  24458. // withUsageTotal sets the old UsageTotal of the mutation.
  24459. func withUsageTotal(node *UsageTotal) usagetotalOption {
  24460. return func(m *UsageTotalMutation) {
  24461. m.oldValue = func(context.Context) (*UsageTotal, error) {
  24462. return node, nil
  24463. }
  24464. m.id = &node.ID
  24465. }
  24466. }
  24467. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24468. // executed in a transaction (ent.Tx), a transactional client is returned.
  24469. func (m UsageTotalMutation) Client() *Client {
  24470. client := &Client{config: m.config}
  24471. client.init()
  24472. return client
  24473. }
  24474. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24475. // it returns an error otherwise.
  24476. func (m UsageTotalMutation) Tx() (*Tx, error) {
  24477. if _, ok := m.driver.(*txDriver); !ok {
  24478. return nil, errors.New("ent: mutation is not running in a transaction")
  24479. }
  24480. tx := &Tx{config: m.config}
  24481. tx.init()
  24482. return tx, nil
  24483. }
  24484. // SetID sets the value of the id field. Note that this
  24485. // operation is only accepted on creation of UsageTotal entities.
  24486. func (m *UsageTotalMutation) SetID(id uint64) {
  24487. m.id = &id
  24488. }
  24489. // ID returns the ID value in the mutation. Note that the ID is only available
  24490. // if it was provided to the builder or after it was returned from the database.
  24491. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  24492. if m.id == nil {
  24493. return
  24494. }
  24495. return *m.id, true
  24496. }
  24497. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24498. // That means, if the mutation is applied within a transaction with an isolation level such
  24499. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24500. // or updated by the mutation.
  24501. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  24502. switch {
  24503. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24504. id, exists := m.ID()
  24505. if exists {
  24506. return []uint64{id}, nil
  24507. }
  24508. fallthrough
  24509. case m.op.Is(OpUpdate | OpDelete):
  24510. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  24511. default:
  24512. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24513. }
  24514. }
  24515. // SetCreatedAt sets the "created_at" field.
  24516. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  24517. m.created_at = &t
  24518. }
  24519. // CreatedAt returns the value of the "created_at" field in the mutation.
  24520. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  24521. v := m.created_at
  24522. if v == nil {
  24523. return
  24524. }
  24525. return *v, true
  24526. }
  24527. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  24528. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24530. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24531. if !m.op.Is(OpUpdateOne) {
  24532. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24533. }
  24534. if m.id == nil || m.oldValue == nil {
  24535. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24536. }
  24537. oldValue, err := m.oldValue(ctx)
  24538. if err != nil {
  24539. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24540. }
  24541. return oldValue.CreatedAt, nil
  24542. }
  24543. // ResetCreatedAt resets all changes to the "created_at" field.
  24544. func (m *UsageTotalMutation) ResetCreatedAt() {
  24545. m.created_at = nil
  24546. }
  24547. // SetUpdatedAt sets the "updated_at" field.
  24548. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  24549. m.updated_at = &t
  24550. }
  24551. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24552. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  24553. v := m.updated_at
  24554. if v == nil {
  24555. return
  24556. }
  24557. return *v, true
  24558. }
  24559. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  24560. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24562. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24563. if !m.op.Is(OpUpdateOne) {
  24564. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24565. }
  24566. if m.id == nil || m.oldValue == nil {
  24567. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24568. }
  24569. oldValue, err := m.oldValue(ctx)
  24570. if err != nil {
  24571. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24572. }
  24573. return oldValue.UpdatedAt, nil
  24574. }
  24575. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24576. func (m *UsageTotalMutation) ResetUpdatedAt() {
  24577. m.updated_at = nil
  24578. }
  24579. // SetStatus sets the "status" field.
  24580. func (m *UsageTotalMutation) SetStatus(u uint8) {
  24581. m.status = &u
  24582. m.addstatus = nil
  24583. }
  24584. // Status returns the value of the "status" field in the mutation.
  24585. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  24586. v := m.status
  24587. if v == nil {
  24588. return
  24589. }
  24590. return *v, true
  24591. }
  24592. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  24593. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24595. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24596. if !m.op.Is(OpUpdateOne) {
  24597. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24598. }
  24599. if m.id == nil || m.oldValue == nil {
  24600. return v, errors.New("OldStatus requires an ID field in the mutation")
  24601. }
  24602. oldValue, err := m.oldValue(ctx)
  24603. if err != nil {
  24604. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24605. }
  24606. return oldValue.Status, nil
  24607. }
  24608. // AddStatus adds u to the "status" field.
  24609. func (m *UsageTotalMutation) AddStatus(u int8) {
  24610. if m.addstatus != nil {
  24611. *m.addstatus += u
  24612. } else {
  24613. m.addstatus = &u
  24614. }
  24615. }
  24616. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24617. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  24618. v := m.addstatus
  24619. if v == nil {
  24620. return
  24621. }
  24622. return *v, true
  24623. }
  24624. // ClearStatus clears the value of the "status" field.
  24625. func (m *UsageTotalMutation) ClearStatus() {
  24626. m.status = nil
  24627. m.addstatus = nil
  24628. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  24629. }
  24630. // StatusCleared returns if the "status" field was cleared in this mutation.
  24631. func (m *UsageTotalMutation) StatusCleared() bool {
  24632. _, ok := m.clearedFields[usagetotal.FieldStatus]
  24633. return ok
  24634. }
  24635. // ResetStatus resets all changes to the "status" field.
  24636. func (m *UsageTotalMutation) ResetStatus() {
  24637. m.status = nil
  24638. m.addstatus = nil
  24639. delete(m.clearedFields, usagetotal.FieldStatus)
  24640. }
  24641. // SetType sets the "type" field.
  24642. func (m *UsageTotalMutation) SetType(i int) {
  24643. m._type = &i
  24644. m.add_type = nil
  24645. }
  24646. // GetType returns the value of the "type" field in the mutation.
  24647. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  24648. v := m._type
  24649. if v == nil {
  24650. return
  24651. }
  24652. return *v, true
  24653. }
  24654. // OldType returns the old "type" field's value of the UsageTotal entity.
  24655. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24657. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  24658. if !m.op.Is(OpUpdateOne) {
  24659. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24660. }
  24661. if m.id == nil || m.oldValue == nil {
  24662. return v, errors.New("OldType requires an ID field in the mutation")
  24663. }
  24664. oldValue, err := m.oldValue(ctx)
  24665. if err != nil {
  24666. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24667. }
  24668. return oldValue.Type, nil
  24669. }
  24670. // AddType adds i to the "type" field.
  24671. func (m *UsageTotalMutation) AddType(i int) {
  24672. if m.add_type != nil {
  24673. *m.add_type += i
  24674. } else {
  24675. m.add_type = &i
  24676. }
  24677. }
  24678. // AddedType returns the value that was added to the "type" field in this mutation.
  24679. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  24680. v := m.add_type
  24681. if v == nil {
  24682. return
  24683. }
  24684. return *v, true
  24685. }
  24686. // ClearType clears the value of the "type" field.
  24687. func (m *UsageTotalMutation) ClearType() {
  24688. m._type = nil
  24689. m.add_type = nil
  24690. m.clearedFields[usagetotal.FieldType] = struct{}{}
  24691. }
  24692. // TypeCleared returns if the "type" field was cleared in this mutation.
  24693. func (m *UsageTotalMutation) TypeCleared() bool {
  24694. _, ok := m.clearedFields[usagetotal.FieldType]
  24695. return ok
  24696. }
  24697. // ResetType resets all changes to the "type" field.
  24698. func (m *UsageTotalMutation) ResetType() {
  24699. m._type = nil
  24700. m.add_type = nil
  24701. delete(m.clearedFields, usagetotal.FieldType)
  24702. }
  24703. // SetBotID sets the "bot_id" field.
  24704. func (m *UsageTotalMutation) SetBotID(s string) {
  24705. m.bot_id = &s
  24706. }
  24707. // BotID returns the value of the "bot_id" field in the mutation.
  24708. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  24709. v := m.bot_id
  24710. if v == nil {
  24711. return
  24712. }
  24713. return *v, true
  24714. }
  24715. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  24716. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24718. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  24719. if !m.op.Is(OpUpdateOne) {
  24720. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  24721. }
  24722. if m.id == nil || m.oldValue == nil {
  24723. return v, errors.New("OldBotID requires an ID field in the mutation")
  24724. }
  24725. oldValue, err := m.oldValue(ctx)
  24726. if err != nil {
  24727. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  24728. }
  24729. return oldValue.BotID, nil
  24730. }
  24731. // ResetBotID resets all changes to the "bot_id" field.
  24732. func (m *UsageTotalMutation) ResetBotID() {
  24733. m.bot_id = nil
  24734. }
  24735. // SetTotalTokens sets the "total_tokens" field.
  24736. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  24737. m.total_tokens = &u
  24738. m.addtotal_tokens = nil
  24739. }
  24740. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  24741. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  24742. v := m.total_tokens
  24743. if v == nil {
  24744. return
  24745. }
  24746. return *v, true
  24747. }
  24748. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  24749. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24751. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  24752. if !m.op.Is(OpUpdateOne) {
  24753. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  24754. }
  24755. if m.id == nil || m.oldValue == nil {
  24756. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  24757. }
  24758. oldValue, err := m.oldValue(ctx)
  24759. if err != nil {
  24760. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  24761. }
  24762. return oldValue.TotalTokens, nil
  24763. }
  24764. // AddTotalTokens adds u to the "total_tokens" field.
  24765. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  24766. if m.addtotal_tokens != nil {
  24767. *m.addtotal_tokens += u
  24768. } else {
  24769. m.addtotal_tokens = &u
  24770. }
  24771. }
  24772. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  24773. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  24774. v := m.addtotal_tokens
  24775. if v == nil {
  24776. return
  24777. }
  24778. return *v, true
  24779. }
  24780. // ClearTotalTokens clears the value of the "total_tokens" field.
  24781. func (m *UsageTotalMutation) ClearTotalTokens() {
  24782. m.total_tokens = nil
  24783. m.addtotal_tokens = nil
  24784. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  24785. }
  24786. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  24787. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  24788. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  24789. return ok
  24790. }
  24791. // ResetTotalTokens resets all changes to the "total_tokens" field.
  24792. func (m *UsageTotalMutation) ResetTotalTokens() {
  24793. m.total_tokens = nil
  24794. m.addtotal_tokens = nil
  24795. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  24796. }
  24797. // SetStartIndex sets the "start_index" field.
  24798. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  24799. m.start_index = &u
  24800. m.addstart_index = nil
  24801. }
  24802. // StartIndex returns the value of the "start_index" field in the mutation.
  24803. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  24804. v := m.start_index
  24805. if v == nil {
  24806. return
  24807. }
  24808. return *v, true
  24809. }
  24810. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  24811. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24813. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  24814. if !m.op.Is(OpUpdateOne) {
  24815. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  24816. }
  24817. if m.id == nil || m.oldValue == nil {
  24818. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  24819. }
  24820. oldValue, err := m.oldValue(ctx)
  24821. if err != nil {
  24822. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  24823. }
  24824. return oldValue.StartIndex, nil
  24825. }
  24826. // AddStartIndex adds u to the "start_index" field.
  24827. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  24828. if m.addstart_index != nil {
  24829. *m.addstart_index += u
  24830. } else {
  24831. m.addstart_index = &u
  24832. }
  24833. }
  24834. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  24835. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  24836. v := m.addstart_index
  24837. if v == nil {
  24838. return
  24839. }
  24840. return *v, true
  24841. }
  24842. // ClearStartIndex clears the value of the "start_index" field.
  24843. func (m *UsageTotalMutation) ClearStartIndex() {
  24844. m.start_index = nil
  24845. m.addstart_index = nil
  24846. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  24847. }
  24848. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  24849. func (m *UsageTotalMutation) StartIndexCleared() bool {
  24850. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  24851. return ok
  24852. }
  24853. // ResetStartIndex resets all changes to the "start_index" field.
  24854. func (m *UsageTotalMutation) ResetStartIndex() {
  24855. m.start_index = nil
  24856. m.addstart_index = nil
  24857. delete(m.clearedFields, usagetotal.FieldStartIndex)
  24858. }
  24859. // SetEndIndex sets the "end_index" field.
  24860. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  24861. m.end_index = &u
  24862. m.addend_index = nil
  24863. }
  24864. // EndIndex returns the value of the "end_index" field in the mutation.
  24865. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  24866. v := m.end_index
  24867. if v == nil {
  24868. return
  24869. }
  24870. return *v, true
  24871. }
  24872. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  24873. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24875. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  24876. if !m.op.Is(OpUpdateOne) {
  24877. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  24878. }
  24879. if m.id == nil || m.oldValue == nil {
  24880. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  24881. }
  24882. oldValue, err := m.oldValue(ctx)
  24883. if err != nil {
  24884. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  24885. }
  24886. return oldValue.EndIndex, nil
  24887. }
  24888. // AddEndIndex adds u to the "end_index" field.
  24889. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  24890. if m.addend_index != nil {
  24891. *m.addend_index += u
  24892. } else {
  24893. m.addend_index = &u
  24894. }
  24895. }
  24896. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  24897. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  24898. v := m.addend_index
  24899. if v == nil {
  24900. return
  24901. }
  24902. return *v, true
  24903. }
  24904. // ClearEndIndex clears the value of the "end_index" field.
  24905. func (m *UsageTotalMutation) ClearEndIndex() {
  24906. m.end_index = nil
  24907. m.addend_index = nil
  24908. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  24909. }
  24910. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  24911. func (m *UsageTotalMutation) EndIndexCleared() bool {
  24912. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  24913. return ok
  24914. }
  24915. // ResetEndIndex resets all changes to the "end_index" field.
  24916. func (m *UsageTotalMutation) ResetEndIndex() {
  24917. m.end_index = nil
  24918. m.addend_index = nil
  24919. delete(m.clearedFields, usagetotal.FieldEndIndex)
  24920. }
  24921. // SetOrganizationID sets the "organization_id" field.
  24922. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  24923. m.organization_id = &u
  24924. m.addorganization_id = nil
  24925. }
  24926. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24927. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  24928. v := m.organization_id
  24929. if v == nil {
  24930. return
  24931. }
  24932. return *v, true
  24933. }
  24934. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  24935. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24937. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24938. if !m.op.Is(OpUpdateOne) {
  24939. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24940. }
  24941. if m.id == nil || m.oldValue == nil {
  24942. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24943. }
  24944. oldValue, err := m.oldValue(ctx)
  24945. if err != nil {
  24946. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24947. }
  24948. return oldValue.OrganizationID, nil
  24949. }
  24950. // AddOrganizationID adds u to the "organization_id" field.
  24951. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  24952. if m.addorganization_id != nil {
  24953. *m.addorganization_id += u
  24954. } else {
  24955. m.addorganization_id = &u
  24956. }
  24957. }
  24958. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24959. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  24960. v := m.addorganization_id
  24961. if v == nil {
  24962. return
  24963. }
  24964. return *v, true
  24965. }
  24966. // ClearOrganizationID clears the value of the "organization_id" field.
  24967. func (m *UsageTotalMutation) ClearOrganizationID() {
  24968. m.organization_id = nil
  24969. m.addorganization_id = nil
  24970. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  24971. }
  24972. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24973. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  24974. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  24975. return ok
  24976. }
  24977. // ResetOrganizationID resets all changes to the "organization_id" field.
  24978. func (m *UsageTotalMutation) ResetOrganizationID() {
  24979. m.organization_id = nil
  24980. m.addorganization_id = nil
  24981. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  24982. }
  24983. // Where appends a list predicates to the UsageTotalMutation builder.
  24984. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  24985. m.predicates = append(m.predicates, ps...)
  24986. }
  24987. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  24988. // users can use type-assertion to append predicates that do not depend on any generated package.
  24989. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  24990. p := make([]predicate.UsageTotal, len(ps))
  24991. for i := range ps {
  24992. p[i] = ps[i]
  24993. }
  24994. m.Where(p...)
  24995. }
  24996. // Op returns the operation name.
  24997. func (m *UsageTotalMutation) Op() Op {
  24998. return m.op
  24999. }
  25000. // SetOp allows setting the mutation operation.
  25001. func (m *UsageTotalMutation) SetOp(op Op) {
  25002. m.op = op
  25003. }
  25004. // Type returns the node type of this mutation (UsageTotal).
  25005. func (m *UsageTotalMutation) Type() string {
  25006. return m.typ
  25007. }
  25008. // Fields returns all fields that were changed during this mutation. Note that in
  25009. // order to get all numeric fields that were incremented/decremented, call
  25010. // AddedFields().
  25011. func (m *UsageTotalMutation) Fields() []string {
  25012. fields := make([]string, 0, 9)
  25013. if m.created_at != nil {
  25014. fields = append(fields, usagetotal.FieldCreatedAt)
  25015. }
  25016. if m.updated_at != nil {
  25017. fields = append(fields, usagetotal.FieldUpdatedAt)
  25018. }
  25019. if m.status != nil {
  25020. fields = append(fields, usagetotal.FieldStatus)
  25021. }
  25022. if m._type != nil {
  25023. fields = append(fields, usagetotal.FieldType)
  25024. }
  25025. if m.bot_id != nil {
  25026. fields = append(fields, usagetotal.FieldBotID)
  25027. }
  25028. if m.total_tokens != nil {
  25029. fields = append(fields, usagetotal.FieldTotalTokens)
  25030. }
  25031. if m.start_index != nil {
  25032. fields = append(fields, usagetotal.FieldStartIndex)
  25033. }
  25034. if m.end_index != nil {
  25035. fields = append(fields, usagetotal.FieldEndIndex)
  25036. }
  25037. if m.organization_id != nil {
  25038. fields = append(fields, usagetotal.FieldOrganizationID)
  25039. }
  25040. return fields
  25041. }
  25042. // Field returns the value of a field with the given name. The second boolean
  25043. // return value indicates that this field was not set, or was not defined in the
  25044. // schema.
  25045. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  25046. switch name {
  25047. case usagetotal.FieldCreatedAt:
  25048. return m.CreatedAt()
  25049. case usagetotal.FieldUpdatedAt:
  25050. return m.UpdatedAt()
  25051. case usagetotal.FieldStatus:
  25052. return m.Status()
  25053. case usagetotal.FieldType:
  25054. return m.GetType()
  25055. case usagetotal.FieldBotID:
  25056. return m.BotID()
  25057. case usagetotal.FieldTotalTokens:
  25058. return m.TotalTokens()
  25059. case usagetotal.FieldStartIndex:
  25060. return m.StartIndex()
  25061. case usagetotal.FieldEndIndex:
  25062. return m.EndIndex()
  25063. case usagetotal.FieldOrganizationID:
  25064. return m.OrganizationID()
  25065. }
  25066. return nil, false
  25067. }
  25068. // OldField returns the old value of the field from the database. An error is
  25069. // returned if the mutation operation is not UpdateOne, or the query to the
  25070. // database failed.
  25071. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25072. switch name {
  25073. case usagetotal.FieldCreatedAt:
  25074. return m.OldCreatedAt(ctx)
  25075. case usagetotal.FieldUpdatedAt:
  25076. return m.OldUpdatedAt(ctx)
  25077. case usagetotal.FieldStatus:
  25078. return m.OldStatus(ctx)
  25079. case usagetotal.FieldType:
  25080. return m.OldType(ctx)
  25081. case usagetotal.FieldBotID:
  25082. return m.OldBotID(ctx)
  25083. case usagetotal.FieldTotalTokens:
  25084. return m.OldTotalTokens(ctx)
  25085. case usagetotal.FieldStartIndex:
  25086. return m.OldStartIndex(ctx)
  25087. case usagetotal.FieldEndIndex:
  25088. return m.OldEndIndex(ctx)
  25089. case usagetotal.FieldOrganizationID:
  25090. return m.OldOrganizationID(ctx)
  25091. }
  25092. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  25093. }
  25094. // SetField sets the value of a field with the given name. It returns an error if
  25095. // the field is not defined in the schema, or if the type mismatched the field
  25096. // type.
  25097. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  25098. switch name {
  25099. case usagetotal.FieldCreatedAt:
  25100. v, ok := value.(time.Time)
  25101. if !ok {
  25102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25103. }
  25104. m.SetCreatedAt(v)
  25105. return nil
  25106. case usagetotal.FieldUpdatedAt:
  25107. v, ok := value.(time.Time)
  25108. if !ok {
  25109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25110. }
  25111. m.SetUpdatedAt(v)
  25112. return nil
  25113. case usagetotal.FieldStatus:
  25114. v, ok := value.(uint8)
  25115. if !ok {
  25116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25117. }
  25118. m.SetStatus(v)
  25119. return nil
  25120. case usagetotal.FieldType:
  25121. v, ok := value.(int)
  25122. if !ok {
  25123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25124. }
  25125. m.SetType(v)
  25126. return nil
  25127. case usagetotal.FieldBotID:
  25128. v, ok := value.(string)
  25129. if !ok {
  25130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25131. }
  25132. m.SetBotID(v)
  25133. return nil
  25134. case usagetotal.FieldTotalTokens:
  25135. v, ok := value.(uint64)
  25136. if !ok {
  25137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25138. }
  25139. m.SetTotalTokens(v)
  25140. return nil
  25141. case usagetotal.FieldStartIndex:
  25142. v, ok := value.(uint64)
  25143. if !ok {
  25144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25145. }
  25146. m.SetStartIndex(v)
  25147. return nil
  25148. case usagetotal.FieldEndIndex:
  25149. v, ok := value.(uint64)
  25150. if !ok {
  25151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25152. }
  25153. m.SetEndIndex(v)
  25154. return nil
  25155. case usagetotal.FieldOrganizationID:
  25156. v, ok := value.(uint64)
  25157. if !ok {
  25158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25159. }
  25160. m.SetOrganizationID(v)
  25161. return nil
  25162. }
  25163. return fmt.Errorf("unknown UsageTotal field %s", name)
  25164. }
  25165. // AddedFields returns all numeric fields that were incremented/decremented during
  25166. // this mutation.
  25167. func (m *UsageTotalMutation) AddedFields() []string {
  25168. var fields []string
  25169. if m.addstatus != nil {
  25170. fields = append(fields, usagetotal.FieldStatus)
  25171. }
  25172. if m.add_type != nil {
  25173. fields = append(fields, usagetotal.FieldType)
  25174. }
  25175. if m.addtotal_tokens != nil {
  25176. fields = append(fields, usagetotal.FieldTotalTokens)
  25177. }
  25178. if m.addstart_index != nil {
  25179. fields = append(fields, usagetotal.FieldStartIndex)
  25180. }
  25181. if m.addend_index != nil {
  25182. fields = append(fields, usagetotal.FieldEndIndex)
  25183. }
  25184. if m.addorganization_id != nil {
  25185. fields = append(fields, usagetotal.FieldOrganizationID)
  25186. }
  25187. return fields
  25188. }
  25189. // AddedField returns the numeric value that was incremented/decremented on a field
  25190. // with the given name. The second boolean return value indicates that this field
  25191. // was not set, or was not defined in the schema.
  25192. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  25193. switch name {
  25194. case usagetotal.FieldStatus:
  25195. return m.AddedStatus()
  25196. case usagetotal.FieldType:
  25197. return m.AddedType()
  25198. case usagetotal.FieldTotalTokens:
  25199. return m.AddedTotalTokens()
  25200. case usagetotal.FieldStartIndex:
  25201. return m.AddedStartIndex()
  25202. case usagetotal.FieldEndIndex:
  25203. return m.AddedEndIndex()
  25204. case usagetotal.FieldOrganizationID:
  25205. return m.AddedOrganizationID()
  25206. }
  25207. return nil, false
  25208. }
  25209. // AddField adds the value to the field with the given name. It returns an error if
  25210. // the field is not defined in the schema, or if the type mismatched the field
  25211. // type.
  25212. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  25213. switch name {
  25214. case usagetotal.FieldStatus:
  25215. v, ok := value.(int8)
  25216. if !ok {
  25217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25218. }
  25219. m.AddStatus(v)
  25220. return nil
  25221. case usagetotal.FieldType:
  25222. v, ok := value.(int)
  25223. if !ok {
  25224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25225. }
  25226. m.AddType(v)
  25227. return nil
  25228. case usagetotal.FieldTotalTokens:
  25229. v, ok := value.(int64)
  25230. if !ok {
  25231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25232. }
  25233. m.AddTotalTokens(v)
  25234. return nil
  25235. case usagetotal.FieldStartIndex:
  25236. v, ok := value.(int64)
  25237. if !ok {
  25238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25239. }
  25240. m.AddStartIndex(v)
  25241. return nil
  25242. case usagetotal.FieldEndIndex:
  25243. v, ok := value.(int64)
  25244. if !ok {
  25245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25246. }
  25247. m.AddEndIndex(v)
  25248. return nil
  25249. case usagetotal.FieldOrganizationID:
  25250. v, ok := value.(int64)
  25251. if !ok {
  25252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25253. }
  25254. m.AddOrganizationID(v)
  25255. return nil
  25256. }
  25257. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  25258. }
  25259. // ClearedFields returns all nullable fields that were cleared during this
  25260. // mutation.
  25261. func (m *UsageTotalMutation) ClearedFields() []string {
  25262. var fields []string
  25263. if m.FieldCleared(usagetotal.FieldStatus) {
  25264. fields = append(fields, usagetotal.FieldStatus)
  25265. }
  25266. if m.FieldCleared(usagetotal.FieldType) {
  25267. fields = append(fields, usagetotal.FieldType)
  25268. }
  25269. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  25270. fields = append(fields, usagetotal.FieldTotalTokens)
  25271. }
  25272. if m.FieldCleared(usagetotal.FieldStartIndex) {
  25273. fields = append(fields, usagetotal.FieldStartIndex)
  25274. }
  25275. if m.FieldCleared(usagetotal.FieldEndIndex) {
  25276. fields = append(fields, usagetotal.FieldEndIndex)
  25277. }
  25278. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  25279. fields = append(fields, usagetotal.FieldOrganizationID)
  25280. }
  25281. return fields
  25282. }
  25283. // FieldCleared returns a boolean indicating if a field with the given name was
  25284. // cleared in this mutation.
  25285. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  25286. _, ok := m.clearedFields[name]
  25287. return ok
  25288. }
  25289. // ClearField clears the value of the field with the given name. It returns an
  25290. // error if the field is not defined in the schema.
  25291. func (m *UsageTotalMutation) ClearField(name string) error {
  25292. switch name {
  25293. case usagetotal.FieldStatus:
  25294. m.ClearStatus()
  25295. return nil
  25296. case usagetotal.FieldType:
  25297. m.ClearType()
  25298. return nil
  25299. case usagetotal.FieldTotalTokens:
  25300. m.ClearTotalTokens()
  25301. return nil
  25302. case usagetotal.FieldStartIndex:
  25303. m.ClearStartIndex()
  25304. return nil
  25305. case usagetotal.FieldEndIndex:
  25306. m.ClearEndIndex()
  25307. return nil
  25308. case usagetotal.FieldOrganizationID:
  25309. m.ClearOrganizationID()
  25310. return nil
  25311. }
  25312. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  25313. }
  25314. // ResetField resets all changes in the mutation for the field with the given name.
  25315. // It returns an error if the field is not defined in the schema.
  25316. func (m *UsageTotalMutation) ResetField(name string) error {
  25317. switch name {
  25318. case usagetotal.FieldCreatedAt:
  25319. m.ResetCreatedAt()
  25320. return nil
  25321. case usagetotal.FieldUpdatedAt:
  25322. m.ResetUpdatedAt()
  25323. return nil
  25324. case usagetotal.FieldStatus:
  25325. m.ResetStatus()
  25326. return nil
  25327. case usagetotal.FieldType:
  25328. m.ResetType()
  25329. return nil
  25330. case usagetotal.FieldBotID:
  25331. m.ResetBotID()
  25332. return nil
  25333. case usagetotal.FieldTotalTokens:
  25334. m.ResetTotalTokens()
  25335. return nil
  25336. case usagetotal.FieldStartIndex:
  25337. m.ResetStartIndex()
  25338. return nil
  25339. case usagetotal.FieldEndIndex:
  25340. m.ResetEndIndex()
  25341. return nil
  25342. case usagetotal.FieldOrganizationID:
  25343. m.ResetOrganizationID()
  25344. return nil
  25345. }
  25346. return fmt.Errorf("unknown UsageTotal field %s", name)
  25347. }
  25348. // AddedEdges returns all edge names that were set/added in this mutation.
  25349. func (m *UsageTotalMutation) AddedEdges() []string {
  25350. edges := make([]string, 0, 0)
  25351. return edges
  25352. }
  25353. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25354. // name in this mutation.
  25355. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  25356. return nil
  25357. }
  25358. // RemovedEdges returns all edge names that were removed in this mutation.
  25359. func (m *UsageTotalMutation) RemovedEdges() []string {
  25360. edges := make([]string, 0, 0)
  25361. return edges
  25362. }
  25363. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25364. // the given name in this mutation.
  25365. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  25366. return nil
  25367. }
  25368. // ClearedEdges returns all edge names that were cleared in this mutation.
  25369. func (m *UsageTotalMutation) ClearedEdges() []string {
  25370. edges := make([]string, 0, 0)
  25371. return edges
  25372. }
  25373. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25374. // was cleared in this mutation.
  25375. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  25376. return false
  25377. }
  25378. // ClearEdge clears the value of the edge with the given name. It returns an error
  25379. // if that edge is not defined in the schema.
  25380. func (m *UsageTotalMutation) ClearEdge(name string) error {
  25381. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  25382. }
  25383. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25384. // It returns an error if the edge is not defined in the schema.
  25385. func (m *UsageTotalMutation) ResetEdge(name string) error {
  25386. return fmt.Errorf("unknown UsageTotal edge %s", name)
  25387. }
  25388. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  25389. type WorkExperienceMutation struct {
  25390. config
  25391. op Op
  25392. typ string
  25393. id *uint64
  25394. created_at *time.Time
  25395. updated_at *time.Time
  25396. deleted_at *time.Time
  25397. start_date *time.Time
  25398. end_date *time.Time
  25399. company *string
  25400. experience *string
  25401. organization_id *uint64
  25402. addorganization_id *int64
  25403. clearedFields map[string]struct{}
  25404. employee *uint64
  25405. clearedemployee bool
  25406. done bool
  25407. oldValue func(context.Context) (*WorkExperience, error)
  25408. predicates []predicate.WorkExperience
  25409. }
  25410. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  25411. // workexperienceOption allows management of the mutation configuration using functional options.
  25412. type workexperienceOption func(*WorkExperienceMutation)
  25413. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  25414. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  25415. m := &WorkExperienceMutation{
  25416. config: c,
  25417. op: op,
  25418. typ: TypeWorkExperience,
  25419. clearedFields: make(map[string]struct{}),
  25420. }
  25421. for _, opt := range opts {
  25422. opt(m)
  25423. }
  25424. return m
  25425. }
  25426. // withWorkExperienceID sets the ID field of the mutation.
  25427. func withWorkExperienceID(id uint64) workexperienceOption {
  25428. return func(m *WorkExperienceMutation) {
  25429. var (
  25430. err error
  25431. once sync.Once
  25432. value *WorkExperience
  25433. )
  25434. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  25435. once.Do(func() {
  25436. if m.done {
  25437. err = errors.New("querying old values post mutation is not allowed")
  25438. } else {
  25439. value, err = m.Client().WorkExperience.Get(ctx, id)
  25440. }
  25441. })
  25442. return value, err
  25443. }
  25444. m.id = &id
  25445. }
  25446. }
  25447. // withWorkExperience sets the old WorkExperience of the mutation.
  25448. func withWorkExperience(node *WorkExperience) workexperienceOption {
  25449. return func(m *WorkExperienceMutation) {
  25450. m.oldValue = func(context.Context) (*WorkExperience, error) {
  25451. return node, nil
  25452. }
  25453. m.id = &node.ID
  25454. }
  25455. }
  25456. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25457. // executed in a transaction (ent.Tx), a transactional client is returned.
  25458. func (m WorkExperienceMutation) Client() *Client {
  25459. client := &Client{config: m.config}
  25460. client.init()
  25461. return client
  25462. }
  25463. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25464. // it returns an error otherwise.
  25465. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  25466. if _, ok := m.driver.(*txDriver); !ok {
  25467. return nil, errors.New("ent: mutation is not running in a transaction")
  25468. }
  25469. tx := &Tx{config: m.config}
  25470. tx.init()
  25471. return tx, nil
  25472. }
  25473. // SetID sets the value of the id field. Note that this
  25474. // operation is only accepted on creation of WorkExperience entities.
  25475. func (m *WorkExperienceMutation) SetID(id uint64) {
  25476. m.id = &id
  25477. }
  25478. // ID returns the ID value in the mutation. Note that the ID is only available
  25479. // if it was provided to the builder or after it was returned from the database.
  25480. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  25481. if m.id == nil {
  25482. return
  25483. }
  25484. return *m.id, true
  25485. }
  25486. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25487. // That means, if the mutation is applied within a transaction with an isolation level such
  25488. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25489. // or updated by the mutation.
  25490. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  25491. switch {
  25492. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25493. id, exists := m.ID()
  25494. if exists {
  25495. return []uint64{id}, nil
  25496. }
  25497. fallthrough
  25498. case m.op.Is(OpUpdate | OpDelete):
  25499. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  25500. default:
  25501. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25502. }
  25503. }
  25504. // SetCreatedAt sets the "created_at" field.
  25505. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  25506. m.created_at = &t
  25507. }
  25508. // CreatedAt returns the value of the "created_at" field in the mutation.
  25509. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  25510. v := m.created_at
  25511. if v == nil {
  25512. return
  25513. }
  25514. return *v, true
  25515. }
  25516. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  25517. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25519. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25520. if !m.op.Is(OpUpdateOne) {
  25521. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25522. }
  25523. if m.id == nil || m.oldValue == nil {
  25524. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25525. }
  25526. oldValue, err := m.oldValue(ctx)
  25527. if err != nil {
  25528. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25529. }
  25530. return oldValue.CreatedAt, nil
  25531. }
  25532. // ResetCreatedAt resets all changes to the "created_at" field.
  25533. func (m *WorkExperienceMutation) ResetCreatedAt() {
  25534. m.created_at = nil
  25535. }
  25536. // SetUpdatedAt sets the "updated_at" field.
  25537. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  25538. m.updated_at = &t
  25539. }
  25540. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25541. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  25542. v := m.updated_at
  25543. if v == nil {
  25544. return
  25545. }
  25546. return *v, true
  25547. }
  25548. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  25549. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25551. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25552. if !m.op.Is(OpUpdateOne) {
  25553. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25554. }
  25555. if m.id == nil || m.oldValue == nil {
  25556. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25557. }
  25558. oldValue, err := m.oldValue(ctx)
  25559. if err != nil {
  25560. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25561. }
  25562. return oldValue.UpdatedAt, nil
  25563. }
  25564. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25565. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  25566. m.updated_at = nil
  25567. }
  25568. // SetDeletedAt sets the "deleted_at" field.
  25569. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  25570. m.deleted_at = &t
  25571. }
  25572. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25573. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  25574. v := m.deleted_at
  25575. if v == nil {
  25576. return
  25577. }
  25578. return *v, true
  25579. }
  25580. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  25581. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25583. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25584. if !m.op.Is(OpUpdateOne) {
  25585. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25586. }
  25587. if m.id == nil || m.oldValue == nil {
  25588. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25589. }
  25590. oldValue, err := m.oldValue(ctx)
  25591. if err != nil {
  25592. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25593. }
  25594. return oldValue.DeletedAt, nil
  25595. }
  25596. // ClearDeletedAt clears the value of the "deleted_at" field.
  25597. func (m *WorkExperienceMutation) ClearDeletedAt() {
  25598. m.deleted_at = nil
  25599. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  25600. }
  25601. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25602. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  25603. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  25604. return ok
  25605. }
  25606. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25607. func (m *WorkExperienceMutation) ResetDeletedAt() {
  25608. m.deleted_at = nil
  25609. delete(m.clearedFields, workexperience.FieldDeletedAt)
  25610. }
  25611. // SetEmployeeID sets the "employee_id" field.
  25612. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  25613. m.employee = &u
  25614. }
  25615. // EmployeeID returns the value of the "employee_id" field in the mutation.
  25616. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  25617. v := m.employee
  25618. if v == nil {
  25619. return
  25620. }
  25621. return *v, true
  25622. }
  25623. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  25624. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25626. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  25627. if !m.op.Is(OpUpdateOne) {
  25628. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  25629. }
  25630. if m.id == nil || m.oldValue == nil {
  25631. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  25632. }
  25633. oldValue, err := m.oldValue(ctx)
  25634. if err != nil {
  25635. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  25636. }
  25637. return oldValue.EmployeeID, nil
  25638. }
  25639. // ResetEmployeeID resets all changes to the "employee_id" field.
  25640. func (m *WorkExperienceMutation) ResetEmployeeID() {
  25641. m.employee = nil
  25642. }
  25643. // SetStartDate sets the "start_date" field.
  25644. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  25645. m.start_date = &t
  25646. }
  25647. // StartDate returns the value of the "start_date" field in the mutation.
  25648. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  25649. v := m.start_date
  25650. if v == nil {
  25651. return
  25652. }
  25653. return *v, true
  25654. }
  25655. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  25656. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25658. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  25659. if !m.op.Is(OpUpdateOne) {
  25660. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  25661. }
  25662. if m.id == nil || m.oldValue == nil {
  25663. return v, errors.New("OldStartDate requires an ID field in the mutation")
  25664. }
  25665. oldValue, err := m.oldValue(ctx)
  25666. if err != nil {
  25667. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  25668. }
  25669. return oldValue.StartDate, nil
  25670. }
  25671. // ResetStartDate resets all changes to the "start_date" field.
  25672. func (m *WorkExperienceMutation) ResetStartDate() {
  25673. m.start_date = nil
  25674. }
  25675. // SetEndDate sets the "end_date" field.
  25676. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  25677. m.end_date = &t
  25678. }
  25679. // EndDate returns the value of the "end_date" field in the mutation.
  25680. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  25681. v := m.end_date
  25682. if v == nil {
  25683. return
  25684. }
  25685. return *v, true
  25686. }
  25687. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  25688. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25690. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  25691. if !m.op.Is(OpUpdateOne) {
  25692. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  25693. }
  25694. if m.id == nil || m.oldValue == nil {
  25695. return v, errors.New("OldEndDate requires an ID field in the mutation")
  25696. }
  25697. oldValue, err := m.oldValue(ctx)
  25698. if err != nil {
  25699. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  25700. }
  25701. return oldValue.EndDate, nil
  25702. }
  25703. // ResetEndDate resets all changes to the "end_date" field.
  25704. func (m *WorkExperienceMutation) ResetEndDate() {
  25705. m.end_date = nil
  25706. }
  25707. // SetCompany sets the "company" field.
  25708. func (m *WorkExperienceMutation) SetCompany(s string) {
  25709. m.company = &s
  25710. }
  25711. // Company returns the value of the "company" field in the mutation.
  25712. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  25713. v := m.company
  25714. if v == nil {
  25715. return
  25716. }
  25717. return *v, true
  25718. }
  25719. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  25720. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25722. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  25723. if !m.op.Is(OpUpdateOne) {
  25724. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  25725. }
  25726. if m.id == nil || m.oldValue == nil {
  25727. return v, errors.New("OldCompany requires an ID field in the mutation")
  25728. }
  25729. oldValue, err := m.oldValue(ctx)
  25730. if err != nil {
  25731. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  25732. }
  25733. return oldValue.Company, nil
  25734. }
  25735. // ResetCompany resets all changes to the "company" field.
  25736. func (m *WorkExperienceMutation) ResetCompany() {
  25737. m.company = nil
  25738. }
  25739. // SetExperience sets the "experience" field.
  25740. func (m *WorkExperienceMutation) SetExperience(s string) {
  25741. m.experience = &s
  25742. }
  25743. // Experience returns the value of the "experience" field in the mutation.
  25744. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  25745. v := m.experience
  25746. if v == nil {
  25747. return
  25748. }
  25749. return *v, true
  25750. }
  25751. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  25752. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25754. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  25755. if !m.op.Is(OpUpdateOne) {
  25756. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  25757. }
  25758. if m.id == nil || m.oldValue == nil {
  25759. return v, errors.New("OldExperience requires an ID field in the mutation")
  25760. }
  25761. oldValue, err := m.oldValue(ctx)
  25762. if err != nil {
  25763. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  25764. }
  25765. return oldValue.Experience, nil
  25766. }
  25767. // ResetExperience resets all changes to the "experience" field.
  25768. func (m *WorkExperienceMutation) ResetExperience() {
  25769. m.experience = nil
  25770. }
  25771. // SetOrganizationID sets the "organization_id" field.
  25772. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  25773. m.organization_id = &u
  25774. m.addorganization_id = nil
  25775. }
  25776. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25777. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  25778. v := m.organization_id
  25779. if v == nil {
  25780. return
  25781. }
  25782. return *v, true
  25783. }
  25784. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  25785. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25787. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25788. if !m.op.Is(OpUpdateOne) {
  25789. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25790. }
  25791. if m.id == nil || m.oldValue == nil {
  25792. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25793. }
  25794. oldValue, err := m.oldValue(ctx)
  25795. if err != nil {
  25796. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25797. }
  25798. return oldValue.OrganizationID, nil
  25799. }
  25800. // AddOrganizationID adds u to the "organization_id" field.
  25801. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  25802. if m.addorganization_id != nil {
  25803. *m.addorganization_id += u
  25804. } else {
  25805. m.addorganization_id = &u
  25806. }
  25807. }
  25808. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25809. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  25810. v := m.addorganization_id
  25811. if v == nil {
  25812. return
  25813. }
  25814. return *v, true
  25815. }
  25816. // ResetOrganizationID resets all changes to the "organization_id" field.
  25817. func (m *WorkExperienceMutation) ResetOrganizationID() {
  25818. m.organization_id = nil
  25819. m.addorganization_id = nil
  25820. }
  25821. // ClearEmployee clears the "employee" edge to the Employee entity.
  25822. func (m *WorkExperienceMutation) ClearEmployee() {
  25823. m.clearedemployee = true
  25824. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  25825. }
  25826. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  25827. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  25828. return m.clearedemployee
  25829. }
  25830. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  25831. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25832. // EmployeeID instead. It exists only for internal usage by the builders.
  25833. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  25834. if id := m.employee; id != nil {
  25835. ids = append(ids, *id)
  25836. }
  25837. return
  25838. }
  25839. // ResetEmployee resets all changes to the "employee" edge.
  25840. func (m *WorkExperienceMutation) ResetEmployee() {
  25841. m.employee = nil
  25842. m.clearedemployee = false
  25843. }
  25844. // Where appends a list predicates to the WorkExperienceMutation builder.
  25845. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  25846. m.predicates = append(m.predicates, ps...)
  25847. }
  25848. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  25849. // users can use type-assertion to append predicates that do not depend on any generated package.
  25850. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  25851. p := make([]predicate.WorkExperience, len(ps))
  25852. for i := range ps {
  25853. p[i] = ps[i]
  25854. }
  25855. m.Where(p...)
  25856. }
  25857. // Op returns the operation name.
  25858. func (m *WorkExperienceMutation) Op() Op {
  25859. return m.op
  25860. }
  25861. // SetOp allows setting the mutation operation.
  25862. func (m *WorkExperienceMutation) SetOp(op Op) {
  25863. m.op = op
  25864. }
  25865. // Type returns the node type of this mutation (WorkExperience).
  25866. func (m *WorkExperienceMutation) Type() string {
  25867. return m.typ
  25868. }
  25869. // Fields returns all fields that were changed during this mutation. Note that in
  25870. // order to get all numeric fields that were incremented/decremented, call
  25871. // AddedFields().
  25872. func (m *WorkExperienceMutation) Fields() []string {
  25873. fields := make([]string, 0, 9)
  25874. if m.created_at != nil {
  25875. fields = append(fields, workexperience.FieldCreatedAt)
  25876. }
  25877. if m.updated_at != nil {
  25878. fields = append(fields, workexperience.FieldUpdatedAt)
  25879. }
  25880. if m.deleted_at != nil {
  25881. fields = append(fields, workexperience.FieldDeletedAt)
  25882. }
  25883. if m.employee != nil {
  25884. fields = append(fields, workexperience.FieldEmployeeID)
  25885. }
  25886. if m.start_date != nil {
  25887. fields = append(fields, workexperience.FieldStartDate)
  25888. }
  25889. if m.end_date != nil {
  25890. fields = append(fields, workexperience.FieldEndDate)
  25891. }
  25892. if m.company != nil {
  25893. fields = append(fields, workexperience.FieldCompany)
  25894. }
  25895. if m.experience != nil {
  25896. fields = append(fields, workexperience.FieldExperience)
  25897. }
  25898. if m.organization_id != nil {
  25899. fields = append(fields, workexperience.FieldOrganizationID)
  25900. }
  25901. return fields
  25902. }
  25903. // Field returns the value of a field with the given name. The second boolean
  25904. // return value indicates that this field was not set, or was not defined in the
  25905. // schema.
  25906. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  25907. switch name {
  25908. case workexperience.FieldCreatedAt:
  25909. return m.CreatedAt()
  25910. case workexperience.FieldUpdatedAt:
  25911. return m.UpdatedAt()
  25912. case workexperience.FieldDeletedAt:
  25913. return m.DeletedAt()
  25914. case workexperience.FieldEmployeeID:
  25915. return m.EmployeeID()
  25916. case workexperience.FieldStartDate:
  25917. return m.StartDate()
  25918. case workexperience.FieldEndDate:
  25919. return m.EndDate()
  25920. case workexperience.FieldCompany:
  25921. return m.Company()
  25922. case workexperience.FieldExperience:
  25923. return m.Experience()
  25924. case workexperience.FieldOrganizationID:
  25925. return m.OrganizationID()
  25926. }
  25927. return nil, false
  25928. }
  25929. // OldField returns the old value of the field from the database. An error is
  25930. // returned if the mutation operation is not UpdateOne, or the query to the
  25931. // database failed.
  25932. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25933. switch name {
  25934. case workexperience.FieldCreatedAt:
  25935. return m.OldCreatedAt(ctx)
  25936. case workexperience.FieldUpdatedAt:
  25937. return m.OldUpdatedAt(ctx)
  25938. case workexperience.FieldDeletedAt:
  25939. return m.OldDeletedAt(ctx)
  25940. case workexperience.FieldEmployeeID:
  25941. return m.OldEmployeeID(ctx)
  25942. case workexperience.FieldStartDate:
  25943. return m.OldStartDate(ctx)
  25944. case workexperience.FieldEndDate:
  25945. return m.OldEndDate(ctx)
  25946. case workexperience.FieldCompany:
  25947. return m.OldCompany(ctx)
  25948. case workexperience.FieldExperience:
  25949. return m.OldExperience(ctx)
  25950. case workexperience.FieldOrganizationID:
  25951. return m.OldOrganizationID(ctx)
  25952. }
  25953. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  25954. }
  25955. // SetField sets the value of a field with the given name. It returns an error if
  25956. // the field is not defined in the schema, or if the type mismatched the field
  25957. // type.
  25958. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  25959. switch name {
  25960. case workexperience.FieldCreatedAt:
  25961. v, ok := value.(time.Time)
  25962. if !ok {
  25963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25964. }
  25965. m.SetCreatedAt(v)
  25966. return nil
  25967. case workexperience.FieldUpdatedAt:
  25968. v, ok := value.(time.Time)
  25969. if !ok {
  25970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25971. }
  25972. m.SetUpdatedAt(v)
  25973. return nil
  25974. case workexperience.FieldDeletedAt:
  25975. v, ok := value.(time.Time)
  25976. if !ok {
  25977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25978. }
  25979. m.SetDeletedAt(v)
  25980. return nil
  25981. case workexperience.FieldEmployeeID:
  25982. v, ok := value.(uint64)
  25983. if !ok {
  25984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25985. }
  25986. m.SetEmployeeID(v)
  25987. return nil
  25988. case workexperience.FieldStartDate:
  25989. v, ok := value.(time.Time)
  25990. if !ok {
  25991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25992. }
  25993. m.SetStartDate(v)
  25994. return nil
  25995. case workexperience.FieldEndDate:
  25996. v, ok := value.(time.Time)
  25997. if !ok {
  25998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25999. }
  26000. m.SetEndDate(v)
  26001. return nil
  26002. case workexperience.FieldCompany:
  26003. v, ok := value.(string)
  26004. if !ok {
  26005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26006. }
  26007. m.SetCompany(v)
  26008. return nil
  26009. case workexperience.FieldExperience:
  26010. v, ok := value.(string)
  26011. if !ok {
  26012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26013. }
  26014. m.SetExperience(v)
  26015. return nil
  26016. case workexperience.FieldOrganizationID:
  26017. v, ok := value.(uint64)
  26018. if !ok {
  26019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26020. }
  26021. m.SetOrganizationID(v)
  26022. return nil
  26023. }
  26024. return fmt.Errorf("unknown WorkExperience field %s", name)
  26025. }
  26026. // AddedFields returns all numeric fields that were incremented/decremented during
  26027. // this mutation.
  26028. func (m *WorkExperienceMutation) AddedFields() []string {
  26029. var fields []string
  26030. if m.addorganization_id != nil {
  26031. fields = append(fields, workexperience.FieldOrganizationID)
  26032. }
  26033. return fields
  26034. }
  26035. // AddedField returns the numeric value that was incremented/decremented on a field
  26036. // with the given name. The second boolean return value indicates that this field
  26037. // was not set, or was not defined in the schema.
  26038. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  26039. switch name {
  26040. case workexperience.FieldOrganizationID:
  26041. return m.AddedOrganizationID()
  26042. }
  26043. return nil, false
  26044. }
  26045. // AddField adds the value to the field with the given name. It returns an error if
  26046. // the field is not defined in the schema, or if the type mismatched the field
  26047. // type.
  26048. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  26049. switch name {
  26050. case workexperience.FieldOrganizationID:
  26051. v, ok := value.(int64)
  26052. if !ok {
  26053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26054. }
  26055. m.AddOrganizationID(v)
  26056. return nil
  26057. }
  26058. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  26059. }
  26060. // ClearedFields returns all nullable fields that were cleared during this
  26061. // mutation.
  26062. func (m *WorkExperienceMutation) ClearedFields() []string {
  26063. var fields []string
  26064. if m.FieldCleared(workexperience.FieldDeletedAt) {
  26065. fields = append(fields, workexperience.FieldDeletedAt)
  26066. }
  26067. return fields
  26068. }
  26069. // FieldCleared returns a boolean indicating if a field with the given name was
  26070. // cleared in this mutation.
  26071. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  26072. _, ok := m.clearedFields[name]
  26073. return ok
  26074. }
  26075. // ClearField clears the value of the field with the given name. It returns an
  26076. // error if the field is not defined in the schema.
  26077. func (m *WorkExperienceMutation) ClearField(name string) error {
  26078. switch name {
  26079. case workexperience.FieldDeletedAt:
  26080. m.ClearDeletedAt()
  26081. return nil
  26082. }
  26083. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  26084. }
  26085. // ResetField resets all changes in the mutation for the field with the given name.
  26086. // It returns an error if the field is not defined in the schema.
  26087. func (m *WorkExperienceMutation) ResetField(name string) error {
  26088. switch name {
  26089. case workexperience.FieldCreatedAt:
  26090. m.ResetCreatedAt()
  26091. return nil
  26092. case workexperience.FieldUpdatedAt:
  26093. m.ResetUpdatedAt()
  26094. return nil
  26095. case workexperience.FieldDeletedAt:
  26096. m.ResetDeletedAt()
  26097. return nil
  26098. case workexperience.FieldEmployeeID:
  26099. m.ResetEmployeeID()
  26100. return nil
  26101. case workexperience.FieldStartDate:
  26102. m.ResetStartDate()
  26103. return nil
  26104. case workexperience.FieldEndDate:
  26105. m.ResetEndDate()
  26106. return nil
  26107. case workexperience.FieldCompany:
  26108. m.ResetCompany()
  26109. return nil
  26110. case workexperience.FieldExperience:
  26111. m.ResetExperience()
  26112. return nil
  26113. case workexperience.FieldOrganizationID:
  26114. m.ResetOrganizationID()
  26115. return nil
  26116. }
  26117. return fmt.Errorf("unknown WorkExperience field %s", name)
  26118. }
  26119. // AddedEdges returns all edge names that were set/added in this mutation.
  26120. func (m *WorkExperienceMutation) AddedEdges() []string {
  26121. edges := make([]string, 0, 1)
  26122. if m.employee != nil {
  26123. edges = append(edges, workexperience.EdgeEmployee)
  26124. }
  26125. return edges
  26126. }
  26127. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26128. // name in this mutation.
  26129. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  26130. switch name {
  26131. case workexperience.EdgeEmployee:
  26132. if id := m.employee; id != nil {
  26133. return []ent.Value{*id}
  26134. }
  26135. }
  26136. return nil
  26137. }
  26138. // RemovedEdges returns all edge names that were removed in this mutation.
  26139. func (m *WorkExperienceMutation) RemovedEdges() []string {
  26140. edges := make([]string, 0, 1)
  26141. return edges
  26142. }
  26143. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26144. // the given name in this mutation.
  26145. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  26146. return nil
  26147. }
  26148. // ClearedEdges returns all edge names that were cleared in this mutation.
  26149. func (m *WorkExperienceMutation) ClearedEdges() []string {
  26150. edges := make([]string, 0, 1)
  26151. if m.clearedemployee {
  26152. edges = append(edges, workexperience.EdgeEmployee)
  26153. }
  26154. return edges
  26155. }
  26156. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26157. // was cleared in this mutation.
  26158. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  26159. switch name {
  26160. case workexperience.EdgeEmployee:
  26161. return m.clearedemployee
  26162. }
  26163. return false
  26164. }
  26165. // ClearEdge clears the value of the edge with the given name. It returns an error
  26166. // if that edge is not defined in the schema.
  26167. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  26168. switch name {
  26169. case workexperience.EdgeEmployee:
  26170. m.ClearEmployee()
  26171. return nil
  26172. }
  26173. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  26174. }
  26175. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26176. // It returns an error if the edge is not defined in the schema.
  26177. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  26178. switch name {
  26179. case workexperience.EdgeEmployee:
  26180. m.ResetEmployee()
  26181. return nil
  26182. }
  26183. return fmt.Errorf("unknown WorkExperience edge %s", name)
  26184. }
  26185. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  26186. type WpChatroomMutation struct {
  26187. config
  26188. op Op
  26189. typ string
  26190. id *uint64
  26191. created_at *time.Time
  26192. updated_at *time.Time
  26193. status *uint8
  26194. addstatus *int8
  26195. wx_wxid *string
  26196. chatroom_id *string
  26197. nickname *string
  26198. owner *string
  26199. avatar *string
  26200. member_list *[]string
  26201. appendmember_list []string
  26202. clearedFields map[string]struct{}
  26203. done bool
  26204. oldValue func(context.Context) (*WpChatroom, error)
  26205. predicates []predicate.WpChatroom
  26206. }
  26207. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  26208. // wpchatroomOption allows management of the mutation configuration using functional options.
  26209. type wpchatroomOption func(*WpChatroomMutation)
  26210. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  26211. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  26212. m := &WpChatroomMutation{
  26213. config: c,
  26214. op: op,
  26215. typ: TypeWpChatroom,
  26216. clearedFields: make(map[string]struct{}),
  26217. }
  26218. for _, opt := range opts {
  26219. opt(m)
  26220. }
  26221. return m
  26222. }
  26223. // withWpChatroomID sets the ID field of the mutation.
  26224. func withWpChatroomID(id uint64) wpchatroomOption {
  26225. return func(m *WpChatroomMutation) {
  26226. var (
  26227. err error
  26228. once sync.Once
  26229. value *WpChatroom
  26230. )
  26231. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  26232. once.Do(func() {
  26233. if m.done {
  26234. err = errors.New("querying old values post mutation is not allowed")
  26235. } else {
  26236. value, err = m.Client().WpChatroom.Get(ctx, id)
  26237. }
  26238. })
  26239. return value, err
  26240. }
  26241. m.id = &id
  26242. }
  26243. }
  26244. // withWpChatroom sets the old WpChatroom of the mutation.
  26245. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  26246. return func(m *WpChatroomMutation) {
  26247. m.oldValue = func(context.Context) (*WpChatroom, error) {
  26248. return node, nil
  26249. }
  26250. m.id = &node.ID
  26251. }
  26252. }
  26253. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26254. // executed in a transaction (ent.Tx), a transactional client is returned.
  26255. func (m WpChatroomMutation) Client() *Client {
  26256. client := &Client{config: m.config}
  26257. client.init()
  26258. return client
  26259. }
  26260. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26261. // it returns an error otherwise.
  26262. func (m WpChatroomMutation) Tx() (*Tx, error) {
  26263. if _, ok := m.driver.(*txDriver); !ok {
  26264. return nil, errors.New("ent: mutation is not running in a transaction")
  26265. }
  26266. tx := &Tx{config: m.config}
  26267. tx.init()
  26268. return tx, nil
  26269. }
  26270. // SetID sets the value of the id field. Note that this
  26271. // operation is only accepted on creation of WpChatroom entities.
  26272. func (m *WpChatroomMutation) SetID(id uint64) {
  26273. m.id = &id
  26274. }
  26275. // ID returns the ID value in the mutation. Note that the ID is only available
  26276. // if it was provided to the builder or after it was returned from the database.
  26277. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  26278. if m.id == nil {
  26279. return
  26280. }
  26281. return *m.id, true
  26282. }
  26283. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26284. // That means, if the mutation is applied within a transaction with an isolation level such
  26285. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26286. // or updated by the mutation.
  26287. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  26288. switch {
  26289. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26290. id, exists := m.ID()
  26291. if exists {
  26292. return []uint64{id}, nil
  26293. }
  26294. fallthrough
  26295. case m.op.Is(OpUpdate | OpDelete):
  26296. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  26297. default:
  26298. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26299. }
  26300. }
  26301. // SetCreatedAt sets the "created_at" field.
  26302. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  26303. m.created_at = &t
  26304. }
  26305. // CreatedAt returns the value of the "created_at" field in the mutation.
  26306. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  26307. v := m.created_at
  26308. if v == nil {
  26309. return
  26310. }
  26311. return *v, true
  26312. }
  26313. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  26314. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26316. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26317. if !m.op.Is(OpUpdateOne) {
  26318. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26319. }
  26320. if m.id == nil || m.oldValue == nil {
  26321. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26322. }
  26323. oldValue, err := m.oldValue(ctx)
  26324. if err != nil {
  26325. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26326. }
  26327. return oldValue.CreatedAt, nil
  26328. }
  26329. // ResetCreatedAt resets all changes to the "created_at" field.
  26330. func (m *WpChatroomMutation) ResetCreatedAt() {
  26331. m.created_at = nil
  26332. }
  26333. // SetUpdatedAt sets the "updated_at" field.
  26334. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  26335. m.updated_at = &t
  26336. }
  26337. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26338. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  26339. v := m.updated_at
  26340. if v == nil {
  26341. return
  26342. }
  26343. return *v, true
  26344. }
  26345. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  26346. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26348. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26349. if !m.op.Is(OpUpdateOne) {
  26350. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26351. }
  26352. if m.id == nil || m.oldValue == nil {
  26353. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26354. }
  26355. oldValue, err := m.oldValue(ctx)
  26356. if err != nil {
  26357. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26358. }
  26359. return oldValue.UpdatedAt, nil
  26360. }
  26361. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26362. func (m *WpChatroomMutation) ResetUpdatedAt() {
  26363. m.updated_at = nil
  26364. }
  26365. // SetStatus sets the "status" field.
  26366. func (m *WpChatroomMutation) SetStatus(u uint8) {
  26367. m.status = &u
  26368. m.addstatus = nil
  26369. }
  26370. // Status returns the value of the "status" field in the mutation.
  26371. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  26372. v := m.status
  26373. if v == nil {
  26374. return
  26375. }
  26376. return *v, true
  26377. }
  26378. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  26379. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26381. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26382. if !m.op.Is(OpUpdateOne) {
  26383. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26384. }
  26385. if m.id == nil || m.oldValue == nil {
  26386. return v, errors.New("OldStatus requires an ID field in the mutation")
  26387. }
  26388. oldValue, err := m.oldValue(ctx)
  26389. if err != nil {
  26390. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26391. }
  26392. return oldValue.Status, nil
  26393. }
  26394. // AddStatus adds u to the "status" field.
  26395. func (m *WpChatroomMutation) AddStatus(u int8) {
  26396. if m.addstatus != nil {
  26397. *m.addstatus += u
  26398. } else {
  26399. m.addstatus = &u
  26400. }
  26401. }
  26402. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26403. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  26404. v := m.addstatus
  26405. if v == nil {
  26406. return
  26407. }
  26408. return *v, true
  26409. }
  26410. // ClearStatus clears the value of the "status" field.
  26411. func (m *WpChatroomMutation) ClearStatus() {
  26412. m.status = nil
  26413. m.addstatus = nil
  26414. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  26415. }
  26416. // StatusCleared returns if the "status" field was cleared in this mutation.
  26417. func (m *WpChatroomMutation) StatusCleared() bool {
  26418. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  26419. return ok
  26420. }
  26421. // ResetStatus resets all changes to the "status" field.
  26422. func (m *WpChatroomMutation) ResetStatus() {
  26423. m.status = nil
  26424. m.addstatus = nil
  26425. delete(m.clearedFields, wpchatroom.FieldStatus)
  26426. }
  26427. // SetWxWxid sets the "wx_wxid" field.
  26428. func (m *WpChatroomMutation) SetWxWxid(s string) {
  26429. m.wx_wxid = &s
  26430. }
  26431. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  26432. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  26433. v := m.wx_wxid
  26434. if v == nil {
  26435. return
  26436. }
  26437. return *v, true
  26438. }
  26439. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  26440. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26442. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  26443. if !m.op.Is(OpUpdateOne) {
  26444. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  26445. }
  26446. if m.id == nil || m.oldValue == nil {
  26447. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  26448. }
  26449. oldValue, err := m.oldValue(ctx)
  26450. if err != nil {
  26451. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  26452. }
  26453. return oldValue.WxWxid, nil
  26454. }
  26455. // ResetWxWxid resets all changes to the "wx_wxid" field.
  26456. func (m *WpChatroomMutation) ResetWxWxid() {
  26457. m.wx_wxid = nil
  26458. }
  26459. // SetChatroomID sets the "chatroom_id" field.
  26460. func (m *WpChatroomMutation) SetChatroomID(s string) {
  26461. m.chatroom_id = &s
  26462. }
  26463. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  26464. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  26465. v := m.chatroom_id
  26466. if v == nil {
  26467. return
  26468. }
  26469. return *v, true
  26470. }
  26471. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  26472. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26474. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  26475. if !m.op.Is(OpUpdateOne) {
  26476. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  26477. }
  26478. if m.id == nil || m.oldValue == nil {
  26479. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  26480. }
  26481. oldValue, err := m.oldValue(ctx)
  26482. if err != nil {
  26483. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  26484. }
  26485. return oldValue.ChatroomID, nil
  26486. }
  26487. // ResetChatroomID resets all changes to the "chatroom_id" field.
  26488. func (m *WpChatroomMutation) ResetChatroomID() {
  26489. m.chatroom_id = nil
  26490. }
  26491. // SetNickname sets the "nickname" field.
  26492. func (m *WpChatroomMutation) SetNickname(s string) {
  26493. m.nickname = &s
  26494. }
  26495. // Nickname returns the value of the "nickname" field in the mutation.
  26496. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  26497. v := m.nickname
  26498. if v == nil {
  26499. return
  26500. }
  26501. return *v, true
  26502. }
  26503. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  26504. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26506. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  26507. if !m.op.Is(OpUpdateOne) {
  26508. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  26509. }
  26510. if m.id == nil || m.oldValue == nil {
  26511. return v, errors.New("OldNickname requires an ID field in the mutation")
  26512. }
  26513. oldValue, err := m.oldValue(ctx)
  26514. if err != nil {
  26515. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  26516. }
  26517. return oldValue.Nickname, nil
  26518. }
  26519. // ResetNickname resets all changes to the "nickname" field.
  26520. func (m *WpChatroomMutation) ResetNickname() {
  26521. m.nickname = nil
  26522. }
  26523. // SetOwner sets the "owner" field.
  26524. func (m *WpChatroomMutation) SetOwner(s string) {
  26525. m.owner = &s
  26526. }
  26527. // Owner returns the value of the "owner" field in the mutation.
  26528. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  26529. v := m.owner
  26530. if v == nil {
  26531. return
  26532. }
  26533. return *v, true
  26534. }
  26535. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  26536. // If the WpChatroom 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 *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  26539. if !m.op.Is(OpUpdateOne) {
  26540. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  26541. }
  26542. if m.id == nil || m.oldValue == nil {
  26543. return v, errors.New("OldOwner 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 OldOwner: %w", err)
  26548. }
  26549. return oldValue.Owner, nil
  26550. }
  26551. // ResetOwner resets all changes to the "owner" field.
  26552. func (m *WpChatroomMutation) ResetOwner() {
  26553. m.owner = nil
  26554. }
  26555. // SetAvatar sets the "avatar" field.
  26556. func (m *WpChatroomMutation) SetAvatar(s string) {
  26557. m.avatar = &s
  26558. }
  26559. // Avatar returns the value of the "avatar" field in the mutation.
  26560. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  26561. v := m.avatar
  26562. if v == nil {
  26563. return
  26564. }
  26565. return *v, true
  26566. }
  26567. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  26568. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26570. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  26571. if !m.op.Is(OpUpdateOne) {
  26572. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  26573. }
  26574. if m.id == nil || m.oldValue == nil {
  26575. return v, errors.New("OldAvatar requires an ID field in the mutation")
  26576. }
  26577. oldValue, err := m.oldValue(ctx)
  26578. if err != nil {
  26579. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  26580. }
  26581. return oldValue.Avatar, nil
  26582. }
  26583. // ResetAvatar resets all changes to the "avatar" field.
  26584. func (m *WpChatroomMutation) ResetAvatar() {
  26585. m.avatar = nil
  26586. }
  26587. // SetMemberList sets the "member_list" field.
  26588. func (m *WpChatroomMutation) SetMemberList(s []string) {
  26589. m.member_list = &s
  26590. m.appendmember_list = nil
  26591. }
  26592. // MemberList returns the value of the "member_list" field in the mutation.
  26593. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  26594. v := m.member_list
  26595. if v == nil {
  26596. return
  26597. }
  26598. return *v, true
  26599. }
  26600. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  26601. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  26602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26603. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  26604. if !m.op.Is(OpUpdateOne) {
  26605. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  26606. }
  26607. if m.id == nil || m.oldValue == nil {
  26608. return v, errors.New("OldMemberList requires an ID field in the mutation")
  26609. }
  26610. oldValue, err := m.oldValue(ctx)
  26611. if err != nil {
  26612. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  26613. }
  26614. return oldValue.MemberList, nil
  26615. }
  26616. // AppendMemberList adds s to the "member_list" field.
  26617. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  26618. m.appendmember_list = append(m.appendmember_list, s...)
  26619. }
  26620. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  26621. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  26622. if len(m.appendmember_list) == 0 {
  26623. return nil, false
  26624. }
  26625. return m.appendmember_list, true
  26626. }
  26627. // ResetMemberList resets all changes to the "member_list" field.
  26628. func (m *WpChatroomMutation) ResetMemberList() {
  26629. m.member_list = nil
  26630. m.appendmember_list = nil
  26631. }
  26632. // Where appends a list predicates to the WpChatroomMutation builder.
  26633. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  26634. m.predicates = append(m.predicates, ps...)
  26635. }
  26636. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  26637. // users can use type-assertion to append predicates that do not depend on any generated package.
  26638. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  26639. p := make([]predicate.WpChatroom, len(ps))
  26640. for i := range ps {
  26641. p[i] = ps[i]
  26642. }
  26643. m.Where(p...)
  26644. }
  26645. // Op returns the operation name.
  26646. func (m *WpChatroomMutation) Op() Op {
  26647. return m.op
  26648. }
  26649. // SetOp allows setting the mutation operation.
  26650. func (m *WpChatroomMutation) SetOp(op Op) {
  26651. m.op = op
  26652. }
  26653. // Type returns the node type of this mutation (WpChatroom).
  26654. func (m *WpChatroomMutation) Type() string {
  26655. return m.typ
  26656. }
  26657. // Fields returns all fields that were changed during this mutation. Note that in
  26658. // order to get all numeric fields that were incremented/decremented, call
  26659. // AddedFields().
  26660. func (m *WpChatroomMutation) Fields() []string {
  26661. fields := make([]string, 0, 9)
  26662. if m.created_at != nil {
  26663. fields = append(fields, wpchatroom.FieldCreatedAt)
  26664. }
  26665. if m.updated_at != nil {
  26666. fields = append(fields, wpchatroom.FieldUpdatedAt)
  26667. }
  26668. if m.status != nil {
  26669. fields = append(fields, wpchatroom.FieldStatus)
  26670. }
  26671. if m.wx_wxid != nil {
  26672. fields = append(fields, wpchatroom.FieldWxWxid)
  26673. }
  26674. if m.chatroom_id != nil {
  26675. fields = append(fields, wpchatroom.FieldChatroomID)
  26676. }
  26677. if m.nickname != nil {
  26678. fields = append(fields, wpchatroom.FieldNickname)
  26679. }
  26680. if m.owner != nil {
  26681. fields = append(fields, wpchatroom.FieldOwner)
  26682. }
  26683. if m.avatar != nil {
  26684. fields = append(fields, wpchatroom.FieldAvatar)
  26685. }
  26686. if m.member_list != nil {
  26687. fields = append(fields, wpchatroom.FieldMemberList)
  26688. }
  26689. return fields
  26690. }
  26691. // Field returns the value of a field with the given name. The second boolean
  26692. // return value indicates that this field was not set, or was not defined in the
  26693. // schema.
  26694. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  26695. switch name {
  26696. case wpchatroom.FieldCreatedAt:
  26697. return m.CreatedAt()
  26698. case wpchatroom.FieldUpdatedAt:
  26699. return m.UpdatedAt()
  26700. case wpchatroom.FieldStatus:
  26701. return m.Status()
  26702. case wpchatroom.FieldWxWxid:
  26703. return m.WxWxid()
  26704. case wpchatroom.FieldChatroomID:
  26705. return m.ChatroomID()
  26706. case wpchatroom.FieldNickname:
  26707. return m.Nickname()
  26708. case wpchatroom.FieldOwner:
  26709. return m.Owner()
  26710. case wpchatroom.FieldAvatar:
  26711. return m.Avatar()
  26712. case wpchatroom.FieldMemberList:
  26713. return m.MemberList()
  26714. }
  26715. return nil, false
  26716. }
  26717. // OldField returns the old value of the field from the database. An error is
  26718. // returned if the mutation operation is not UpdateOne, or the query to the
  26719. // database failed.
  26720. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26721. switch name {
  26722. case wpchatroom.FieldCreatedAt:
  26723. return m.OldCreatedAt(ctx)
  26724. case wpchatroom.FieldUpdatedAt:
  26725. return m.OldUpdatedAt(ctx)
  26726. case wpchatroom.FieldStatus:
  26727. return m.OldStatus(ctx)
  26728. case wpchatroom.FieldWxWxid:
  26729. return m.OldWxWxid(ctx)
  26730. case wpchatroom.FieldChatroomID:
  26731. return m.OldChatroomID(ctx)
  26732. case wpchatroom.FieldNickname:
  26733. return m.OldNickname(ctx)
  26734. case wpchatroom.FieldOwner:
  26735. return m.OldOwner(ctx)
  26736. case wpchatroom.FieldAvatar:
  26737. return m.OldAvatar(ctx)
  26738. case wpchatroom.FieldMemberList:
  26739. return m.OldMemberList(ctx)
  26740. }
  26741. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  26742. }
  26743. // SetField sets the value of a field with the given name. It returns an error if
  26744. // the field is not defined in the schema, or if the type mismatched the field
  26745. // type.
  26746. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  26747. switch name {
  26748. case wpchatroom.FieldCreatedAt:
  26749. v, ok := value.(time.Time)
  26750. if !ok {
  26751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26752. }
  26753. m.SetCreatedAt(v)
  26754. return nil
  26755. case wpchatroom.FieldUpdatedAt:
  26756. v, ok := value.(time.Time)
  26757. if !ok {
  26758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26759. }
  26760. m.SetUpdatedAt(v)
  26761. return nil
  26762. case wpchatroom.FieldStatus:
  26763. v, ok := value.(uint8)
  26764. if !ok {
  26765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26766. }
  26767. m.SetStatus(v)
  26768. return nil
  26769. case wpchatroom.FieldWxWxid:
  26770. v, ok := value.(string)
  26771. if !ok {
  26772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26773. }
  26774. m.SetWxWxid(v)
  26775. return nil
  26776. case wpchatroom.FieldChatroomID:
  26777. v, ok := value.(string)
  26778. if !ok {
  26779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26780. }
  26781. m.SetChatroomID(v)
  26782. return nil
  26783. case wpchatroom.FieldNickname:
  26784. v, ok := value.(string)
  26785. if !ok {
  26786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26787. }
  26788. m.SetNickname(v)
  26789. return nil
  26790. case wpchatroom.FieldOwner:
  26791. v, ok := value.(string)
  26792. if !ok {
  26793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26794. }
  26795. m.SetOwner(v)
  26796. return nil
  26797. case wpchatroom.FieldAvatar:
  26798. v, ok := value.(string)
  26799. if !ok {
  26800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26801. }
  26802. m.SetAvatar(v)
  26803. return nil
  26804. case wpchatroom.FieldMemberList:
  26805. v, ok := value.([]string)
  26806. if !ok {
  26807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26808. }
  26809. m.SetMemberList(v)
  26810. return nil
  26811. }
  26812. return fmt.Errorf("unknown WpChatroom field %s", name)
  26813. }
  26814. // AddedFields returns all numeric fields that were incremented/decremented during
  26815. // this mutation.
  26816. func (m *WpChatroomMutation) AddedFields() []string {
  26817. var fields []string
  26818. if m.addstatus != nil {
  26819. fields = append(fields, wpchatroom.FieldStatus)
  26820. }
  26821. return fields
  26822. }
  26823. // AddedField returns the numeric value that was incremented/decremented on a field
  26824. // with the given name. The second boolean return value indicates that this field
  26825. // was not set, or was not defined in the schema.
  26826. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  26827. switch name {
  26828. case wpchatroom.FieldStatus:
  26829. return m.AddedStatus()
  26830. }
  26831. return nil, false
  26832. }
  26833. // AddField adds the value to the field with the given name. It returns an error if
  26834. // the field is not defined in the schema, or if the type mismatched the field
  26835. // type.
  26836. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  26837. switch name {
  26838. case wpchatroom.FieldStatus:
  26839. v, ok := value.(int8)
  26840. if !ok {
  26841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26842. }
  26843. m.AddStatus(v)
  26844. return nil
  26845. }
  26846. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  26847. }
  26848. // ClearedFields returns all nullable fields that were cleared during this
  26849. // mutation.
  26850. func (m *WpChatroomMutation) ClearedFields() []string {
  26851. var fields []string
  26852. if m.FieldCleared(wpchatroom.FieldStatus) {
  26853. fields = append(fields, wpchatroom.FieldStatus)
  26854. }
  26855. return fields
  26856. }
  26857. // FieldCleared returns a boolean indicating if a field with the given name was
  26858. // cleared in this mutation.
  26859. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  26860. _, ok := m.clearedFields[name]
  26861. return ok
  26862. }
  26863. // ClearField clears the value of the field with the given name. It returns an
  26864. // error if the field is not defined in the schema.
  26865. func (m *WpChatroomMutation) ClearField(name string) error {
  26866. switch name {
  26867. case wpchatroom.FieldStatus:
  26868. m.ClearStatus()
  26869. return nil
  26870. }
  26871. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  26872. }
  26873. // ResetField resets all changes in the mutation for the field with the given name.
  26874. // It returns an error if the field is not defined in the schema.
  26875. func (m *WpChatroomMutation) ResetField(name string) error {
  26876. switch name {
  26877. case wpchatroom.FieldCreatedAt:
  26878. m.ResetCreatedAt()
  26879. return nil
  26880. case wpchatroom.FieldUpdatedAt:
  26881. m.ResetUpdatedAt()
  26882. return nil
  26883. case wpchatroom.FieldStatus:
  26884. m.ResetStatus()
  26885. return nil
  26886. case wpchatroom.FieldWxWxid:
  26887. m.ResetWxWxid()
  26888. return nil
  26889. case wpchatroom.FieldChatroomID:
  26890. m.ResetChatroomID()
  26891. return nil
  26892. case wpchatroom.FieldNickname:
  26893. m.ResetNickname()
  26894. return nil
  26895. case wpchatroom.FieldOwner:
  26896. m.ResetOwner()
  26897. return nil
  26898. case wpchatroom.FieldAvatar:
  26899. m.ResetAvatar()
  26900. return nil
  26901. case wpchatroom.FieldMemberList:
  26902. m.ResetMemberList()
  26903. return nil
  26904. }
  26905. return fmt.Errorf("unknown WpChatroom field %s", name)
  26906. }
  26907. // AddedEdges returns all edge names that were set/added in this mutation.
  26908. func (m *WpChatroomMutation) AddedEdges() []string {
  26909. edges := make([]string, 0, 0)
  26910. return edges
  26911. }
  26912. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26913. // name in this mutation.
  26914. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  26915. return nil
  26916. }
  26917. // RemovedEdges returns all edge names that were removed in this mutation.
  26918. func (m *WpChatroomMutation) RemovedEdges() []string {
  26919. edges := make([]string, 0, 0)
  26920. return edges
  26921. }
  26922. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26923. // the given name in this mutation.
  26924. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  26925. return nil
  26926. }
  26927. // ClearedEdges returns all edge names that were cleared in this mutation.
  26928. func (m *WpChatroomMutation) ClearedEdges() []string {
  26929. edges := make([]string, 0, 0)
  26930. return edges
  26931. }
  26932. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26933. // was cleared in this mutation.
  26934. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  26935. return false
  26936. }
  26937. // ClearEdge clears the value of the edge with the given name. It returns an error
  26938. // if that edge is not defined in the schema.
  26939. func (m *WpChatroomMutation) ClearEdge(name string) error {
  26940. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  26941. }
  26942. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26943. // It returns an error if the edge is not defined in the schema.
  26944. func (m *WpChatroomMutation) ResetEdge(name string) error {
  26945. return fmt.Errorf("unknown WpChatroom edge %s", name)
  26946. }
  26947. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  26948. type WpChatroomMemberMutation struct {
  26949. config
  26950. op Op
  26951. typ string
  26952. id *uint64
  26953. created_at *time.Time
  26954. updated_at *time.Time
  26955. status *uint8
  26956. addstatus *int8
  26957. wx_wxid *string
  26958. wxid *string
  26959. nickname *string
  26960. avatar *string
  26961. clearedFields map[string]struct{}
  26962. done bool
  26963. oldValue func(context.Context) (*WpChatroomMember, error)
  26964. predicates []predicate.WpChatroomMember
  26965. }
  26966. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  26967. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  26968. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  26969. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  26970. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  26971. m := &WpChatroomMemberMutation{
  26972. config: c,
  26973. op: op,
  26974. typ: TypeWpChatroomMember,
  26975. clearedFields: make(map[string]struct{}),
  26976. }
  26977. for _, opt := range opts {
  26978. opt(m)
  26979. }
  26980. return m
  26981. }
  26982. // withWpChatroomMemberID sets the ID field of the mutation.
  26983. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  26984. return func(m *WpChatroomMemberMutation) {
  26985. var (
  26986. err error
  26987. once sync.Once
  26988. value *WpChatroomMember
  26989. )
  26990. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  26991. once.Do(func() {
  26992. if m.done {
  26993. err = errors.New("querying old values post mutation is not allowed")
  26994. } else {
  26995. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  26996. }
  26997. })
  26998. return value, err
  26999. }
  27000. m.id = &id
  27001. }
  27002. }
  27003. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  27004. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  27005. return func(m *WpChatroomMemberMutation) {
  27006. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  27007. return node, nil
  27008. }
  27009. m.id = &node.ID
  27010. }
  27011. }
  27012. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27013. // executed in a transaction (ent.Tx), a transactional client is returned.
  27014. func (m WpChatroomMemberMutation) Client() *Client {
  27015. client := &Client{config: m.config}
  27016. client.init()
  27017. return client
  27018. }
  27019. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27020. // it returns an error otherwise.
  27021. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  27022. if _, ok := m.driver.(*txDriver); !ok {
  27023. return nil, errors.New("ent: mutation is not running in a transaction")
  27024. }
  27025. tx := &Tx{config: m.config}
  27026. tx.init()
  27027. return tx, nil
  27028. }
  27029. // SetID sets the value of the id field. Note that this
  27030. // operation is only accepted on creation of WpChatroomMember entities.
  27031. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  27032. m.id = &id
  27033. }
  27034. // ID returns the ID value in the mutation. Note that the ID is only available
  27035. // if it was provided to the builder or after it was returned from the database.
  27036. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  27037. if m.id == nil {
  27038. return
  27039. }
  27040. return *m.id, true
  27041. }
  27042. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27043. // That means, if the mutation is applied within a transaction with an isolation level such
  27044. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27045. // or updated by the mutation.
  27046. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  27047. switch {
  27048. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27049. id, exists := m.ID()
  27050. if exists {
  27051. return []uint64{id}, nil
  27052. }
  27053. fallthrough
  27054. case m.op.Is(OpUpdate | OpDelete):
  27055. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  27056. default:
  27057. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27058. }
  27059. }
  27060. // SetCreatedAt sets the "created_at" field.
  27061. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  27062. m.created_at = &t
  27063. }
  27064. // CreatedAt returns the value of the "created_at" field in the mutation.
  27065. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  27066. v := m.created_at
  27067. if v == nil {
  27068. return
  27069. }
  27070. return *v, true
  27071. }
  27072. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  27073. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27075. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27076. if !m.op.Is(OpUpdateOne) {
  27077. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27078. }
  27079. if m.id == nil || m.oldValue == nil {
  27080. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27081. }
  27082. oldValue, err := m.oldValue(ctx)
  27083. if err != nil {
  27084. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27085. }
  27086. return oldValue.CreatedAt, nil
  27087. }
  27088. // ResetCreatedAt resets all changes to the "created_at" field.
  27089. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  27090. m.created_at = nil
  27091. }
  27092. // SetUpdatedAt sets the "updated_at" field.
  27093. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  27094. m.updated_at = &t
  27095. }
  27096. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27097. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  27098. v := m.updated_at
  27099. if v == nil {
  27100. return
  27101. }
  27102. return *v, true
  27103. }
  27104. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  27105. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27107. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27108. if !m.op.Is(OpUpdateOne) {
  27109. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27110. }
  27111. if m.id == nil || m.oldValue == nil {
  27112. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27113. }
  27114. oldValue, err := m.oldValue(ctx)
  27115. if err != nil {
  27116. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27117. }
  27118. return oldValue.UpdatedAt, nil
  27119. }
  27120. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27121. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  27122. m.updated_at = nil
  27123. }
  27124. // SetStatus sets the "status" field.
  27125. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  27126. m.status = &u
  27127. m.addstatus = nil
  27128. }
  27129. // Status returns the value of the "status" field in the mutation.
  27130. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  27131. v := m.status
  27132. if v == nil {
  27133. return
  27134. }
  27135. return *v, true
  27136. }
  27137. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  27138. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27140. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27141. if !m.op.Is(OpUpdateOne) {
  27142. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27143. }
  27144. if m.id == nil || m.oldValue == nil {
  27145. return v, errors.New("OldStatus requires an ID field in the mutation")
  27146. }
  27147. oldValue, err := m.oldValue(ctx)
  27148. if err != nil {
  27149. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27150. }
  27151. return oldValue.Status, nil
  27152. }
  27153. // AddStatus adds u to the "status" field.
  27154. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  27155. if m.addstatus != nil {
  27156. *m.addstatus += u
  27157. } else {
  27158. m.addstatus = &u
  27159. }
  27160. }
  27161. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27162. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  27163. v := m.addstatus
  27164. if v == nil {
  27165. return
  27166. }
  27167. return *v, true
  27168. }
  27169. // ClearStatus clears the value of the "status" field.
  27170. func (m *WpChatroomMemberMutation) ClearStatus() {
  27171. m.status = nil
  27172. m.addstatus = nil
  27173. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  27174. }
  27175. // StatusCleared returns if the "status" field was cleared in this mutation.
  27176. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  27177. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  27178. return ok
  27179. }
  27180. // ResetStatus resets all changes to the "status" field.
  27181. func (m *WpChatroomMemberMutation) ResetStatus() {
  27182. m.status = nil
  27183. m.addstatus = nil
  27184. delete(m.clearedFields, wpchatroommember.FieldStatus)
  27185. }
  27186. // SetWxWxid sets the "wx_wxid" field.
  27187. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  27188. m.wx_wxid = &s
  27189. }
  27190. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  27191. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  27192. v := m.wx_wxid
  27193. if v == nil {
  27194. return
  27195. }
  27196. return *v, true
  27197. }
  27198. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  27199. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27201. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  27202. if !m.op.Is(OpUpdateOne) {
  27203. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  27204. }
  27205. if m.id == nil || m.oldValue == nil {
  27206. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  27207. }
  27208. oldValue, err := m.oldValue(ctx)
  27209. if err != nil {
  27210. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  27211. }
  27212. return oldValue.WxWxid, nil
  27213. }
  27214. // ResetWxWxid resets all changes to the "wx_wxid" field.
  27215. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  27216. m.wx_wxid = nil
  27217. }
  27218. // SetWxid sets the "wxid" field.
  27219. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  27220. m.wxid = &s
  27221. }
  27222. // Wxid returns the value of the "wxid" field in the mutation.
  27223. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  27224. v := m.wxid
  27225. if v == nil {
  27226. return
  27227. }
  27228. return *v, true
  27229. }
  27230. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  27231. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27233. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  27234. if !m.op.Is(OpUpdateOne) {
  27235. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  27236. }
  27237. if m.id == nil || m.oldValue == nil {
  27238. return v, errors.New("OldWxid requires an ID field in the mutation")
  27239. }
  27240. oldValue, err := m.oldValue(ctx)
  27241. if err != nil {
  27242. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  27243. }
  27244. return oldValue.Wxid, nil
  27245. }
  27246. // ResetWxid resets all changes to the "wxid" field.
  27247. func (m *WpChatroomMemberMutation) ResetWxid() {
  27248. m.wxid = nil
  27249. }
  27250. // SetNickname sets the "nickname" field.
  27251. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  27252. m.nickname = &s
  27253. }
  27254. // Nickname returns the value of the "nickname" field in the mutation.
  27255. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  27256. v := m.nickname
  27257. if v == nil {
  27258. return
  27259. }
  27260. return *v, true
  27261. }
  27262. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  27263. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27265. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  27266. if !m.op.Is(OpUpdateOne) {
  27267. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  27268. }
  27269. if m.id == nil || m.oldValue == nil {
  27270. return v, errors.New("OldNickname requires an ID field in the mutation")
  27271. }
  27272. oldValue, err := m.oldValue(ctx)
  27273. if err != nil {
  27274. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  27275. }
  27276. return oldValue.Nickname, nil
  27277. }
  27278. // ResetNickname resets all changes to the "nickname" field.
  27279. func (m *WpChatroomMemberMutation) ResetNickname() {
  27280. m.nickname = nil
  27281. }
  27282. // SetAvatar sets the "avatar" field.
  27283. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  27284. m.avatar = &s
  27285. }
  27286. // Avatar returns the value of the "avatar" field in the mutation.
  27287. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  27288. v := m.avatar
  27289. if v == nil {
  27290. return
  27291. }
  27292. return *v, true
  27293. }
  27294. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  27295. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  27296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27297. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  27298. if !m.op.Is(OpUpdateOne) {
  27299. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  27300. }
  27301. if m.id == nil || m.oldValue == nil {
  27302. return v, errors.New("OldAvatar requires an ID field in the mutation")
  27303. }
  27304. oldValue, err := m.oldValue(ctx)
  27305. if err != nil {
  27306. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  27307. }
  27308. return oldValue.Avatar, nil
  27309. }
  27310. // ResetAvatar resets all changes to the "avatar" field.
  27311. func (m *WpChatroomMemberMutation) ResetAvatar() {
  27312. m.avatar = nil
  27313. }
  27314. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  27315. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  27316. m.predicates = append(m.predicates, ps...)
  27317. }
  27318. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  27319. // users can use type-assertion to append predicates that do not depend on any generated package.
  27320. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  27321. p := make([]predicate.WpChatroomMember, len(ps))
  27322. for i := range ps {
  27323. p[i] = ps[i]
  27324. }
  27325. m.Where(p...)
  27326. }
  27327. // Op returns the operation name.
  27328. func (m *WpChatroomMemberMutation) Op() Op {
  27329. return m.op
  27330. }
  27331. // SetOp allows setting the mutation operation.
  27332. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  27333. m.op = op
  27334. }
  27335. // Type returns the node type of this mutation (WpChatroomMember).
  27336. func (m *WpChatroomMemberMutation) Type() string {
  27337. return m.typ
  27338. }
  27339. // Fields returns all fields that were changed during this mutation. Note that in
  27340. // order to get all numeric fields that were incremented/decremented, call
  27341. // AddedFields().
  27342. func (m *WpChatroomMemberMutation) Fields() []string {
  27343. fields := make([]string, 0, 7)
  27344. if m.created_at != nil {
  27345. fields = append(fields, wpchatroommember.FieldCreatedAt)
  27346. }
  27347. if m.updated_at != nil {
  27348. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  27349. }
  27350. if m.status != nil {
  27351. fields = append(fields, wpchatroommember.FieldStatus)
  27352. }
  27353. if m.wx_wxid != nil {
  27354. fields = append(fields, wpchatroommember.FieldWxWxid)
  27355. }
  27356. if m.wxid != nil {
  27357. fields = append(fields, wpchatroommember.FieldWxid)
  27358. }
  27359. if m.nickname != nil {
  27360. fields = append(fields, wpchatroommember.FieldNickname)
  27361. }
  27362. if m.avatar != nil {
  27363. fields = append(fields, wpchatroommember.FieldAvatar)
  27364. }
  27365. return fields
  27366. }
  27367. // Field returns the value of a field with the given name. The second boolean
  27368. // return value indicates that this field was not set, or was not defined in the
  27369. // schema.
  27370. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  27371. switch name {
  27372. case wpchatroommember.FieldCreatedAt:
  27373. return m.CreatedAt()
  27374. case wpchatroommember.FieldUpdatedAt:
  27375. return m.UpdatedAt()
  27376. case wpchatroommember.FieldStatus:
  27377. return m.Status()
  27378. case wpchatroommember.FieldWxWxid:
  27379. return m.WxWxid()
  27380. case wpchatroommember.FieldWxid:
  27381. return m.Wxid()
  27382. case wpchatroommember.FieldNickname:
  27383. return m.Nickname()
  27384. case wpchatroommember.FieldAvatar:
  27385. return m.Avatar()
  27386. }
  27387. return nil, false
  27388. }
  27389. // OldField returns the old value of the field from the database. An error is
  27390. // returned if the mutation operation is not UpdateOne, or the query to the
  27391. // database failed.
  27392. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27393. switch name {
  27394. case wpchatroommember.FieldCreatedAt:
  27395. return m.OldCreatedAt(ctx)
  27396. case wpchatroommember.FieldUpdatedAt:
  27397. return m.OldUpdatedAt(ctx)
  27398. case wpchatroommember.FieldStatus:
  27399. return m.OldStatus(ctx)
  27400. case wpchatroommember.FieldWxWxid:
  27401. return m.OldWxWxid(ctx)
  27402. case wpchatroommember.FieldWxid:
  27403. return m.OldWxid(ctx)
  27404. case wpchatroommember.FieldNickname:
  27405. return m.OldNickname(ctx)
  27406. case wpchatroommember.FieldAvatar:
  27407. return m.OldAvatar(ctx)
  27408. }
  27409. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  27410. }
  27411. // SetField sets the value of a field with the given name. It returns an error if
  27412. // the field is not defined in the schema, or if the type mismatched the field
  27413. // type.
  27414. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  27415. switch name {
  27416. case wpchatroommember.FieldCreatedAt:
  27417. v, ok := value.(time.Time)
  27418. if !ok {
  27419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27420. }
  27421. m.SetCreatedAt(v)
  27422. return nil
  27423. case wpchatroommember.FieldUpdatedAt:
  27424. v, ok := value.(time.Time)
  27425. if !ok {
  27426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27427. }
  27428. m.SetUpdatedAt(v)
  27429. return nil
  27430. case wpchatroommember.FieldStatus:
  27431. v, ok := value.(uint8)
  27432. if !ok {
  27433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27434. }
  27435. m.SetStatus(v)
  27436. return nil
  27437. case wpchatroommember.FieldWxWxid:
  27438. v, ok := value.(string)
  27439. if !ok {
  27440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27441. }
  27442. m.SetWxWxid(v)
  27443. return nil
  27444. case wpchatroommember.FieldWxid:
  27445. v, ok := value.(string)
  27446. if !ok {
  27447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27448. }
  27449. m.SetWxid(v)
  27450. return nil
  27451. case wpchatroommember.FieldNickname:
  27452. v, ok := value.(string)
  27453. if !ok {
  27454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27455. }
  27456. m.SetNickname(v)
  27457. return nil
  27458. case wpchatroommember.FieldAvatar:
  27459. v, ok := value.(string)
  27460. if !ok {
  27461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27462. }
  27463. m.SetAvatar(v)
  27464. return nil
  27465. }
  27466. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  27467. }
  27468. // AddedFields returns all numeric fields that were incremented/decremented during
  27469. // this mutation.
  27470. func (m *WpChatroomMemberMutation) AddedFields() []string {
  27471. var fields []string
  27472. if m.addstatus != nil {
  27473. fields = append(fields, wpchatroommember.FieldStatus)
  27474. }
  27475. return fields
  27476. }
  27477. // AddedField returns the numeric value that was incremented/decremented on a field
  27478. // with the given name. The second boolean return value indicates that this field
  27479. // was not set, or was not defined in the schema.
  27480. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  27481. switch name {
  27482. case wpchatroommember.FieldStatus:
  27483. return m.AddedStatus()
  27484. }
  27485. return nil, false
  27486. }
  27487. // AddField adds the value to the field with the given name. It returns an error if
  27488. // the field is not defined in the schema, or if the type mismatched the field
  27489. // type.
  27490. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  27491. switch name {
  27492. case wpchatroommember.FieldStatus:
  27493. v, ok := value.(int8)
  27494. if !ok {
  27495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27496. }
  27497. m.AddStatus(v)
  27498. return nil
  27499. }
  27500. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  27501. }
  27502. // ClearedFields returns all nullable fields that were cleared during this
  27503. // mutation.
  27504. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  27505. var fields []string
  27506. if m.FieldCleared(wpchatroommember.FieldStatus) {
  27507. fields = append(fields, wpchatroommember.FieldStatus)
  27508. }
  27509. return fields
  27510. }
  27511. // FieldCleared returns a boolean indicating if a field with the given name was
  27512. // cleared in this mutation.
  27513. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  27514. _, ok := m.clearedFields[name]
  27515. return ok
  27516. }
  27517. // ClearField clears the value of the field with the given name. It returns an
  27518. // error if the field is not defined in the schema.
  27519. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  27520. switch name {
  27521. case wpchatroommember.FieldStatus:
  27522. m.ClearStatus()
  27523. return nil
  27524. }
  27525. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  27526. }
  27527. // ResetField resets all changes in the mutation for the field with the given name.
  27528. // It returns an error if the field is not defined in the schema.
  27529. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  27530. switch name {
  27531. case wpchatroommember.FieldCreatedAt:
  27532. m.ResetCreatedAt()
  27533. return nil
  27534. case wpchatroommember.FieldUpdatedAt:
  27535. m.ResetUpdatedAt()
  27536. return nil
  27537. case wpchatroommember.FieldStatus:
  27538. m.ResetStatus()
  27539. return nil
  27540. case wpchatroommember.FieldWxWxid:
  27541. m.ResetWxWxid()
  27542. return nil
  27543. case wpchatroommember.FieldWxid:
  27544. m.ResetWxid()
  27545. return nil
  27546. case wpchatroommember.FieldNickname:
  27547. m.ResetNickname()
  27548. return nil
  27549. case wpchatroommember.FieldAvatar:
  27550. m.ResetAvatar()
  27551. return nil
  27552. }
  27553. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  27554. }
  27555. // AddedEdges returns all edge names that were set/added in this mutation.
  27556. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  27557. edges := make([]string, 0, 0)
  27558. return edges
  27559. }
  27560. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27561. // name in this mutation.
  27562. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  27563. return nil
  27564. }
  27565. // RemovedEdges returns all edge names that were removed in this mutation.
  27566. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  27567. edges := make([]string, 0, 0)
  27568. return edges
  27569. }
  27570. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27571. // the given name in this mutation.
  27572. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  27573. return nil
  27574. }
  27575. // ClearedEdges returns all edge names that were cleared in this mutation.
  27576. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  27577. edges := make([]string, 0, 0)
  27578. return edges
  27579. }
  27580. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27581. // was cleared in this mutation.
  27582. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  27583. return false
  27584. }
  27585. // ClearEdge clears the value of the edge with the given name. It returns an error
  27586. // if that edge is not defined in the schema.
  27587. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  27588. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  27589. }
  27590. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27591. // It returns an error if the edge is not defined in the schema.
  27592. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  27593. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  27594. }
  27595. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  27596. type WxMutation struct {
  27597. config
  27598. op Op
  27599. typ string
  27600. id *uint64
  27601. created_at *time.Time
  27602. updated_at *time.Time
  27603. status *uint8
  27604. addstatus *int8
  27605. deleted_at *time.Time
  27606. port *string
  27607. process_id *string
  27608. callback *string
  27609. wxid *string
  27610. account *string
  27611. nickname *string
  27612. tel *string
  27613. head_big *string
  27614. organization_id *uint64
  27615. addorganization_id *int64
  27616. api_base *string
  27617. api_key *string
  27618. allow_list *[]string
  27619. appendallow_list []string
  27620. group_allow_list *[]string
  27621. appendgroup_allow_list []string
  27622. block_list *[]string
  27623. appendblock_list []string
  27624. group_block_list *[]string
  27625. appendgroup_block_list []string
  27626. clearedFields map[string]struct{}
  27627. server *uint64
  27628. clearedserver bool
  27629. agent *uint64
  27630. clearedagent bool
  27631. done bool
  27632. oldValue func(context.Context) (*Wx, error)
  27633. predicates []predicate.Wx
  27634. }
  27635. var _ ent.Mutation = (*WxMutation)(nil)
  27636. // wxOption allows management of the mutation configuration using functional options.
  27637. type wxOption func(*WxMutation)
  27638. // newWxMutation creates new mutation for the Wx entity.
  27639. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  27640. m := &WxMutation{
  27641. config: c,
  27642. op: op,
  27643. typ: TypeWx,
  27644. clearedFields: make(map[string]struct{}),
  27645. }
  27646. for _, opt := range opts {
  27647. opt(m)
  27648. }
  27649. return m
  27650. }
  27651. // withWxID sets the ID field of the mutation.
  27652. func withWxID(id uint64) wxOption {
  27653. return func(m *WxMutation) {
  27654. var (
  27655. err error
  27656. once sync.Once
  27657. value *Wx
  27658. )
  27659. m.oldValue = func(ctx context.Context) (*Wx, error) {
  27660. once.Do(func() {
  27661. if m.done {
  27662. err = errors.New("querying old values post mutation is not allowed")
  27663. } else {
  27664. value, err = m.Client().Wx.Get(ctx, id)
  27665. }
  27666. })
  27667. return value, err
  27668. }
  27669. m.id = &id
  27670. }
  27671. }
  27672. // withWx sets the old Wx of the mutation.
  27673. func withWx(node *Wx) wxOption {
  27674. return func(m *WxMutation) {
  27675. m.oldValue = func(context.Context) (*Wx, error) {
  27676. return node, nil
  27677. }
  27678. m.id = &node.ID
  27679. }
  27680. }
  27681. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27682. // executed in a transaction (ent.Tx), a transactional client is returned.
  27683. func (m WxMutation) Client() *Client {
  27684. client := &Client{config: m.config}
  27685. client.init()
  27686. return client
  27687. }
  27688. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27689. // it returns an error otherwise.
  27690. func (m WxMutation) Tx() (*Tx, error) {
  27691. if _, ok := m.driver.(*txDriver); !ok {
  27692. return nil, errors.New("ent: mutation is not running in a transaction")
  27693. }
  27694. tx := &Tx{config: m.config}
  27695. tx.init()
  27696. return tx, nil
  27697. }
  27698. // SetID sets the value of the id field. Note that this
  27699. // operation is only accepted on creation of Wx entities.
  27700. func (m *WxMutation) SetID(id uint64) {
  27701. m.id = &id
  27702. }
  27703. // ID returns the ID value in the mutation. Note that the ID is only available
  27704. // if it was provided to the builder or after it was returned from the database.
  27705. func (m *WxMutation) ID() (id uint64, exists bool) {
  27706. if m.id == nil {
  27707. return
  27708. }
  27709. return *m.id, true
  27710. }
  27711. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27712. // That means, if the mutation is applied within a transaction with an isolation level such
  27713. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27714. // or updated by the mutation.
  27715. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  27716. switch {
  27717. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27718. id, exists := m.ID()
  27719. if exists {
  27720. return []uint64{id}, nil
  27721. }
  27722. fallthrough
  27723. case m.op.Is(OpUpdate | OpDelete):
  27724. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  27725. default:
  27726. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27727. }
  27728. }
  27729. // SetCreatedAt sets the "created_at" field.
  27730. func (m *WxMutation) SetCreatedAt(t time.Time) {
  27731. m.created_at = &t
  27732. }
  27733. // CreatedAt returns the value of the "created_at" field in the mutation.
  27734. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  27735. v := m.created_at
  27736. if v == nil {
  27737. return
  27738. }
  27739. return *v, true
  27740. }
  27741. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  27742. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27744. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27745. if !m.op.Is(OpUpdateOne) {
  27746. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27747. }
  27748. if m.id == nil || m.oldValue == nil {
  27749. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27750. }
  27751. oldValue, err := m.oldValue(ctx)
  27752. if err != nil {
  27753. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27754. }
  27755. return oldValue.CreatedAt, nil
  27756. }
  27757. // ResetCreatedAt resets all changes to the "created_at" field.
  27758. func (m *WxMutation) ResetCreatedAt() {
  27759. m.created_at = nil
  27760. }
  27761. // SetUpdatedAt sets the "updated_at" field.
  27762. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  27763. m.updated_at = &t
  27764. }
  27765. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27766. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  27767. v := m.updated_at
  27768. if v == nil {
  27769. return
  27770. }
  27771. return *v, true
  27772. }
  27773. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  27774. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27776. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27777. if !m.op.Is(OpUpdateOne) {
  27778. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27779. }
  27780. if m.id == nil || m.oldValue == nil {
  27781. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27782. }
  27783. oldValue, err := m.oldValue(ctx)
  27784. if err != nil {
  27785. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27786. }
  27787. return oldValue.UpdatedAt, nil
  27788. }
  27789. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27790. func (m *WxMutation) ResetUpdatedAt() {
  27791. m.updated_at = nil
  27792. }
  27793. // SetStatus sets the "status" field.
  27794. func (m *WxMutation) SetStatus(u uint8) {
  27795. m.status = &u
  27796. m.addstatus = nil
  27797. }
  27798. // Status returns the value of the "status" field in the mutation.
  27799. func (m *WxMutation) Status() (r uint8, exists bool) {
  27800. v := m.status
  27801. if v == nil {
  27802. return
  27803. }
  27804. return *v, true
  27805. }
  27806. // OldStatus returns the old "status" field's value of the Wx entity.
  27807. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27809. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27810. if !m.op.Is(OpUpdateOne) {
  27811. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27812. }
  27813. if m.id == nil || m.oldValue == nil {
  27814. return v, errors.New("OldStatus requires an ID field in the mutation")
  27815. }
  27816. oldValue, err := m.oldValue(ctx)
  27817. if err != nil {
  27818. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27819. }
  27820. return oldValue.Status, nil
  27821. }
  27822. // AddStatus adds u to the "status" field.
  27823. func (m *WxMutation) AddStatus(u int8) {
  27824. if m.addstatus != nil {
  27825. *m.addstatus += u
  27826. } else {
  27827. m.addstatus = &u
  27828. }
  27829. }
  27830. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27831. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  27832. v := m.addstatus
  27833. if v == nil {
  27834. return
  27835. }
  27836. return *v, true
  27837. }
  27838. // ClearStatus clears the value of the "status" field.
  27839. func (m *WxMutation) ClearStatus() {
  27840. m.status = nil
  27841. m.addstatus = nil
  27842. m.clearedFields[wx.FieldStatus] = struct{}{}
  27843. }
  27844. // StatusCleared returns if the "status" field was cleared in this mutation.
  27845. func (m *WxMutation) StatusCleared() bool {
  27846. _, ok := m.clearedFields[wx.FieldStatus]
  27847. return ok
  27848. }
  27849. // ResetStatus resets all changes to the "status" field.
  27850. func (m *WxMutation) ResetStatus() {
  27851. m.status = nil
  27852. m.addstatus = nil
  27853. delete(m.clearedFields, wx.FieldStatus)
  27854. }
  27855. // SetDeletedAt sets the "deleted_at" field.
  27856. func (m *WxMutation) SetDeletedAt(t time.Time) {
  27857. m.deleted_at = &t
  27858. }
  27859. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27860. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  27861. v := m.deleted_at
  27862. if v == nil {
  27863. return
  27864. }
  27865. return *v, true
  27866. }
  27867. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  27868. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27870. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27871. if !m.op.Is(OpUpdateOne) {
  27872. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27873. }
  27874. if m.id == nil || m.oldValue == nil {
  27875. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27876. }
  27877. oldValue, err := m.oldValue(ctx)
  27878. if err != nil {
  27879. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27880. }
  27881. return oldValue.DeletedAt, nil
  27882. }
  27883. // ClearDeletedAt clears the value of the "deleted_at" field.
  27884. func (m *WxMutation) ClearDeletedAt() {
  27885. m.deleted_at = nil
  27886. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  27887. }
  27888. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27889. func (m *WxMutation) DeletedAtCleared() bool {
  27890. _, ok := m.clearedFields[wx.FieldDeletedAt]
  27891. return ok
  27892. }
  27893. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27894. func (m *WxMutation) ResetDeletedAt() {
  27895. m.deleted_at = nil
  27896. delete(m.clearedFields, wx.FieldDeletedAt)
  27897. }
  27898. // SetServerID sets the "server_id" field.
  27899. func (m *WxMutation) SetServerID(u uint64) {
  27900. m.server = &u
  27901. }
  27902. // ServerID returns the value of the "server_id" field in the mutation.
  27903. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  27904. v := m.server
  27905. if v == nil {
  27906. return
  27907. }
  27908. return *v, true
  27909. }
  27910. // OldServerID returns the old "server_id" field's value of the Wx entity.
  27911. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27913. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  27914. if !m.op.Is(OpUpdateOne) {
  27915. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  27916. }
  27917. if m.id == nil || m.oldValue == nil {
  27918. return v, errors.New("OldServerID requires an ID field in the mutation")
  27919. }
  27920. oldValue, err := m.oldValue(ctx)
  27921. if err != nil {
  27922. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  27923. }
  27924. return oldValue.ServerID, nil
  27925. }
  27926. // ClearServerID clears the value of the "server_id" field.
  27927. func (m *WxMutation) ClearServerID() {
  27928. m.server = nil
  27929. m.clearedFields[wx.FieldServerID] = struct{}{}
  27930. }
  27931. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  27932. func (m *WxMutation) ServerIDCleared() bool {
  27933. _, ok := m.clearedFields[wx.FieldServerID]
  27934. return ok
  27935. }
  27936. // ResetServerID resets all changes to the "server_id" field.
  27937. func (m *WxMutation) ResetServerID() {
  27938. m.server = nil
  27939. delete(m.clearedFields, wx.FieldServerID)
  27940. }
  27941. // SetPort sets the "port" field.
  27942. func (m *WxMutation) SetPort(s string) {
  27943. m.port = &s
  27944. }
  27945. // Port returns the value of the "port" field in the mutation.
  27946. func (m *WxMutation) Port() (r string, exists bool) {
  27947. v := m.port
  27948. if v == nil {
  27949. return
  27950. }
  27951. return *v, true
  27952. }
  27953. // OldPort returns the old "port" field's value of the Wx entity.
  27954. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27956. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  27957. if !m.op.Is(OpUpdateOne) {
  27958. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  27959. }
  27960. if m.id == nil || m.oldValue == nil {
  27961. return v, errors.New("OldPort requires an ID field in the mutation")
  27962. }
  27963. oldValue, err := m.oldValue(ctx)
  27964. if err != nil {
  27965. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  27966. }
  27967. return oldValue.Port, nil
  27968. }
  27969. // ResetPort resets all changes to the "port" field.
  27970. func (m *WxMutation) ResetPort() {
  27971. m.port = nil
  27972. }
  27973. // SetProcessID sets the "process_id" field.
  27974. func (m *WxMutation) SetProcessID(s string) {
  27975. m.process_id = &s
  27976. }
  27977. // ProcessID returns the value of the "process_id" field in the mutation.
  27978. func (m *WxMutation) ProcessID() (r string, exists bool) {
  27979. v := m.process_id
  27980. if v == nil {
  27981. return
  27982. }
  27983. return *v, true
  27984. }
  27985. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  27986. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27988. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  27989. if !m.op.Is(OpUpdateOne) {
  27990. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  27991. }
  27992. if m.id == nil || m.oldValue == nil {
  27993. return v, errors.New("OldProcessID requires an ID field in the mutation")
  27994. }
  27995. oldValue, err := m.oldValue(ctx)
  27996. if err != nil {
  27997. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  27998. }
  27999. return oldValue.ProcessID, nil
  28000. }
  28001. // ResetProcessID resets all changes to the "process_id" field.
  28002. func (m *WxMutation) ResetProcessID() {
  28003. m.process_id = nil
  28004. }
  28005. // SetCallback sets the "callback" field.
  28006. func (m *WxMutation) SetCallback(s string) {
  28007. m.callback = &s
  28008. }
  28009. // Callback returns the value of the "callback" field in the mutation.
  28010. func (m *WxMutation) Callback() (r string, exists bool) {
  28011. v := m.callback
  28012. if v == nil {
  28013. return
  28014. }
  28015. return *v, true
  28016. }
  28017. // OldCallback returns the old "callback" field's value of the Wx entity.
  28018. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28020. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  28021. if !m.op.Is(OpUpdateOne) {
  28022. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  28023. }
  28024. if m.id == nil || m.oldValue == nil {
  28025. return v, errors.New("OldCallback requires an ID field in the mutation")
  28026. }
  28027. oldValue, err := m.oldValue(ctx)
  28028. if err != nil {
  28029. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  28030. }
  28031. return oldValue.Callback, nil
  28032. }
  28033. // ResetCallback resets all changes to the "callback" field.
  28034. func (m *WxMutation) ResetCallback() {
  28035. m.callback = nil
  28036. }
  28037. // SetWxid sets the "wxid" field.
  28038. func (m *WxMutation) SetWxid(s string) {
  28039. m.wxid = &s
  28040. }
  28041. // Wxid returns the value of the "wxid" field in the mutation.
  28042. func (m *WxMutation) Wxid() (r string, exists bool) {
  28043. v := m.wxid
  28044. if v == nil {
  28045. return
  28046. }
  28047. return *v, true
  28048. }
  28049. // OldWxid returns the old "wxid" field's value of the Wx entity.
  28050. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28052. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  28053. if !m.op.Is(OpUpdateOne) {
  28054. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  28055. }
  28056. if m.id == nil || m.oldValue == nil {
  28057. return v, errors.New("OldWxid requires an ID field in the mutation")
  28058. }
  28059. oldValue, err := m.oldValue(ctx)
  28060. if err != nil {
  28061. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  28062. }
  28063. return oldValue.Wxid, nil
  28064. }
  28065. // ResetWxid resets all changes to the "wxid" field.
  28066. func (m *WxMutation) ResetWxid() {
  28067. m.wxid = nil
  28068. }
  28069. // SetAccount sets the "account" field.
  28070. func (m *WxMutation) SetAccount(s string) {
  28071. m.account = &s
  28072. }
  28073. // Account returns the value of the "account" field in the mutation.
  28074. func (m *WxMutation) Account() (r string, exists bool) {
  28075. v := m.account
  28076. if v == nil {
  28077. return
  28078. }
  28079. return *v, true
  28080. }
  28081. // OldAccount returns the old "account" field's value of the Wx entity.
  28082. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28084. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  28085. if !m.op.Is(OpUpdateOne) {
  28086. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  28087. }
  28088. if m.id == nil || m.oldValue == nil {
  28089. return v, errors.New("OldAccount requires an ID field in the mutation")
  28090. }
  28091. oldValue, err := m.oldValue(ctx)
  28092. if err != nil {
  28093. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  28094. }
  28095. return oldValue.Account, nil
  28096. }
  28097. // ResetAccount resets all changes to the "account" field.
  28098. func (m *WxMutation) ResetAccount() {
  28099. m.account = nil
  28100. }
  28101. // SetNickname sets the "nickname" field.
  28102. func (m *WxMutation) SetNickname(s string) {
  28103. m.nickname = &s
  28104. }
  28105. // Nickname returns the value of the "nickname" field in the mutation.
  28106. func (m *WxMutation) Nickname() (r string, exists bool) {
  28107. v := m.nickname
  28108. if v == nil {
  28109. return
  28110. }
  28111. return *v, true
  28112. }
  28113. // OldNickname returns the old "nickname" field's value of the Wx entity.
  28114. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28116. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  28117. if !m.op.Is(OpUpdateOne) {
  28118. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  28119. }
  28120. if m.id == nil || m.oldValue == nil {
  28121. return v, errors.New("OldNickname requires an ID field in the mutation")
  28122. }
  28123. oldValue, err := m.oldValue(ctx)
  28124. if err != nil {
  28125. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  28126. }
  28127. return oldValue.Nickname, nil
  28128. }
  28129. // ResetNickname resets all changes to the "nickname" field.
  28130. func (m *WxMutation) ResetNickname() {
  28131. m.nickname = nil
  28132. }
  28133. // SetTel sets the "tel" field.
  28134. func (m *WxMutation) SetTel(s string) {
  28135. m.tel = &s
  28136. }
  28137. // Tel returns the value of the "tel" field in the mutation.
  28138. func (m *WxMutation) Tel() (r string, exists bool) {
  28139. v := m.tel
  28140. if v == nil {
  28141. return
  28142. }
  28143. return *v, true
  28144. }
  28145. // OldTel returns the old "tel" field's value of the Wx entity.
  28146. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28148. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  28149. if !m.op.Is(OpUpdateOne) {
  28150. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  28151. }
  28152. if m.id == nil || m.oldValue == nil {
  28153. return v, errors.New("OldTel requires an ID field in the mutation")
  28154. }
  28155. oldValue, err := m.oldValue(ctx)
  28156. if err != nil {
  28157. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  28158. }
  28159. return oldValue.Tel, nil
  28160. }
  28161. // ResetTel resets all changes to the "tel" field.
  28162. func (m *WxMutation) ResetTel() {
  28163. m.tel = nil
  28164. }
  28165. // SetHeadBig sets the "head_big" field.
  28166. func (m *WxMutation) SetHeadBig(s string) {
  28167. m.head_big = &s
  28168. }
  28169. // HeadBig returns the value of the "head_big" field in the mutation.
  28170. func (m *WxMutation) HeadBig() (r string, exists bool) {
  28171. v := m.head_big
  28172. if v == nil {
  28173. return
  28174. }
  28175. return *v, true
  28176. }
  28177. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  28178. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28180. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  28181. if !m.op.Is(OpUpdateOne) {
  28182. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  28183. }
  28184. if m.id == nil || m.oldValue == nil {
  28185. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  28186. }
  28187. oldValue, err := m.oldValue(ctx)
  28188. if err != nil {
  28189. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  28190. }
  28191. return oldValue.HeadBig, nil
  28192. }
  28193. // ResetHeadBig resets all changes to the "head_big" field.
  28194. func (m *WxMutation) ResetHeadBig() {
  28195. m.head_big = nil
  28196. }
  28197. // SetOrganizationID sets the "organization_id" field.
  28198. func (m *WxMutation) SetOrganizationID(u uint64) {
  28199. m.organization_id = &u
  28200. m.addorganization_id = nil
  28201. }
  28202. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28203. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  28204. v := m.organization_id
  28205. if v == nil {
  28206. return
  28207. }
  28208. return *v, true
  28209. }
  28210. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  28211. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28213. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28214. if !m.op.Is(OpUpdateOne) {
  28215. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28216. }
  28217. if m.id == nil || m.oldValue == nil {
  28218. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28219. }
  28220. oldValue, err := m.oldValue(ctx)
  28221. if err != nil {
  28222. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28223. }
  28224. return oldValue.OrganizationID, nil
  28225. }
  28226. // AddOrganizationID adds u to the "organization_id" field.
  28227. func (m *WxMutation) AddOrganizationID(u int64) {
  28228. if m.addorganization_id != nil {
  28229. *m.addorganization_id += u
  28230. } else {
  28231. m.addorganization_id = &u
  28232. }
  28233. }
  28234. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28235. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  28236. v := m.addorganization_id
  28237. if v == nil {
  28238. return
  28239. }
  28240. return *v, true
  28241. }
  28242. // ClearOrganizationID clears the value of the "organization_id" field.
  28243. func (m *WxMutation) ClearOrganizationID() {
  28244. m.organization_id = nil
  28245. m.addorganization_id = nil
  28246. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  28247. }
  28248. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28249. func (m *WxMutation) OrganizationIDCleared() bool {
  28250. _, ok := m.clearedFields[wx.FieldOrganizationID]
  28251. return ok
  28252. }
  28253. // ResetOrganizationID resets all changes to the "organization_id" field.
  28254. func (m *WxMutation) ResetOrganizationID() {
  28255. m.organization_id = nil
  28256. m.addorganization_id = nil
  28257. delete(m.clearedFields, wx.FieldOrganizationID)
  28258. }
  28259. // SetAgentID sets the "agent_id" field.
  28260. func (m *WxMutation) SetAgentID(u uint64) {
  28261. m.agent = &u
  28262. }
  28263. // AgentID returns the value of the "agent_id" field in the mutation.
  28264. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  28265. v := m.agent
  28266. if v == nil {
  28267. return
  28268. }
  28269. return *v, true
  28270. }
  28271. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  28272. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28274. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  28275. if !m.op.Is(OpUpdateOne) {
  28276. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  28277. }
  28278. if m.id == nil || m.oldValue == nil {
  28279. return v, errors.New("OldAgentID requires an ID field in the mutation")
  28280. }
  28281. oldValue, err := m.oldValue(ctx)
  28282. if err != nil {
  28283. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  28284. }
  28285. return oldValue.AgentID, nil
  28286. }
  28287. // ResetAgentID resets all changes to the "agent_id" field.
  28288. func (m *WxMutation) ResetAgentID() {
  28289. m.agent = nil
  28290. }
  28291. // SetAPIBase sets the "api_base" field.
  28292. func (m *WxMutation) SetAPIBase(s string) {
  28293. m.api_base = &s
  28294. }
  28295. // APIBase returns the value of the "api_base" field in the mutation.
  28296. func (m *WxMutation) APIBase() (r string, exists bool) {
  28297. v := m.api_base
  28298. if v == nil {
  28299. return
  28300. }
  28301. return *v, true
  28302. }
  28303. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  28304. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28306. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  28307. if !m.op.Is(OpUpdateOne) {
  28308. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  28309. }
  28310. if m.id == nil || m.oldValue == nil {
  28311. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  28312. }
  28313. oldValue, err := m.oldValue(ctx)
  28314. if err != nil {
  28315. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  28316. }
  28317. return oldValue.APIBase, nil
  28318. }
  28319. // ClearAPIBase clears the value of the "api_base" field.
  28320. func (m *WxMutation) ClearAPIBase() {
  28321. m.api_base = nil
  28322. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  28323. }
  28324. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  28325. func (m *WxMutation) APIBaseCleared() bool {
  28326. _, ok := m.clearedFields[wx.FieldAPIBase]
  28327. return ok
  28328. }
  28329. // ResetAPIBase resets all changes to the "api_base" field.
  28330. func (m *WxMutation) ResetAPIBase() {
  28331. m.api_base = nil
  28332. delete(m.clearedFields, wx.FieldAPIBase)
  28333. }
  28334. // SetAPIKey sets the "api_key" field.
  28335. func (m *WxMutation) SetAPIKey(s string) {
  28336. m.api_key = &s
  28337. }
  28338. // APIKey returns the value of the "api_key" field in the mutation.
  28339. func (m *WxMutation) APIKey() (r string, exists bool) {
  28340. v := m.api_key
  28341. if v == nil {
  28342. return
  28343. }
  28344. return *v, true
  28345. }
  28346. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  28347. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28349. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  28350. if !m.op.Is(OpUpdateOne) {
  28351. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  28352. }
  28353. if m.id == nil || m.oldValue == nil {
  28354. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  28355. }
  28356. oldValue, err := m.oldValue(ctx)
  28357. if err != nil {
  28358. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  28359. }
  28360. return oldValue.APIKey, nil
  28361. }
  28362. // ClearAPIKey clears the value of the "api_key" field.
  28363. func (m *WxMutation) ClearAPIKey() {
  28364. m.api_key = nil
  28365. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  28366. }
  28367. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  28368. func (m *WxMutation) APIKeyCleared() bool {
  28369. _, ok := m.clearedFields[wx.FieldAPIKey]
  28370. return ok
  28371. }
  28372. // ResetAPIKey resets all changes to the "api_key" field.
  28373. func (m *WxMutation) ResetAPIKey() {
  28374. m.api_key = nil
  28375. delete(m.clearedFields, wx.FieldAPIKey)
  28376. }
  28377. // SetAllowList sets the "allow_list" field.
  28378. func (m *WxMutation) SetAllowList(s []string) {
  28379. m.allow_list = &s
  28380. m.appendallow_list = nil
  28381. }
  28382. // AllowList returns the value of the "allow_list" field in the mutation.
  28383. func (m *WxMutation) AllowList() (r []string, exists bool) {
  28384. v := m.allow_list
  28385. if v == nil {
  28386. return
  28387. }
  28388. return *v, true
  28389. }
  28390. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  28391. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28393. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  28394. if !m.op.Is(OpUpdateOne) {
  28395. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  28396. }
  28397. if m.id == nil || m.oldValue == nil {
  28398. return v, errors.New("OldAllowList requires an ID field in the mutation")
  28399. }
  28400. oldValue, err := m.oldValue(ctx)
  28401. if err != nil {
  28402. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  28403. }
  28404. return oldValue.AllowList, nil
  28405. }
  28406. // AppendAllowList adds s to the "allow_list" field.
  28407. func (m *WxMutation) AppendAllowList(s []string) {
  28408. m.appendallow_list = append(m.appendallow_list, s...)
  28409. }
  28410. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  28411. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  28412. if len(m.appendallow_list) == 0 {
  28413. return nil, false
  28414. }
  28415. return m.appendallow_list, true
  28416. }
  28417. // ResetAllowList resets all changes to the "allow_list" field.
  28418. func (m *WxMutation) ResetAllowList() {
  28419. m.allow_list = nil
  28420. m.appendallow_list = nil
  28421. }
  28422. // SetGroupAllowList sets the "group_allow_list" field.
  28423. func (m *WxMutation) SetGroupAllowList(s []string) {
  28424. m.group_allow_list = &s
  28425. m.appendgroup_allow_list = nil
  28426. }
  28427. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  28428. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  28429. v := m.group_allow_list
  28430. if v == nil {
  28431. return
  28432. }
  28433. return *v, true
  28434. }
  28435. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  28436. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28438. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  28439. if !m.op.Is(OpUpdateOne) {
  28440. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  28441. }
  28442. if m.id == nil || m.oldValue == nil {
  28443. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  28444. }
  28445. oldValue, err := m.oldValue(ctx)
  28446. if err != nil {
  28447. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  28448. }
  28449. return oldValue.GroupAllowList, nil
  28450. }
  28451. // AppendGroupAllowList adds s to the "group_allow_list" field.
  28452. func (m *WxMutation) AppendGroupAllowList(s []string) {
  28453. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  28454. }
  28455. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  28456. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  28457. if len(m.appendgroup_allow_list) == 0 {
  28458. return nil, false
  28459. }
  28460. return m.appendgroup_allow_list, true
  28461. }
  28462. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  28463. func (m *WxMutation) ResetGroupAllowList() {
  28464. m.group_allow_list = nil
  28465. m.appendgroup_allow_list = nil
  28466. }
  28467. // SetBlockList sets the "block_list" field.
  28468. func (m *WxMutation) SetBlockList(s []string) {
  28469. m.block_list = &s
  28470. m.appendblock_list = nil
  28471. }
  28472. // BlockList returns the value of the "block_list" field in the mutation.
  28473. func (m *WxMutation) BlockList() (r []string, exists bool) {
  28474. v := m.block_list
  28475. if v == nil {
  28476. return
  28477. }
  28478. return *v, true
  28479. }
  28480. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  28481. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28483. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  28484. if !m.op.Is(OpUpdateOne) {
  28485. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  28486. }
  28487. if m.id == nil || m.oldValue == nil {
  28488. return v, errors.New("OldBlockList requires an ID field in the mutation")
  28489. }
  28490. oldValue, err := m.oldValue(ctx)
  28491. if err != nil {
  28492. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  28493. }
  28494. return oldValue.BlockList, nil
  28495. }
  28496. // AppendBlockList adds s to the "block_list" field.
  28497. func (m *WxMutation) AppendBlockList(s []string) {
  28498. m.appendblock_list = append(m.appendblock_list, s...)
  28499. }
  28500. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  28501. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  28502. if len(m.appendblock_list) == 0 {
  28503. return nil, false
  28504. }
  28505. return m.appendblock_list, true
  28506. }
  28507. // ResetBlockList resets all changes to the "block_list" field.
  28508. func (m *WxMutation) ResetBlockList() {
  28509. m.block_list = nil
  28510. m.appendblock_list = nil
  28511. }
  28512. // SetGroupBlockList sets the "group_block_list" field.
  28513. func (m *WxMutation) SetGroupBlockList(s []string) {
  28514. m.group_block_list = &s
  28515. m.appendgroup_block_list = nil
  28516. }
  28517. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  28518. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  28519. v := m.group_block_list
  28520. if v == nil {
  28521. return
  28522. }
  28523. return *v, true
  28524. }
  28525. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  28526. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  28527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28528. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  28529. if !m.op.Is(OpUpdateOne) {
  28530. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  28531. }
  28532. if m.id == nil || m.oldValue == nil {
  28533. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  28534. }
  28535. oldValue, err := m.oldValue(ctx)
  28536. if err != nil {
  28537. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  28538. }
  28539. return oldValue.GroupBlockList, nil
  28540. }
  28541. // AppendGroupBlockList adds s to the "group_block_list" field.
  28542. func (m *WxMutation) AppendGroupBlockList(s []string) {
  28543. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  28544. }
  28545. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  28546. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  28547. if len(m.appendgroup_block_list) == 0 {
  28548. return nil, false
  28549. }
  28550. return m.appendgroup_block_list, true
  28551. }
  28552. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  28553. func (m *WxMutation) ResetGroupBlockList() {
  28554. m.group_block_list = nil
  28555. m.appendgroup_block_list = nil
  28556. }
  28557. // ClearServer clears the "server" edge to the Server entity.
  28558. func (m *WxMutation) ClearServer() {
  28559. m.clearedserver = true
  28560. m.clearedFields[wx.FieldServerID] = struct{}{}
  28561. }
  28562. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  28563. func (m *WxMutation) ServerCleared() bool {
  28564. return m.ServerIDCleared() || m.clearedserver
  28565. }
  28566. // ServerIDs returns the "server" edge IDs in the mutation.
  28567. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28568. // ServerID instead. It exists only for internal usage by the builders.
  28569. func (m *WxMutation) ServerIDs() (ids []uint64) {
  28570. if id := m.server; id != nil {
  28571. ids = append(ids, *id)
  28572. }
  28573. return
  28574. }
  28575. // ResetServer resets all changes to the "server" edge.
  28576. func (m *WxMutation) ResetServer() {
  28577. m.server = nil
  28578. m.clearedserver = false
  28579. }
  28580. // ClearAgent clears the "agent" edge to the Agent entity.
  28581. func (m *WxMutation) ClearAgent() {
  28582. m.clearedagent = true
  28583. m.clearedFields[wx.FieldAgentID] = struct{}{}
  28584. }
  28585. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  28586. func (m *WxMutation) AgentCleared() bool {
  28587. return m.clearedagent
  28588. }
  28589. // AgentIDs returns the "agent" edge IDs in the mutation.
  28590. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28591. // AgentID instead. It exists only for internal usage by the builders.
  28592. func (m *WxMutation) AgentIDs() (ids []uint64) {
  28593. if id := m.agent; id != nil {
  28594. ids = append(ids, *id)
  28595. }
  28596. return
  28597. }
  28598. // ResetAgent resets all changes to the "agent" edge.
  28599. func (m *WxMutation) ResetAgent() {
  28600. m.agent = nil
  28601. m.clearedagent = false
  28602. }
  28603. // Where appends a list predicates to the WxMutation builder.
  28604. func (m *WxMutation) Where(ps ...predicate.Wx) {
  28605. m.predicates = append(m.predicates, ps...)
  28606. }
  28607. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  28608. // users can use type-assertion to append predicates that do not depend on any generated package.
  28609. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  28610. p := make([]predicate.Wx, len(ps))
  28611. for i := range ps {
  28612. p[i] = ps[i]
  28613. }
  28614. m.Where(p...)
  28615. }
  28616. // Op returns the operation name.
  28617. func (m *WxMutation) Op() Op {
  28618. return m.op
  28619. }
  28620. // SetOp allows setting the mutation operation.
  28621. func (m *WxMutation) SetOp(op Op) {
  28622. m.op = op
  28623. }
  28624. // Type returns the node type of this mutation (Wx).
  28625. func (m *WxMutation) Type() string {
  28626. return m.typ
  28627. }
  28628. // Fields returns all fields that were changed during this mutation. Note that in
  28629. // order to get all numeric fields that were incremented/decremented, call
  28630. // AddedFields().
  28631. func (m *WxMutation) Fields() []string {
  28632. fields := make([]string, 0, 21)
  28633. if m.created_at != nil {
  28634. fields = append(fields, wx.FieldCreatedAt)
  28635. }
  28636. if m.updated_at != nil {
  28637. fields = append(fields, wx.FieldUpdatedAt)
  28638. }
  28639. if m.status != nil {
  28640. fields = append(fields, wx.FieldStatus)
  28641. }
  28642. if m.deleted_at != nil {
  28643. fields = append(fields, wx.FieldDeletedAt)
  28644. }
  28645. if m.server != nil {
  28646. fields = append(fields, wx.FieldServerID)
  28647. }
  28648. if m.port != nil {
  28649. fields = append(fields, wx.FieldPort)
  28650. }
  28651. if m.process_id != nil {
  28652. fields = append(fields, wx.FieldProcessID)
  28653. }
  28654. if m.callback != nil {
  28655. fields = append(fields, wx.FieldCallback)
  28656. }
  28657. if m.wxid != nil {
  28658. fields = append(fields, wx.FieldWxid)
  28659. }
  28660. if m.account != nil {
  28661. fields = append(fields, wx.FieldAccount)
  28662. }
  28663. if m.nickname != nil {
  28664. fields = append(fields, wx.FieldNickname)
  28665. }
  28666. if m.tel != nil {
  28667. fields = append(fields, wx.FieldTel)
  28668. }
  28669. if m.head_big != nil {
  28670. fields = append(fields, wx.FieldHeadBig)
  28671. }
  28672. if m.organization_id != nil {
  28673. fields = append(fields, wx.FieldOrganizationID)
  28674. }
  28675. if m.agent != nil {
  28676. fields = append(fields, wx.FieldAgentID)
  28677. }
  28678. if m.api_base != nil {
  28679. fields = append(fields, wx.FieldAPIBase)
  28680. }
  28681. if m.api_key != nil {
  28682. fields = append(fields, wx.FieldAPIKey)
  28683. }
  28684. if m.allow_list != nil {
  28685. fields = append(fields, wx.FieldAllowList)
  28686. }
  28687. if m.group_allow_list != nil {
  28688. fields = append(fields, wx.FieldGroupAllowList)
  28689. }
  28690. if m.block_list != nil {
  28691. fields = append(fields, wx.FieldBlockList)
  28692. }
  28693. if m.group_block_list != nil {
  28694. fields = append(fields, wx.FieldGroupBlockList)
  28695. }
  28696. return fields
  28697. }
  28698. // Field returns the value of a field with the given name. The second boolean
  28699. // return value indicates that this field was not set, or was not defined in the
  28700. // schema.
  28701. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  28702. switch name {
  28703. case wx.FieldCreatedAt:
  28704. return m.CreatedAt()
  28705. case wx.FieldUpdatedAt:
  28706. return m.UpdatedAt()
  28707. case wx.FieldStatus:
  28708. return m.Status()
  28709. case wx.FieldDeletedAt:
  28710. return m.DeletedAt()
  28711. case wx.FieldServerID:
  28712. return m.ServerID()
  28713. case wx.FieldPort:
  28714. return m.Port()
  28715. case wx.FieldProcessID:
  28716. return m.ProcessID()
  28717. case wx.FieldCallback:
  28718. return m.Callback()
  28719. case wx.FieldWxid:
  28720. return m.Wxid()
  28721. case wx.FieldAccount:
  28722. return m.Account()
  28723. case wx.FieldNickname:
  28724. return m.Nickname()
  28725. case wx.FieldTel:
  28726. return m.Tel()
  28727. case wx.FieldHeadBig:
  28728. return m.HeadBig()
  28729. case wx.FieldOrganizationID:
  28730. return m.OrganizationID()
  28731. case wx.FieldAgentID:
  28732. return m.AgentID()
  28733. case wx.FieldAPIBase:
  28734. return m.APIBase()
  28735. case wx.FieldAPIKey:
  28736. return m.APIKey()
  28737. case wx.FieldAllowList:
  28738. return m.AllowList()
  28739. case wx.FieldGroupAllowList:
  28740. return m.GroupAllowList()
  28741. case wx.FieldBlockList:
  28742. return m.BlockList()
  28743. case wx.FieldGroupBlockList:
  28744. return m.GroupBlockList()
  28745. }
  28746. return nil, false
  28747. }
  28748. // OldField returns the old value of the field from the database. An error is
  28749. // returned if the mutation operation is not UpdateOne, or the query to the
  28750. // database failed.
  28751. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28752. switch name {
  28753. case wx.FieldCreatedAt:
  28754. return m.OldCreatedAt(ctx)
  28755. case wx.FieldUpdatedAt:
  28756. return m.OldUpdatedAt(ctx)
  28757. case wx.FieldStatus:
  28758. return m.OldStatus(ctx)
  28759. case wx.FieldDeletedAt:
  28760. return m.OldDeletedAt(ctx)
  28761. case wx.FieldServerID:
  28762. return m.OldServerID(ctx)
  28763. case wx.FieldPort:
  28764. return m.OldPort(ctx)
  28765. case wx.FieldProcessID:
  28766. return m.OldProcessID(ctx)
  28767. case wx.FieldCallback:
  28768. return m.OldCallback(ctx)
  28769. case wx.FieldWxid:
  28770. return m.OldWxid(ctx)
  28771. case wx.FieldAccount:
  28772. return m.OldAccount(ctx)
  28773. case wx.FieldNickname:
  28774. return m.OldNickname(ctx)
  28775. case wx.FieldTel:
  28776. return m.OldTel(ctx)
  28777. case wx.FieldHeadBig:
  28778. return m.OldHeadBig(ctx)
  28779. case wx.FieldOrganizationID:
  28780. return m.OldOrganizationID(ctx)
  28781. case wx.FieldAgentID:
  28782. return m.OldAgentID(ctx)
  28783. case wx.FieldAPIBase:
  28784. return m.OldAPIBase(ctx)
  28785. case wx.FieldAPIKey:
  28786. return m.OldAPIKey(ctx)
  28787. case wx.FieldAllowList:
  28788. return m.OldAllowList(ctx)
  28789. case wx.FieldGroupAllowList:
  28790. return m.OldGroupAllowList(ctx)
  28791. case wx.FieldBlockList:
  28792. return m.OldBlockList(ctx)
  28793. case wx.FieldGroupBlockList:
  28794. return m.OldGroupBlockList(ctx)
  28795. }
  28796. return nil, fmt.Errorf("unknown Wx field %s", name)
  28797. }
  28798. // SetField sets the value of a field with the given name. It returns an error if
  28799. // the field is not defined in the schema, or if the type mismatched the field
  28800. // type.
  28801. func (m *WxMutation) SetField(name string, value ent.Value) error {
  28802. switch name {
  28803. case wx.FieldCreatedAt:
  28804. v, ok := value.(time.Time)
  28805. if !ok {
  28806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28807. }
  28808. m.SetCreatedAt(v)
  28809. return nil
  28810. case wx.FieldUpdatedAt:
  28811. v, ok := value.(time.Time)
  28812. if !ok {
  28813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28814. }
  28815. m.SetUpdatedAt(v)
  28816. return nil
  28817. case wx.FieldStatus:
  28818. v, ok := value.(uint8)
  28819. if !ok {
  28820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28821. }
  28822. m.SetStatus(v)
  28823. return nil
  28824. case wx.FieldDeletedAt:
  28825. v, ok := value.(time.Time)
  28826. if !ok {
  28827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28828. }
  28829. m.SetDeletedAt(v)
  28830. return nil
  28831. case wx.FieldServerID:
  28832. v, ok := value.(uint64)
  28833. if !ok {
  28834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28835. }
  28836. m.SetServerID(v)
  28837. return nil
  28838. case wx.FieldPort:
  28839. v, ok := value.(string)
  28840. if !ok {
  28841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28842. }
  28843. m.SetPort(v)
  28844. return nil
  28845. case wx.FieldProcessID:
  28846. v, ok := value.(string)
  28847. if !ok {
  28848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28849. }
  28850. m.SetProcessID(v)
  28851. return nil
  28852. case wx.FieldCallback:
  28853. v, ok := value.(string)
  28854. if !ok {
  28855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28856. }
  28857. m.SetCallback(v)
  28858. return nil
  28859. case wx.FieldWxid:
  28860. v, ok := value.(string)
  28861. if !ok {
  28862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28863. }
  28864. m.SetWxid(v)
  28865. return nil
  28866. case wx.FieldAccount:
  28867. v, ok := value.(string)
  28868. if !ok {
  28869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28870. }
  28871. m.SetAccount(v)
  28872. return nil
  28873. case wx.FieldNickname:
  28874. v, ok := value.(string)
  28875. if !ok {
  28876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28877. }
  28878. m.SetNickname(v)
  28879. return nil
  28880. case wx.FieldTel:
  28881. v, ok := value.(string)
  28882. if !ok {
  28883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28884. }
  28885. m.SetTel(v)
  28886. return nil
  28887. case wx.FieldHeadBig:
  28888. v, ok := value.(string)
  28889. if !ok {
  28890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28891. }
  28892. m.SetHeadBig(v)
  28893. return nil
  28894. case wx.FieldOrganizationID:
  28895. v, ok := value.(uint64)
  28896. if !ok {
  28897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28898. }
  28899. m.SetOrganizationID(v)
  28900. return nil
  28901. case wx.FieldAgentID:
  28902. v, ok := value.(uint64)
  28903. if !ok {
  28904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28905. }
  28906. m.SetAgentID(v)
  28907. return nil
  28908. case wx.FieldAPIBase:
  28909. v, ok := value.(string)
  28910. if !ok {
  28911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28912. }
  28913. m.SetAPIBase(v)
  28914. return nil
  28915. case wx.FieldAPIKey:
  28916. v, ok := value.(string)
  28917. if !ok {
  28918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28919. }
  28920. m.SetAPIKey(v)
  28921. return nil
  28922. case wx.FieldAllowList:
  28923. v, ok := value.([]string)
  28924. if !ok {
  28925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28926. }
  28927. m.SetAllowList(v)
  28928. return nil
  28929. case wx.FieldGroupAllowList:
  28930. v, ok := value.([]string)
  28931. if !ok {
  28932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28933. }
  28934. m.SetGroupAllowList(v)
  28935. return nil
  28936. case wx.FieldBlockList:
  28937. v, ok := value.([]string)
  28938. if !ok {
  28939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28940. }
  28941. m.SetBlockList(v)
  28942. return nil
  28943. case wx.FieldGroupBlockList:
  28944. v, ok := value.([]string)
  28945. if !ok {
  28946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28947. }
  28948. m.SetGroupBlockList(v)
  28949. return nil
  28950. }
  28951. return fmt.Errorf("unknown Wx field %s", name)
  28952. }
  28953. // AddedFields returns all numeric fields that were incremented/decremented during
  28954. // this mutation.
  28955. func (m *WxMutation) AddedFields() []string {
  28956. var fields []string
  28957. if m.addstatus != nil {
  28958. fields = append(fields, wx.FieldStatus)
  28959. }
  28960. if m.addorganization_id != nil {
  28961. fields = append(fields, wx.FieldOrganizationID)
  28962. }
  28963. return fields
  28964. }
  28965. // AddedField returns the numeric value that was incremented/decremented on a field
  28966. // with the given name. The second boolean return value indicates that this field
  28967. // was not set, or was not defined in the schema.
  28968. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  28969. switch name {
  28970. case wx.FieldStatus:
  28971. return m.AddedStatus()
  28972. case wx.FieldOrganizationID:
  28973. return m.AddedOrganizationID()
  28974. }
  28975. return nil, false
  28976. }
  28977. // AddField adds the value to the field with the given name. It returns an error if
  28978. // the field is not defined in the schema, or if the type mismatched the field
  28979. // type.
  28980. func (m *WxMutation) AddField(name string, value ent.Value) error {
  28981. switch name {
  28982. case wx.FieldStatus:
  28983. v, ok := value.(int8)
  28984. if !ok {
  28985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28986. }
  28987. m.AddStatus(v)
  28988. return nil
  28989. case wx.FieldOrganizationID:
  28990. v, ok := value.(int64)
  28991. if !ok {
  28992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28993. }
  28994. m.AddOrganizationID(v)
  28995. return nil
  28996. }
  28997. return fmt.Errorf("unknown Wx numeric field %s", name)
  28998. }
  28999. // ClearedFields returns all nullable fields that were cleared during this
  29000. // mutation.
  29001. func (m *WxMutation) ClearedFields() []string {
  29002. var fields []string
  29003. if m.FieldCleared(wx.FieldStatus) {
  29004. fields = append(fields, wx.FieldStatus)
  29005. }
  29006. if m.FieldCleared(wx.FieldDeletedAt) {
  29007. fields = append(fields, wx.FieldDeletedAt)
  29008. }
  29009. if m.FieldCleared(wx.FieldServerID) {
  29010. fields = append(fields, wx.FieldServerID)
  29011. }
  29012. if m.FieldCleared(wx.FieldOrganizationID) {
  29013. fields = append(fields, wx.FieldOrganizationID)
  29014. }
  29015. if m.FieldCleared(wx.FieldAPIBase) {
  29016. fields = append(fields, wx.FieldAPIBase)
  29017. }
  29018. if m.FieldCleared(wx.FieldAPIKey) {
  29019. fields = append(fields, wx.FieldAPIKey)
  29020. }
  29021. return fields
  29022. }
  29023. // FieldCleared returns a boolean indicating if a field with the given name was
  29024. // cleared in this mutation.
  29025. func (m *WxMutation) FieldCleared(name string) bool {
  29026. _, ok := m.clearedFields[name]
  29027. return ok
  29028. }
  29029. // ClearField clears the value of the field with the given name. It returns an
  29030. // error if the field is not defined in the schema.
  29031. func (m *WxMutation) ClearField(name string) error {
  29032. switch name {
  29033. case wx.FieldStatus:
  29034. m.ClearStatus()
  29035. return nil
  29036. case wx.FieldDeletedAt:
  29037. m.ClearDeletedAt()
  29038. return nil
  29039. case wx.FieldServerID:
  29040. m.ClearServerID()
  29041. return nil
  29042. case wx.FieldOrganizationID:
  29043. m.ClearOrganizationID()
  29044. return nil
  29045. case wx.FieldAPIBase:
  29046. m.ClearAPIBase()
  29047. return nil
  29048. case wx.FieldAPIKey:
  29049. m.ClearAPIKey()
  29050. return nil
  29051. }
  29052. return fmt.Errorf("unknown Wx nullable field %s", name)
  29053. }
  29054. // ResetField resets all changes in the mutation for the field with the given name.
  29055. // It returns an error if the field is not defined in the schema.
  29056. func (m *WxMutation) ResetField(name string) error {
  29057. switch name {
  29058. case wx.FieldCreatedAt:
  29059. m.ResetCreatedAt()
  29060. return nil
  29061. case wx.FieldUpdatedAt:
  29062. m.ResetUpdatedAt()
  29063. return nil
  29064. case wx.FieldStatus:
  29065. m.ResetStatus()
  29066. return nil
  29067. case wx.FieldDeletedAt:
  29068. m.ResetDeletedAt()
  29069. return nil
  29070. case wx.FieldServerID:
  29071. m.ResetServerID()
  29072. return nil
  29073. case wx.FieldPort:
  29074. m.ResetPort()
  29075. return nil
  29076. case wx.FieldProcessID:
  29077. m.ResetProcessID()
  29078. return nil
  29079. case wx.FieldCallback:
  29080. m.ResetCallback()
  29081. return nil
  29082. case wx.FieldWxid:
  29083. m.ResetWxid()
  29084. return nil
  29085. case wx.FieldAccount:
  29086. m.ResetAccount()
  29087. return nil
  29088. case wx.FieldNickname:
  29089. m.ResetNickname()
  29090. return nil
  29091. case wx.FieldTel:
  29092. m.ResetTel()
  29093. return nil
  29094. case wx.FieldHeadBig:
  29095. m.ResetHeadBig()
  29096. return nil
  29097. case wx.FieldOrganizationID:
  29098. m.ResetOrganizationID()
  29099. return nil
  29100. case wx.FieldAgentID:
  29101. m.ResetAgentID()
  29102. return nil
  29103. case wx.FieldAPIBase:
  29104. m.ResetAPIBase()
  29105. return nil
  29106. case wx.FieldAPIKey:
  29107. m.ResetAPIKey()
  29108. return nil
  29109. case wx.FieldAllowList:
  29110. m.ResetAllowList()
  29111. return nil
  29112. case wx.FieldGroupAllowList:
  29113. m.ResetGroupAllowList()
  29114. return nil
  29115. case wx.FieldBlockList:
  29116. m.ResetBlockList()
  29117. return nil
  29118. case wx.FieldGroupBlockList:
  29119. m.ResetGroupBlockList()
  29120. return nil
  29121. }
  29122. return fmt.Errorf("unknown Wx field %s", name)
  29123. }
  29124. // AddedEdges returns all edge names that were set/added in this mutation.
  29125. func (m *WxMutation) AddedEdges() []string {
  29126. edges := make([]string, 0, 2)
  29127. if m.server != nil {
  29128. edges = append(edges, wx.EdgeServer)
  29129. }
  29130. if m.agent != nil {
  29131. edges = append(edges, wx.EdgeAgent)
  29132. }
  29133. return edges
  29134. }
  29135. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29136. // name in this mutation.
  29137. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  29138. switch name {
  29139. case wx.EdgeServer:
  29140. if id := m.server; id != nil {
  29141. return []ent.Value{*id}
  29142. }
  29143. case wx.EdgeAgent:
  29144. if id := m.agent; id != nil {
  29145. return []ent.Value{*id}
  29146. }
  29147. }
  29148. return nil
  29149. }
  29150. // RemovedEdges returns all edge names that were removed in this mutation.
  29151. func (m *WxMutation) RemovedEdges() []string {
  29152. edges := make([]string, 0, 2)
  29153. return edges
  29154. }
  29155. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29156. // the given name in this mutation.
  29157. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  29158. return nil
  29159. }
  29160. // ClearedEdges returns all edge names that were cleared in this mutation.
  29161. func (m *WxMutation) ClearedEdges() []string {
  29162. edges := make([]string, 0, 2)
  29163. if m.clearedserver {
  29164. edges = append(edges, wx.EdgeServer)
  29165. }
  29166. if m.clearedagent {
  29167. edges = append(edges, wx.EdgeAgent)
  29168. }
  29169. return edges
  29170. }
  29171. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29172. // was cleared in this mutation.
  29173. func (m *WxMutation) EdgeCleared(name string) bool {
  29174. switch name {
  29175. case wx.EdgeServer:
  29176. return m.clearedserver
  29177. case wx.EdgeAgent:
  29178. return m.clearedagent
  29179. }
  29180. return false
  29181. }
  29182. // ClearEdge clears the value of the edge with the given name. It returns an error
  29183. // if that edge is not defined in the schema.
  29184. func (m *WxMutation) ClearEdge(name string) error {
  29185. switch name {
  29186. case wx.EdgeServer:
  29187. m.ClearServer()
  29188. return nil
  29189. case wx.EdgeAgent:
  29190. m.ClearAgent()
  29191. return nil
  29192. }
  29193. return fmt.Errorf("unknown Wx unique edge %s", name)
  29194. }
  29195. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29196. // It returns an error if the edge is not defined in the schema.
  29197. func (m *WxMutation) ResetEdge(name string) error {
  29198. switch name {
  29199. case wx.EdgeServer:
  29200. m.ResetServer()
  29201. return nil
  29202. case wx.EdgeAgent:
  29203. m.ResetAgent()
  29204. return nil
  29205. }
  29206. return fmt.Errorf("unknown Wx edge %s", name)
  29207. }
  29208. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  29209. type WxCardMutation struct {
  29210. config
  29211. op Op
  29212. typ string
  29213. id *uint64
  29214. created_at *time.Time
  29215. updated_at *time.Time
  29216. deleted_at *time.Time
  29217. user_id *uint64
  29218. adduser_id *int64
  29219. wx_user_id *uint64
  29220. addwx_user_id *int64
  29221. avatar *string
  29222. logo *string
  29223. name *string
  29224. company *string
  29225. address *string
  29226. phone *string
  29227. official_account *string
  29228. wechat_account *string
  29229. email *string
  29230. api_base *string
  29231. api_key *string
  29232. ai_info *string
  29233. intro *string
  29234. clearedFields map[string]struct{}
  29235. done bool
  29236. oldValue func(context.Context) (*WxCard, error)
  29237. predicates []predicate.WxCard
  29238. }
  29239. var _ ent.Mutation = (*WxCardMutation)(nil)
  29240. // wxcardOption allows management of the mutation configuration using functional options.
  29241. type wxcardOption func(*WxCardMutation)
  29242. // newWxCardMutation creates new mutation for the WxCard entity.
  29243. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  29244. m := &WxCardMutation{
  29245. config: c,
  29246. op: op,
  29247. typ: TypeWxCard,
  29248. clearedFields: make(map[string]struct{}),
  29249. }
  29250. for _, opt := range opts {
  29251. opt(m)
  29252. }
  29253. return m
  29254. }
  29255. // withWxCardID sets the ID field of the mutation.
  29256. func withWxCardID(id uint64) wxcardOption {
  29257. return func(m *WxCardMutation) {
  29258. var (
  29259. err error
  29260. once sync.Once
  29261. value *WxCard
  29262. )
  29263. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  29264. once.Do(func() {
  29265. if m.done {
  29266. err = errors.New("querying old values post mutation is not allowed")
  29267. } else {
  29268. value, err = m.Client().WxCard.Get(ctx, id)
  29269. }
  29270. })
  29271. return value, err
  29272. }
  29273. m.id = &id
  29274. }
  29275. }
  29276. // withWxCard sets the old WxCard of the mutation.
  29277. func withWxCard(node *WxCard) wxcardOption {
  29278. return func(m *WxCardMutation) {
  29279. m.oldValue = func(context.Context) (*WxCard, error) {
  29280. return node, nil
  29281. }
  29282. m.id = &node.ID
  29283. }
  29284. }
  29285. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29286. // executed in a transaction (ent.Tx), a transactional client is returned.
  29287. func (m WxCardMutation) Client() *Client {
  29288. client := &Client{config: m.config}
  29289. client.init()
  29290. return client
  29291. }
  29292. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29293. // it returns an error otherwise.
  29294. func (m WxCardMutation) Tx() (*Tx, error) {
  29295. if _, ok := m.driver.(*txDriver); !ok {
  29296. return nil, errors.New("ent: mutation is not running in a transaction")
  29297. }
  29298. tx := &Tx{config: m.config}
  29299. tx.init()
  29300. return tx, nil
  29301. }
  29302. // SetID sets the value of the id field. Note that this
  29303. // operation is only accepted on creation of WxCard entities.
  29304. func (m *WxCardMutation) SetID(id uint64) {
  29305. m.id = &id
  29306. }
  29307. // ID returns the ID value in the mutation. Note that the ID is only available
  29308. // if it was provided to the builder or after it was returned from the database.
  29309. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  29310. if m.id == nil {
  29311. return
  29312. }
  29313. return *m.id, true
  29314. }
  29315. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29316. // That means, if the mutation is applied within a transaction with an isolation level such
  29317. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29318. // or updated by the mutation.
  29319. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  29320. switch {
  29321. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29322. id, exists := m.ID()
  29323. if exists {
  29324. return []uint64{id}, nil
  29325. }
  29326. fallthrough
  29327. case m.op.Is(OpUpdate | OpDelete):
  29328. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  29329. default:
  29330. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29331. }
  29332. }
  29333. // SetCreatedAt sets the "created_at" field.
  29334. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  29335. m.created_at = &t
  29336. }
  29337. // CreatedAt returns the value of the "created_at" field in the mutation.
  29338. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  29339. v := m.created_at
  29340. if v == nil {
  29341. return
  29342. }
  29343. return *v, true
  29344. }
  29345. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  29346. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29348. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29349. if !m.op.Is(OpUpdateOne) {
  29350. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29351. }
  29352. if m.id == nil || m.oldValue == nil {
  29353. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29354. }
  29355. oldValue, err := m.oldValue(ctx)
  29356. if err != nil {
  29357. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29358. }
  29359. return oldValue.CreatedAt, nil
  29360. }
  29361. // ResetCreatedAt resets all changes to the "created_at" field.
  29362. func (m *WxCardMutation) ResetCreatedAt() {
  29363. m.created_at = nil
  29364. }
  29365. // SetUpdatedAt sets the "updated_at" field.
  29366. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  29367. m.updated_at = &t
  29368. }
  29369. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29370. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  29371. v := m.updated_at
  29372. if v == nil {
  29373. return
  29374. }
  29375. return *v, true
  29376. }
  29377. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  29378. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29380. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29381. if !m.op.Is(OpUpdateOne) {
  29382. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29383. }
  29384. if m.id == nil || m.oldValue == nil {
  29385. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29386. }
  29387. oldValue, err := m.oldValue(ctx)
  29388. if err != nil {
  29389. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29390. }
  29391. return oldValue.UpdatedAt, nil
  29392. }
  29393. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29394. func (m *WxCardMutation) ResetUpdatedAt() {
  29395. m.updated_at = nil
  29396. }
  29397. // SetDeletedAt sets the "deleted_at" field.
  29398. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  29399. m.deleted_at = &t
  29400. }
  29401. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29402. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  29403. v := m.deleted_at
  29404. if v == nil {
  29405. return
  29406. }
  29407. return *v, true
  29408. }
  29409. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  29410. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29412. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29413. if !m.op.Is(OpUpdateOne) {
  29414. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29415. }
  29416. if m.id == nil || m.oldValue == nil {
  29417. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29418. }
  29419. oldValue, err := m.oldValue(ctx)
  29420. if err != nil {
  29421. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29422. }
  29423. return oldValue.DeletedAt, nil
  29424. }
  29425. // ClearDeletedAt clears the value of the "deleted_at" field.
  29426. func (m *WxCardMutation) ClearDeletedAt() {
  29427. m.deleted_at = nil
  29428. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  29429. }
  29430. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29431. func (m *WxCardMutation) DeletedAtCleared() bool {
  29432. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  29433. return ok
  29434. }
  29435. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29436. func (m *WxCardMutation) ResetDeletedAt() {
  29437. m.deleted_at = nil
  29438. delete(m.clearedFields, wxcard.FieldDeletedAt)
  29439. }
  29440. // SetUserID sets the "user_id" field.
  29441. func (m *WxCardMutation) SetUserID(u uint64) {
  29442. m.user_id = &u
  29443. m.adduser_id = nil
  29444. }
  29445. // UserID returns the value of the "user_id" field in the mutation.
  29446. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  29447. v := m.user_id
  29448. if v == nil {
  29449. return
  29450. }
  29451. return *v, true
  29452. }
  29453. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  29454. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29456. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  29457. if !m.op.Is(OpUpdateOne) {
  29458. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  29459. }
  29460. if m.id == nil || m.oldValue == nil {
  29461. return v, errors.New("OldUserID requires an ID field in the mutation")
  29462. }
  29463. oldValue, err := m.oldValue(ctx)
  29464. if err != nil {
  29465. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  29466. }
  29467. return oldValue.UserID, nil
  29468. }
  29469. // AddUserID adds u to the "user_id" field.
  29470. func (m *WxCardMutation) AddUserID(u int64) {
  29471. if m.adduser_id != nil {
  29472. *m.adduser_id += u
  29473. } else {
  29474. m.adduser_id = &u
  29475. }
  29476. }
  29477. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  29478. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  29479. v := m.adduser_id
  29480. if v == nil {
  29481. return
  29482. }
  29483. return *v, true
  29484. }
  29485. // ClearUserID clears the value of the "user_id" field.
  29486. func (m *WxCardMutation) ClearUserID() {
  29487. m.user_id = nil
  29488. m.adduser_id = nil
  29489. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  29490. }
  29491. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  29492. func (m *WxCardMutation) UserIDCleared() bool {
  29493. _, ok := m.clearedFields[wxcard.FieldUserID]
  29494. return ok
  29495. }
  29496. // ResetUserID resets all changes to the "user_id" field.
  29497. func (m *WxCardMutation) ResetUserID() {
  29498. m.user_id = nil
  29499. m.adduser_id = nil
  29500. delete(m.clearedFields, wxcard.FieldUserID)
  29501. }
  29502. // SetWxUserID sets the "wx_user_id" field.
  29503. func (m *WxCardMutation) SetWxUserID(u uint64) {
  29504. m.wx_user_id = &u
  29505. m.addwx_user_id = nil
  29506. }
  29507. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  29508. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  29509. v := m.wx_user_id
  29510. if v == nil {
  29511. return
  29512. }
  29513. return *v, true
  29514. }
  29515. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  29516. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29518. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  29519. if !m.op.Is(OpUpdateOne) {
  29520. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  29521. }
  29522. if m.id == nil || m.oldValue == nil {
  29523. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  29524. }
  29525. oldValue, err := m.oldValue(ctx)
  29526. if err != nil {
  29527. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  29528. }
  29529. return oldValue.WxUserID, nil
  29530. }
  29531. // AddWxUserID adds u to the "wx_user_id" field.
  29532. func (m *WxCardMutation) AddWxUserID(u int64) {
  29533. if m.addwx_user_id != nil {
  29534. *m.addwx_user_id += u
  29535. } else {
  29536. m.addwx_user_id = &u
  29537. }
  29538. }
  29539. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  29540. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  29541. v := m.addwx_user_id
  29542. if v == nil {
  29543. return
  29544. }
  29545. return *v, true
  29546. }
  29547. // ClearWxUserID clears the value of the "wx_user_id" field.
  29548. func (m *WxCardMutation) ClearWxUserID() {
  29549. m.wx_user_id = nil
  29550. m.addwx_user_id = nil
  29551. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  29552. }
  29553. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  29554. func (m *WxCardMutation) WxUserIDCleared() bool {
  29555. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  29556. return ok
  29557. }
  29558. // ResetWxUserID resets all changes to the "wx_user_id" field.
  29559. func (m *WxCardMutation) ResetWxUserID() {
  29560. m.wx_user_id = nil
  29561. m.addwx_user_id = nil
  29562. delete(m.clearedFields, wxcard.FieldWxUserID)
  29563. }
  29564. // SetAvatar sets the "avatar" field.
  29565. func (m *WxCardMutation) SetAvatar(s string) {
  29566. m.avatar = &s
  29567. }
  29568. // Avatar returns the value of the "avatar" field in the mutation.
  29569. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  29570. v := m.avatar
  29571. if v == nil {
  29572. return
  29573. }
  29574. return *v, true
  29575. }
  29576. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  29577. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29579. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  29580. if !m.op.Is(OpUpdateOne) {
  29581. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  29582. }
  29583. if m.id == nil || m.oldValue == nil {
  29584. return v, errors.New("OldAvatar requires an ID field in the mutation")
  29585. }
  29586. oldValue, err := m.oldValue(ctx)
  29587. if err != nil {
  29588. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  29589. }
  29590. return oldValue.Avatar, nil
  29591. }
  29592. // ResetAvatar resets all changes to the "avatar" field.
  29593. func (m *WxCardMutation) ResetAvatar() {
  29594. m.avatar = nil
  29595. }
  29596. // SetLogo sets the "logo" field.
  29597. func (m *WxCardMutation) SetLogo(s string) {
  29598. m.logo = &s
  29599. }
  29600. // Logo returns the value of the "logo" field in the mutation.
  29601. func (m *WxCardMutation) Logo() (r string, exists bool) {
  29602. v := m.logo
  29603. if v == nil {
  29604. return
  29605. }
  29606. return *v, true
  29607. }
  29608. // OldLogo returns the old "logo" field's value of the WxCard entity.
  29609. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29611. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  29612. if !m.op.Is(OpUpdateOne) {
  29613. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  29614. }
  29615. if m.id == nil || m.oldValue == nil {
  29616. return v, errors.New("OldLogo requires an ID field in the mutation")
  29617. }
  29618. oldValue, err := m.oldValue(ctx)
  29619. if err != nil {
  29620. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  29621. }
  29622. return oldValue.Logo, nil
  29623. }
  29624. // ResetLogo resets all changes to the "logo" field.
  29625. func (m *WxCardMutation) ResetLogo() {
  29626. m.logo = nil
  29627. }
  29628. // SetName sets the "name" field.
  29629. func (m *WxCardMutation) SetName(s string) {
  29630. m.name = &s
  29631. }
  29632. // Name returns the value of the "name" field in the mutation.
  29633. func (m *WxCardMutation) Name() (r string, exists bool) {
  29634. v := m.name
  29635. if v == nil {
  29636. return
  29637. }
  29638. return *v, true
  29639. }
  29640. // OldName returns the old "name" field's value of the WxCard entity.
  29641. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29643. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  29644. if !m.op.Is(OpUpdateOne) {
  29645. return v, errors.New("OldName is only allowed on UpdateOne operations")
  29646. }
  29647. if m.id == nil || m.oldValue == nil {
  29648. return v, errors.New("OldName requires an ID field in the mutation")
  29649. }
  29650. oldValue, err := m.oldValue(ctx)
  29651. if err != nil {
  29652. return v, fmt.Errorf("querying old value for OldName: %w", err)
  29653. }
  29654. return oldValue.Name, nil
  29655. }
  29656. // ResetName resets all changes to the "name" field.
  29657. func (m *WxCardMutation) ResetName() {
  29658. m.name = nil
  29659. }
  29660. // SetCompany sets the "company" field.
  29661. func (m *WxCardMutation) SetCompany(s string) {
  29662. m.company = &s
  29663. }
  29664. // Company returns the value of the "company" field in the mutation.
  29665. func (m *WxCardMutation) Company() (r string, exists bool) {
  29666. v := m.company
  29667. if v == nil {
  29668. return
  29669. }
  29670. return *v, true
  29671. }
  29672. // OldCompany returns the old "company" field's value of the WxCard entity.
  29673. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29675. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  29676. if !m.op.Is(OpUpdateOne) {
  29677. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  29678. }
  29679. if m.id == nil || m.oldValue == nil {
  29680. return v, errors.New("OldCompany requires an ID field in the mutation")
  29681. }
  29682. oldValue, err := m.oldValue(ctx)
  29683. if err != nil {
  29684. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  29685. }
  29686. return oldValue.Company, nil
  29687. }
  29688. // ResetCompany resets all changes to the "company" field.
  29689. func (m *WxCardMutation) ResetCompany() {
  29690. m.company = nil
  29691. }
  29692. // SetAddress sets the "address" field.
  29693. func (m *WxCardMutation) SetAddress(s string) {
  29694. m.address = &s
  29695. }
  29696. // Address returns the value of the "address" field in the mutation.
  29697. func (m *WxCardMutation) Address() (r string, exists bool) {
  29698. v := m.address
  29699. if v == nil {
  29700. return
  29701. }
  29702. return *v, true
  29703. }
  29704. // OldAddress returns the old "address" field's value of the WxCard entity.
  29705. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29707. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  29708. if !m.op.Is(OpUpdateOne) {
  29709. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  29710. }
  29711. if m.id == nil || m.oldValue == nil {
  29712. return v, errors.New("OldAddress requires an ID field in the mutation")
  29713. }
  29714. oldValue, err := m.oldValue(ctx)
  29715. if err != nil {
  29716. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  29717. }
  29718. return oldValue.Address, nil
  29719. }
  29720. // ResetAddress resets all changes to the "address" field.
  29721. func (m *WxCardMutation) ResetAddress() {
  29722. m.address = nil
  29723. }
  29724. // SetPhone sets the "phone" field.
  29725. func (m *WxCardMutation) SetPhone(s string) {
  29726. m.phone = &s
  29727. }
  29728. // Phone returns the value of the "phone" field in the mutation.
  29729. func (m *WxCardMutation) Phone() (r string, exists bool) {
  29730. v := m.phone
  29731. if v == nil {
  29732. return
  29733. }
  29734. return *v, true
  29735. }
  29736. // OldPhone returns the old "phone" field's value of the WxCard entity.
  29737. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29739. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  29740. if !m.op.Is(OpUpdateOne) {
  29741. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  29742. }
  29743. if m.id == nil || m.oldValue == nil {
  29744. return v, errors.New("OldPhone requires an ID field in the mutation")
  29745. }
  29746. oldValue, err := m.oldValue(ctx)
  29747. if err != nil {
  29748. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  29749. }
  29750. return oldValue.Phone, nil
  29751. }
  29752. // ResetPhone resets all changes to the "phone" field.
  29753. func (m *WxCardMutation) ResetPhone() {
  29754. m.phone = nil
  29755. }
  29756. // SetOfficialAccount sets the "official_account" field.
  29757. func (m *WxCardMutation) SetOfficialAccount(s string) {
  29758. m.official_account = &s
  29759. }
  29760. // OfficialAccount returns the value of the "official_account" field in the mutation.
  29761. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  29762. v := m.official_account
  29763. if v == nil {
  29764. return
  29765. }
  29766. return *v, true
  29767. }
  29768. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  29769. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29771. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  29772. if !m.op.Is(OpUpdateOne) {
  29773. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  29774. }
  29775. if m.id == nil || m.oldValue == nil {
  29776. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  29777. }
  29778. oldValue, err := m.oldValue(ctx)
  29779. if err != nil {
  29780. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  29781. }
  29782. return oldValue.OfficialAccount, nil
  29783. }
  29784. // ResetOfficialAccount resets all changes to the "official_account" field.
  29785. func (m *WxCardMutation) ResetOfficialAccount() {
  29786. m.official_account = nil
  29787. }
  29788. // SetWechatAccount sets the "wechat_account" field.
  29789. func (m *WxCardMutation) SetWechatAccount(s string) {
  29790. m.wechat_account = &s
  29791. }
  29792. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  29793. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  29794. v := m.wechat_account
  29795. if v == nil {
  29796. return
  29797. }
  29798. return *v, true
  29799. }
  29800. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  29801. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29803. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  29804. if !m.op.Is(OpUpdateOne) {
  29805. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  29806. }
  29807. if m.id == nil || m.oldValue == nil {
  29808. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  29809. }
  29810. oldValue, err := m.oldValue(ctx)
  29811. if err != nil {
  29812. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  29813. }
  29814. return oldValue.WechatAccount, nil
  29815. }
  29816. // ResetWechatAccount resets all changes to the "wechat_account" field.
  29817. func (m *WxCardMutation) ResetWechatAccount() {
  29818. m.wechat_account = nil
  29819. }
  29820. // SetEmail sets the "email" field.
  29821. func (m *WxCardMutation) SetEmail(s string) {
  29822. m.email = &s
  29823. }
  29824. // Email returns the value of the "email" field in the mutation.
  29825. func (m *WxCardMutation) Email() (r string, exists bool) {
  29826. v := m.email
  29827. if v == nil {
  29828. return
  29829. }
  29830. return *v, true
  29831. }
  29832. // OldEmail returns the old "email" field's value of the WxCard entity.
  29833. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29835. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  29836. if !m.op.Is(OpUpdateOne) {
  29837. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  29838. }
  29839. if m.id == nil || m.oldValue == nil {
  29840. return v, errors.New("OldEmail requires an ID field in the mutation")
  29841. }
  29842. oldValue, err := m.oldValue(ctx)
  29843. if err != nil {
  29844. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  29845. }
  29846. return oldValue.Email, nil
  29847. }
  29848. // ClearEmail clears the value of the "email" field.
  29849. func (m *WxCardMutation) ClearEmail() {
  29850. m.email = nil
  29851. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  29852. }
  29853. // EmailCleared returns if the "email" field was cleared in this mutation.
  29854. func (m *WxCardMutation) EmailCleared() bool {
  29855. _, ok := m.clearedFields[wxcard.FieldEmail]
  29856. return ok
  29857. }
  29858. // ResetEmail resets all changes to the "email" field.
  29859. func (m *WxCardMutation) ResetEmail() {
  29860. m.email = nil
  29861. delete(m.clearedFields, wxcard.FieldEmail)
  29862. }
  29863. // SetAPIBase sets the "api_base" field.
  29864. func (m *WxCardMutation) SetAPIBase(s string) {
  29865. m.api_base = &s
  29866. }
  29867. // APIBase returns the value of the "api_base" field in the mutation.
  29868. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  29869. v := m.api_base
  29870. if v == nil {
  29871. return
  29872. }
  29873. return *v, true
  29874. }
  29875. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  29876. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29878. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  29879. if !m.op.Is(OpUpdateOne) {
  29880. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  29881. }
  29882. if m.id == nil || m.oldValue == nil {
  29883. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  29884. }
  29885. oldValue, err := m.oldValue(ctx)
  29886. if err != nil {
  29887. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  29888. }
  29889. return oldValue.APIBase, nil
  29890. }
  29891. // ClearAPIBase clears the value of the "api_base" field.
  29892. func (m *WxCardMutation) ClearAPIBase() {
  29893. m.api_base = nil
  29894. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  29895. }
  29896. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  29897. func (m *WxCardMutation) APIBaseCleared() bool {
  29898. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  29899. return ok
  29900. }
  29901. // ResetAPIBase resets all changes to the "api_base" field.
  29902. func (m *WxCardMutation) ResetAPIBase() {
  29903. m.api_base = nil
  29904. delete(m.clearedFields, wxcard.FieldAPIBase)
  29905. }
  29906. // SetAPIKey sets the "api_key" field.
  29907. func (m *WxCardMutation) SetAPIKey(s string) {
  29908. m.api_key = &s
  29909. }
  29910. // APIKey returns the value of the "api_key" field in the mutation.
  29911. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  29912. v := m.api_key
  29913. if v == nil {
  29914. return
  29915. }
  29916. return *v, true
  29917. }
  29918. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  29919. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29921. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  29922. if !m.op.Is(OpUpdateOne) {
  29923. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  29924. }
  29925. if m.id == nil || m.oldValue == nil {
  29926. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  29927. }
  29928. oldValue, err := m.oldValue(ctx)
  29929. if err != nil {
  29930. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  29931. }
  29932. return oldValue.APIKey, nil
  29933. }
  29934. // ClearAPIKey clears the value of the "api_key" field.
  29935. func (m *WxCardMutation) ClearAPIKey() {
  29936. m.api_key = nil
  29937. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  29938. }
  29939. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  29940. func (m *WxCardMutation) APIKeyCleared() bool {
  29941. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  29942. return ok
  29943. }
  29944. // ResetAPIKey resets all changes to the "api_key" field.
  29945. func (m *WxCardMutation) ResetAPIKey() {
  29946. m.api_key = nil
  29947. delete(m.clearedFields, wxcard.FieldAPIKey)
  29948. }
  29949. // SetAiInfo sets the "ai_info" field.
  29950. func (m *WxCardMutation) SetAiInfo(s string) {
  29951. m.ai_info = &s
  29952. }
  29953. // AiInfo returns the value of the "ai_info" field in the mutation.
  29954. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  29955. v := m.ai_info
  29956. if v == nil {
  29957. return
  29958. }
  29959. return *v, true
  29960. }
  29961. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  29962. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29964. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  29965. if !m.op.Is(OpUpdateOne) {
  29966. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  29967. }
  29968. if m.id == nil || m.oldValue == nil {
  29969. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  29970. }
  29971. oldValue, err := m.oldValue(ctx)
  29972. if err != nil {
  29973. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  29974. }
  29975. return oldValue.AiInfo, nil
  29976. }
  29977. // ClearAiInfo clears the value of the "ai_info" field.
  29978. func (m *WxCardMutation) ClearAiInfo() {
  29979. m.ai_info = nil
  29980. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  29981. }
  29982. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  29983. func (m *WxCardMutation) AiInfoCleared() bool {
  29984. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  29985. return ok
  29986. }
  29987. // ResetAiInfo resets all changes to the "ai_info" field.
  29988. func (m *WxCardMutation) ResetAiInfo() {
  29989. m.ai_info = nil
  29990. delete(m.clearedFields, wxcard.FieldAiInfo)
  29991. }
  29992. // SetIntro sets the "intro" field.
  29993. func (m *WxCardMutation) SetIntro(s string) {
  29994. m.intro = &s
  29995. }
  29996. // Intro returns the value of the "intro" field in the mutation.
  29997. func (m *WxCardMutation) Intro() (r string, exists bool) {
  29998. v := m.intro
  29999. if v == nil {
  30000. return
  30001. }
  30002. return *v, true
  30003. }
  30004. // OldIntro returns the old "intro" field's value of the WxCard entity.
  30005. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  30006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30007. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  30008. if !m.op.Is(OpUpdateOne) {
  30009. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  30010. }
  30011. if m.id == nil || m.oldValue == nil {
  30012. return v, errors.New("OldIntro requires an ID field in the mutation")
  30013. }
  30014. oldValue, err := m.oldValue(ctx)
  30015. if err != nil {
  30016. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  30017. }
  30018. return oldValue.Intro, nil
  30019. }
  30020. // ClearIntro clears the value of the "intro" field.
  30021. func (m *WxCardMutation) ClearIntro() {
  30022. m.intro = nil
  30023. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  30024. }
  30025. // IntroCleared returns if the "intro" field was cleared in this mutation.
  30026. func (m *WxCardMutation) IntroCleared() bool {
  30027. _, ok := m.clearedFields[wxcard.FieldIntro]
  30028. return ok
  30029. }
  30030. // ResetIntro resets all changes to the "intro" field.
  30031. func (m *WxCardMutation) ResetIntro() {
  30032. m.intro = nil
  30033. delete(m.clearedFields, wxcard.FieldIntro)
  30034. }
  30035. // Where appends a list predicates to the WxCardMutation builder.
  30036. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  30037. m.predicates = append(m.predicates, ps...)
  30038. }
  30039. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  30040. // users can use type-assertion to append predicates that do not depend on any generated package.
  30041. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  30042. p := make([]predicate.WxCard, len(ps))
  30043. for i := range ps {
  30044. p[i] = ps[i]
  30045. }
  30046. m.Where(p...)
  30047. }
  30048. // Op returns the operation name.
  30049. func (m *WxCardMutation) Op() Op {
  30050. return m.op
  30051. }
  30052. // SetOp allows setting the mutation operation.
  30053. func (m *WxCardMutation) SetOp(op Op) {
  30054. m.op = op
  30055. }
  30056. // Type returns the node type of this mutation (WxCard).
  30057. func (m *WxCardMutation) Type() string {
  30058. return m.typ
  30059. }
  30060. // Fields returns all fields that were changed during this mutation. Note that in
  30061. // order to get all numeric fields that were incremented/decremented, call
  30062. // AddedFields().
  30063. func (m *WxCardMutation) Fields() []string {
  30064. fields := make([]string, 0, 18)
  30065. if m.created_at != nil {
  30066. fields = append(fields, wxcard.FieldCreatedAt)
  30067. }
  30068. if m.updated_at != nil {
  30069. fields = append(fields, wxcard.FieldUpdatedAt)
  30070. }
  30071. if m.deleted_at != nil {
  30072. fields = append(fields, wxcard.FieldDeletedAt)
  30073. }
  30074. if m.user_id != nil {
  30075. fields = append(fields, wxcard.FieldUserID)
  30076. }
  30077. if m.wx_user_id != nil {
  30078. fields = append(fields, wxcard.FieldWxUserID)
  30079. }
  30080. if m.avatar != nil {
  30081. fields = append(fields, wxcard.FieldAvatar)
  30082. }
  30083. if m.logo != nil {
  30084. fields = append(fields, wxcard.FieldLogo)
  30085. }
  30086. if m.name != nil {
  30087. fields = append(fields, wxcard.FieldName)
  30088. }
  30089. if m.company != nil {
  30090. fields = append(fields, wxcard.FieldCompany)
  30091. }
  30092. if m.address != nil {
  30093. fields = append(fields, wxcard.FieldAddress)
  30094. }
  30095. if m.phone != nil {
  30096. fields = append(fields, wxcard.FieldPhone)
  30097. }
  30098. if m.official_account != nil {
  30099. fields = append(fields, wxcard.FieldOfficialAccount)
  30100. }
  30101. if m.wechat_account != nil {
  30102. fields = append(fields, wxcard.FieldWechatAccount)
  30103. }
  30104. if m.email != nil {
  30105. fields = append(fields, wxcard.FieldEmail)
  30106. }
  30107. if m.api_base != nil {
  30108. fields = append(fields, wxcard.FieldAPIBase)
  30109. }
  30110. if m.api_key != nil {
  30111. fields = append(fields, wxcard.FieldAPIKey)
  30112. }
  30113. if m.ai_info != nil {
  30114. fields = append(fields, wxcard.FieldAiInfo)
  30115. }
  30116. if m.intro != nil {
  30117. fields = append(fields, wxcard.FieldIntro)
  30118. }
  30119. return fields
  30120. }
  30121. // Field returns the value of a field with the given name. The second boolean
  30122. // return value indicates that this field was not set, or was not defined in the
  30123. // schema.
  30124. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  30125. switch name {
  30126. case wxcard.FieldCreatedAt:
  30127. return m.CreatedAt()
  30128. case wxcard.FieldUpdatedAt:
  30129. return m.UpdatedAt()
  30130. case wxcard.FieldDeletedAt:
  30131. return m.DeletedAt()
  30132. case wxcard.FieldUserID:
  30133. return m.UserID()
  30134. case wxcard.FieldWxUserID:
  30135. return m.WxUserID()
  30136. case wxcard.FieldAvatar:
  30137. return m.Avatar()
  30138. case wxcard.FieldLogo:
  30139. return m.Logo()
  30140. case wxcard.FieldName:
  30141. return m.Name()
  30142. case wxcard.FieldCompany:
  30143. return m.Company()
  30144. case wxcard.FieldAddress:
  30145. return m.Address()
  30146. case wxcard.FieldPhone:
  30147. return m.Phone()
  30148. case wxcard.FieldOfficialAccount:
  30149. return m.OfficialAccount()
  30150. case wxcard.FieldWechatAccount:
  30151. return m.WechatAccount()
  30152. case wxcard.FieldEmail:
  30153. return m.Email()
  30154. case wxcard.FieldAPIBase:
  30155. return m.APIBase()
  30156. case wxcard.FieldAPIKey:
  30157. return m.APIKey()
  30158. case wxcard.FieldAiInfo:
  30159. return m.AiInfo()
  30160. case wxcard.FieldIntro:
  30161. return m.Intro()
  30162. }
  30163. return nil, false
  30164. }
  30165. // OldField returns the old value of the field from the database. An error is
  30166. // returned if the mutation operation is not UpdateOne, or the query to the
  30167. // database failed.
  30168. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30169. switch name {
  30170. case wxcard.FieldCreatedAt:
  30171. return m.OldCreatedAt(ctx)
  30172. case wxcard.FieldUpdatedAt:
  30173. return m.OldUpdatedAt(ctx)
  30174. case wxcard.FieldDeletedAt:
  30175. return m.OldDeletedAt(ctx)
  30176. case wxcard.FieldUserID:
  30177. return m.OldUserID(ctx)
  30178. case wxcard.FieldWxUserID:
  30179. return m.OldWxUserID(ctx)
  30180. case wxcard.FieldAvatar:
  30181. return m.OldAvatar(ctx)
  30182. case wxcard.FieldLogo:
  30183. return m.OldLogo(ctx)
  30184. case wxcard.FieldName:
  30185. return m.OldName(ctx)
  30186. case wxcard.FieldCompany:
  30187. return m.OldCompany(ctx)
  30188. case wxcard.FieldAddress:
  30189. return m.OldAddress(ctx)
  30190. case wxcard.FieldPhone:
  30191. return m.OldPhone(ctx)
  30192. case wxcard.FieldOfficialAccount:
  30193. return m.OldOfficialAccount(ctx)
  30194. case wxcard.FieldWechatAccount:
  30195. return m.OldWechatAccount(ctx)
  30196. case wxcard.FieldEmail:
  30197. return m.OldEmail(ctx)
  30198. case wxcard.FieldAPIBase:
  30199. return m.OldAPIBase(ctx)
  30200. case wxcard.FieldAPIKey:
  30201. return m.OldAPIKey(ctx)
  30202. case wxcard.FieldAiInfo:
  30203. return m.OldAiInfo(ctx)
  30204. case wxcard.FieldIntro:
  30205. return m.OldIntro(ctx)
  30206. }
  30207. return nil, fmt.Errorf("unknown WxCard field %s", name)
  30208. }
  30209. // SetField sets the value of a field with the given name. It returns an error if
  30210. // the field is not defined in the schema, or if the type mismatched the field
  30211. // type.
  30212. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  30213. switch name {
  30214. case wxcard.FieldCreatedAt:
  30215. v, ok := value.(time.Time)
  30216. if !ok {
  30217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30218. }
  30219. m.SetCreatedAt(v)
  30220. return nil
  30221. case wxcard.FieldUpdatedAt:
  30222. v, ok := value.(time.Time)
  30223. if !ok {
  30224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30225. }
  30226. m.SetUpdatedAt(v)
  30227. return nil
  30228. case wxcard.FieldDeletedAt:
  30229. v, ok := value.(time.Time)
  30230. if !ok {
  30231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30232. }
  30233. m.SetDeletedAt(v)
  30234. return nil
  30235. case wxcard.FieldUserID:
  30236. v, ok := value.(uint64)
  30237. if !ok {
  30238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30239. }
  30240. m.SetUserID(v)
  30241. return nil
  30242. case wxcard.FieldWxUserID:
  30243. v, ok := value.(uint64)
  30244. if !ok {
  30245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30246. }
  30247. m.SetWxUserID(v)
  30248. return nil
  30249. case wxcard.FieldAvatar:
  30250. v, ok := value.(string)
  30251. if !ok {
  30252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30253. }
  30254. m.SetAvatar(v)
  30255. return nil
  30256. case wxcard.FieldLogo:
  30257. v, ok := value.(string)
  30258. if !ok {
  30259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30260. }
  30261. m.SetLogo(v)
  30262. return nil
  30263. case wxcard.FieldName:
  30264. v, ok := value.(string)
  30265. if !ok {
  30266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30267. }
  30268. m.SetName(v)
  30269. return nil
  30270. case wxcard.FieldCompany:
  30271. v, ok := value.(string)
  30272. if !ok {
  30273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30274. }
  30275. m.SetCompany(v)
  30276. return nil
  30277. case wxcard.FieldAddress:
  30278. v, ok := value.(string)
  30279. if !ok {
  30280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30281. }
  30282. m.SetAddress(v)
  30283. return nil
  30284. case wxcard.FieldPhone:
  30285. v, ok := value.(string)
  30286. if !ok {
  30287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30288. }
  30289. m.SetPhone(v)
  30290. return nil
  30291. case wxcard.FieldOfficialAccount:
  30292. v, ok := value.(string)
  30293. if !ok {
  30294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30295. }
  30296. m.SetOfficialAccount(v)
  30297. return nil
  30298. case wxcard.FieldWechatAccount:
  30299. v, ok := value.(string)
  30300. if !ok {
  30301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30302. }
  30303. m.SetWechatAccount(v)
  30304. return nil
  30305. case wxcard.FieldEmail:
  30306. v, ok := value.(string)
  30307. if !ok {
  30308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30309. }
  30310. m.SetEmail(v)
  30311. return nil
  30312. case wxcard.FieldAPIBase:
  30313. v, ok := value.(string)
  30314. if !ok {
  30315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30316. }
  30317. m.SetAPIBase(v)
  30318. return nil
  30319. case wxcard.FieldAPIKey:
  30320. v, ok := value.(string)
  30321. if !ok {
  30322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30323. }
  30324. m.SetAPIKey(v)
  30325. return nil
  30326. case wxcard.FieldAiInfo:
  30327. v, ok := value.(string)
  30328. if !ok {
  30329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30330. }
  30331. m.SetAiInfo(v)
  30332. return nil
  30333. case wxcard.FieldIntro:
  30334. v, ok := value.(string)
  30335. if !ok {
  30336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30337. }
  30338. m.SetIntro(v)
  30339. return nil
  30340. }
  30341. return fmt.Errorf("unknown WxCard field %s", name)
  30342. }
  30343. // AddedFields returns all numeric fields that were incremented/decremented during
  30344. // this mutation.
  30345. func (m *WxCardMutation) AddedFields() []string {
  30346. var fields []string
  30347. if m.adduser_id != nil {
  30348. fields = append(fields, wxcard.FieldUserID)
  30349. }
  30350. if m.addwx_user_id != nil {
  30351. fields = append(fields, wxcard.FieldWxUserID)
  30352. }
  30353. return fields
  30354. }
  30355. // AddedField returns the numeric value that was incremented/decremented on a field
  30356. // with the given name. The second boolean return value indicates that this field
  30357. // was not set, or was not defined in the schema.
  30358. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  30359. switch name {
  30360. case wxcard.FieldUserID:
  30361. return m.AddedUserID()
  30362. case wxcard.FieldWxUserID:
  30363. return m.AddedWxUserID()
  30364. }
  30365. return nil, false
  30366. }
  30367. // AddField adds the value to the field with the given name. It returns an error if
  30368. // the field is not defined in the schema, or if the type mismatched the field
  30369. // type.
  30370. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  30371. switch name {
  30372. case wxcard.FieldUserID:
  30373. v, ok := value.(int64)
  30374. if !ok {
  30375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30376. }
  30377. m.AddUserID(v)
  30378. return nil
  30379. case wxcard.FieldWxUserID:
  30380. v, ok := value.(int64)
  30381. if !ok {
  30382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30383. }
  30384. m.AddWxUserID(v)
  30385. return nil
  30386. }
  30387. return fmt.Errorf("unknown WxCard numeric field %s", name)
  30388. }
  30389. // ClearedFields returns all nullable fields that were cleared during this
  30390. // mutation.
  30391. func (m *WxCardMutation) ClearedFields() []string {
  30392. var fields []string
  30393. if m.FieldCleared(wxcard.FieldDeletedAt) {
  30394. fields = append(fields, wxcard.FieldDeletedAt)
  30395. }
  30396. if m.FieldCleared(wxcard.FieldUserID) {
  30397. fields = append(fields, wxcard.FieldUserID)
  30398. }
  30399. if m.FieldCleared(wxcard.FieldWxUserID) {
  30400. fields = append(fields, wxcard.FieldWxUserID)
  30401. }
  30402. if m.FieldCleared(wxcard.FieldEmail) {
  30403. fields = append(fields, wxcard.FieldEmail)
  30404. }
  30405. if m.FieldCleared(wxcard.FieldAPIBase) {
  30406. fields = append(fields, wxcard.FieldAPIBase)
  30407. }
  30408. if m.FieldCleared(wxcard.FieldAPIKey) {
  30409. fields = append(fields, wxcard.FieldAPIKey)
  30410. }
  30411. if m.FieldCleared(wxcard.FieldAiInfo) {
  30412. fields = append(fields, wxcard.FieldAiInfo)
  30413. }
  30414. if m.FieldCleared(wxcard.FieldIntro) {
  30415. fields = append(fields, wxcard.FieldIntro)
  30416. }
  30417. return fields
  30418. }
  30419. // FieldCleared returns a boolean indicating if a field with the given name was
  30420. // cleared in this mutation.
  30421. func (m *WxCardMutation) FieldCleared(name string) bool {
  30422. _, ok := m.clearedFields[name]
  30423. return ok
  30424. }
  30425. // ClearField clears the value of the field with the given name. It returns an
  30426. // error if the field is not defined in the schema.
  30427. func (m *WxCardMutation) ClearField(name string) error {
  30428. switch name {
  30429. case wxcard.FieldDeletedAt:
  30430. m.ClearDeletedAt()
  30431. return nil
  30432. case wxcard.FieldUserID:
  30433. m.ClearUserID()
  30434. return nil
  30435. case wxcard.FieldWxUserID:
  30436. m.ClearWxUserID()
  30437. return nil
  30438. case wxcard.FieldEmail:
  30439. m.ClearEmail()
  30440. return nil
  30441. case wxcard.FieldAPIBase:
  30442. m.ClearAPIBase()
  30443. return nil
  30444. case wxcard.FieldAPIKey:
  30445. m.ClearAPIKey()
  30446. return nil
  30447. case wxcard.FieldAiInfo:
  30448. m.ClearAiInfo()
  30449. return nil
  30450. case wxcard.FieldIntro:
  30451. m.ClearIntro()
  30452. return nil
  30453. }
  30454. return fmt.Errorf("unknown WxCard nullable field %s", name)
  30455. }
  30456. // ResetField resets all changes in the mutation for the field with the given name.
  30457. // It returns an error if the field is not defined in the schema.
  30458. func (m *WxCardMutation) ResetField(name string) error {
  30459. switch name {
  30460. case wxcard.FieldCreatedAt:
  30461. m.ResetCreatedAt()
  30462. return nil
  30463. case wxcard.FieldUpdatedAt:
  30464. m.ResetUpdatedAt()
  30465. return nil
  30466. case wxcard.FieldDeletedAt:
  30467. m.ResetDeletedAt()
  30468. return nil
  30469. case wxcard.FieldUserID:
  30470. m.ResetUserID()
  30471. return nil
  30472. case wxcard.FieldWxUserID:
  30473. m.ResetWxUserID()
  30474. return nil
  30475. case wxcard.FieldAvatar:
  30476. m.ResetAvatar()
  30477. return nil
  30478. case wxcard.FieldLogo:
  30479. m.ResetLogo()
  30480. return nil
  30481. case wxcard.FieldName:
  30482. m.ResetName()
  30483. return nil
  30484. case wxcard.FieldCompany:
  30485. m.ResetCompany()
  30486. return nil
  30487. case wxcard.FieldAddress:
  30488. m.ResetAddress()
  30489. return nil
  30490. case wxcard.FieldPhone:
  30491. m.ResetPhone()
  30492. return nil
  30493. case wxcard.FieldOfficialAccount:
  30494. m.ResetOfficialAccount()
  30495. return nil
  30496. case wxcard.FieldWechatAccount:
  30497. m.ResetWechatAccount()
  30498. return nil
  30499. case wxcard.FieldEmail:
  30500. m.ResetEmail()
  30501. return nil
  30502. case wxcard.FieldAPIBase:
  30503. m.ResetAPIBase()
  30504. return nil
  30505. case wxcard.FieldAPIKey:
  30506. m.ResetAPIKey()
  30507. return nil
  30508. case wxcard.FieldAiInfo:
  30509. m.ResetAiInfo()
  30510. return nil
  30511. case wxcard.FieldIntro:
  30512. m.ResetIntro()
  30513. return nil
  30514. }
  30515. return fmt.Errorf("unknown WxCard field %s", name)
  30516. }
  30517. // AddedEdges returns all edge names that were set/added in this mutation.
  30518. func (m *WxCardMutation) AddedEdges() []string {
  30519. edges := make([]string, 0, 0)
  30520. return edges
  30521. }
  30522. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30523. // name in this mutation.
  30524. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  30525. return nil
  30526. }
  30527. // RemovedEdges returns all edge names that were removed in this mutation.
  30528. func (m *WxCardMutation) RemovedEdges() []string {
  30529. edges := make([]string, 0, 0)
  30530. return edges
  30531. }
  30532. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30533. // the given name in this mutation.
  30534. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  30535. return nil
  30536. }
  30537. // ClearedEdges returns all edge names that were cleared in this mutation.
  30538. func (m *WxCardMutation) ClearedEdges() []string {
  30539. edges := make([]string, 0, 0)
  30540. return edges
  30541. }
  30542. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30543. // was cleared in this mutation.
  30544. func (m *WxCardMutation) EdgeCleared(name string) bool {
  30545. return false
  30546. }
  30547. // ClearEdge clears the value of the edge with the given name. It returns an error
  30548. // if that edge is not defined in the schema.
  30549. func (m *WxCardMutation) ClearEdge(name string) error {
  30550. return fmt.Errorf("unknown WxCard unique edge %s", name)
  30551. }
  30552. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30553. // It returns an error if the edge is not defined in the schema.
  30554. func (m *WxCardMutation) ResetEdge(name string) error {
  30555. return fmt.Errorf("unknown WxCard edge %s", name)
  30556. }
  30557. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  30558. type WxCardUserMutation struct {
  30559. config
  30560. op Op
  30561. typ string
  30562. id *uint64
  30563. created_at *time.Time
  30564. updated_at *time.Time
  30565. deleted_at *time.Time
  30566. wxid *string
  30567. account *string
  30568. avatar *string
  30569. nickname *string
  30570. remark *string
  30571. phone *string
  30572. open_id *string
  30573. union_id *string
  30574. session_key *string
  30575. is_vip *int
  30576. addis_vip *int
  30577. clearedFields map[string]struct{}
  30578. done bool
  30579. oldValue func(context.Context) (*WxCardUser, error)
  30580. predicates []predicate.WxCardUser
  30581. }
  30582. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  30583. // wxcarduserOption allows management of the mutation configuration using functional options.
  30584. type wxcarduserOption func(*WxCardUserMutation)
  30585. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  30586. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  30587. m := &WxCardUserMutation{
  30588. config: c,
  30589. op: op,
  30590. typ: TypeWxCardUser,
  30591. clearedFields: make(map[string]struct{}),
  30592. }
  30593. for _, opt := range opts {
  30594. opt(m)
  30595. }
  30596. return m
  30597. }
  30598. // withWxCardUserID sets the ID field of the mutation.
  30599. func withWxCardUserID(id uint64) wxcarduserOption {
  30600. return func(m *WxCardUserMutation) {
  30601. var (
  30602. err error
  30603. once sync.Once
  30604. value *WxCardUser
  30605. )
  30606. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  30607. once.Do(func() {
  30608. if m.done {
  30609. err = errors.New("querying old values post mutation is not allowed")
  30610. } else {
  30611. value, err = m.Client().WxCardUser.Get(ctx, id)
  30612. }
  30613. })
  30614. return value, err
  30615. }
  30616. m.id = &id
  30617. }
  30618. }
  30619. // withWxCardUser sets the old WxCardUser of the mutation.
  30620. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  30621. return func(m *WxCardUserMutation) {
  30622. m.oldValue = func(context.Context) (*WxCardUser, error) {
  30623. return node, nil
  30624. }
  30625. m.id = &node.ID
  30626. }
  30627. }
  30628. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30629. // executed in a transaction (ent.Tx), a transactional client is returned.
  30630. func (m WxCardUserMutation) Client() *Client {
  30631. client := &Client{config: m.config}
  30632. client.init()
  30633. return client
  30634. }
  30635. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30636. // it returns an error otherwise.
  30637. func (m WxCardUserMutation) Tx() (*Tx, error) {
  30638. if _, ok := m.driver.(*txDriver); !ok {
  30639. return nil, errors.New("ent: mutation is not running in a transaction")
  30640. }
  30641. tx := &Tx{config: m.config}
  30642. tx.init()
  30643. return tx, nil
  30644. }
  30645. // SetID sets the value of the id field. Note that this
  30646. // operation is only accepted on creation of WxCardUser entities.
  30647. func (m *WxCardUserMutation) SetID(id uint64) {
  30648. m.id = &id
  30649. }
  30650. // ID returns the ID value in the mutation. Note that the ID is only available
  30651. // if it was provided to the builder or after it was returned from the database.
  30652. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  30653. if m.id == nil {
  30654. return
  30655. }
  30656. return *m.id, true
  30657. }
  30658. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30659. // That means, if the mutation is applied within a transaction with an isolation level such
  30660. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30661. // or updated by the mutation.
  30662. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  30663. switch {
  30664. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30665. id, exists := m.ID()
  30666. if exists {
  30667. return []uint64{id}, nil
  30668. }
  30669. fallthrough
  30670. case m.op.Is(OpUpdate | OpDelete):
  30671. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  30672. default:
  30673. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30674. }
  30675. }
  30676. // SetCreatedAt sets the "created_at" field.
  30677. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  30678. m.created_at = &t
  30679. }
  30680. // CreatedAt returns the value of the "created_at" field in the mutation.
  30681. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  30682. v := m.created_at
  30683. if v == nil {
  30684. return
  30685. }
  30686. return *v, true
  30687. }
  30688. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  30689. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30691. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30692. if !m.op.Is(OpUpdateOne) {
  30693. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30694. }
  30695. if m.id == nil || m.oldValue == nil {
  30696. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30697. }
  30698. oldValue, err := m.oldValue(ctx)
  30699. if err != nil {
  30700. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30701. }
  30702. return oldValue.CreatedAt, nil
  30703. }
  30704. // ResetCreatedAt resets all changes to the "created_at" field.
  30705. func (m *WxCardUserMutation) ResetCreatedAt() {
  30706. m.created_at = nil
  30707. }
  30708. // SetUpdatedAt sets the "updated_at" field.
  30709. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  30710. m.updated_at = &t
  30711. }
  30712. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30713. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  30714. v := m.updated_at
  30715. if v == nil {
  30716. return
  30717. }
  30718. return *v, true
  30719. }
  30720. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  30721. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30723. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30724. if !m.op.Is(OpUpdateOne) {
  30725. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30726. }
  30727. if m.id == nil || m.oldValue == nil {
  30728. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30729. }
  30730. oldValue, err := m.oldValue(ctx)
  30731. if err != nil {
  30732. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30733. }
  30734. return oldValue.UpdatedAt, nil
  30735. }
  30736. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30737. func (m *WxCardUserMutation) ResetUpdatedAt() {
  30738. m.updated_at = nil
  30739. }
  30740. // SetDeletedAt sets the "deleted_at" field.
  30741. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  30742. m.deleted_at = &t
  30743. }
  30744. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30745. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  30746. v := m.deleted_at
  30747. if v == nil {
  30748. return
  30749. }
  30750. return *v, true
  30751. }
  30752. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  30753. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30755. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30756. if !m.op.Is(OpUpdateOne) {
  30757. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30758. }
  30759. if m.id == nil || m.oldValue == nil {
  30760. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30761. }
  30762. oldValue, err := m.oldValue(ctx)
  30763. if err != nil {
  30764. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30765. }
  30766. return oldValue.DeletedAt, nil
  30767. }
  30768. // ClearDeletedAt clears the value of the "deleted_at" field.
  30769. func (m *WxCardUserMutation) ClearDeletedAt() {
  30770. m.deleted_at = nil
  30771. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  30772. }
  30773. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30774. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  30775. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  30776. return ok
  30777. }
  30778. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30779. func (m *WxCardUserMutation) ResetDeletedAt() {
  30780. m.deleted_at = nil
  30781. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  30782. }
  30783. // SetWxid sets the "wxid" field.
  30784. func (m *WxCardUserMutation) SetWxid(s string) {
  30785. m.wxid = &s
  30786. }
  30787. // Wxid returns the value of the "wxid" field in the mutation.
  30788. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  30789. v := m.wxid
  30790. if v == nil {
  30791. return
  30792. }
  30793. return *v, true
  30794. }
  30795. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  30796. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30798. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  30799. if !m.op.Is(OpUpdateOne) {
  30800. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  30801. }
  30802. if m.id == nil || m.oldValue == nil {
  30803. return v, errors.New("OldWxid requires an ID field in the mutation")
  30804. }
  30805. oldValue, err := m.oldValue(ctx)
  30806. if err != nil {
  30807. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  30808. }
  30809. return oldValue.Wxid, nil
  30810. }
  30811. // ResetWxid resets all changes to the "wxid" field.
  30812. func (m *WxCardUserMutation) ResetWxid() {
  30813. m.wxid = nil
  30814. }
  30815. // SetAccount sets the "account" field.
  30816. func (m *WxCardUserMutation) SetAccount(s string) {
  30817. m.account = &s
  30818. }
  30819. // Account returns the value of the "account" field in the mutation.
  30820. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  30821. v := m.account
  30822. if v == nil {
  30823. return
  30824. }
  30825. return *v, true
  30826. }
  30827. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  30828. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30830. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  30831. if !m.op.Is(OpUpdateOne) {
  30832. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  30833. }
  30834. if m.id == nil || m.oldValue == nil {
  30835. return v, errors.New("OldAccount requires an ID field in the mutation")
  30836. }
  30837. oldValue, err := m.oldValue(ctx)
  30838. if err != nil {
  30839. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  30840. }
  30841. return oldValue.Account, nil
  30842. }
  30843. // ResetAccount resets all changes to the "account" field.
  30844. func (m *WxCardUserMutation) ResetAccount() {
  30845. m.account = nil
  30846. }
  30847. // SetAvatar sets the "avatar" field.
  30848. func (m *WxCardUserMutation) SetAvatar(s string) {
  30849. m.avatar = &s
  30850. }
  30851. // Avatar returns the value of the "avatar" field in the mutation.
  30852. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  30853. v := m.avatar
  30854. if v == nil {
  30855. return
  30856. }
  30857. return *v, true
  30858. }
  30859. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  30860. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30862. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  30863. if !m.op.Is(OpUpdateOne) {
  30864. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  30865. }
  30866. if m.id == nil || m.oldValue == nil {
  30867. return v, errors.New("OldAvatar requires an ID field in the mutation")
  30868. }
  30869. oldValue, err := m.oldValue(ctx)
  30870. if err != nil {
  30871. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  30872. }
  30873. return oldValue.Avatar, nil
  30874. }
  30875. // ResetAvatar resets all changes to the "avatar" field.
  30876. func (m *WxCardUserMutation) ResetAvatar() {
  30877. m.avatar = nil
  30878. }
  30879. // SetNickname sets the "nickname" field.
  30880. func (m *WxCardUserMutation) SetNickname(s string) {
  30881. m.nickname = &s
  30882. }
  30883. // Nickname returns the value of the "nickname" field in the mutation.
  30884. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  30885. v := m.nickname
  30886. if v == nil {
  30887. return
  30888. }
  30889. return *v, true
  30890. }
  30891. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  30892. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30894. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  30895. if !m.op.Is(OpUpdateOne) {
  30896. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  30897. }
  30898. if m.id == nil || m.oldValue == nil {
  30899. return v, errors.New("OldNickname requires an ID field in the mutation")
  30900. }
  30901. oldValue, err := m.oldValue(ctx)
  30902. if err != nil {
  30903. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  30904. }
  30905. return oldValue.Nickname, nil
  30906. }
  30907. // ResetNickname resets all changes to the "nickname" field.
  30908. func (m *WxCardUserMutation) ResetNickname() {
  30909. m.nickname = nil
  30910. }
  30911. // SetRemark sets the "remark" field.
  30912. func (m *WxCardUserMutation) SetRemark(s string) {
  30913. m.remark = &s
  30914. }
  30915. // Remark returns the value of the "remark" field in the mutation.
  30916. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  30917. v := m.remark
  30918. if v == nil {
  30919. return
  30920. }
  30921. return *v, true
  30922. }
  30923. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  30924. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30926. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  30927. if !m.op.Is(OpUpdateOne) {
  30928. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  30929. }
  30930. if m.id == nil || m.oldValue == nil {
  30931. return v, errors.New("OldRemark requires an ID field in the mutation")
  30932. }
  30933. oldValue, err := m.oldValue(ctx)
  30934. if err != nil {
  30935. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  30936. }
  30937. return oldValue.Remark, nil
  30938. }
  30939. // ResetRemark resets all changes to the "remark" field.
  30940. func (m *WxCardUserMutation) ResetRemark() {
  30941. m.remark = nil
  30942. }
  30943. // SetPhone sets the "phone" field.
  30944. func (m *WxCardUserMutation) SetPhone(s string) {
  30945. m.phone = &s
  30946. }
  30947. // Phone returns the value of the "phone" field in the mutation.
  30948. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  30949. v := m.phone
  30950. if v == nil {
  30951. return
  30952. }
  30953. return *v, true
  30954. }
  30955. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  30956. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30958. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  30959. if !m.op.Is(OpUpdateOne) {
  30960. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  30961. }
  30962. if m.id == nil || m.oldValue == nil {
  30963. return v, errors.New("OldPhone requires an ID field in the mutation")
  30964. }
  30965. oldValue, err := m.oldValue(ctx)
  30966. if err != nil {
  30967. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  30968. }
  30969. return oldValue.Phone, nil
  30970. }
  30971. // ResetPhone resets all changes to the "phone" field.
  30972. func (m *WxCardUserMutation) ResetPhone() {
  30973. m.phone = nil
  30974. }
  30975. // SetOpenID sets the "open_id" field.
  30976. func (m *WxCardUserMutation) SetOpenID(s string) {
  30977. m.open_id = &s
  30978. }
  30979. // OpenID returns the value of the "open_id" field in the mutation.
  30980. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  30981. v := m.open_id
  30982. if v == nil {
  30983. return
  30984. }
  30985. return *v, true
  30986. }
  30987. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  30988. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30990. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  30991. if !m.op.Is(OpUpdateOne) {
  30992. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  30993. }
  30994. if m.id == nil || m.oldValue == nil {
  30995. return v, errors.New("OldOpenID requires an ID field in the mutation")
  30996. }
  30997. oldValue, err := m.oldValue(ctx)
  30998. if err != nil {
  30999. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  31000. }
  31001. return oldValue.OpenID, nil
  31002. }
  31003. // ResetOpenID resets all changes to the "open_id" field.
  31004. func (m *WxCardUserMutation) ResetOpenID() {
  31005. m.open_id = nil
  31006. }
  31007. // SetUnionID sets the "union_id" field.
  31008. func (m *WxCardUserMutation) SetUnionID(s string) {
  31009. m.union_id = &s
  31010. }
  31011. // UnionID returns the value of the "union_id" field in the mutation.
  31012. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  31013. v := m.union_id
  31014. if v == nil {
  31015. return
  31016. }
  31017. return *v, true
  31018. }
  31019. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  31020. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31022. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  31023. if !m.op.Is(OpUpdateOne) {
  31024. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  31025. }
  31026. if m.id == nil || m.oldValue == nil {
  31027. return v, errors.New("OldUnionID requires an ID field in the mutation")
  31028. }
  31029. oldValue, err := m.oldValue(ctx)
  31030. if err != nil {
  31031. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  31032. }
  31033. return oldValue.UnionID, nil
  31034. }
  31035. // ResetUnionID resets all changes to the "union_id" field.
  31036. func (m *WxCardUserMutation) ResetUnionID() {
  31037. m.union_id = nil
  31038. }
  31039. // SetSessionKey sets the "session_key" field.
  31040. func (m *WxCardUserMutation) SetSessionKey(s string) {
  31041. m.session_key = &s
  31042. }
  31043. // SessionKey returns the value of the "session_key" field in the mutation.
  31044. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  31045. v := m.session_key
  31046. if v == nil {
  31047. return
  31048. }
  31049. return *v, true
  31050. }
  31051. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  31052. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31054. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  31055. if !m.op.Is(OpUpdateOne) {
  31056. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  31057. }
  31058. if m.id == nil || m.oldValue == nil {
  31059. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  31060. }
  31061. oldValue, err := m.oldValue(ctx)
  31062. if err != nil {
  31063. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  31064. }
  31065. return oldValue.SessionKey, nil
  31066. }
  31067. // ResetSessionKey resets all changes to the "session_key" field.
  31068. func (m *WxCardUserMutation) ResetSessionKey() {
  31069. m.session_key = nil
  31070. }
  31071. // SetIsVip sets the "is_vip" field.
  31072. func (m *WxCardUserMutation) SetIsVip(i int) {
  31073. m.is_vip = &i
  31074. m.addis_vip = nil
  31075. }
  31076. // IsVip returns the value of the "is_vip" field in the mutation.
  31077. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  31078. v := m.is_vip
  31079. if v == nil {
  31080. return
  31081. }
  31082. return *v, true
  31083. }
  31084. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  31085. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  31086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31087. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  31088. if !m.op.Is(OpUpdateOne) {
  31089. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  31090. }
  31091. if m.id == nil || m.oldValue == nil {
  31092. return v, errors.New("OldIsVip requires an ID field in the mutation")
  31093. }
  31094. oldValue, err := m.oldValue(ctx)
  31095. if err != nil {
  31096. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  31097. }
  31098. return oldValue.IsVip, nil
  31099. }
  31100. // AddIsVip adds i to the "is_vip" field.
  31101. func (m *WxCardUserMutation) AddIsVip(i int) {
  31102. if m.addis_vip != nil {
  31103. *m.addis_vip += i
  31104. } else {
  31105. m.addis_vip = &i
  31106. }
  31107. }
  31108. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  31109. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  31110. v := m.addis_vip
  31111. if v == nil {
  31112. return
  31113. }
  31114. return *v, true
  31115. }
  31116. // ResetIsVip resets all changes to the "is_vip" field.
  31117. func (m *WxCardUserMutation) ResetIsVip() {
  31118. m.is_vip = nil
  31119. m.addis_vip = nil
  31120. }
  31121. // Where appends a list predicates to the WxCardUserMutation builder.
  31122. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  31123. m.predicates = append(m.predicates, ps...)
  31124. }
  31125. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  31126. // users can use type-assertion to append predicates that do not depend on any generated package.
  31127. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  31128. p := make([]predicate.WxCardUser, len(ps))
  31129. for i := range ps {
  31130. p[i] = ps[i]
  31131. }
  31132. m.Where(p...)
  31133. }
  31134. // Op returns the operation name.
  31135. func (m *WxCardUserMutation) Op() Op {
  31136. return m.op
  31137. }
  31138. // SetOp allows setting the mutation operation.
  31139. func (m *WxCardUserMutation) SetOp(op Op) {
  31140. m.op = op
  31141. }
  31142. // Type returns the node type of this mutation (WxCardUser).
  31143. func (m *WxCardUserMutation) Type() string {
  31144. return m.typ
  31145. }
  31146. // Fields returns all fields that were changed during this mutation. Note that in
  31147. // order to get all numeric fields that were incremented/decremented, call
  31148. // AddedFields().
  31149. func (m *WxCardUserMutation) Fields() []string {
  31150. fields := make([]string, 0, 13)
  31151. if m.created_at != nil {
  31152. fields = append(fields, wxcarduser.FieldCreatedAt)
  31153. }
  31154. if m.updated_at != nil {
  31155. fields = append(fields, wxcarduser.FieldUpdatedAt)
  31156. }
  31157. if m.deleted_at != nil {
  31158. fields = append(fields, wxcarduser.FieldDeletedAt)
  31159. }
  31160. if m.wxid != nil {
  31161. fields = append(fields, wxcarduser.FieldWxid)
  31162. }
  31163. if m.account != nil {
  31164. fields = append(fields, wxcarduser.FieldAccount)
  31165. }
  31166. if m.avatar != nil {
  31167. fields = append(fields, wxcarduser.FieldAvatar)
  31168. }
  31169. if m.nickname != nil {
  31170. fields = append(fields, wxcarduser.FieldNickname)
  31171. }
  31172. if m.remark != nil {
  31173. fields = append(fields, wxcarduser.FieldRemark)
  31174. }
  31175. if m.phone != nil {
  31176. fields = append(fields, wxcarduser.FieldPhone)
  31177. }
  31178. if m.open_id != nil {
  31179. fields = append(fields, wxcarduser.FieldOpenID)
  31180. }
  31181. if m.union_id != nil {
  31182. fields = append(fields, wxcarduser.FieldUnionID)
  31183. }
  31184. if m.session_key != nil {
  31185. fields = append(fields, wxcarduser.FieldSessionKey)
  31186. }
  31187. if m.is_vip != nil {
  31188. fields = append(fields, wxcarduser.FieldIsVip)
  31189. }
  31190. return fields
  31191. }
  31192. // Field returns the value of a field with the given name. The second boolean
  31193. // return value indicates that this field was not set, or was not defined in the
  31194. // schema.
  31195. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  31196. switch name {
  31197. case wxcarduser.FieldCreatedAt:
  31198. return m.CreatedAt()
  31199. case wxcarduser.FieldUpdatedAt:
  31200. return m.UpdatedAt()
  31201. case wxcarduser.FieldDeletedAt:
  31202. return m.DeletedAt()
  31203. case wxcarduser.FieldWxid:
  31204. return m.Wxid()
  31205. case wxcarduser.FieldAccount:
  31206. return m.Account()
  31207. case wxcarduser.FieldAvatar:
  31208. return m.Avatar()
  31209. case wxcarduser.FieldNickname:
  31210. return m.Nickname()
  31211. case wxcarduser.FieldRemark:
  31212. return m.Remark()
  31213. case wxcarduser.FieldPhone:
  31214. return m.Phone()
  31215. case wxcarduser.FieldOpenID:
  31216. return m.OpenID()
  31217. case wxcarduser.FieldUnionID:
  31218. return m.UnionID()
  31219. case wxcarduser.FieldSessionKey:
  31220. return m.SessionKey()
  31221. case wxcarduser.FieldIsVip:
  31222. return m.IsVip()
  31223. }
  31224. return nil, false
  31225. }
  31226. // OldField returns the old value of the field from the database. An error is
  31227. // returned if the mutation operation is not UpdateOne, or the query to the
  31228. // database failed.
  31229. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31230. switch name {
  31231. case wxcarduser.FieldCreatedAt:
  31232. return m.OldCreatedAt(ctx)
  31233. case wxcarduser.FieldUpdatedAt:
  31234. return m.OldUpdatedAt(ctx)
  31235. case wxcarduser.FieldDeletedAt:
  31236. return m.OldDeletedAt(ctx)
  31237. case wxcarduser.FieldWxid:
  31238. return m.OldWxid(ctx)
  31239. case wxcarduser.FieldAccount:
  31240. return m.OldAccount(ctx)
  31241. case wxcarduser.FieldAvatar:
  31242. return m.OldAvatar(ctx)
  31243. case wxcarduser.FieldNickname:
  31244. return m.OldNickname(ctx)
  31245. case wxcarduser.FieldRemark:
  31246. return m.OldRemark(ctx)
  31247. case wxcarduser.FieldPhone:
  31248. return m.OldPhone(ctx)
  31249. case wxcarduser.FieldOpenID:
  31250. return m.OldOpenID(ctx)
  31251. case wxcarduser.FieldUnionID:
  31252. return m.OldUnionID(ctx)
  31253. case wxcarduser.FieldSessionKey:
  31254. return m.OldSessionKey(ctx)
  31255. case wxcarduser.FieldIsVip:
  31256. return m.OldIsVip(ctx)
  31257. }
  31258. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  31259. }
  31260. // SetField sets the value of a field with the given name. It returns an error if
  31261. // the field is not defined in the schema, or if the type mismatched the field
  31262. // type.
  31263. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  31264. switch name {
  31265. case wxcarduser.FieldCreatedAt:
  31266. v, ok := value.(time.Time)
  31267. if !ok {
  31268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31269. }
  31270. m.SetCreatedAt(v)
  31271. return nil
  31272. case wxcarduser.FieldUpdatedAt:
  31273. v, ok := value.(time.Time)
  31274. if !ok {
  31275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31276. }
  31277. m.SetUpdatedAt(v)
  31278. return nil
  31279. case wxcarduser.FieldDeletedAt:
  31280. v, ok := value.(time.Time)
  31281. if !ok {
  31282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31283. }
  31284. m.SetDeletedAt(v)
  31285. return nil
  31286. case wxcarduser.FieldWxid:
  31287. v, ok := value.(string)
  31288. if !ok {
  31289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31290. }
  31291. m.SetWxid(v)
  31292. return nil
  31293. case wxcarduser.FieldAccount:
  31294. v, ok := value.(string)
  31295. if !ok {
  31296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31297. }
  31298. m.SetAccount(v)
  31299. return nil
  31300. case wxcarduser.FieldAvatar:
  31301. v, ok := value.(string)
  31302. if !ok {
  31303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31304. }
  31305. m.SetAvatar(v)
  31306. return nil
  31307. case wxcarduser.FieldNickname:
  31308. v, ok := value.(string)
  31309. if !ok {
  31310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31311. }
  31312. m.SetNickname(v)
  31313. return nil
  31314. case wxcarduser.FieldRemark:
  31315. v, ok := value.(string)
  31316. if !ok {
  31317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31318. }
  31319. m.SetRemark(v)
  31320. return nil
  31321. case wxcarduser.FieldPhone:
  31322. v, ok := value.(string)
  31323. if !ok {
  31324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31325. }
  31326. m.SetPhone(v)
  31327. return nil
  31328. case wxcarduser.FieldOpenID:
  31329. v, ok := value.(string)
  31330. if !ok {
  31331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31332. }
  31333. m.SetOpenID(v)
  31334. return nil
  31335. case wxcarduser.FieldUnionID:
  31336. v, ok := value.(string)
  31337. if !ok {
  31338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31339. }
  31340. m.SetUnionID(v)
  31341. return nil
  31342. case wxcarduser.FieldSessionKey:
  31343. v, ok := value.(string)
  31344. if !ok {
  31345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31346. }
  31347. m.SetSessionKey(v)
  31348. return nil
  31349. case wxcarduser.FieldIsVip:
  31350. v, ok := value.(int)
  31351. if !ok {
  31352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31353. }
  31354. m.SetIsVip(v)
  31355. return nil
  31356. }
  31357. return fmt.Errorf("unknown WxCardUser field %s", name)
  31358. }
  31359. // AddedFields returns all numeric fields that were incremented/decremented during
  31360. // this mutation.
  31361. func (m *WxCardUserMutation) AddedFields() []string {
  31362. var fields []string
  31363. if m.addis_vip != nil {
  31364. fields = append(fields, wxcarduser.FieldIsVip)
  31365. }
  31366. return fields
  31367. }
  31368. // AddedField returns the numeric value that was incremented/decremented on a field
  31369. // with the given name. The second boolean return value indicates that this field
  31370. // was not set, or was not defined in the schema.
  31371. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  31372. switch name {
  31373. case wxcarduser.FieldIsVip:
  31374. return m.AddedIsVip()
  31375. }
  31376. return nil, false
  31377. }
  31378. // AddField adds the value to the field with the given name. It returns an error if
  31379. // the field is not defined in the schema, or if the type mismatched the field
  31380. // type.
  31381. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  31382. switch name {
  31383. case wxcarduser.FieldIsVip:
  31384. v, ok := value.(int)
  31385. if !ok {
  31386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31387. }
  31388. m.AddIsVip(v)
  31389. return nil
  31390. }
  31391. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  31392. }
  31393. // ClearedFields returns all nullable fields that were cleared during this
  31394. // mutation.
  31395. func (m *WxCardUserMutation) ClearedFields() []string {
  31396. var fields []string
  31397. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  31398. fields = append(fields, wxcarduser.FieldDeletedAt)
  31399. }
  31400. return fields
  31401. }
  31402. // FieldCleared returns a boolean indicating if a field with the given name was
  31403. // cleared in this mutation.
  31404. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  31405. _, ok := m.clearedFields[name]
  31406. return ok
  31407. }
  31408. // ClearField clears the value of the field with the given name. It returns an
  31409. // error if the field is not defined in the schema.
  31410. func (m *WxCardUserMutation) ClearField(name string) error {
  31411. switch name {
  31412. case wxcarduser.FieldDeletedAt:
  31413. m.ClearDeletedAt()
  31414. return nil
  31415. }
  31416. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  31417. }
  31418. // ResetField resets all changes in the mutation for the field with the given name.
  31419. // It returns an error if the field is not defined in the schema.
  31420. func (m *WxCardUserMutation) ResetField(name string) error {
  31421. switch name {
  31422. case wxcarduser.FieldCreatedAt:
  31423. m.ResetCreatedAt()
  31424. return nil
  31425. case wxcarduser.FieldUpdatedAt:
  31426. m.ResetUpdatedAt()
  31427. return nil
  31428. case wxcarduser.FieldDeletedAt:
  31429. m.ResetDeletedAt()
  31430. return nil
  31431. case wxcarduser.FieldWxid:
  31432. m.ResetWxid()
  31433. return nil
  31434. case wxcarduser.FieldAccount:
  31435. m.ResetAccount()
  31436. return nil
  31437. case wxcarduser.FieldAvatar:
  31438. m.ResetAvatar()
  31439. return nil
  31440. case wxcarduser.FieldNickname:
  31441. m.ResetNickname()
  31442. return nil
  31443. case wxcarduser.FieldRemark:
  31444. m.ResetRemark()
  31445. return nil
  31446. case wxcarduser.FieldPhone:
  31447. m.ResetPhone()
  31448. return nil
  31449. case wxcarduser.FieldOpenID:
  31450. m.ResetOpenID()
  31451. return nil
  31452. case wxcarduser.FieldUnionID:
  31453. m.ResetUnionID()
  31454. return nil
  31455. case wxcarduser.FieldSessionKey:
  31456. m.ResetSessionKey()
  31457. return nil
  31458. case wxcarduser.FieldIsVip:
  31459. m.ResetIsVip()
  31460. return nil
  31461. }
  31462. return fmt.Errorf("unknown WxCardUser field %s", name)
  31463. }
  31464. // AddedEdges returns all edge names that were set/added in this mutation.
  31465. func (m *WxCardUserMutation) AddedEdges() []string {
  31466. edges := make([]string, 0, 0)
  31467. return edges
  31468. }
  31469. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31470. // name in this mutation.
  31471. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  31472. return nil
  31473. }
  31474. // RemovedEdges returns all edge names that were removed in this mutation.
  31475. func (m *WxCardUserMutation) RemovedEdges() []string {
  31476. edges := make([]string, 0, 0)
  31477. return edges
  31478. }
  31479. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31480. // the given name in this mutation.
  31481. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  31482. return nil
  31483. }
  31484. // ClearedEdges returns all edge names that were cleared in this mutation.
  31485. func (m *WxCardUserMutation) ClearedEdges() []string {
  31486. edges := make([]string, 0, 0)
  31487. return edges
  31488. }
  31489. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31490. // was cleared in this mutation.
  31491. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  31492. return false
  31493. }
  31494. // ClearEdge clears the value of the edge with the given name. It returns an error
  31495. // if that edge is not defined in the schema.
  31496. func (m *WxCardUserMutation) ClearEdge(name string) error {
  31497. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  31498. }
  31499. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31500. // It returns an error if the edge is not defined in the schema.
  31501. func (m *WxCardUserMutation) ResetEdge(name string) error {
  31502. return fmt.Errorf("unknown WxCardUser edge %s", name)
  31503. }
  31504. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  31505. type WxCardVisitMutation struct {
  31506. config
  31507. op Op
  31508. typ string
  31509. id *uint64
  31510. created_at *time.Time
  31511. updated_at *time.Time
  31512. deleted_at *time.Time
  31513. user_id *uint64
  31514. adduser_id *int64
  31515. bot_id *uint64
  31516. addbot_id *int64
  31517. bot_type *uint8
  31518. addbot_type *int8
  31519. clearedFields map[string]struct{}
  31520. done bool
  31521. oldValue func(context.Context) (*WxCardVisit, error)
  31522. predicates []predicate.WxCardVisit
  31523. }
  31524. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  31525. // wxcardvisitOption allows management of the mutation configuration using functional options.
  31526. type wxcardvisitOption func(*WxCardVisitMutation)
  31527. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  31528. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  31529. m := &WxCardVisitMutation{
  31530. config: c,
  31531. op: op,
  31532. typ: TypeWxCardVisit,
  31533. clearedFields: make(map[string]struct{}),
  31534. }
  31535. for _, opt := range opts {
  31536. opt(m)
  31537. }
  31538. return m
  31539. }
  31540. // withWxCardVisitID sets the ID field of the mutation.
  31541. func withWxCardVisitID(id uint64) wxcardvisitOption {
  31542. return func(m *WxCardVisitMutation) {
  31543. var (
  31544. err error
  31545. once sync.Once
  31546. value *WxCardVisit
  31547. )
  31548. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  31549. once.Do(func() {
  31550. if m.done {
  31551. err = errors.New("querying old values post mutation is not allowed")
  31552. } else {
  31553. value, err = m.Client().WxCardVisit.Get(ctx, id)
  31554. }
  31555. })
  31556. return value, err
  31557. }
  31558. m.id = &id
  31559. }
  31560. }
  31561. // withWxCardVisit sets the old WxCardVisit of the mutation.
  31562. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  31563. return func(m *WxCardVisitMutation) {
  31564. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  31565. return node, nil
  31566. }
  31567. m.id = &node.ID
  31568. }
  31569. }
  31570. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31571. // executed in a transaction (ent.Tx), a transactional client is returned.
  31572. func (m WxCardVisitMutation) Client() *Client {
  31573. client := &Client{config: m.config}
  31574. client.init()
  31575. return client
  31576. }
  31577. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31578. // it returns an error otherwise.
  31579. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  31580. if _, ok := m.driver.(*txDriver); !ok {
  31581. return nil, errors.New("ent: mutation is not running in a transaction")
  31582. }
  31583. tx := &Tx{config: m.config}
  31584. tx.init()
  31585. return tx, nil
  31586. }
  31587. // SetID sets the value of the id field. Note that this
  31588. // operation is only accepted on creation of WxCardVisit entities.
  31589. func (m *WxCardVisitMutation) SetID(id uint64) {
  31590. m.id = &id
  31591. }
  31592. // ID returns the ID value in the mutation. Note that the ID is only available
  31593. // if it was provided to the builder or after it was returned from the database.
  31594. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  31595. if m.id == nil {
  31596. return
  31597. }
  31598. return *m.id, true
  31599. }
  31600. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31601. // That means, if the mutation is applied within a transaction with an isolation level such
  31602. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31603. // or updated by the mutation.
  31604. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  31605. switch {
  31606. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31607. id, exists := m.ID()
  31608. if exists {
  31609. return []uint64{id}, nil
  31610. }
  31611. fallthrough
  31612. case m.op.Is(OpUpdate | OpDelete):
  31613. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  31614. default:
  31615. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31616. }
  31617. }
  31618. // SetCreatedAt sets the "created_at" field.
  31619. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  31620. m.created_at = &t
  31621. }
  31622. // CreatedAt returns the value of the "created_at" field in the mutation.
  31623. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  31624. v := m.created_at
  31625. if v == nil {
  31626. return
  31627. }
  31628. return *v, true
  31629. }
  31630. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  31631. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31633. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31634. if !m.op.Is(OpUpdateOne) {
  31635. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31636. }
  31637. if m.id == nil || m.oldValue == nil {
  31638. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31639. }
  31640. oldValue, err := m.oldValue(ctx)
  31641. if err != nil {
  31642. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31643. }
  31644. return oldValue.CreatedAt, nil
  31645. }
  31646. // ResetCreatedAt resets all changes to the "created_at" field.
  31647. func (m *WxCardVisitMutation) ResetCreatedAt() {
  31648. m.created_at = nil
  31649. }
  31650. // SetUpdatedAt sets the "updated_at" field.
  31651. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  31652. m.updated_at = &t
  31653. }
  31654. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31655. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  31656. v := m.updated_at
  31657. if v == nil {
  31658. return
  31659. }
  31660. return *v, true
  31661. }
  31662. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  31663. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31665. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31666. if !m.op.Is(OpUpdateOne) {
  31667. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31668. }
  31669. if m.id == nil || m.oldValue == nil {
  31670. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31671. }
  31672. oldValue, err := m.oldValue(ctx)
  31673. if err != nil {
  31674. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31675. }
  31676. return oldValue.UpdatedAt, nil
  31677. }
  31678. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31679. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  31680. m.updated_at = nil
  31681. }
  31682. // SetDeletedAt sets the "deleted_at" field.
  31683. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  31684. m.deleted_at = &t
  31685. }
  31686. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31687. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  31688. v := m.deleted_at
  31689. if v == nil {
  31690. return
  31691. }
  31692. return *v, true
  31693. }
  31694. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  31695. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31697. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31698. if !m.op.Is(OpUpdateOne) {
  31699. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31700. }
  31701. if m.id == nil || m.oldValue == nil {
  31702. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31703. }
  31704. oldValue, err := m.oldValue(ctx)
  31705. if err != nil {
  31706. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31707. }
  31708. return oldValue.DeletedAt, nil
  31709. }
  31710. // ClearDeletedAt clears the value of the "deleted_at" field.
  31711. func (m *WxCardVisitMutation) ClearDeletedAt() {
  31712. m.deleted_at = nil
  31713. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  31714. }
  31715. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31716. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  31717. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  31718. return ok
  31719. }
  31720. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31721. func (m *WxCardVisitMutation) ResetDeletedAt() {
  31722. m.deleted_at = nil
  31723. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  31724. }
  31725. // SetUserID sets the "user_id" field.
  31726. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  31727. m.user_id = &u
  31728. m.adduser_id = nil
  31729. }
  31730. // UserID returns the value of the "user_id" field in the mutation.
  31731. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  31732. v := m.user_id
  31733. if v == nil {
  31734. return
  31735. }
  31736. return *v, true
  31737. }
  31738. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  31739. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31741. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  31742. if !m.op.Is(OpUpdateOne) {
  31743. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  31744. }
  31745. if m.id == nil || m.oldValue == nil {
  31746. return v, errors.New("OldUserID requires an ID field in the mutation")
  31747. }
  31748. oldValue, err := m.oldValue(ctx)
  31749. if err != nil {
  31750. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  31751. }
  31752. return oldValue.UserID, nil
  31753. }
  31754. // AddUserID adds u to the "user_id" field.
  31755. func (m *WxCardVisitMutation) AddUserID(u int64) {
  31756. if m.adduser_id != nil {
  31757. *m.adduser_id += u
  31758. } else {
  31759. m.adduser_id = &u
  31760. }
  31761. }
  31762. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  31763. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  31764. v := m.adduser_id
  31765. if v == nil {
  31766. return
  31767. }
  31768. return *v, true
  31769. }
  31770. // ClearUserID clears the value of the "user_id" field.
  31771. func (m *WxCardVisitMutation) ClearUserID() {
  31772. m.user_id = nil
  31773. m.adduser_id = nil
  31774. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  31775. }
  31776. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  31777. func (m *WxCardVisitMutation) UserIDCleared() bool {
  31778. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  31779. return ok
  31780. }
  31781. // ResetUserID resets all changes to the "user_id" field.
  31782. func (m *WxCardVisitMutation) ResetUserID() {
  31783. m.user_id = nil
  31784. m.adduser_id = nil
  31785. delete(m.clearedFields, wxcardvisit.FieldUserID)
  31786. }
  31787. // SetBotID sets the "bot_id" field.
  31788. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  31789. m.bot_id = &u
  31790. m.addbot_id = nil
  31791. }
  31792. // BotID returns the value of the "bot_id" field in the mutation.
  31793. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  31794. v := m.bot_id
  31795. if v == nil {
  31796. return
  31797. }
  31798. return *v, true
  31799. }
  31800. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  31801. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31803. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  31804. if !m.op.Is(OpUpdateOne) {
  31805. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31806. }
  31807. if m.id == nil || m.oldValue == nil {
  31808. return v, errors.New("OldBotID requires an ID field in the mutation")
  31809. }
  31810. oldValue, err := m.oldValue(ctx)
  31811. if err != nil {
  31812. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31813. }
  31814. return oldValue.BotID, nil
  31815. }
  31816. // AddBotID adds u to the "bot_id" field.
  31817. func (m *WxCardVisitMutation) AddBotID(u int64) {
  31818. if m.addbot_id != nil {
  31819. *m.addbot_id += u
  31820. } else {
  31821. m.addbot_id = &u
  31822. }
  31823. }
  31824. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  31825. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  31826. v := m.addbot_id
  31827. if v == nil {
  31828. return
  31829. }
  31830. return *v, true
  31831. }
  31832. // ResetBotID resets all changes to the "bot_id" field.
  31833. func (m *WxCardVisitMutation) ResetBotID() {
  31834. m.bot_id = nil
  31835. m.addbot_id = nil
  31836. }
  31837. // SetBotType sets the "bot_type" field.
  31838. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  31839. m.bot_type = &u
  31840. m.addbot_type = nil
  31841. }
  31842. // BotType returns the value of the "bot_type" field in the mutation.
  31843. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  31844. v := m.bot_type
  31845. if v == nil {
  31846. return
  31847. }
  31848. return *v, true
  31849. }
  31850. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  31851. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31853. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  31854. if !m.op.Is(OpUpdateOne) {
  31855. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  31856. }
  31857. if m.id == nil || m.oldValue == nil {
  31858. return v, errors.New("OldBotType requires an ID field in the mutation")
  31859. }
  31860. oldValue, err := m.oldValue(ctx)
  31861. if err != nil {
  31862. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  31863. }
  31864. return oldValue.BotType, nil
  31865. }
  31866. // AddBotType adds u to the "bot_type" field.
  31867. func (m *WxCardVisitMutation) AddBotType(u int8) {
  31868. if m.addbot_type != nil {
  31869. *m.addbot_type += u
  31870. } else {
  31871. m.addbot_type = &u
  31872. }
  31873. }
  31874. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  31875. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  31876. v := m.addbot_type
  31877. if v == nil {
  31878. return
  31879. }
  31880. return *v, true
  31881. }
  31882. // ResetBotType resets all changes to the "bot_type" field.
  31883. func (m *WxCardVisitMutation) ResetBotType() {
  31884. m.bot_type = nil
  31885. m.addbot_type = nil
  31886. }
  31887. // Where appends a list predicates to the WxCardVisitMutation builder.
  31888. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  31889. m.predicates = append(m.predicates, ps...)
  31890. }
  31891. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  31892. // users can use type-assertion to append predicates that do not depend on any generated package.
  31893. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  31894. p := make([]predicate.WxCardVisit, len(ps))
  31895. for i := range ps {
  31896. p[i] = ps[i]
  31897. }
  31898. m.Where(p...)
  31899. }
  31900. // Op returns the operation name.
  31901. func (m *WxCardVisitMutation) Op() Op {
  31902. return m.op
  31903. }
  31904. // SetOp allows setting the mutation operation.
  31905. func (m *WxCardVisitMutation) SetOp(op Op) {
  31906. m.op = op
  31907. }
  31908. // Type returns the node type of this mutation (WxCardVisit).
  31909. func (m *WxCardVisitMutation) Type() string {
  31910. return m.typ
  31911. }
  31912. // Fields returns all fields that were changed during this mutation. Note that in
  31913. // order to get all numeric fields that were incremented/decremented, call
  31914. // AddedFields().
  31915. func (m *WxCardVisitMutation) Fields() []string {
  31916. fields := make([]string, 0, 6)
  31917. if m.created_at != nil {
  31918. fields = append(fields, wxcardvisit.FieldCreatedAt)
  31919. }
  31920. if m.updated_at != nil {
  31921. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  31922. }
  31923. if m.deleted_at != nil {
  31924. fields = append(fields, wxcardvisit.FieldDeletedAt)
  31925. }
  31926. if m.user_id != nil {
  31927. fields = append(fields, wxcardvisit.FieldUserID)
  31928. }
  31929. if m.bot_id != nil {
  31930. fields = append(fields, wxcardvisit.FieldBotID)
  31931. }
  31932. if m.bot_type != nil {
  31933. fields = append(fields, wxcardvisit.FieldBotType)
  31934. }
  31935. return fields
  31936. }
  31937. // Field returns the value of a field with the given name. The second boolean
  31938. // return value indicates that this field was not set, or was not defined in the
  31939. // schema.
  31940. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  31941. switch name {
  31942. case wxcardvisit.FieldCreatedAt:
  31943. return m.CreatedAt()
  31944. case wxcardvisit.FieldUpdatedAt:
  31945. return m.UpdatedAt()
  31946. case wxcardvisit.FieldDeletedAt:
  31947. return m.DeletedAt()
  31948. case wxcardvisit.FieldUserID:
  31949. return m.UserID()
  31950. case wxcardvisit.FieldBotID:
  31951. return m.BotID()
  31952. case wxcardvisit.FieldBotType:
  31953. return m.BotType()
  31954. }
  31955. return nil, false
  31956. }
  31957. // OldField returns the old value of the field from the database. An error is
  31958. // returned if the mutation operation is not UpdateOne, or the query to the
  31959. // database failed.
  31960. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31961. switch name {
  31962. case wxcardvisit.FieldCreatedAt:
  31963. return m.OldCreatedAt(ctx)
  31964. case wxcardvisit.FieldUpdatedAt:
  31965. return m.OldUpdatedAt(ctx)
  31966. case wxcardvisit.FieldDeletedAt:
  31967. return m.OldDeletedAt(ctx)
  31968. case wxcardvisit.FieldUserID:
  31969. return m.OldUserID(ctx)
  31970. case wxcardvisit.FieldBotID:
  31971. return m.OldBotID(ctx)
  31972. case wxcardvisit.FieldBotType:
  31973. return m.OldBotType(ctx)
  31974. }
  31975. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  31976. }
  31977. // SetField sets the value of a field with the given name. It returns an error if
  31978. // the field is not defined in the schema, or if the type mismatched the field
  31979. // type.
  31980. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  31981. switch name {
  31982. case wxcardvisit.FieldCreatedAt:
  31983. v, ok := value.(time.Time)
  31984. if !ok {
  31985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31986. }
  31987. m.SetCreatedAt(v)
  31988. return nil
  31989. case wxcardvisit.FieldUpdatedAt:
  31990. v, ok := value.(time.Time)
  31991. if !ok {
  31992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31993. }
  31994. m.SetUpdatedAt(v)
  31995. return nil
  31996. case wxcardvisit.FieldDeletedAt:
  31997. v, ok := value.(time.Time)
  31998. if !ok {
  31999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32000. }
  32001. m.SetDeletedAt(v)
  32002. return nil
  32003. case wxcardvisit.FieldUserID:
  32004. v, ok := value.(uint64)
  32005. if !ok {
  32006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32007. }
  32008. m.SetUserID(v)
  32009. return nil
  32010. case wxcardvisit.FieldBotID:
  32011. v, ok := value.(uint64)
  32012. if !ok {
  32013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32014. }
  32015. m.SetBotID(v)
  32016. return nil
  32017. case wxcardvisit.FieldBotType:
  32018. v, ok := value.(uint8)
  32019. if !ok {
  32020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32021. }
  32022. m.SetBotType(v)
  32023. return nil
  32024. }
  32025. return fmt.Errorf("unknown WxCardVisit field %s", name)
  32026. }
  32027. // AddedFields returns all numeric fields that were incremented/decremented during
  32028. // this mutation.
  32029. func (m *WxCardVisitMutation) AddedFields() []string {
  32030. var fields []string
  32031. if m.adduser_id != nil {
  32032. fields = append(fields, wxcardvisit.FieldUserID)
  32033. }
  32034. if m.addbot_id != nil {
  32035. fields = append(fields, wxcardvisit.FieldBotID)
  32036. }
  32037. if m.addbot_type != nil {
  32038. fields = append(fields, wxcardvisit.FieldBotType)
  32039. }
  32040. return fields
  32041. }
  32042. // AddedField returns the numeric value that was incremented/decremented on a field
  32043. // with the given name. The second boolean return value indicates that this field
  32044. // was not set, or was not defined in the schema.
  32045. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  32046. switch name {
  32047. case wxcardvisit.FieldUserID:
  32048. return m.AddedUserID()
  32049. case wxcardvisit.FieldBotID:
  32050. return m.AddedBotID()
  32051. case wxcardvisit.FieldBotType:
  32052. return m.AddedBotType()
  32053. }
  32054. return nil, false
  32055. }
  32056. // AddField adds the value to the field with the given name. It returns an error if
  32057. // the field is not defined in the schema, or if the type mismatched the field
  32058. // type.
  32059. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  32060. switch name {
  32061. case wxcardvisit.FieldUserID:
  32062. v, ok := value.(int64)
  32063. if !ok {
  32064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32065. }
  32066. m.AddUserID(v)
  32067. return nil
  32068. case wxcardvisit.FieldBotID:
  32069. v, ok := value.(int64)
  32070. if !ok {
  32071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32072. }
  32073. m.AddBotID(v)
  32074. return nil
  32075. case wxcardvisit.FieldBotType:
  32076. v, ok := value.(int8)
  32077. if !ok {
  32078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32079. }
  32080. m.AddBotType(v)
  32081. return nil
  32082. }
  32083. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  32084. }
  32085. // ClearedFields returns all nullable fields that were cleared during this
  32086. // mutation.
  32087. func (m *WxCardVisitMutation) ClearedFields() []string {
  32088. var fields []string
  32089. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  32090. fields = append(fields, wxcardvisit.FieldDeletedAt)
  32091. }
  32092. if m.FieldCleared(wxcardvisit.FieldUserID) {
  32093. fields = append(fields, wxcardvisit.FieldUserID)
  32094. }
  32095. return fields
  32096. }
  32097. // FieldCleared returns a boolean indicating if a field with the given name was
  32098. // cleared in this mutation.
  32099. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  32100. _, ok := m.clearedFields[name]
  32101. return ok
  32102. }
  32103. // ClearField clears the value of the field with the given name. It returns an
  32104. // error if the field is not defined in the schema.
  32105. func (m *WxCardVisitMutation) ClearField(name string) error {
  32106. switch name {
  32107. case wxcardvisit.FieldDeletedAt:
  32108. m.ClearDeletedAt()
  32109. return nil
  32110. case wxcardvisit.FieldUserID:
  32111. m.ClearUserID()
  32112. return nil
  32113. }
  32114. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  32115. }
  32116. // ResetField resets all changes in the mutation for the field with the given name.
  32117. // It returns an error if the field is not defined in the schema.
  32118. func (m *WxCardVisitMutation) ResetField(name string) error {
  32119. switch name {
  32120. case wxcardvisit.FieldCreatedAt:
  32121. m.ResetCreatedAt()
  32122. return nil
  32123. case wxcardvisit.FieldUpdatedAt:
  32124. m.ResetUpdatedAt()
  32125. return nil
  32126. case wxcardvisit.FieldDeletedAt:
  32127. m.ResetDeletedAt()
  32128. return nil
  32129. case wxcardvisit.FieldUserID:
  32130. m.ResetUserID()
  32131. return nil
  32132. case wxcardvisit.FieldBotID:
  32133. m.ResetBotID()
  32134. return nil
  32135. case wxcardvisit.FieldBotType:
  32136. m.ResetBotType()
  32137. return nil
  32138. }
  32139. return fmt.Errorf("unknown WxCardVisit field %s", name)
  32140. }
  32141. // AddedEdges returns all edge names that were set/added in this mutation.
  32142. func (m *WxCardVisitMutation) AddedEdges() []string {
  32143. edges := make([]string, 0, 0)
  32144. return edges
  32145. }
  32146. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32147. // name in this mutation.
  32148. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  32149. return nil
  32150. }
  32151. // RemovedEdges returns all edge names that were removed in this mutation.
  32152. func (m *WxCardVisitMutation) RemovedEdges() []string {
  32153. edges := make([]string, 0, 0)
  32154. return edges
  32155. }
  32156. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32157. // the given name in this mutation.
  32158. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  32159. return nil
  32160. }
  32161. // ClearedEdges returns all edge names that were cleared in this mutation.
  32162. func (m *WxCardVisitMutation) ClearedEdges() []string {
  32163. edges := make([]string, 0, 0)
  32164. return edges
  32165. }
  32166. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32167. // was cleared in this mutation.
  32168. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  32169. return false
  32170. }
  32171. // ClearEdge clears the value of the edge with the given name. It returns an error
  32172. // if that edge is not defined in the schema.
  32173. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  32174. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  32175. }
  32176. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32177. // It returns an error if the edge is not defined in the schema.
  32178. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  32179. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  32180. }