mutation.go 971 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908
  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/batchmsg"
  13. "wechat-api/ent/category"
  14. "wechat-api/ent/chatrecords"
  15. "wechat-api/ent/chatsession"
  16. "wechat-api/ent/contact"
  17. "wechat-api/ent/custom_types"
  18. "wechat-api/ent/employee"
  19. "wechat-api/ent/employeeconfig"
  20. "wechat-api/ent/label"
  21. "wechat-api/ent/labelrelationship"
  22. "wechat-api/ent/message"
  23. "wechat-api/ent/messagerecords"
  24. "wechat-api/ent/msg"
  25. "wechat-api/ent/predicate"
  26. "wechat-api/ent/server"
  27. "wechat-api/ent/sopnode"
  28. "wechat-api/ent/sopstage"
  29. "wechat-api/ent/soptask"
  30. "wechat-api/ent/token"
  31. "wechat-api/ent/tutorial"
  32. "wechat-api/ent/usagedetail"
  33. "wechat-api/ent/usagetotal"
  34. "wechat-api/ent/workexperience"
  35. "wechat-api/ent/wx"
  36. "wechat-api/ent/wxcard"
  37. "wechat-api/ent/wxcarduser"
  38. "wechat-api/ent/wxcardvisit"
  39. "entgo.io/ent"
  40. "entgo.io/ent/dialect/sql"
  41. )
  42. const (
  43. // Operation types.
  44. OpCreate = ent.OpCreate
  45. OpDelete = ent.OpDelete
  46. OpDeleteOne = ent.OpDeleteOne
  47. OpUpdate = ent.OpUpdate
  48. OpUpdateOne = ent.OpUpdateOne
  49. // Node types.
  50. TypeAgent = "Agent"
  51. TypeAgentBase = "AgentBase"
  52. TypeAliyunAvatar = "AliyunAvatar"
  53. TypeBatchMsg = "BatchMsg"
  54. TypeCategory = "Category"
  55. TypeChatRecords = "ChatRecords"
  56. TypeChatSession = "ChatSession"
  57. TypeContact = "Contact"
  58. TypeEmployee = "Employee"
  59. TypeEmployeeConfig = "EmployeeConfig"
  60. TypeLabel = "Label"
  61. TypeLabelRelationship = "LabelRelationship"
  62. TypeMessage = "Message"
  63. TypeMessageRecords = "MessageRecords"
  64. TypeMsg = "Msg"
  65. TypeServer = "Server"
  66. TypeSopNode = "SopNode"
  67. TypeSopStage = "SopStage"
  68. TypeSopTask = "SopTask"
  69. TypeToken = "Token"
  70. TypeTutorial = "Tutorial"
  71. TypeUsageDetail = "UsageDetail"
  72. TypeUsageTotal = "UsageTotal"
  73. TypeWorkExperience = "WorkExperience"
  74. TypeWx = "Wx"
  75. TypeWxCard = "WxCard"
  76. TypeWxCardUser = "WxCardUser"
  77. TypeWxCardVisit = "WxCardVisit"
  78. )
  79. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  80. type AgentMutation struct {
  81. config
  82. op Op
  83. typ string
  84. id *uint64
  85. created_at *time.Time
  86. updated_at *time.Time
  87. deleted_at *time.Time
  88. name *string
  89. role *string
  90. status *int
  91. addstatus *int
  92. background *string
  93. examples *string
  94. organization_id *uint64
  95. addorganization_id *int64
  96. dataset_id *string
  97. collection_id *string
  98. clearedFields map[string]struct{}
  99. wx_agent map[uint64]struct{}
  100. removedwx_agent map[uint64]struct{}
  101. clearedwx_agent bool
  102. token_agent map[uint64]struct{}
  103. removedtoken_agent map[uint64]struct{}
  104. clearedtoken_agent bool
  105. done bool
  106. oldValue func(context.Context) (*Agent, error)
  107. predicates []predicate.Agent
  108. }
  109. var _ ent.Mutation = (*AgentMutation)(nil)
  110. // agentOption allows management of the mutation configuration using functional options.
  111. type agentOption func(*AgentMutation)
  112. // newAgentMutation creates new mutation for the Agent entity.
  113. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  114. m := &AgentMutation{
  115. config: c,
  116. op: op,
  117. typ: TypeAgent,
  118. clearedFields: make(map[string]struct{}),
  119. }
  120. for _, opt := range opts {
  121. opt(m)
  122. }
  123. return m
  124. }
  125. // withAgentID sets the ID field of the mutation.
  126. func withAgentID(id uint64) agentOption {
  127. return func(m *AgentMutation) {
  128. var (
  129. err error
  130. once sync.Once
  131. value *Agent
  132. )
  133. m.oldValue = func(ctx context.Context) (*Agent, error) {
  134. once.Do(func() {
  135. if m.done {
  136. err = errors.New("querying old values post mutation is not allowed")
  137. } else {
  138. value, err = m.Client().Agent.Get(ctx, id)
  139. }
  140. })
  141. return value, err
  142. }
  143. m.id = &id
  144. }
  145. }
  146. // withAgent sets the old Agent of the mutation.
  147. func withAgent(node *Agent) agentOption {
  148. return func(m *AgentMutation) {
  149. m.oldValue = func(context.Context) (*Agent, error) {
  150. return node, nil
  151. }
  152. m.id = &node.ID
  153. }
  154. }
  155. // Client returns a new `ent.Client` from the mutation. If the mutation was
  156. // executed in a transaction (ent.Tx), a transactional client is returned.
  157. func (m AgentMutation) Client() *Client {
  158. client := &Client{config: m.config}
  159. client.init()
  160. return client
  161. }
  162. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  163. // it returns an error otherwise.
  164. func (m AgentMutation) Tx() (*Tx, error) {
  165. if _, ok := m.driver.(*txDriver); !ok {
  166. return nil, errors.New("ent: mutation is not running in a transaction")
  167. }
  168. tx := &Tx{config: m.config}
  169. tx.init()
  170. return tx, nil
  171. }
  172. // SetID sets the value of the id field. Note that this
  173. // operation is only accepted on creation of Agent entities.
  174. func (m *AgentMutation) SetID(id uint64) {
  175. m.id = &id
  176. }
  177. // ID returns the ID value in the mutation. Note that the ID is only available
  178. // if it was provided to the builder or after it was returned from the database.
  179. func (m *AgentMutation) ID() (id uint64, exists bool) {
  180. if m.id == nil {
  181. return
  182. }
  183. return *m.id, true
  184. }
  185. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  186. // That means, if the mutation is applied within a transaction with an isolation level such
  187. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  188. // or updated by the mutation.
  189. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  190. switch {
  191. case m.op.Is(OpUpdateOne | OpDeleteOne):
  192. id, exists := m.ID()
  193. if exists {
  194. return []uint64{id}, nil
  195. }
  196. fallthrough
  197. case m.op.Is(OpUpdate | OpDelete):
  198. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  199. default:
  200. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  201. }
  202. }
  203. // SetCreatedAt sets the "created_at" field.
  204. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  205. m.created_at = &t
  206. }
  207. // CreatedAt returns the value of the "created_at" field in the mutation.
  208. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  209. v := m.created_at
  210. if v == nil {
  211. return
  212. }
  213. return *v, true
  214. }
  215. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  216. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  218. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  219. if !m.op.Is(OpUpdateOne) {
  220. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  221. }
  222. if m.id == nil || m.oldValue == nil {
  223. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  224. }
  225. oldValue, err := m.oldValue(ctx)
  226. if err != nil {
  227. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  228. }
  229. return oldValue.CreatedAt, nil
  230. }
  231. // ResetCreatedAt resets all changes to the "created_at" field.
  232. func (m *AgentMutation) ResetCreatedAt() {
  233. m.created_at = nil
  234. }
  235. // SetUpdatedAt sets the "updated_at" field.
  236. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  237. m.updated_at = &t
  238. }
  239. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  240. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  241. v := m.updated_at
  242. if v == nil {
  243. return
  244. }
  245. return *v, true
  246. }
  247. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  248. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  250. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  251. if !m.op.Is(OpUpdateOne) {
  252. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  253. }
  254. if m.id == nil || m.oldValue == nil {
  255. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  256. }
  257. oldValue, err := m.oldValue(ctx)
  258. if err != nil {
  259. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  260. }
  261. return oldValue.UpdatedAt, nil
  262. }
  263. // ResetUpdatedAt resets all changes to the "updated_at" field.
  264. func (m *AgentMutation) ResetUpdatedAt() {
  265. m.updated_at = nil
  266. }
  267. // SetDeletedAt sets the "deleted_at" field.
  268. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  269. m.deleted_at = &t
  270. }
  271. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  272. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  273. v := m.deleted_at
  274. if v == nil {
  275. return
  276. }
  277. return *v, true
  278. }
  279. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  280. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  282. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  283. if !m.op.Is(OpUpdateOne) {
  284. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  285. }
  286. if m.id == nil || m.oldValue == nil {
  287. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  288. }
  289. oldValue, err := m.oldValue(ctx)
  290. if err != nil {
  291. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  292. }
  293. return oldValue.DeletedAt, nil
  294. }
  295. // ClearDeletedAt clears the value of the "deleted_at" field.
  296. func (m *AgentMutation) ClearDeletedAt() {
  297. m.deleted_at = nil
  298. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  299. }
  300. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  301. func (m *AgentMutation) DeletedAtCleared() bool {
  302. _, ok := m.clearedFields[agent.FieldDeletedAt]
  303. return ok
  304. }
  305. // ResetDeletedAt resets all changes to the "deleted_at" field.
  306. func (m *AgentMutation) ResetDeletedAt() {
  307. m.deleted_at = nil
  308. delete(m.clearedFields, agent.FieldDeletedAt)
  309. }
  310. // SetName sets the "name" field.
  311. func (m *AgentMutation) SetName(s string) {
  312. m.name = &s
  313. }
  314. // Name returns the value of the "name" field in the mutation.
  315. func (m *AgentMutation) Name() (r string, exists bool) {
  316. v := m.name
  317. if v == nil {
  318. return
  319. }
  320. return *v, true
  321. }
  322. // OldName returns the old "name" field's value of the Agent entity.
  323. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  325. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  326. if !m.op.Is(OpUpdateOne) {
  327. return v, errors.New("OldName is only allowed on UpdateOne operations")
  328. }
  329. if m.id == nil || m.oldValue == nil {
  330. return v, errors.New("OldName requires an ID field in the mutation")
  331. }
  332. oldValue, err := m.oldValue(ctx)
  333. if err != nil {
  334. return v, fmt.Errorf("querying old value for OldName: %w", err)
  335. }
  336. return oldValue.Name, nil
  337. }
  338. // ResetName resets all changes to the "name" field.
  339. func (m *AgentMutation) ResetName() {
  340. m.name = nil
  341. }
  342. // SetRole sets the "role" field.
  343. func (m *AgentMutation) SetRole(s string) {
  344. m.role = &s
  345. }
  346. // Role returns the value of the "role" field in the mutation.
  347. func (m *AgentMutation) Role() (r string, exists bool) {
  348. v := m.role
  349. if v == nil {
  350. return
  351. }
  352. return *v, true
  353. }
  354. // OldRole returns the old "role" field's value of the Agent entity.
  355. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  357. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  358. if !m.op.Is(OpUpdateOne) {
  359. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  360. }
  361. if m.id == nil || m.oldValue == nil {
  362. return v, errors.New("OldRole requires an ID field in the mutation")
  363. }
  364. oldValue, err := m.oldValue(ctx)
  365. if err != nil {
  366. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  367. }
  368. return oldValue.Role, nil
  369. }
  370. // ResetRole resets all changes to the "role" field.
  371. func (m *AgentMutation) ResetRole() {
  372. m.role = nil
  373. }
  374. // SetStatus sets the "status" field.
  375. func (m *AgentMutation) SetStatus(i int) {
  376. m.status = &i
  377. m.addstatus = nil
  378. }
  379. // Status returns the value of the "status" field in the mutation.
  380. func (m *AgentMutation) Status() (r int, exists bool) {
  381. v := m.status
  382. if v == nil {
  383. return
  384. }
  385. return *v, true
  386. }
  387. // OldStatus returns the old "status" field's value of the Agent entity.
  388. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  390. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  391. if !m.op.Is(OpUpdateOne) {
  392. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  393. }
  394. if m.id == nil || m.oldValue == nil {
  395. return v, errors.New("OldStatus requires an ID field in the mutation")
  396. }
  397. oldValue, err := m.oldValue(ctx)
  398. if err != nil {
  399. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  400. }
  401. return oldValue.Status, nil
  402. }
  403. // AddStatus adds i to the "status" field.
  404. func (m *AgentMutation) AddStatus(i int) {
  405. if m.addstatus != nil {
  406. *m.addstatus += i
  407. } else {
  408. m.addstatus = &i
  409. }
  410. }
  411. // AddedStatus returns the value that was added to the "status" field in this mutation.
  412. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  413. v := m.addstatus
  414. if v == nil {
  415. return
  416. }
  417. return *v, true
  418. }
  419. // ClearStatus clears the value of the "status" field.
  420. func (m *AgentMutation) ClearStatus() {
  421. m.status = nil
  422. m.addstatus = nil
  423. m.clearedFields[agent.FieldStatus] = struct{}{}
  424. }
  425. // StatusCleared returns if the "status" field was cleared in this mutation.
  426. func (m *AgentMutation) StatusCleared() bool {
  427. _, ok := m.clearedFields[agent.FieldStatus]
  428. return ok
  429. }
  430. // ResetStatus resets all changes to the "status" field.
  431. func (m *AgentMutation) ResetStatus() {
  432. m.status = nil
  433. m.addstatus = nil
  434. delete(m.clearedFields, agent.FieldStatus)
  435. }
  436. // SetBackground sets the "background" field.
  437. func (m *AgentMutation) SetBackground(s string) {
  438. m.background = &s
  439. }
  440. // Background returns the value of the "background" field in the mutation.
  441. func (m *AgentMutation) Background() (r string, exists bool) {
  442. v := m.background
  443. if v == nil {
  444. return
  445. }
  446. return *v, true
  447. }
  448. // OldBackground returns the old "background" field's value of the Agent entity.
  449. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  451. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  452. if !m.op.Is(OpUpdateOne) {
  453. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  454. }
  455. if m.id == nil || m.oldValue == nil {
  456. return v, errors.New("OldBackground requires an ID field in the mutation")
  457. }
  458. oldValue, err := m.oldValue(ctx)
  459. if err != nil {
  460. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  461. }
  462. return oldValue.Background, nil
  463. }
  464. // ClearBackground clears the value of the "background" field.
  465. func (m *AgentMutation) ClearBackground() {
  466. m.background = nil
  467. m.clearedFields[agent.FieldBackground] = struct{}{}
  468. }
  469. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  470. func (m *AgentMutation) BackgroundCleared() bool {
  471. _, ok := m.clearedFields[agent.FieldBackground]
  472. return ok
  473. }
  474. // ResetBackground resets all changes to the "background" field.
  475. func (m *AgentMutation) ResetBackground() {
  476. m.background = nil
  477. delete(m.clearedFields, agent.FieldBackground)
  478. }
  479. // SetExamples sets the "examples" field.
  480. func (m *AgentMutation) SetExamples(s string) {
  481. m.examples = &s
  482. }
  483. // Examples returns the value of the "examples" field in the mutation.
  484. func (m *AgentMutation) Examples() (r string, exists bool) {
  485. v := m.examples
  486. if v == nil {
  487. return
  488. }
  489. return *v, true
  490. }
  491. // OldExamples returns the old "examples" field's value of the Agent entity.
  492. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  494. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  495. if !m.op.Is(OpUpdateOne) {
  496. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  497. }
  498. if m.id == nil || m.oldValue == nil {
  499. return v, errors.New("OldExamples requires an ID field in the mutation")
  500. }
  501. oldValue, err := m.oldValue(ctx)
  502. if err != nil {
  503. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  504. }
  505. return oldValue.Examples, nil
  506. }
  507. // ClearExamples clears the value of the "examples" field.
  508. func (m *AgentMutation) ClearExamples() {
  509. m.examples = nil
  510. m.clearedFields[agent.FieldExamples] = struct{}{}
  511. }
  512. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  513. func (m *AgentMutation) ExamplesCleared() bool {
  514. _, ok := m.clearedFields[agent.FieldExamples]
  515. return ok
  516. }
  517. // ResetExamples resets all changes to the "examples" field.
  518. func (m *AgentMutation) ResetExamples() {
  519. m.examples = nil
  520. delete(m.clearedFields, agent.FieldExamples)
  521. }
  522. // SetOrganizationID sets the "organization_id" field.
  523. func (m *AgentMutation) SetOrganizationID(u uint64) {
  524. m.organization_id = &u
  525. m.addorganization_id = nil
  526. }
  527. // OrganizationID returns the value of the "organization_id" field in the mutation.
  528. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  529. v := m.organization_id
  530. if v == nil {
  531. return
  532. }
  533. return *v, true
  534. }
  535. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  536. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  538. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  539. if !m.op.Is(OpUpdateOne) {
  540. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  541. }
  542. if m.id == nil || m.oldValue == nil {
  543. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  544. }
  545. oldValue, err := m.oldValue(ctx)
  546. if err != nil {
  547. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  548. }
  549. return oldValue.OrganizationID, nil
  550. }
  551. // AddOrganizationID adds u to the "organization_id" field.
  552. func (m *AgentMutation) AddOrganizationID(u int64) {
  553. if m.addorganization_id != nil {
  554. *m.addorganization_id += u
  555. } else {
  556. m.addorganization_id = &u
  557. }
  558. }
  559. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  560. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  561. v := m.addorganization_id
  562. if v == nil {
  563. return
  564. }
  565. return *v, true
  566. }
  567. // ResetOrganizationID resets all changes to the "organization_id" field.
  568. func (m *AgentMutation) ResetOrganizationID() {
  569. m.organization_id = nil
  570. m.addorganization_id = nil
  571. }
  572. // SetDatasetID sets the "dataset_id" field.
  573. func (m *AgentMutation) SetDatasetID(s string) {
  574. m.dataset_id = &s
  575. }
  576. // DatasetID returns the value of the "dataset_id" field in the mutation.
  577. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  578. v := m.dataset_id
  579. if v == nil {
  580. return
  581. }
  582. return *v, true
  583. }
  584. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  585. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  587. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  588. if !m.op.Is(OpUpdateOne) {
  589. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  590. }
  591. if m.id == nil || m.oldValue == nil {
  592. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  593. }
  594. oldValue, err := m.oldValue(ctx)
  595. if err != nil {
  596. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  597. }
  598. return oldValue.DatasetID, nil
  599. }
  600. // ResetDatasetID resets all changes to the "dataset_id" field.
  601. func (m *AgentMutation) ResetDatasetID() {
  602. m.dataset_id = nil
  603. }
  604. // SetCollectionID sets the "collection_id" field.
  605. func (m *AgentMutation) SetCollectionID(s string) {
  606. m.collection_id = &s
  607. }
  608. // CollectionID returns the value of the "collection_id" field in the mutation.
  609. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  610. v := m.collection_id
  611. if v == nil {
  612. return
  613. }
  614. return *v, true
  615. }
  616. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  617. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  619. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  620. if !m.op.Is(OpUpdateOne) {
  621. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  622. }
  623. if m.id == nil || m.oldValue == nil {
  624. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  625. }
  626. oldValue, err := m.oldValue(ctx)
  627. if err != nil {
  628. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  629. }
  630. return oldValue.CollectionID, nil
  631. }
  632. // ResetCollectionID resets all changes to the "collection_id" field.
  633. func (m *AgentMutation) ResetCollectionID() {
  634. m.collection_id = nil
  635. }
  636. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  637. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  638. if m.wx_agent == nil {
  639. m.wx_agent = make(map[uint64]struct{})
  640. }
  641. for i := range ids {
  642. m.wx_agent[ids[i]] = struct{}{}
  643. }
  644. }
  645. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  646. func (m *AgentMutation) ClearWxAgent() {
  647. m.clearedwx_agent = true
  648. }
  649. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  650. func (m *AgentMutation) WxAgentCleared() bool {
  651. return m.clearedwx_agent
  652. }
  653. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  654. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  655. if m.removedwx_agent == nil {
  656. m.removedwx_agent = make(map[uint64]struct{})
  657. }
  658. for i := range ids {
  659. delete(m.wx_agent, ids[i])
  660. m.removedwx_agent[ids[i]] = struct{}{}
  661. }
  662. }
  663. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  664. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  665. for id := range m.removedwx_agent {
  666. ids = append(ids, id)
  667. }
  668. return
  669. }
  670. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  671. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  672. for id := range m.wx_agent {
  673. ids = append(ids, id)
  674. }
  675. return
  676. }
  677. // ResetWxAgent resets all changes to the "wx_agent" edge.
  678. func (m *AgentMutation) ResetWxAgent() {
  679. m.wx_agent = nil
  680. m.clearedwx_agent = false
  681. m.removedwx_agent = nil
  682. }
  683. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  684. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  685. if m.token_agent == nil {
  686. m.token_agent = make(map[uint64]struct{})
  687. }
  688. for i := range ids {
  689. m.token_agent[ids[i]] = struct{}{}
  690. }
  691. }
  692. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  693. func (m *AgentMutation) ClearTokenAgent() {
  694. m.clearedtoken_agent = true
  695. }
  696. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  697. func (m *AgentMutation) TokenAgentCleared() bool {
  698. return m.clearedtoken_agent
  699. }
  700. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  701. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  702. if m.removedtoken_agent == nil {
  703. m.removedtoken_agent = make(map[uint64]struct{})
  704. }
  705. for i := range ids {
  706. delete(m.token_agent, ids[i])
  707. m.removedtoken_agent[ids[i]] = struct{}{}
  708. }
  709. }
  710. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  711. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  712. for id := range m.removedtoken_agent {
  713. ids = append(ids, id)
  714. }
  715. return
  716. }
  717. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  718. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  719. for id := range m.token_agent {
  720. ids = append(ids, id)
  721. }
  722. return
  723. }
  724. // ResetTokenAgent resets all changes to the "token_agent" edge.
  725. func (m *AgentMutation) ResetTokenAgent() {
  726. m.token_agent = nil
  727. m.clearedtoken_agent = false
  728. m.removedtoken_agent = nil
  729. }
  730. // Where appends a list predicates to the AgentMutation builder.
  731. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  732. m.predicates = append(m.predicates, ps...)
  733. }
  734. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  735. // users can use type-assertion to append predicates that do not depend on any generated package.
  736. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  737. p := make([]predicate.Agent, len(ps))
  738. for i := range ps {
  739. p[i] = ps[i]
  740. }
  741. m.Where(p...)
  742. }
  743. // Op returns the operation name.
  744. func (m *AgentMutation) Op() Op {
  745. return m.op
  746. }
  747. // SetOp allows setting the mutation operation.
  748. func (m *AgentMutation) SetOp(op Op) {
  749. m.op = op
  750. }
  751. // Type returns the node type of this mutation (Agent).
  752. func (m *AgentMutation) Type() string {
  753. return m.typ
  754. }
  755. // Fields returns all fields that were changed during this mutation. Note that in
  756. // order to get all numeric fields that were incremented/decremented, call
  757. // AddedFields().
  758. func (m *AgentMutation) Fields() []string {
  759. fields := make([]string, 0, 11)
  760. if m.created_at != nil {
  761. fields = append(fields, agent.FieldCreatedAt)
  762. }
  763. if m.updated_at != nil {
  764. fields = append(fields, agent.FieldUpdatedAt)
  765. }
  766. if m.deleted_at != nil {
  767. fields = append(fields, agent.FieldDeletedAt)
  768. }
  769. if m.name != nil {
  770. fields = append(fields, agent.FieldName)
  771. }
  772. if m.role != nil {
  773. fields = append(fields, agent.FieldRole)
  774. }
  775. if m.status != nil {
  776. fields = append(fields, agent.FieldStatus)
  777. }
  778. if m.background != nil {
  779. fields = append(fields, agent.FieldBackground)
  780. }
  781. if m.examples != nil {
  782. fields = append(fields, agent.FieldExamples)
  783. }
  784. if m.organization_id != nil {
  785. fields = append(fields, agent.FieldOrganizationID)
  786. }
  787. if m.dataset_id != nil {
  788. fields = append(fields, agent.FieldDatasetID)
  789. }
  790. if m.collection_id != nil {
  791. fields = append(fields, agent.FieldCollectionID)
  792. }
  793. return fields
  794. }
  795. // Field returns the value of a field with the given name. The second boolean
  796. // return value indicates that this field was not set, or was not defined in the
  797. // schema.
  798. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  799. switch name {
  800. case agent.FieldCreatedAt:
  801. return m.CreatedAt()
  802. case agent.FieldUpdatedAt:
  803. return m.UpdatedAt()
  804. case agent.FieldDeletedAt:
  805. return m.DeletedAt()
  806. case agent.FieldName:
  807. return m.Name()
  808. case agent.FieldRole:
  809. return m.Role()
  810. case agent.FieldStatus:
  811. return m.Status()
  812. case agent.FieldBackground:
  813. return m.Background()
  814. case agent.FieldExamples:
  815. return m.Examples()
  816. case agent.FieldOrganizationID:
  817. return m.OrganizationID()
  818. case agent.FieldDatasetID:
  819. return m.DatasetID()
  820. case agent.FieldCollectionID:
  821. return m.CollectionID()
  822. }
  823. return nil, false
  824. }
  825. // OldField returns the old value of the field from the database. An error is
  826. // returned if the mutation operation is not UpdateOne, or the query to the
  827. // database failed.
  828. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  829. switch name {
  830. case agent.FieldCreatedAt:
  831. return m.OldCreatedAt(ctx)
  832. case agent.FieldUpdatedAt:
  833. return m.OldUpdatedAt(ctx)
  834. case agent.FieldDeletedAt:
  835. return m.OldDeletedAt(ctx)
  836. case agent.FieldName:
  837. return m.OldName(ctx)
  838. case agent.FieldRole:
  839. return m.OldRole(ctx)
  840. case agent.FieldStatus:
  841. return m.OldStatus(ctx)
  842. case agent.FieldBackground:
  843. return m.OldBackground(ctx)
  844. case agent.FieldExamples:
  845. return m.OldExamples(ctx)
  846. case agent.FieldOrganizationID:
  847. return m.OldOrganizationID(ctx)
  848. case agent.FieldDatasetID:
  849. return m.OldDatasetID(ctx)
  850. case agent.FieldCollectionID:
  851. return m.OldCollectionID(ctx)
  852. }
  853. return nil, fmt.Errorf("unknown Agent field %s", name)
  854. }
  855. // SetField sets the value of a field with the given name. It returns an error if
  856. // the field is not defined in the schema, or if the type mismatched the field
  857. // type.
  858. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  859. switch name {
  860. case agent.FieldCreatedAt:
  861. v, ok := value.(time.Time)
  862. if !ok {
  863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  864. }
  865. m.SetCreatedAt(v)
  866. return nil
  867. case agent.FieldUpdatedAt:
  868. v, ok := value.(time.Time)
  869. if !ok {
  870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  871. }
  872. m.SetUpdatedAt(v)
  873. return nil
  874. case agent.FieldDeletedAt:
  875. v, ok := value.(time.Time)
  876. if !ok {
  877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  878. }
  879. m.SetDeletedAt(v)
  880. return nil
  881. case agent.FieldName:
  882. v, ok := value.(string)
  883. if !ok {
  884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  885. }
  886. m.SetName(v)
  887. return nil
  888. case agent.FieldRole:
  889. v, ok := value.(string)
  890. if !ok {
  891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  892. }
  893. m.SetRole(v)
  894. return nil
  895. case agent.FieldStatus:
  896. v, ok := value.(int)
  897. if !ok {
  898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  899. }
  900. m.SetStatus(v)
  901. return nil
  902. case agent.FieldBackground:
  903. v, ok := value.(string)
  904. if !ok {
  905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  906. }
  907. m.SetBackground(v)
  908. return nil
  909. case agent.FieldExamples:
  910. v, ok := value.(string)
  911. if !ok {
  912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  913. }
  914. m.SetExamples(v)
  915. return nil
  916. case agent.FieldOrganizationID:
  917. v, ok := value.(uint64)
  918. if !ok {
  919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  920. }
  921. m.SetOrganizationID(v)
  922. return nil
  923. case agent.FieldDatasetID:
  924. v, ok := value.(string)
  925. if !ok {
  926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  927. }
  928. m.SetDatasetID(v)
  929. return nil
  930. case agent.FieldCollectionID:
  931. v, ok := value.(string)
  932. if !ok {
  933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  934. }
  935. m.SetCollectionID(v)
  936. return nil
  937. }
  938. return fmt.Errorf("unknown Agent field %s", name)
  939. }
  940. // AddedFields returns all numeric fields that were incremented/decremented during
  941. // this mutation.
  942. func (m *AgentMutation) AddedFields() []string {
  943. var fields []string
  944. if m.addstatus != nil {
  945. fields = append(fields, agent.FieldStatus)
  946. }
  947. if m.addorganization_id != nil {
  948. fields = append(fields, agent.FieldOrganizationID)
  949. }
  950. return fields
  951. }
  952. // AddedField returns the numeric value that was incremented/decremented on a field
  953. // with the given name. The second boolean return value indicates that this field
  954. // was not set, or was not defined in the schema.
  955. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  956. switch name {
  957. case agent.FieldStatus:
  958. return m.AddedStatus()
  959. case agent.FieldOrganizationID:
  960. return m.AddedOrganizationID()
  961. }
  962. return nil, false
  963. }
  964. // AddField adds the value to the field with the given name. It returns an error if
  965. // the field is not defined in the schema, or if the type mismatched the field
  966. // type.
  967. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  968. switch name {
  969. case agent.FieldStatus:
  970. v, ok := value.(int)
  971. if !ok {
  972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  973. }
  974. m.AddStatus(v)
  975. return nil
  976. case agent.FieldOrganizationID:
  977. v, ok := value.(int64)
  978. if !ok {
  979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  980. }
  981. m.AddOrganizationID(v)
  982. return nil
  983. }
  984. return fmt.Errorf("unknown Agent numeric field %s", name)
  985. }
  986. // ClearedFields returns all nullable fields that were cleared during this
  987. // mutation.
  988. func (m *AgentMutation) ClearedFields() []string {
  989. var fields []string
  990. if m.FieldCleared(agent.FieldDeletedAt) {
  991. fields = append(fields, agent.FieldDeletedAt)
  992. }
  993. if m.FieldCleared(agent.FieldStatus) {
  994. fields = append(fields, agent.FieldStatus)
  995. }
  996. if m.FieldCleared(agent.FieldBackground) {
  997. fields = append(fields, agent.FieldBackground)
  998. }
  999. if m.FieldCleared(agent.FieldExamples) {
  1000. fields = append(fields, agent.FieldExamples)
  1001. }
  1002. return fields
  1003. }
  1004. // FieldCleared returns a boolean indicating if a field with the given name was
  1005. // cleared in this mutation.
  1006. func (m *AgentMutation) FieldCleared(name string) bool {
  1007. _, ok := m.clearedFields[name]
  1008. return ok
  1009. }
  1010. // ClearField clears the value of the field with the given name. It returns an
  1011. // error if the field is not defined in the schema.
  1012. func (m *AgentMutation) ClearField(name string) error {
  1013. switch name {
  1014. case agent.FieldDeletedAt:
  1015. m.ClearDeletedAt()
  1016. return nil
  1017. case agent.FieldStatus:
  1018. m.ClearStatus()
  1019. return nil
  1020. case agent.FieldBackground:
  1021. m.ClearBackground()
  1022. return nil
  1023. case agent.FieldExamples:
  1024. m.ClearExamples()
  1025. return nil
  1026. }
  1027. return fmt.Errorf("unknown Agent nullable field %s", name)
  1028. }
  1029. // ResetField resets all changes in the mutation for the field with the given name.
  1030. // It returns an error if the field is not defined in the schema.
  1031. func (m *AgentMutation) ResetField(name string) error {
  1032. switch name {
  1033. case agent.FieldCreatedAt:
  1034. m.ResetCreatedAt()
  1035. return nil
  1036. case agent.FieldUpdatedAt:
  1037. m.ResetUpdatedAt()
  1038. return nil
  1039. case agent.FieldDeletedAt:
  1040. m.ResetDeletedAt()
  1041. return nil
  1042. case agent.FieldName:
  1043. m.ResetName()
  1044. return nil
  1045. case agent.FieldRole:
  1046. m.ResetRole()
  1047. return nil
  1048. case agent.FieldStatus:
  1049. m.ResetStatus()
  1050. return nil
  1051. case agent.FieldBackground:
  1052. m.ResetBackground()
  1053. return nil
  1054. case agent.FieldExamples:
  1055. m.ResetExamples()
  1056. return nil
  1057. case agent.FieldOrganizationID:
  1058. m.ResetOrganizationID()
  1059. return nil
  1060. case agent.FieldDatasetID:
  1061. m.ResetDatasetID()
  1062. return nil
  1063. case agent.FieldCollectionID:
  1064. m.ResetCollectionID()
  1065. return nil
  1066. }
  1067. return fmt.Errorf("unknown Agent field %s", name)
  1068. }
  1069. // AddedEdges returns all edge names that were set/added in this mutation.
  1070. func (m *AgentMutation) AddedEdges() []string {
  1071. edges := make([]string, 0, 2)
  1072. if m.wx_agent != nil {
  1073. edges = append(edges, agent.EdgeWxAgent)
  1074. }
  1075. if m.token_agent != nil {
  1076. edges = append(edges, agent.EdgeTokenAgent)
  1077. }
  1078. return edges
  1079. }
  1080. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1081. // name in this mutation.
  1082. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1083. switch name {
  1084. case agent.EdgeWxAgent:
  1085. ids := make([]ent.Value, 0, len(m.wx_agent))
  1086. for id := range m.wx_agent {
  1087. ids = append(ids, id)
  1088. }
  1089. return ids
  1090. case agent.EdgeTokenAgent:
  1091. ids := make([]ent.Value, 0, len(m.token_agent))
  1092. for id := range m.token_agent {
  1093. ids = append(ids, id)
  1094. }
  1095. return ids
  1096. }
  1097. return nil
  1098. }
  1099. // RemovedEdges returns all edge names that were removed in this mutation.
  1100. func (m *AgentMutation) RemovedEdges() []string {
  1101. edges := make([]string, 0, 2)
  1102. if m.removedwx_agent != nil {
  1103. edges = append(edges, agent.EdgeWxAgent)
  1104. }
  1105. if m.removedtoken_agent != nil {
  1106. edges = append(edges, agent.EdgeTokenAgent)
  1107. }
  1108. return edges
  1109. }
  1110. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1111. // the given name in this mutation.
  1112. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1113. switch name {
  1114. case agent.EdgeWxAgent:
  1115. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1116. for id := range m.removedwx_agent {
  1117. ids = append(ids, id)
  1118. }
  1119. return ids
  1120. case agent.EdgeTokenAgent:
  1121. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1122. for id := range m.removedtoken_agent {
  1123. ids = append(ids, id)
  1124. }
  1125. return ids
  1126. }
  1127. return nil
  1128. }
  1129. // ClearedEdges returns all edge names that were cleared in this mutation.
  1130. func (m *AgentMutation) ClearedEdges() []string {
  1131. edges := make([]string, 0, 2)
  1132. if m.clearedwx_agent {
  1133. edges = append(edges, agent.EdgeWxAgent)
  1134. }
  1135. if m.clearedtoken_agent {
  1136. edges = append(edges, agent.EdgeTokenAgent)
  1137. }
  1138. return edges
  1139. }
  1140. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1141. // was cleared in this mutation.
  1142. func (m *AgentMutation) EdgeCleared(name string) bool {
  1143. switch name {
  1144. case agent.EdgeWxAgent:
  1145. return m.clearedwx_agent
  1146. case agent.EdgeTokenAgent:
  1147. return m.clearedtoken_agent
  1148. }
  1149. return false
  1150. }
  1151. // ClearEdge clears the value of the edge with the given name. It returns an error
  1152. // if that edge is not defined in the schema.
  1153. func (m *AgentMutation) ClearEdge(name string) error {
  1154. switch name {
  1155. }
  1156. return fmt.Errorf("unknown Agent unique edge %s", name)
  1157. }
  1158. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1159. // It returns an error if the edge is not defined in the schema.
  1160. func (m *AgentMutation) ResetEdge(name string) error {
  1161. switch name {
  1162. case agent.EdgeWxAgent:
  1163. m.ResetWxAgent()
  1164. return nil
  1165. case agent.EdgeTokenAgent:
  1166. m.ResetTokenAgent()
  1167. return nil
  1168. }
  1169. return fmt.Errorf("unknown Agent edge %s", name)
  1170. }
  1171. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1172. type AgentBaseMutation struct {
  1173. config
  1174. op Op
  1175. typ string
  1176. id *string
  1177. q *string
  1178. a *string
  1179. chunk_index *uint64
  1180. addchunk_index *int64
  1181. indexes *[]string
  1182. appendindexes []string
  1183. dataset_id *string
  1184. collection_id *string
  1185. source_name *string
  1186. can_write *[]bool
  1187. appendcan_write []bool
  1188. is_owner *[]bool
  1189. appendis_owner []bool
  1190. clearedFields map[string]struct{}
  1191. wx_agent map[uint64]struct{}
  1192. removedwx_agent map[uint64]struct{}
  1193. clearedwx_agent bool
  1194. done bool
  1195. oldValue func(context.Context) (*AgentBase, error)
  1196. predicates []predicate.AgentBase
  1197. }
  1198. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1199. // agentbaseOption allows management of the mutation configuration using functional options.
  1200. type agentbaseOption func(*AgentBaseMutation)
  1201. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1202. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1203. m := &AgentBaseMutation{
  1204. config: c,
  1205. op: op,
  1206. typ: TypeAgentBase,
  1207. clearedFields: make(map[string]struct{}),
  1208. }
  1209. for _, opt := range opts {
  1210. opt(m)
  1211. }
  1212. return m
  1213. }
  1214. // withAgentBaseID sets the ID field of the mutation.
  1215. func withAgentBaseID(id string) agentbaseOption {
  1216. return func(m *AgentBaseMutation) {
  1217. var (
  1218. err error
  1219. once sync.Once
  1220. value *AgentBase
  1221. )
  1222. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1223. once.Do(func() {
  1224. if m.done {
  1225. err = errors.New("querying old values post mutation is not allowed")
  1226. } else {
  1227. value, err = m.Client().AgentBase.Get(ctx, id)
  1228. }
  1229. })
  1230. return value, err
  1231. }
  1232. m.id = &id
  1233. }
  1234. }
  1235. // withAgentBase sets the old AgentBase of the mutation.
  1236. func withAgentBase(node *AgentBase) agentbaseOption {
  1237. return func(m *AgentBaseMutation) {
  1238. m.oldValue = func(context.Context) (*AgentBase, error) {
  1239. return node, nil
  1240. }
  1241. m.id = &node.ID
  1242. }
  1243. }
  1244. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1245. // executed in a transaction (ent.Tx), a transactional client is returned.
  1246. func (m AgentBaseMutation) Client() *Client {
  1247. client := &Client{config: m.config}
  1248. client.init()
  1249. return client
  1250. }
  1251. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1252. // it returns an error otherwise.
  1253. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1254. if _, ok := m.driver.(*txDriver); !ok {
  1255. return nil, errors.New("ent: mutation is not running in a transaction")
  1256. }
  1257. tx := &Tx{config: m.config}
  1258. tx.init()
  1259. return tx, nil
  1260. }
  1261. // SetID sets the value of the id field. Note that this
  1262. // operation is only accepted on creation of AgentBase entities.
  1263. func (m *AgentBaseMutation) SetID(id string) {
  1264. m.id = &id
  1265. }
  1266. // ID returns the ID value in the mutation. Note that the ID is only available
  1267. // if it was provided to the builder or after it was returned from the database.
  1268. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1269. if m.id == nil {
  1270. return
  1271. }
  1272. return *m.id, true
  1273. }
  1274. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1275. // That means, if the mutation is applied within a transaction with an isolation level such
  1276. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1277. // or updated by the mutation.
  1278. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1279. switch {
  1280. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1281. id, exists := m.ID()
  1282. if exists {
  1283. return []string{id}, nil
  1284. }
  1285. fallthrough
  1286. case m.op.Is(OpUpdate | OpDelete):
  1287. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1288. default:
  1289. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1290. }
  1291. }
  1292. // SetQ sets the "q" field.
  1293. func (m *AgentBaseMutation) SetQ(s string) {
  1294. m.q = &s
  1295. }
  1296. // Q returns the value of the "q" field in the mutation.
  1297. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1298. v := m.q
  1299. if v == nil {
  1300. return
  1301. }
  1302. return *v, true
  1303. }
  1304. // OldQ returns the old "q" field's value of the AgentBase entity.
  1305. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1307. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1308. if !m.op.Is(OpUpdateOne) {
  1309. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1310. }
  1311. if m.id == nil || m.oldValue == nil {
  1312. return v, errors.New("OldQ requires an ID field in the mutation")
  1313. }
  1314. oldValue, err := m.oldValue(ctx)
  1315. if err != nil {
  1316. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1317. }
  1318. return oldValue.Q, nil
  1319. }
  1320. // ClearQ clears the value of the "q" field.
  1321. func (m *AgentBaseMutation) ClearQ() {
  1322. m.q = nil
  1323. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1324. }
  1325. // QCleared returns if the "q" field was cleared in this mutation.
  1326. func (m *AgentBaseMutation) QCleared() bool {
  1327. _, ok := m.clearedFields[agentbase.FieldQ]
  1328. return ok
  1329. }
  1330. // ResetQ resets all changes to the "q" field.
  1331. func (m *AgentBaseMutation) ResetQ() {
  1332. m.q = nil
  1333. delete(m.clearedFields, agentbase.FieldQ)
  1334. }
  1335. // SetA sets the "a" field.
  1336. func (m *AgentBaseMutation) SetA(s string) {
  1337. m.a = &s
  1338. }
  1339. // A returns the value of the "a" field in the mutation.
  1340. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1341. v := m.a
  1342. if v == nil {
  1343. return
  1344. }
  1345. return *v, true
  1346. }
  1347. // OldA returns the old "a" field's value of the AgentBase entity.
  1348. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1350. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1351. if !m.op.Is(OpUpdateOne) {
  1352. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1353. }
  1354. if m.id == nil || m.oldValue == nil {
  1355. return v, errors.New("OldA requires an ID field in the mutation")
  1356. }
  1357. oldValue, err := m.oldValue(ctx)
  1358. if err != nil {
  1359. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1360. }
  1361. return oldValue.A, nil
  1362. }
  1363. // ClearA clears the value of the "a" field.
  1364. func (m *AgentBaseMutation) ClearA() {
  1365. m.a = nil
  1366. m.clearedFields[agentbase.FieldA] = struct{}{}
  1367. }
  1368. // ACleared returns if the "a" field was cleared in this mutation.
  1369. func (m *AgentBaseMutation) ACleared() bool {
  1370. _, ok := m.clearedFields[agentbase.FieldA]
  1371. return ok
  1372. }
  1373. // ResetA resets all changes to the "a" field.
  1374. func (m *AgentBaseMutation) ResetA() {
  1375. m.a = nil
  1376. delete(m.clearedFields, agentbase.FieldA)
  1377. }
  1378. // SetChunkIndex sets the "chunk_index" field.
  1379. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1380. m.chunk_index = &u
  1381. m.addchunk_index = nil
  1382. }
  1383. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1384. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1385. v := m.chunk_index
  1386. if v == nil {
  1387. return
  1388. }
  1389. return *v, true
  1390. }
  1391. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1392. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1394. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1395. if !m.op.Is(OpUpdateOne) {
  1396. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1397. }
  1398. if m.id == nil || m.oldValue == nil {
  1399. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1400. }
  1401. oldValue, err := m.oldValue(ctx)
  1402. if err != nil {
  1403. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1404. }
  1405. return oldValue.ChunkIndex, nil
  1406. }
  1407. // AddChunkIndex adds u to the "chunk_index" field.
  1408. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1409. if m.addchunk_index != nil {
  1410. *m.addchunk_index += u
  1411. } else {
  1412. m.addchunk_index = &u
  1413. }
  1414. }
  1415. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1416. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1417. v := m.addchunk_index
  1418. if v == nil {
  1419. return
  1420. }
  1421. return *v, true
  1422. }
  1423. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1424. func (m *AgentBaseMutation) ResetChunkIndex() {
  1425. m.chunk_index = nil
  1426. m.addchunk_index = nil
  1427. }
  1428. // SetIndexes sets the "indexes" field.
  1429. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1430. m.indexes = &s
  1431. m.appendindexes = nil
  1432. }
  1433. // Indexes returns the value of the "indexes" field in the mutation.
  1434. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1435. v := m.indexes
  1436. if v == nil {
  1437. return
  1438. }
  1439. return *v, true
  1440. }
  1441. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1442. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1444. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1445. if !m.op.Is(OpUpdateOne) {
  1446. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1447. }
  1448. if m.id == nil || m.oldValue == nil {
  1449. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1450. }
  1451. oldValue, err := m.oldValue(ctx)
  1452. if err != nil {
  1453. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1454. }
  1455. return oldValue.Indexes, nil
  1456. }
  1457. // AppendIndexes adds s to the "indexes" field.
  1458. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1459. m.appendindexes = append(m.appendindexes, s...)
  1460. }
  1461. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1462. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1463. if len(m.appendindexes) == 0 {
  1464. return nil, false
  1465. }
  1466. return m.appendindexes, true
  1467. }
  1468. // ClearIndexes clears the value of the "indexes" field.
  1469. func (m *AgentBaseMutation) ClearIndexes() {
  1470. m.indexes = nil
  1471. m.appendindexes = nil
  1472. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1473. }
  1474. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1475. func (m *AgentBaseMutation) IndexesCleared() bool {
  1476. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1477. return ok
  1478. }
  1479. // ResetIndexes resets all changes to the "indexes" field.
  1480. func (m *AgentBaseMutation) ResetIndexes() {
  1481. m.indexes = nil
  1482. m.appendindexes = nil
  1483. delete(m.clearedFields, agentbase.FieldIndexes)
  1484. }
  1485. // SetDatasetID sets the "dataset_id" field.
  1486. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1487. m.dataset_id = &s
  1488. }
  1489. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1490. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1491. v := m.dataset_id
  1492. if v == nil {
  1493. return
  1494. }
  1495. return *v, true
  1496. }
  1497. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1498. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1500. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1501. if !m.op.Is(OpUpdateOne) {
  1502. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1503. }
  1504. if m.id == nil || m.oldValue == nil {
  1505. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1506. }
  1507. oldValue, err := m.oldValue(ctx)
  1508. if err != nil {
  1509. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1510. }
  1511. return oldValue.DatasetID, nil
  1512. }
  1513. // ClearDatasetID clears the value of the "dataset_id" field.
  1514. func (m *AgentBaseMutation) ClearDatasetID() {
  1515. m.dataset_id = nil
  1516. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1517. }
  1518. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1519. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1520. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1521. return ok
  1522. }
  1523. // ResetDatasetID resets all changes to the "dataset_id" field.
  1524. func (m *AgentBaseMutation) ResetDatasetID() {
  1525. m.dataset_id = nil
  1526. delete(m.clearedFields, agentbase.FieldDatasetID)
  1527. }
  1528. // SetCollectionID sets the "collection_id" field.
  1529. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1530. m.collection_id = &s
  1531. }
  1532. // CollectionID returns the value of the "collection_id" field in the mutation.
  1533. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1534. v := m.collection_id
  1535. if v == nil {
  1536. return
  1537. }
  1538. return *v, true
  1539. }
  1540. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1541. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1543. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1544. if !m.op.Is(OpUpdateOne) {
  1545. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1546. }
  1547. if m.id == nil || m.oldValue == nil {
  1548. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1549. }
  1550. oldValue, err := m.oldValue(ctx)
  1551. if err != nil {
  1552. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1553. }
  1554. return oldValue.CollectionID, nil
  1555. }
  1556. // ClearCollectionID clears the value of the "collection_id" field.
  1557. func (m *AgentBaseMutation) ClearCollectionID() {
  1558. m.collection_id = nil
  1559. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1560. }
  1561. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1562. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1563. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1564. return ok
  1565. }
  1566. // ResetCollectionID resets all changes to the "collection_id" field.
  1567. func (m *AgentBaseMutation) ResetCollectionID() {
  1568. m.collection_id = nil
  1569. delete(m.clearedFields, agentbase.FieldCollectionID)
  1570. }
  1571. // SetSourceName sets the "source_name" field.
  1572. func (m *AgentBaseMutation) SetSourceName(s string) {
  1573. m.source_name = &s
  1574. }
  1575. // SourceName returns the value of the "source_name" field in the mutation.
  1576. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1577. v := m.source_name
  1578. if v == nil {
  1579. return
  1580. }
  1581. return *v, true
  1582. }
  1583. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1584. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1586. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1587. if !m.op.Is(OpUpdateOne) {
  1588. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1589. }
  1590. if m.id == nil || m.oldValue == nil {
  1591. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1592. }
  1593. oldValue, err := m.oldValue(ctx)
  1594. if err != nil {
  1595. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1596. }
  1597. return oldValue.SourceName, nil
  1598. }
  1599. // ClearSourceName clears the value of the "source_name" field.
  1600. func (m *AgentBaseMutation) ClearSourceName() {
  1601. m.source_name = nil
  1602. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1603. }
  1604. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1605. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1606. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1607. return ok
  1608. }
  1609. // ResetSourceName resets all changes to the "source_name" field.
  1610. func (m *AgentBaseMutation) ResetSourceName() {
  1611. m.source_name = nil
  1612. delete(m.clearedFields, agentbase.FieldSourceName)
  1613. }
  1614. // SetCanWrite sets the "can_write" field.
  1615. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1616. m.can_write = &b
  1617. m.appendcan_write = nil
  1618. }
  1619. // CanWrite returns the value of the "can_write" field in the mutation.
  1620. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1621. v := m.can_write
  1622. if v == nil {
  1623. return
  1624. }
  1625. return *v, true
  1626. }
  1627. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1628. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1630. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1631. if !m.op.Is(OpUpdateOne) {
  1632. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1633. }
  1634. if m.id == nil || m.oldValue == nil {
  1635. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1636. }
  1637. oldValue, err := m.oldValue(ctx)
  1638. if err != nil {
  1639. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1640. }
  1641. return oldValue.CanWrite, nil
  1642. }
  1643. // AppendCanWrite adds b to the "can_write" field.
  1644. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1645. m.appendcan_write = append(m.appendcan_write, b...)
  1646. }
  1647. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1648. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1649. if len(m.appendcan_write) == 0 {
  1650. return nil, false
  1651. }
  1652. return m.appendcan_write, true
  1653. }
  1654. // ClearCanWrite clears the value of the "can_write" field.
  1655. func (m *AgentBaseMutation) ClearCanWrite() {
  1656. m.can_write = nil
  1657. m.appendcan_write = nil
  1658. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1659. }
  1660. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1661. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1662. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1663. return ok
  1664. }
  1665. // ResetCanWrite resets all changes to the "can_write" field.
  1666. func (m *AgentBaseMutation) ResetCanWrite() {
  1667. m.can_write = nil
  1668. m.appendcan_write = nil
  1669. delete(m.clearedFields, agentbase.FieldCanWrite)
  1670. }
  1671. // SetIsOwner sets the "is_owner" field.
  1672. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1673. m.is_owner = &b
  1674. m.appendis_owner = nil
  1675. }
  1676. // IsOwner returns the value of the "is_owner" field in the mutation.
  1677. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1678. v := m.is_owner
  1679. if v == nil {
  1680. return
  1681. }
  1682. return *v, true
  1683. }
  1684. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1685. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1687. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1688. if !m.op.Is(OpUpdateOne) {
  1689. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1690. }
  1691. if m.id == nil || m.oldValue == nil {
  1692. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1693. }
  1694. oldValue, err := m.oldValue(ctx)
  1695. if err != nil {
  1696. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1697. }
  1698. return oldValue.IsOwner, nil
  1699. }
  1700. // AppendIsOwner adds b to the "is_owner" field.
  1701. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1702. m.appendis_owner = append(m.appendis_owner, b...)
  1703. }
  1704. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1705. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1706. if len(m.appendis_owner) == 0 {
  1707. return nil, false
  1708. }
  1709. return m.appendis_owner, true
  1710. }
  1711. // ClearIsOwner clears the value of the "is_owner" field.
  1712. func (m *AgentBaseMutation) ClearIsOwner() {
  1713. m.is_owner = nil
  1714. m.appendis_owner = nil
  1715. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1716. }
  1717. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1718. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1719. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1720. return ok
  1721. }
  1722. // ResetIsOwner resets all changes to the "is_owner" field.
  1723. func (m *AgentBaseMutation) ResetIsOwner() {
  1724. m.is_owner = nil
  1725. m.appendis_owner = nil
  1726. delete(m.clearedFields, agentbase.FieldIsOwner)
  1727. }
  1728. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1729. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1730. if m.wx_agent == nil {
  1731. m.wx_agent = make(map[uint64]struct{})
  1732. }
  1733. for i := range ids {
  1734. m.wx_agent[ids[i]] = struct{}{}
  1735. }
  1736. }
  1737. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1738. func (m *AgentBaseMutation) ClearWxAgent() {
  1739. m.clearedwx_agent = true
  1740. }
  1741. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1742. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1743. return m.clearedwx_agent
  1744. }
  1745. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1746. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1747. if m.removedwx_agent == nil {
  1748. m.removedwx_agent = make(map[uint64]struct{})
  1749. }
  1750. for i := range ids {
  1751. delete(m.wx_agent, ids[i])
  1752. m.removedwx_agent[ids[i]] = struct{}{}
  1753. }
  1754. }
  1755. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1756. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1757. for id := range m.removedwx_agent {
  1758. ids = append(ids, id)
  1759. }
  1760. return
  1761. }
  1762. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1763. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1764. for id := range m.wx_agent {
  1765. ids = append(ids, id)
  1766. }
  1767. return
  1768. }
  1769. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1770. func (m *AgentBaseMutation) ResetWxAgent() {
  1771. m.wx_agent = nil
  1772. m.clearedwx_agent = false
  1773. m.removedwx_agent = nil
  1774. }
  1775. // Where appends a list predicates to the AgentBaseMutation builder.
  1776. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1777. m.predicates = append(m.predicates, ps...)
  1778. }
  1779. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1780. // users can use type-assertion to append predicates that do not depend on any generated package.
  1781. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1782. p := make([]predicate.AgentBase, len(ps))
  1783. for i := range ps {
  1784. p[i] = ps[i]
  1785. }
  1786. m.Where(p...)
  1787. }
  1788. // Op returns the operation name.
  1789. func (m *AgentBaseMutation) Op() Op {
  1790. return m.op
  1791. }
  1792. // SetOp allows setting the mutation operation.
  1793. func (m *AgentBaseMutation) SetOp(op Op) {
  1794. m.op = op
  1795. }
  1796. // Type returns the node type of this mutation (AgentBase).
  1797. func (m *AgentBaseMutation) Type() string {
  1798. return m.typ
  1799. }
  1800. // Fields returns all fields that were changed during this mutation. Note that in
  1801. // order to get all numeric fields that were incremented/decremented, call
  1802. // AddedFields().
  1803. func (m *AgentBaseMutation) Fields() []string {
  1804. fields := make([]string, 0, 9)
  1805. if m.q != nil {
  1806. fields = append(fields, agentbase.FieldQ)
  1807. }
  1808. if m.a != nil {
  1809. fields = append(fields, agentbase.FieldA)
  1810. }
  1811. if m.chunk_index != nil {
  1812. fields = append(fields, agentbase.FieldChunkIndex)
  1813. }
  1814. if m.indexes != nil {
  1815. fields = append(fields, agentbase.FieldIndexes)
  1816. }
  1817. if m.dataset_id != nil {
  1818. fields = append(fields, agentbase.FieldDatasetID)
  1819. }
  1820. if m.collection_id != nil {
  1821. fields = append(fields, agentbase.FieldCollectionID)
  1822. }
  1823. if m.source_name != nil {
  1824. fields = append(fields, agentbase.FieldSourceName)
  1825. }
  1826. if m.can_write != nil {
  1827. fields = append(fields, agentbase.FieldCanWrite)
  1828. }
  1829. if m.is_owner != nil {
  1830. fields = append(fields, agentbase.FieldIsOwner)
  1831. }
  1832. return fields
  1833. }
  1834. // Field returns the value of a field with the given name. The second boolean
  1835. // return value indicates that this field was not set, or was not defined in the
  1836. // schema.
  1837. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1838. switch name {
  1839. case agentbase.FieldQ:
  1840. return m.Q()
  1841. case agentbase.FieldA:
  1842. return m.A()
  1843. case agentbase.FieldChunkIndex:
  1844. return m.ChunkIndex()
  1845. case agentbase.FieldIndexes:
  1846. return m.Indexes()
  1847. case agentbase.FieldDatasetID:
  1848. return m.DatasetID()
  1849. case agentbase.FieldCollectionID:
  1850. return m.CollectionID()
  1851. case agentbase.FieldSourceName:
  1852. return m.SourceName()
  1853. case agentbase.FieldCanWrite:
  1854. return m.CanWrite()
  1855. case agentbase.FieldIsOwner:
  1856. return m.IsOwner()
  1857. }
  1858. return nil, false
  1859. }
  1860. // OldField returns the old value of the field from the database. An error is
  1861. // returned if the mutation operation is not UpdateOne, or the query to the
  1862. // database failed.
  1863. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1864. switch name {
  1865. case agentbase.FieldQ:
  1866. return m.OldQ(ctx)
  1867. case agentbase.FieldA:
  1868. return m.OldA(ctx)
  1869. case agentbase.FieldChunkIndex:
  1870. return m.OldChunkIndex(ctx)
  1871. case agentbase.FieldIndexes:
  1872. return m.OldIndexes(ctx)
  1873. case agentbase.FieldDatasetID:
  1874. return m.OldDatasetID(ctx)
  1875. case agentbase.FieldCollectionID:
  1876. return m.OldCollectionID(ctx)
  1877. case agentbase.FieldSourceName:
  1878. return m.OldSourceName(ctx)
  1879. case agentbase.FieldCanWrite:
  1880. return m.OldCanWrite(ctx)
  1881. case agentbase.FieldIsOwner:
  1882. return m.OldIsOwner(ctx)
  1883. }
  1884. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1885. }
  1886. // SetField sets the value of a field with the given name. It returns an error if
  1887. // the field is not defined in the schema, or if the type mismatched the field
  1888. // type.
  1889. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1890. switch name {
  1891. case agentbase.FieldQ:
  1892. v, ok := value.(string)
  1893. if !ok {
  1894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1895. }
  1896. m.SetQ(v)
  1897. return nil
  1898. case agentbase.FieldA:
  1899. v, ok := value.(string)
  1900. if !ok {
  1901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1902. }
  1903. m.SetA(v)
  1904. return nil
  1905. case agentbase.FieldChunkIndex:
  1906. v, ok := value.(uint64)
  1907. if !ok {
  1908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1909. }
  1910. m.SetChunkIndex(v)
  1911. return nil
  1912. case agentbase.FieldIndexes:
  1913. v, ok := value.([]string)
  1914. if !ok {
  1915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1916. }
  1917. m.SetIndexes(v)
  1918. return nil
  1919. case agentbase.FieldDatasetID:
  1920. v, ok := value.(string)
  1921. if !ok {
  1922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1923. }
  1924. m.SetDatasetID(v)
  1925. return nil
  1926. case agentbase.FieldCollectionID:
  1927. v, ok := value.(string)
  1928. if !ok {
  1929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1930. }
  1931. m.SetCollectionID(v)
  1932. return nil
  1933. case agentbase.FieldSourceName:
  1934. v, ok := value.(string)
  1935. if !ok {
  1936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1937. }
  1938. m.SetSourceName(v)
  1939. return nil
  1940. case agentbase.FieldCanWrite:
  1941. v, ok := value.([]bool)
  1942. if !ok {
  1943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1944. }
  1945. m.SetCanWrite(v)
  1946. return nil
  1947. case agentbase.FieldIsOwner:
  1948. v, ok := value.([]bool)
  1949. if !ok {
  1950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1951. }
  1952. m.SetIsOwner(v)
  1953. return nil
  1954. }
  1955. return fmt.Errorf("unknown AgentBase field %s", name)
  1956. }
  1957. // AddedFields returns all numeric fields that were incremented/decremented during
  1958. // this mutation.
  1959. func (m *AgentBaseMutation) AddedFields() []string {
  1960. var fields []string
  1961. if m.addchunk_index != nil {
  1962. fields = append(fields, agentbase.FieldChunkIndex)
  1963. }
  1964. return fields
  1965. }
  1966. // AddedField returns the numeric value that was incremented/decremented on a field
  1967. // with the given name. The second boolean return value indicates that this field
  1968. // was not set, or was not defined in the schema.
  1969. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1970. switch name {
  1971. case agentbase.FieldChunkIndex:
  1972. return m.AddedChunkIndex()
  1973. }
  1974. return nil, false
  1975. }
  1976. // AddField adds the value to the field with the given name. It returns an error if
  1977. // the field is not defined in the schema, or if the type mismatched the field
  1978. // type.
  1979. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1980. switch name {
  1981. case agentbase.FieldChunkIndex:
  1982. v, ok := value.(int64)
  1983. if !ok {
  1984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1985. }
  1986. m.AddChunkIndex(v)
  1987. return nil
  1988. }
  1989. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  1990. }
  1991. // ClearedFields returns all nullable fields that were cleared during this
  1992. // mutation.
  1993. func (m *AgentBaseMutation) ClearedFields() []string {
  1994. var fields []string
  1995. if m.FieldCleared(agentbase.FieldQ) {
  1996. fields = append(fields, agentbase.FieldQ)
  1997. }
  1998. if m.FieldCleared(agentbase.FieldA) {
  1999. fields = append(fields, agentbase.FieldA)
  2000. }
  2001. if m.FieldCleared(agentbase.FieldIndexes) {
  2002. fields = append(fields, agentbase.FieldIndexes)
  2003. }
  2004. if m.FieldCleared(agentbase.FieldDatasetID) {
  2005. fields = append(fields, agentbase.FieldDatasetID)
  2006. }
  2007. if m.FieldCleared(agentbase.FieldCollectionID) {
  2008. fields = append(fields, agentbase.FieldCollectionID)
  2009. }
  2010. if m.FieldCleared(agentbase.FieldSourceName) {
  2011. fields = append(fields, agentbase.FieldSourceName)
  2012. }
  2013. if m.FieldCleared(agentbase.FieldCanWrite) {
  2014. fields = append(fields, agentbase.FieldCanWrite)
  2015. }
  2016. if m.FieldCleared(agentbase.FieldIsOwner) {
  2017. fields = append(fields, agentbase.FieldIsOwner)
  2018. }
  2019. return fields
  2020. }
  2021. // FieldCleared returns a boolean indicating if a field with the given name was
  2022. // cleared in this mutation.
  2023. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2024. _, ok := m.clearedFields[name]
  2025. return ok
  2026. }
  2027. // ClearField clears the value of the field with the given name. It returns an
  2028. // error if the field is not defined in the schema.
  2029. func (m *AgentBaseMutation) ClearField(name string) error {
  2030. switch name {
  2031. case agentbase.FieldQ:
  2032. m.ClearQ()
  2033. return nil
  2034. case agentbase.FieldA:
  2035. m.ClearA()
  2036. return nil
  2037. case agentbase.FieldIndexes:
  2038. m.ClearIndexes()
  2039. return nil
  2040. case agentbase.FieldDatasetID:
  2041. m.ClearDatasetID()
  2042. return nil
  2043. case agentbase.FieldCollectionID:
  2044. m.ClearCollectionID()
  2045. return nil
  2046. case agentbase.FieldSourceName:
  2047. m.ClearSourceName()
  2048. return nil
  2049. case agentbase.FieldCanWrite:
  2050. m.ClearCanWrite()
  2051. return nil
  2052. case agentbase.FieldIsOwner:
  2053. m.ClearIsOwner()
  2054. return nil
  2055. }
  2056. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2057. }
  2058. // ResetField resets all changes in the mutation for the field with the given name.
  2059. // It returns an error if the field is not defined in the schema.
  2060. func (m *AgentBaseMutation) ResetField(name string) error {
  2061. switch name {
  2062. case agentbase.FieldQ:
  2063. m.ResetQ()
  2064. return nil
  2065. case agentbase.FieldA:
  2066. m.ResetA()
  2067. return nil
  2068. case agentbase.FieldChunkIndex:
  2069. m.ResetChunkIndex()
  2070. return nil
  2071. case agentbase.FieldIndexes:
  2072. m.ResetIndexes()
  2073. return nil
  2074. case agentbase.FieldDatasetID:
  2075. m.ResetDatasetID()
  2076. return nil
  2077. case agentbase.FieldCollectionID:
  2078. m.ResetCollectionID()
  2079. return nil
  2080. case agentbase.FieldSourceName:
  2081. m.ResetSourceName()
  2082. return nil
  2083. case agentbase.FieldCanWrite:
  2084. m.ResetCanWrite()
  2085. return nil
  2086. case agentbase.FieldIsOwner:
  2087. m.ResetIsOwner()
  2088. return nil
  2089. }
  2090. return fmt.Errorf("unknown AgentBase field %s", name)
  2091. }
  2092. // AddedEdges returns all edge names that were set/added in this mutation.
  2093. func (m *AgentBaseMutation) AddedEdges() []string {
  2094. edges := make([]string, 0, 1)
  2095. if m.wx_agent != nil {
  2096. edges = append(edges, agentbase.EdgeWxAgent)
  2097. }
  2098. return edges
  2099. }
  2100. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2101. // name in this mutation.
  2102. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2103. switch name {
  2104. case agentbase.EdgeWxAgent:
  2105. ids := make([]ent.Value, 0, len(m.wx_agent))
  2106. for id := range m.wx_agent {
  2107. ids = append(ids, id)
  2108. }
  2109. return ids
  2110. }
  2111. return nil
  2112. }
  2113. // RemovedEdges returns all edge names that were removed in this mutation.
  2114. func (m *AgentBaseMutation) RemovedEdges() []string {
  2115. edges := make([]string, 0, 1)
  2116. if m.removedwx_agent != nil {
  2117. edges = append(edges, agentbase.EdgeWxAgent)
  2118. }
  2119. return edges
  2120. }
  2121. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2122. // the given name in this mutation.
  2123. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2124. switch name {
  2125. case agentbase.EdgeWxAgent:
  2126. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2127. for id := range m.removedwx_agent {
  2128. ids = append(ids, id)
  2129. }
  2130. return ids
  2131. }
  2132. return nil
  2133. }
  2134. // ClearedEdges returns all edge names that were cleared in this mutation.
  2135. func (m *AgentBaseMutation) ClearedEdges() []string {
  2136. edges := make([]string, 0, 1)
  2137. if m.clearedwx_agent {
  2138. edges = append(edges, agentbase.EdgeWxAgent)
  2139. }
  2140. return edges
  2141. }
  2142. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2143. // was cleared in this mutation.
  2144. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2145. switch name {
  2146. case agentbase.EdgeWxAgent:
  2147. return m.clearedwx_agent
  2148. }
  2149. return false
  2150. }
  2151. // ClearEdge clears the value of the edge with the given name. It returns an error
  2152. // if that edge is not defined in the schema.
  2153. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2154. switch name {
  2155. }
  2156. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2157. }
  2158. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2159. // It returns an error if the edge is not defined in the schema.
  2160. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2161. switch name {
  2162. case agentbase.EdgeWxAgent:
  2163. m.ResetWxAgent()
  2164. return nil
  2165. }
  2166. return fmt.Errorf("unknown AgentBase edge %s", name)
  2167. }
  2168. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2169. type AliyunAvatarMutation struct {
  2170. config
  2171. op Op
  2172. typ string
  2173. id *uint64
  2174. created_at *time.Time
  2175. updated_at *time.Time
  2176. deleted_at *time.Time
  2177. user_id *uint64
  2178. adduser_id *int64
  2179. biz_id *string
  2180. access_key_id *string
  2181. access_key_secret *string
  2182. app_id *string
  2183. tenant_id *uint64
  2184. addtenant_id *int64
  2185. response *string
  2186. token *string
  2187. session_id *string
  2188. clearedFields map[string]struct{}
  2189. done bool
  2190. oldValue func(context.Context) (*AliyunAvatar, error)
  2191. predicates []predicate.AliyunAvatar
  2192. }
  2193. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2194. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2195. type aliyunavatarOption func(*AliyunAvatarMutation)
  2196. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2197. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2198. m := &AliyunAvatarMutation{
  2199. config: c,
  2200. op: op,
  2201. typ: TypeAliyunAvatar,
  2202. clearedFields: make(map[string]struct{}),
  2203. }
  2204. for _, opt := range opts {
  2205. opt(m)
  2206. }
  2207. return m
  2208. }
  2209. // withAliyunAvatarID sets the ID field of the mutation.
  2210. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2211. return func(m *AliyunAvatarMutation) {
  2212. var (
  2213. err error
  2214. once sync.Once
  2215. value *AliyunAvatar
  2216. )
  2217. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2218. once.Do(func() {
  2219. if m.done {
  2220. err = errors.New("querying old values post mutation is not allowed")
  2221. } else {
  2222. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2223. }
  2224. })
  2225. return value, err
  2226. }
  2227. m.id = &id
  2228. }
  2229. }
  2230. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2231. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2232. return func(m *AliyunAvatarMutation) {
  2233. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2234. return node, nil
  2235. }
  2236. m.id = &node.ID
  2237. }
  2238. }
  2239. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2240. // executed in a transaction (ent.Tx), a transactional client is returned.
  2241. func (m AliyunAvatarMutation) Client() *Client {
  2242. client := &Client{config: m.config}
  2243. client.init()
  2244. return client
  2245. }
  2246. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2247. // it returns an error otherwise.
  2248. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2249. if _, ok := m.driver.(*txDriver); !ok {
  2250. return nil, errors.New("ent: mutation is not running in a transaction")
  2251. }
  2252. tx := &Tx{config: m.config}
  2253. tx.init()
  2254. return tx, nil
  2255. }
  2256. // SetID sets the value of the id field. Note that this
  2257. // operation is only accepted on creation of AliyunAvatar entities.
  2258. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2259. m.id = &id
  2260. }
  2261. // ID returns the ID value in the mutation. Note that the ID is only available
  2262. // if it was provided to the builder or after it was returned from the database.
  2263. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2264. if m.id == nil {
  2265. return
  2266. }
  2267. return *m.id, true
  2268. }
  2269. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2270. // That means, if the mutation is applied within a transaction with an isolation level such
  2271. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2272. // or updated by the mutation.
  2273. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2274. switch {
  2275. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2276. id, exists := m.ID()
  2277. if exists {
  2278. return []uint64{id}, nil
  2279. }
  2280. fallthrough
  2281. case m.op.Is(OpUpdate | OpDelete):
  2282. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2283. default:
  2284. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2285. }
  2286. }
  2287. // SetCreatedAt sets the "created_at" field.
  2288. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2289. m.created_at = &t
  2290. }
  2291. // CreatedAt returns the value of the "created_at" field in the mutation.
  2292. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2293. v := m.created_at
  2294. if v == nil {
  2295. return
  2296. }
  2297. return *v, true
  2298. }
  2299. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2300. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2302. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2303. if !m.op.Is(OpUpdateOne) {
  2304. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2305. }
  2306. if m.id == nil || m.oldValue == nil {
  2307. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2308. }
  2309. oldValue, err := m.oldValue(ctx)
  2310. if err != nil {
  2311. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2312. }
  2313. return oldValue.CreatedAt, nil
  2314. }
  2315. // ResetCreatedAt resets all changes to the "created_at" field.
  2316. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2317. m.created_at = nil
  2318. }
  2319. // SetUpdatedAt sets the "updated_at" field.
  2320. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2321. m.updated_at = &t
  2322. }
  2323. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2324. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2325. v := m.updated_at
  2326. if v == nil {
  2327. return
  2328. }
  2329. return *v, true
  2330. }
  2331. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2332. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2334. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2335. if !m.op.Is(OpUpdateOne) {
  2336. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2337. }
  2338. if m.id == nil || m.oldValue == nil {
  2339. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2340. }
  2341. oldValue, err := m.oldValue(ctx)
  2342. if err != nil {
  2343. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2344. }
  2345. return oldValue.UpdatedAt, nil
  2346. }
  2347. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2348. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2349. m.updated_at = nil
  2350. }
  2351. // SetDeletedAt sets the "deleted_at" field.
  2352. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2353. m.deleted_at = &t
  2354. }
  2355. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2356. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2357. v := m.deleted_at
  2358. if v == nil {
  2359. return
  2360. }
  2361. return *v, true
  2362. }
  2363. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2364. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2366. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2367. if !m.op.Is(OpUpdateOne) {
  2368. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2369. }
  2370. if m.id == nil || m.oldValue == nil {
  2371. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2372. }
  2373. oldValue, err := m.oldValue(ctx)
  2374. if err != nil {
  2375. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2376. }
  2377. return oldValue.DeletedAt, nil
  2378. }
  2379. // ClearDeletedAt clears the value of the "deleted_at" field.
  2380. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2381. m.deleted_at = nil
  2382. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2383. }
  2384. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2385. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2386. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2387. return ok
  2388. }
  2389. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2390. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2391. m.deleted_at = nil
  2392. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2393. }
  2394. // SetUserID sets the "user_id" field.
  2395. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2396. m.user_id = &u
  2397. m.adduser_id = nil
  2398. }
  2399. // UserID returns the value of the "user_id" field in the mutation.
  2400. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2401. v := m.user_id
  2402. if v == nil {
  2403. return
  2404. }
  2405. return *v, true
  2406. }
  2407. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2408. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2410. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2411. if !m.op.Is(OpUpdateOne) {
  2412. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2413. }
  2414. if m.id == nil || m.oldValue == nil {
  2415. return v, errors.New("OldUserID requires an ID field in the mutation")
  2416. }
  2417. oldValue, err := m.oldValue(ctx)
  2418. if err != nil {
  2419. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2420. }
  2421. return oldValue.UserID, nil
  2422. }
  2423. // AddUserID adds u to the "user_id" field.
  2424. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2425. if m.adduser_id != nil {
  2426. *m.adduser_id += u
  2427. } else {
  2428. m.adduser_id = &u
  2429. }
  2430. }
  2431. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2432. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2433. v := m.adduser_id
  2434. if v == nil {
  2435. return
  2436. }
  2437. return *v, true
  2438. }
  2439. // ResetUserID resets all changes to the "user_id" field.
  2440. func (m *AliyunAvatarMutation) ResetUserID() {
  2441. m.user_id = nil
  2442. m.adduser_id = nil
  2443. }
  2444. // SetBizID sets the "biz_id" field.
  2445. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2446. m.biz_id = &s
  2447. }
  2448. // BizID returns the value of the "biz_id" field in the mutation.
  2449. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2450. v := m.biz_id
  2451. if v == nil {
  2452. return
  2453. }
  2454. return *v, true
  2455. }
  2456. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2457. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2459. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2460. if !m.op.Is(OpUpdateOne) {
  2461. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2462. }
  2463. if m.id == nil || m.oldValue == nil {
  2464. return v, errors.New("OldBizID requires an ID field in the mutation")
  2465. }
  2466. oldValue, err := m.oldValue(ctx)
  2467. if err != nil {
  2468. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2469. }
  2470. return oldValue.BizID, nil
  2471. }
  2472. // ResetBizID resets all changes to the "biz_id" field.
  2473. func (m *AliyunAvatarMutation) ResetBizID() {
  2474. m.biz_id = nil
  2475. }
  2476. // SetAccessKeyID sets the "access_key_id" field.
  2477. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2478. m.access_key_id = &s
  2479. }
  2480. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2481. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2482. v := m.access_key_id
  2483. if v == nil {
  2484. return
  2485. }
  2486. return *v, true
  2487. }
  2488. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2489. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2491. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2492. if !m.op.Is(OpUpdateOne) {
  2493. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2494. }
  2495. if m.id == nil || m.oldValue == nil {
  2496. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2497. }
  2498. oldValue, err := m.oldValue(ctx)
  2499. if err != nil {
  2500. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2501. }
  2502. return oldValue.AccessKeyID, nil
  2503. }
  2504. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2505. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2506. m.access_key_id = nil
  2507. }
  2508. // SetAccessKeySecret sets the "access_key_secret" field.
  2509. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2510. m.access_key_secret = &s
  2511. }
  2512. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2513. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2514. v := m.access_key_secret
  2515. if v == nil {
  2516. return
  2517. }
  2518. return *v, true
  2519. }
  2520. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2521. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2523. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2524. if !m.op.Is(OpUpdateOne) {
  2525. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2526. }
  2527. if m.id == nil || m.oldValue == nil {
  2528. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2529. }
  2530. oldValue, err := m.oldValue(ctx)
  2531. if err != nil {
  2532. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2533. }
  2534. return oldValue.AccessKeySecret, nil
  2535. }
  2536. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2537. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2538. m.access_key_secret = nil
  2539. }
  2540. // SetAppID sets the "app_id" field.
  2541. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2542. m.app_id = &s
  2543. }
  2544. // AppID returns the value of the "app_id" field in the mutation.
  2545. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2546. v := m.app_id
  2547. if v == nil {
  2548. return
  2549. }
  2550. return *v, true
  2551. }
  2552. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2553. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2555. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2556. if !m.op.Is(OpUpdateOne) {
  2557. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2558. }
  2559. if m.id == nil || m.oldValue == nil {
  2560. return v, errors.New("OldAppID requires an ID field in the mutation")
  2561. }
  2562. oldValue, err := m.oldValue(ctx)
  2563. if err != nil {
  2564. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2565. }
  2566. return oldValue.AppID, nil
  2567. }
  2568. // ClearAppID clears the value of the "app_id" field.
  2569. func (m *AliyunAvatarMutation) ClearAppID() {
  2570. m.app_id = nil
  2571. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2572. }
  2573. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2574. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2575. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2576. return ok
  2577. }
  2578. // ResetAppID resets all changes to the "app_id" field.
  2579. func (m *AliyunAvatarMutation) ResetAppID() {
  2580. m.app_id = nil
  2581. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2582. }
  2583. // SetTenantID sets the "tenant_id" field.
  2584. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2585. m.tenant_id = &u
  2586. m.addtenant_id = nil
  2587. }
  2588. // TenantID returns the value of the "tenant_id" field in the mutation.
  2589. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2590. v := m.tenant_id
  2591. if v == nil {
  2592. return
  2593. }
  2594. return *v, true
  2595. }
  2596. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2597. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2599. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2600. if !m.op.Is(OpUpdateOne) {
  2601. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2602. }
  2603. if m.id == nil || m.oldValue == nil {
  2604. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2605. }
  2606. oldValue, err := m.oldValue(ctx)
  2607. if err != nil {
  2608. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2609. }
  2610. return oldValue.TenantID, nil
  2611. }
  2612. // AddTenantID adds u to the "tenant_id" field.
  2613. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2614. if m.addtenant_id != nil {
  2615. *m.addtenant_id += u
  2616. } else {
  2617. m.addtenant_id = &u
  2618. }
  2619. }
  2620. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2621. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2622. v := m.addtenant_id
  2623. if v == nil {
  2624. return
  2625. }
  2626. return *v, true
  2627. }
  2628. // ResetTenantID resets all changes to the "tenant_id" field.
  2629. func (m *AliyunAvatarMutation) ResetTenantID() {
  2630. m.tenant_id = nil
  2631. m.addtenant_id = nil
  2632. }
  2633. // SetResponse sets the "response" field.
  2634. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2635. m.response = &s
  2636. }
  2637. // Response returns the value of the "response" field in the mutation.
  2638. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2639. v := m.response
  2640. if v == nil {
  2641. return
  2642. }
  2643. return *v, true
  2644. }
  2645. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2646. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2648. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2649. if !m.op.Is(OpUpdateOne) {
  2650. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2651. }
  2652. if m.id == nil || m.oldValue == nil {
  2653. return v, errors.New("OldResponse requires an ID field in the mutation")
  2654. }
  2655. oldValue, err := m.oldValue(ctx)
  2656. if err != nil {
  2657. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2658. }
  2659. return oldValue.Response, nil
  2660. }
  2661. // ResetResponse resets all changes to the "response" field.
  2662. func (m *AliyunAvatarMutation) ResetResponse() {
  2663. m.response = nil
  2664. }
  2665. // SetToken sets the "token" field.
  2666. func (m *AliyunAvatarMutation) SetToken(s string) {
  2667. m.token = &s
  2668. }
  2669. // Token returns the value of the "token" field in the mutation.
  2670. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2671. v := m.token
  2672. if v == nil {
  2673. return
  2674. }
  2675. return *v, true
  2676. }
  2677. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2678. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2680. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2681. if !m.op.Is(OpUpdateOne) {
  2682. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2683. }
  2684. if m.id == nil || m.oldValue == nil {
  2685. return v, errors.New("OldToken requires an ID field in the mutation")
  2686. }
  2687. oldValue, err := m.oldValue(ctx)
  2688. if err != nil {
  2689. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2690. }
  2691. return oldValue.Token, nil
  2692. }
  2693. // ResetToken resets all changes to the "token" field.
  2694. func (m *AliyunAvatarMutation) ResetToken() {
  2695. m.token = nil
  2696. }
  2697. // SetSessionID sets the "session_id" field.
  2698. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2699. m.session_id = &s
  2700. }
  2701. // SessionID returns the value of the "session_id" field in the mutation.
  2702. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2703. v := m.session_id
  2704. if v == nil {
  2705. return
  2706. }
  2707. return *v, true
  2708. }
  2709. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2710. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2712. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2713. if !m.op.Is(OpUpdateOne) {
  2714. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2715. }
  2716. if m.id == nil || m.oldValue == nil {
  2717. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2718. }
  2719. oldValue, err := m.oldValue(ctx)
  2720. if err != nil {
  2721. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2722. }
  2723. return oldValue.SessionID, nil
  2724. }
  2725. // ResetSessionID resets all changes to the "session_id" field.
  2726. func (m *AliyunAvatarMutation) ResetSessionID() {
  2727. m.session_id = nil
  2728. }
  2729. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2730. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2731. m.predicates = append(m.predicates, ps...)
  2732. }
  2733. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2734. // users can use type-assertion to append predicates that do not depend on any generated package.
  2735. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2736. p := make([]predicate.AliyunAvatar, len(ps))
  2737. for i := range ps {
  2738. p[i] = ps[i]
  2739. }
  2740. m.Where(p...)
  2741. }
  2742. // Op returns the operation name.
  2743. func (m *AliyunAvatarMutation) Op() Op {
  2744. return m.op
  2745. }
  2746. // SetOp allows setting the mutation operation.
  2747. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2748. m.op = op
  2749. }
  2750. // Type returns the node type of this mutation (AliyunAvatar).
  2751. func (m *AliyunAvatarMutation) Type() string {
  2752. return m.typ
  2753. }
  2754. // Fields returns all fields that were changed during this mutation. Note that in
  2755. // order to get all numeric fields that were incremented/decremented, call
  2756. // AddedFields().
  2757. func (m *AliyunAvatarMutation) Fields() []string {
  2758. fields := make([]string, 0, 12)
  2759. if m.created_at != nil {
  2760. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2761. }
  2762. if m.updated_at != nil {
  2763. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2764. }
  2765. if m.deleted_at != nil {
  2766. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2767. }
  2768. if m.user_id != nil {
  2769. fields = append(fields, aliyunavatar.FieldUserID)
  2770. }
  2771. if m.biz_id != nil {
  2772. fields = append(fields, aliyunavatar.FieldBizID)
  2773. }
  2774. if m.access_key_id != nil {
  2775. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2776. }
  2777. if m.access_key_secret != nil {
  2778. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2779. }
  2780. if m.app_id != nil {
  2781. fields = append(fields, aliyunavatar.FieldAppID)
  2782. }
  2783. if m.tenant_id != nil {
  2784. fields = append(fields, aliyunavatar.FieldTenantID)
  2785. }
  2786. if m.response != nil {
  2787. fields = append(fields, aliyunavatar.FieldResponse)
  2788. }
  2789. if m.token != nil {
  2790. fields = append(fields, aliyunavatar.FieldToken)
  2791. }
  2792. if m.session_id != nil {
  2793. fields = append(fields, aliyunavatar.FieldSessionID)
  2794. }
  2795. return fields
  2796. }
  2797. // Field returns the value of a field with the given name. The second boolean
  2798. // return value indicates that this field was not set, or was not defined in the
  2799. // schema.
  2800. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2801. switch name {
  2802. case aliyunavatar.FieldCreatedAt:
  2803. return m.CreatedAt()
  2804. case aliyunavatar.FieldUpdatedAt:
  2805. return m.UpdatedAt()
  2806. case aliyunavatar.FieldDeletedAt:
  2807. return m.DeletedAt()
  2808. case aliyunavatar.FieldUserID:
  2809. return m.UserID()
  2810. case aliyunavatar.FieldBizID:
  2811. return m.BizID()
  2812. case aliyunavatar.FieldAccessKeyID:
  2813. return m.AccessKeyID()
  2814. case aliyunavatar.FieldAccessKeySecret:
  2815. return m.AccessKeySecret()
  2816. case aliyunavatar.FieldAppID:
  2817. return m.AppID()
  2818. case aliyunavatar.FieldTenantID:
  2819. return m.TenantID()
  2820. case aliyunavatar.FieldResponse:
  2821. return m.Response()
  2822. case aliyunavatar.FieldToken:
  2823. return m.Token()
  2824. case aliyunavatar.FieldSessionID:
  2825. return m.SessionID()
  2826. }
  2827. return nil, false
  2828. }
  2829. // OldField returns the old value of the field from the database. An error is
  2830. // returned if the mutation operation is not UpdateOne, or the query to the
  2831. // database failed.
  2832. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2833. switch name {
  2834. case aliyunavatar.FieldCreatedAt:
  2835. return m.OldCreatedAt(ctx)
  2836. case aliyunavatar.FieldUpdatedAt:
  2837. return m.OldUpdatedAt(ctx)
  2838. case aliyunavatar.FieldDeletedAt:
  2839. return m.OldDeletedAt(ctx)
  2840. case aliyunavatar.FieldUserID:
  2841. return m.OldUserID(ctx)
  2842. case aliyunavatar.FieldBizID:
  2843. return m.OldBizID(ctx)
  2844. case aliyunavatar.FieldAccessKeyID:
  2845. return m.OldAccessKeyID(ctx)
  2846. case aliyunavatar.FieldAccessKeySecret:
  2847. return m.OldAccessKeySecret(ctx)
  2848. case aliyunavatar.FieldAppID:
  2849. return m.OldAppID(ctx)
  2850. case aliyunavatar.FieldTenantID:
  2851. return m.OldTenantID(ctx)
  2852. case aliyunavatar.FieldResponse:
  2853. return m.OldResponse(ctx)
  2854. case aliyunavatar.FieldToken:
  2855. return m.OldToken(ctx)
  2856. case aliyunavatar.FieldSessionID:
  2857. return m.OldSessionID(ctx)
  2858. }
  2859. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2860. }
  2861. // SetField sets the value of a field with the given name. It returns an error if
  2862. // the field is not defined in the schema, or if the type mismatched the field
  2863. // type.
  2864. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2865. switch name {
  2866. case aliyunavatar.FieldCreatedAt:
  2867. v, ok := value.(time.Time)
  2868. if !ok {
  2869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2870. }
  2871. m.SetCreatedAt(v)
  2872. return nil
  2873. case aliyunavatar.FieldUpdatedAt:
  2874. v, ok := value.(time.Time)
  2875. if !ok {
  2876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2877. }
  2878. m.SetUpdatedAt(v)
  2879. return nil
  2880. case aliyunavatar.FieldDeletedAt:
  2881. v, ok := value.(time.Time)
  2882. if !ok {
  2883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2884. }
  2885. m.SetDeletedAt(v)
  2886. return nil
  2887. case aliyunavatar.FieldUserID:
  2888. v, ok := value.(uint64)
  2889. if !ok {
  2890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2891. }
  2892. m.SetUserID(v)
  2893. return nil
  2894. case aliyunavatar.FieldBizID:
  2895. v, ok := value.(string)
  2896. if !ok {
  2897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2898. }
  2899. m.SetBizID(v)
  2900. return nil
  2901. case aliyunavatar.FieldAccessKeyID:
  2902. v, ok := value.(string)
  2903. if !ok {
  2904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2905. }
  2906. m.SetAccessKeyID(v)
  2907. return nil
  2908. case aliyunavatar.FieldAccessKeySecret:
  2909. v, ok := value.(string)
  2910. if !ok {
  2911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2912. }
  2913. m.SetAccessKeySecret(v)
  2914. return nil
  2915. case aliyunavatar.FieldAppID:
  2916. v, ok := value.(string)
  2917. if !ok {
  2918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2919. }
  2920. m.SetAppID(v)
  2921. return nil
  2922. case aliyunavatar.FieldTenantID:
  2923. v, ok := value.(uint64)
  2924. if !ok {
  2925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2926. }
  2927. m.SetTenantID(v)
  2928. return nil
  2929. case aliyunavatar.FieldResponse:
  2930. v, ok := value.(string)
  2931. if !ok {
  2932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2933. }
  2934. m.SetResponse(v)
  2935. return nil
  2936. case aliyunavatar.FieldToken:
  2937. v, ok := value.(string)
  2938. if !ok {
  2939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2940. }
  2941. m.SetToken(v)
  2942. return nil
  2943. case aliyunavatar.FieldSessionID:
  2944. v, ok := value.(string)
  2945. if !ok {
  2946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2947. }
  2948. m.SetSessionID(v)
  2949. return nil
  2950. }
  2951. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2952. }
  2953. // AddedFields returns all numeric fields that were incremented/decremented during
  2954. // this mutation.
  2955. func (m *AliyunAvatarMutation) AddedFields() []string {
  2956. var fields []string
  2957. if m.adduser_id != nil {
  2958. fields = append(fields, aliyunavatar.FieldUserID)
  2959. }
  2960. if m.addtenant_id != nil {
  2961. fields = append(fields, aliyunavatar.FieldTenantID)
  2962. }
  2963. return fields
  2964. }
  2965. // AddedField returns the numeric value that was incremented/decremented on a field
  2966. // with the given name. The second boolean return value indicates that this field
  2967. // was not set, or was not defined in the schema.
  2968. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2969. switch name {
  2970. case aliyunavatar.FieldUserID:
  2971. return m.AddedUserID()
  2972. case aliyunavatar.FieldTenantID:
  2973. return m.AddedTenantID()
  2974. }
  2975. return nil, false
  2976. }
  2977. // AddField adds the value to the field with the given name. It returns an error if
  2978. // the field is not defined in the schema, or if the type mismatched the field
  2979. // type.
  2980. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  2981. switch name {
  2982. case aliyunavatar.FieldUserID:
  2983. v, ok := value.(int64)
  2984. if !ok {
  2985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2986. }
  2987. m.AddUserID(v)
  2988. return nil
  2989. case aliyunavatar.FieldTenantID:
  2990. v, ok := value.(int64)
  2991. if !ok {
  2992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2993. }
  2994. m.AddTenantID(v)
  2995. return nil
  2996. }
  2997. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  2998. }
  2999. // ClearedFields returns all nullable fields that were cleared during this
  3000. // mutation.
  3001. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3002. var fields []string
  3003. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3004. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3005. }
  3006. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3007. fields = append(fields, aliyunavatar.FieldAppID)
  3008. }
  3009. return fields
  3010. }
  3011. // FieldCleared returns a boolean indicating if a field with the given name was
  3012. // cleared in this mutation.
  3013. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3014. _, ok := m.clearedFields[name]
  3015. return ok
  3016. }
  3017. // ClearField clears the value of the field with the given name. It returns an
  3018. // error if the field is not defined in the schema.
  3019. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3020. switch name {
  3021. case aliyunavatar.FieldDeletedAt:
  3022. m.ClearDeletedAt()
  3023. return nil
  3024. case aliyunavatar.FieldAppID:
  3025. m.ClearAppID()
  3026. return nil
  3027. }
  3028. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3029. }
  3030. // ResetField resets all changes in the mutation for the field with the given name.
  3031. // It returns an error if the field is not defined in the schema.
  3032. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3033. switch name {
  3034. case aliyunavatar.FieldCreatedAt:
  3035. m.ResetCreatedAt()
  3036. return nil
  3037. case aliyunavatar.FieldUpdatedAt:
  3038. m.ResetUpdatedAt()
  3039. return nil
  3040. case aliyunavatar.FieldDeletedAt:
  3041. m.ResetDeletedAt()
  3042. return nil
  3043. case aliyunavatar.FieldUserID:
  3044. m.ResetUserID()
  3045. return nil
  3046. case aliyunavatar.FieldBizID:
  3047. m.ResetBizID()
  3048. return nil
  3049. case aliyunavatar.FieldAccessKeyID:
  3050. m.ResetAccessKeyID()
  3051. return nil
  3052. case aliyunavatar.FieldAccessKeySecret:
  3053. m.ResetAccessKeySecret()
  3054. return nil
  3055. case aliyunavatar.FieldAppID:
  3056. m.ResetAppID()
  3057. return nil
  3058. case aliyunavatar.FieldTenantID:
  3059. m.ResetTenantID()
  3060. return nil
  3061. case aliyunavatar.FieldResponse:
  3062. m.ResetResponse()
  3063. return nil
  3064. case aliyunavatar.FieldToken:
  3065. m.ResetToken()
  3066. return nil
  3067. case aliyunavatar.FieldSessionID:
  3068. m.ResetSessionID()
  3069. return nil
  3070. }
  3071. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3072. }
  3073. // AddedEdges returns all edge names that were set/added in this mutation.
  3074. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3075. edges := make([]string, 0, 0)
  3076. return edges
  3077. }
  3078. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3079. // name in this mutation.
  3080. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3081. return nil
  3082. }
  3083. // RemovedEdges returns all edge names that were removed in this mutation.
  3084. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3085. edges := make([]string, 0, 0)
  3086. return edges
  3087. }
  3088. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3089. // the given name in this mutation.
  3090. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3091. return nil
  3092. }
  3093. // ClearedEdges returns all edge names that were cleared in this mutation.
  3094. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3095. edges := make([]string, 0, 0)
  3096. return edges
  3097. }
  3098. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3099. // was cleared in this mutation.
  3100. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3101. return false
  3102. }
  3103. // ClearEdge clears the value of the edge with the given name. It returns an error
  3104. // if that edge is not defined in the schema.
  3105. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3106. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3107. }
  3108. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3109. // It returns an error if the edge is not defined in the schema.
  3110. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3111. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3112. }
  3113. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3114. type BatchMsgMutation struct {
  3115. config
  3116. op Op
  3117. typ string
  3118. id *uint64
  3119. created_at *time.Time
  3120. updated_at *time.Time
  3121. deleted_at *time.Time
  3122. status *uint8
  3123. addstatus *int8
  3124. batch_no *string
  3125. task_name *string
  3126. fromwxid *string
  3127. msg *string
  3128. tag *string
  3129. tagids *string
  3130. total *int32
  3131. addtotal *int32
  3132. success *int32
  3133. addsuccess *int32
  3134. fail *int32
  3135. addfail *int32
  3136. start_time *time.Time
  3137. stop_time *time.Time
  3138. send_time *time.Time
  3139. _type *int32
  3140. add_type *int32
  3141. organization_id *uint64
  3142. addorganization_id *int64
  3143. clearedFields map[string]struct{}
  3144. done bool
  3145. oldValue func(context.Context) (*BatchMsg, error)
  3146. predicates []predicate.BatchMsg
  3147. }
  3148. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3149. // batchmsgOption allows management of the mutation configuration using functional options.
  3150. type batchmsgOption func(*BatchMsgMutation)
  3151. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3152. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3153. m := &BatchMsgMutation{
  3154. config: c,
  3155. op: op,
  3156. typ: TypeBatchMsg,
  3157. clearedFields: make(map[string]struct{}),
  3158. }
  3159. for _, opt := range opts {
  3160. opt(m)
  3161. }
  3162. return m
  3163. }
  3164. // withBatchMsgID sets the ID field of the mutation.
  3165. func withBatchMsgID(id uint64) batchmsgOption {
  3166. return func(m *BatchMsgMutation) {
  3167. var (
  3168. err error
  3169. once sync.Once
  3170. value *BatchMsg
  3171. )
  3172. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3173. once.Do(func() {
  3174. if m.done {
  3175. err = errors.New("querying old values post mutation is not allowed")
  3176. } else {
  3177. value, err = m.Client().BatchMsg.Get(ctx, id)
  3178. }
  3179. })
  3180. return value, err
  3181. }
  3182. m.id = &id
  3183. }
  3184. }
  3185. // withBatchMsg sets the old BatchMsg of the mutation.
  3186. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3187. return func(m *BatchMsgMutation) {
  3188. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3189. return node, nil
  3190. }
  3191. m.id = &node.ID
  3192. }
  3193. }
  3194. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3195. // executed in a transaction (ent.Tx), a transactional client is returned.
  3196. func (m BatchMsgMutation) Client() *Client {
  3197. client := &Client{config: m.config}
  3198. client.init()
  3199. return client
  3200. }
  3201. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3202. // it returns an error otherwise.
  3203. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3204. if _, ok := m.driver.(*txDriver); !ok {
  3205. return nil, errors.New("ent: mutation is not running in a transaction")
  3206. }
  3207. tx := &Tx{config: m.config}
  3208. tx.init()
  3209. return tx, nil
  3210. }
  3211. // SetID sets the value of the id field. Note that this
  3212. // operation is only accepted on creation of BatchMsg entities.
  3213. func (m *BatchMsgMutation) SetID(id uint64) {
  3214. m.id = &id
  3215. }
  3216. // ID returns the ID value in the mutation. Note that the ID is only available
  3217. // if it was provided to the builder or after it was returned from the database.
  3218. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3219. if m.id == nil {
  3220. return
  3221. }
  3222. return *m.id, true
  3223. }
  3224. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3225. // That means, if the mutation is applied within a transaction with an isolation level such
  3226. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3227. // or updated by the mutation.
  3228. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3229. switch {
  3230. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3231. id, exists := m.ID()
  3232. if exists {
  3233. return []uint64{id}, nil
  3234. }
  3235. fallthrough
  3236. case m.op.Is(OpUpdate | OpDelete):
  3237. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  3238. default:
  3239. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3240. }
  3241. }
  3242. // SetCreatedAt sets the "created_at" field.
  3243. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  3244. m.created_at = &t
  3245. }
  3246. // CreatedAt returns the value of the "created_at" field in the mutation.
  3247. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  3248. v := m.created_at
  3249. if v == nil {
  3250. return
  3251. }
  3252. return *v, true
  3253. }
  3254. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  3255. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3257. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3258. if !m.op.Is(OpUpdateOne) {
  3259. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3260. }
  3261. if m.id == nil || m.oldValue == nil {
  3262. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3263. }
  3264. oldValue, err := m.oldValue(ctx)
  3265. if err != nil {
  3266. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3267. }
  3268. return oldValue.CreatedAt, nil
  3269. }
  3270. // ResetCreatedAt resets all changes to the "created_at" field.
  3271. func (m *BatchMsgMutation) ResetCreatedAt() {
  3272. m.created_at = nil
  3273. }
  3274. // SetUpdatedAt sets the "updated_at" field.
  3275. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  3276. m.updated_at = &t
  3277. }
  3278. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3279. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  3280. v := m.updated_at
  3281. if v == nil {
  3282. return
  3283. }
  3284. return *v, true
  3285. }
  3286. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  3287. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3289. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3290. if !m.op.Is(OpUpdateOne) {
  3291. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3292. }
  3293. if m.id == nil || m.oldValue == nil {
  3294. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3295. }
  3296. oldValue, err := m.oldValue(ctx)
  3297. if err != nil {
  3298. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3299. }
  3300. return oldValue.UpdatedAt, nil
  3301. }
  3302. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3303. func (m *BatchMsgMutation) ResetUpdatedAt() {
  3304. m.updated_at = nil
  3305. }
  3306. // SetDeletedAt sets the "deleted_at" field.
  3307. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  3308. m.deleted_at = &t
  3309. }
  3310. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3311. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  3312. v := m.deleted_at
  3313. if v == nil {
  3314. return
  3315. }
  3316. return *v, true
  3317. }
  3318. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  3319. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3321. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3322. if !m.op.Is(OpUpdateOne) {
  3323. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3324. }
  3325. if m.id == nil || m.oldValue == nil {
  3326. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3327. }
  3328. oldValue, err := m.oldValue(ctx)
  3329. if err != nil {
  3330. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3331. }
  3332. return oldValue.DeletedAt, nil
  3333. }
  3334. // ClearDeletedAt clears the value of the "deleted_at" field.
  3335. func (m *BatchMsgMutation) ClearDeletedAt() {
  3336. m.deleted_at = nil
  3337. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  3338. }
  3339. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3340. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  3341. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  3342. return ok
  3343. }
  3344. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3345. func (m *BatchMsgMutation) ResetDeletedAt() {
  3346. m.deleted_at = nil
  3347. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  3348. }
  3349. // SetStatus sets the "status" field.
  3350. func (m *BatchMsgMutation) SetStatus(u uint8) {
  3351. m.status = &u
  3352. m.addstatus = nil
  3353. }
  3354. // Status returns the value of the "status" field in the mutation.
  3355. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  3356. v := m.status
  3357. if v == nil {
  3358. return
  3359. }
  3360. return *v, true
  3361. }
  3362. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  3363. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3365. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3366. if !m.op.Is(OpUpdateOne) {
  3367. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3368. }
  3369. if m.id == nil || m.oldValue == nil {
  3370. return v, errors.New("OldStatus requires an ID field in the mutation")
  3371. }
  3372. oldValue, err := m.oldValue(ctx)
  3373. if err != nil {
  3374. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3375. }
  3376. return oldValue.Status, nil
  3377. }
  3378. // AddStatus adds u to the "status" field.
  3379. func (m *BatchMsgMutation) AddStatus(u int8) {
  3380. if m.addstatus != nil {
  3381. *m.addstatus += u
  3382. } else {
  3383. m.addstatus = &u
  3384. }
  3385. }
  3386. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3387. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  3388. v := m.addstatus
  3389. if v == nil {
  3390. return
  3391. }
  3392. return *v, true
  3393. }
  3394. // ClearStatus clears the value of the "status" field.
  3395. func (m *BatchMsgMutation) ClearStatus() {
  3396. m.status = nil
  3397. m.addstatus = nil
  3398. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  3399. }
  3400. // StatusCleared returns if the "status" field was cleared in this mutation.
  3401. func (m *BatchMsgMutation) StatusCleared() bool {
  3402. _, ok := m.clearedFields[batchmsg.FieldStatus]
  3403. return ok
  3404. }
  3405. // ResetStatus resets all changes to the "status" field.
  3406. func (m *BatchMsgMutation) ResetStatus() {
  3407. m.status = nil
  3408. m.addstatus = nil
  3409. delete(m.clearedFields, batchmsg.FieldStatus)
  3410. }
  3411. // SetBatchNo sets the "batch_no" field.
  3412. func (m *BatchMsgMutation) SetBatchNo(s string) {
  3413. m.batch_no = &s
  3414. }
  3415. // BatchNo returns the value of the "batch_no" field in the mutation.
  3416. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  3417. v := m.batch_no
  3418. if v == nil {
  3419. return
  3420. }
  3421. return *v, true
  3422. }
  3423. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  3424. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3426. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  3427. if !m.op.Is(OpUpdateOne) {
  3428. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  3429. }
  3430. if m.id == nil || m.oldValue == nil {
  3431. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  3432. }
  3433. oldValue, err := m.oldValue(ctx)
  3434. if err != nil {
  3435. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  3436. }
  3437. return oldValue.BatchNo, nil
  3438. }
  3439. // ClearBatchNo clears the value of the "batch_no" field.
  3440. func (m *BatchMsgMutation) ClearBatchNo() {
  3441. m.batch_no = nil
  3442. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  3443. }
  3444. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  3445. func (m *BatchMsgMutation) BatchNoCleared() bool {
  3446. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  3447. return ok
  3448. }
  3449. // ResetBatchNo resets all changes to the "batch_no" field.
  3450. func (m *BatchMsgMutation) ResetBatchNo() {
  3451. m.batch_no = nil
  3452. delete(m.clearedFields, batchmsg.FieldBatchNo)
  3453. }
  3454. // SetTaskName sets the "task_name" field.
  3455. func (m *BatchMsgMutation) SetTaskName(s string) {
  3456. m.task_name = &s
  3457. }
  3458. // TaskName returns the value of the "task_name" field in the mutation.
  3459. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  3460. v := m.task_name
  3461. if v == nil {
  3462. return
  3463. }
  3464. return *v, true
  3465. }
  3466. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  3467. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3469. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  3470. if !m.op.Is(OpUpdateOne) {
  3471. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  3472. }
  3473. if m.id == nil || m.oldValue == nil {
  3474. return v, errors.New("OldTaskName requires an ID field in the mutation")
  3475. }
  3476. oldValue, err := m.oldValue(ctx)
  3477. if err != nil {
  3478. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  3479. }
  3480. return oldValue.TaskName, nil
  3481. }
  3482. // ClearTaskName clears the value of the "task_name" field.
  3483. func (m *BatchMsgMutation) ClearTaskName() {
  3484. m.task_name = nil
  3485. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  3486. }
  3487. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  3488. func (m *BatchMsgMutation) TaskNameCleared() bool {
  3489. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  3490. return ok
  3491. }
  3492. // ResetTaskName resets all changes to the "task_name" field.
  3493. func (m *BatchMsgMutation) ResetTaskName() {
  3494. m.task_name = nil
  3495. delete(m.clearedFields, batchmsg.FieldTaskName)
  3496. }
  3497. // SetFromwxid sets the "fromwxid" field.
  3498. func (m *BatchMsgMutation) SetFromwxid(s string) {
  3499. m.fromwxid = &s
  3500. }
  3501. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  3502. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  3503. v := m.fromwxid
  3504. if v == nil {
  3505. return
  3506. }
  3507. return *v, true
  3508. }
  3509. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  3510. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3512. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  3513. if !m.op.Is(OpUpdateOne) {
  3514. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  3515. }
  3516. if m.id == nil || m.oldValue == nil {
  3517. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  3518. }
  3519. oldValue, err := m.oldValue(ctx)
  3520. if err != nil {
  3521. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  3522. }
  3523. return oldValue.Fromwxid, nil
  3524. }
  3525. // ClearFromwxid clears the value of the "fromwxid" field.
  3526. func (m *BatchMsgMutation) ClearFromwxid() {
  3527. m.fromwxid = nil
  3528. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  3529. }
  3530. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  3531. func (m *BatchMsgMutation) FromwxidCleared() bool {
  3532. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  3533. return ok
  3534. }
  3535. // ResetFromwxid resets all changes to the "fromwxid" field.
  3536. func (m *BatchMsgMutation) ResetFromwxid() {
  3537. m.fromwxid = nil
  3538. delete(m.clearedFields, batchmsg.FieldFromwxid)
  3539. }
  3540. // SetMsg sets the "msg" field.
  3541. func (m *BatchMsgMutation) SetMsg(s string) {
  3542. m.msg = &s
  3543. }
  3544. // Msg returns the value of the "msg" field in the mutation.
  3545. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  3546. v := m.msg
  3547. if v == nil {
  3548. return
  3549. }
  3550. return *v, true
  3551. }
  3552. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  3553. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3555. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  3556. if !m.op.Is(OpUpdateOne) {
  3557. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  3558. }
  3559. if m.id == nil || m.oldValue == nil {
  3560. return v, errors.New("OldMsg requires an ID field in the mutation")
  3561. }
  3562. oldValue, err := m.oldValue(ctx)
  3563. if err != nil {
  3564. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  3565. }
  3566. return oldValue.Msg, nil
  3567. }
  3568. // ClearMsg clears the value of the "msg" field.
  3569. func (m *BatchMsgMutation) ClearMsg() {
  3570. m.msg = nil
  3571. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  3572. }
  3573. // MsgCleared returns if the "msg" field was cleared in this mutation.
  3574. func (m *BatchMsgMutation) MsgCleared() bool {
  3575. _, ok := m.clearedFields[batchmsg.FieldMsg]
  3576. return ok
  3577. }
  3578. // ResetMsg resets all changes to the "msg" field.
  3579. func (m *BatchMsgMutation) ResetMsg() {
  3580. m.msg = nil
  3581. delete(m.clearedFields, batchmsg.FieldMsg)
  3582. }
  3583. // SetTag sets the "tag" field.
  3584. func (m *BatchMsgMutation) SetTag(s string) {
  3585. m.tag = &s
  3586. }
  3587. // Tag returns the value of the "tag" field in the mutation.
  3588. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  3589. v := m.tag
  3590. if v == nil {
  3591. return
  3592. }
  3593. return *v, true
  3594. }
  3595. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  3596. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3598. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  3599. if !m.op.Is(OpUpdateOne) {
  3600. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  3601. }
  3602. if m.id == nil || m.oldValue == nil {
  3603. return v, errors.New("OldTag requires an ID field in the mutation")
  3604. }
  3605. oldValue, err := m.oldValue(ctx)
  3606. if err != nil {
  3607. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  3608. }
  3609. return oldValue.Tag, nil
  3610. }
  3611. // ClearTag clears the value of the "tag" field.
  3612. func (m *BatchMsgMutation) ClearTag() {
  3613. m.tag = nil
  3614. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  3615. }
  3616. // TagCleared returns if the "tag" field was cleared in this mutation.
  3617. func (m *BatchMsgMutation) TagCleared() bool {
  3618. _, ok := m.clearedFields[batchmsg.FieldTag]
  3619. return ok
  3620. }
  3621. // ResetTag resets all changes to the "tag" field.
  3622. func (m *BatchMsgMutation) ResetTag() {
  3623. m.tag = nil
  3624. delete(m.clearedFields, batchmsg.FieldTag)
  3625. }
  3626. // SetTagids sets the "tagids" field.
  3627. func (m *BatchMsgMutation) SetTagids(s string) {
  3628. m.tagids = &s
  3629. }
  3630. // Tagids returns the value of the "tagids" field in the mutation.
  3631. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  3632. v := m.tagids
  3633. if v == nil {
  3634. return
  3635. }
  3636. return *v, true
  3637. }
  3638. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  3639. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3641. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  3642. if !m.op.Is(OpUpdateOne) {
  3643. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  3644. }
  3645. if m.id == nil || m.oldValue == nil {
  3646. return v, errors.New("OldTagids requires an ID field in the mutation")
  3647. }
  3648. oldValue, err := m.oldValue(ctx)
  3649. if err != nil {
  3650. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  3651. }
  3652. return oldValue.Tagids, nil
  3653. }
  3654. // ClearTagids clears the value of the "tagids" field.
  3655. func (m *BatchMsgMutation) ClearTagids() {
  3656. m.tagids = nil
  3657. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  3658. }
  3659. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  3660. func (m *BatchMsgMutation) TagidsCleared() bool {
  3661. _, ok := m.clearedFields[batchmsg.FieldTagids]
  3662. return ok
  3663. }
  3664. // ResetTagids resets all changes to the "tagids" field.
  3665. func (m *BatchMsgMutation) ResetTagids() {
  3666. m.tagids = nil
  3667. delete(m.clearedFields, batchmsg.FieldTagids)
  3668. }
  3669. // SetTotal sets the "total" field.
  3670. func (m *BatchMsgMutation) SetTotal(i int32) {
  3671. m.total = &i
  3672. m.addtotal = nil
  3673. }
  3674. // Total returns the value of the "total" field in the mutation.
  3675. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  3676. v := m.total
  3677. if v == nil {
  3678. return
  3679. }
  3680. return *v, true
  3681. }
  3682. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  3683. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3685. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  3686. if !m.op.Is(OpUpdateOne) {
  3687. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  3688. }
  3689. if m.id == nil || m.oldValue == nil {
  3690. return v, errors.New("OldTotal requires an ID field in the mutation")
  3691. }
  3692. oldValue, err := m.oldValue(ctx)
  3693. if err != nil {
  3694. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  3695. }
  3696. return oldValue.Total, nil
  3697. }
  3698. // AddTotal adds i to the "total" field.
  3699. func (m *BatchMsgMutation) AddTotal(i int32) {
  3700. if m.addtotal != nil {
  3701. *m.addtotal += i
  3702. } else {
  3703. m.addtotal = &i
  3704. }
  3705. }
  3706. // AddedTotal returns the value that was added to the "total" field in this mutation.
  3707. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  3708. v := m.addtotal
  3709. if v == nil {
  3710. return
  3711. }
  3712. return *v, true
  3713. }
  3714. // ClearTotal clears the value of the "total" field.
  3715. func (m *BatchMsgMutation) ClearTotal() {
  3716. m.total = nil
  3717. m.addtotal = nil
  3718. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  3719. }
  3720. // TotalCleared returns if the "total" field was cleared in this mutation.
  3721. func (m *BatchMsgMutation) TotalCleared() bool {
  3722. _, ok := m.clearedFields[batchmsg.FieldTotal]
  3723. return ok
  3724. }
  3725. // ResetTotal resets all changes to the "total" field.
  3726. func (m *BatchMsgMutation) ResetTotal() {
  3727. m.total = nil
  3728. m.addtotal = nil
  3729. delete(m.clearedFields, batchmsg.FieldTotal)
  3730. }
  3731. // SetSuccess sets the "success" field.
  3732. func (m *BatchMsgMutation) SetSuccess(i int32) {
  3733. m.success = &i
  3734. m.addsuccess = nil
  3735. }
  3736. // Success returns the value of the "success" field in the mutation.
  3737. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  3738. v := m.success
  3739. if v == nil {
  3740. return
  3741. }
  3742. return *v, true
  3743. }
  3744. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  3745. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3747. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  3748. if !m.op.Is(OpUpdateOne) {
  3749. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  3750. }
  3751. if m.id == nil || m.oldValue == nil {
  3752. return v, errors.New("OldSuccess requires an ID field in the mutation")
  3753. }
  3754. oldValue, err := m.oldValue(ctx)
  3755. if err != nil {
  3756. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  3757. }
  3758. return oldValue.Success, nil
  3759. }
  3760. // AddSuccess adds i to the "success" field.
  3761. func (m *BatchMsgMutation) AddSuccess(i int32) {
  3762. if m.addsuccess != nil {
  3763. *m.addsuccess += i
  3764. } else {
  3765. m.addsuccess = &i
  3766. }
  3767. }
  3768. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  3769. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  3770. v := m.addsuccess
  3771. if v == nil {
  3772. return
  3773. }
  3774. return *v, true
  3775. }
  3776. // ClearSuccess clears the value of the "success" field.
  3777. func (m *BatchMsgMutation) ClearSuccess() {
  3778. m.success = nil
  3779. m.addsuccess = nil
  3780. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  3781. }
  3782. // SuccessCleared returns if the "success" field was cleared in this mutation.
  3783. func (m *BatchMsgMutation) SuccessCleared() bool {
  3784. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  3785. return ok
  3786. }
  3787. // ResetSuccess resets all changes to the "success" field.
  3788. func (m *BatchMsgMutation) ResetSuccess() {
  3789. m.success = nil
  3790. m.addsuccess = nil
  3791. delete(m.clearedFields, batchmsg.FieldSuccess)
  3792. }
  3793. // SetFail sets the "fail" field.
  3794. func (m *BatchMsgMutation) SetFail(i int32) {
  3795. m.fail = &i
  3796. m.addfail = nil
  3797. }
  3798. // Fail returns the value of the "fail" field in the mutation.
  3799. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  3800. v := m.fail
  3801. if v == nil {
  3802. return
  3803. }
  3804. return *v, true
  3805. }
  3806. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  3807. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3809. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  3810. if !m.op.Is(OpUpdateOne) {
  3811. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  3812. }
  3813. if m.id == nil || m.oldValue == nil {
  3814. return v, errors.New("OldFail requires an ID field in the mutation")
  3815. }
  3816. oldValue, err := m.oldValue(ctx)
  3817. if err != nil {
  3818. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  3819. }
  3820. return oldValue.Fail, nil
  3821. }
  3822. // AddFail adds i to the "fail" field.
  3823. func (m *BatchMsgMutation) AddFail(i int32) {
  3824. if m.addfail != nil {
  3825. *m.addfail += i
  3826. } else {
  3827. m.addfail = &i
  3828. }
  3829. }
  3830. // AddedFail returns the value that was added to the "fail" field in this mutation.
  3831. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  3832. v := m.addfail
  3833. if v == nil {
  3834. return
  3835. }
  3836. return *v, true
  3837. }
  3838. // ClearFail clears the value of the "fail" field.
  3839. func (m *BatchMsgMutation) ClearFail() {
  3840. m.fail = nil
  3841. m.addfail = nil
  3842. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  3843. }
  3844. // FailCleared returns if the "fail" field was cleared in this mutation.
  3845. func (m *BatchMsgMutation) FailCleared() bool {
  3846. _, ok := m.clearedFields[batchmsg.FieldFail]
  3847. return ok
  3848. }
  3849. // ResetFail resets all changes to the "fail" field.
  3850. func (m *BatchMsgMutation) ResetFail() {
  3851. m.fail = nil
  3852. m.addfail = nil
  3853. delete(m.clearedFields, batchmsg.FieldFail)
  3854. }
  3855. // SetStartTime sets the "start_time" field.
  3856. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  3857. m.start_time = &t
  3858. }
  3859. // StartTime returns the value of the "start_time" field in the mutation.
  3860. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  3861. v := m.start_time
  3862. if v == nil {
  3863. return
  3864. }
  3865. return *v, true
  3866. }
  3867. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  3868. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3870. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  3871. if !m.op.Is(OpUpdateOne) {
  3872. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  3873. }
  3874. if m.id == nil || m.oldValue == nil {
  3875. return v, errors.New("OldStartTime requires an ID field in the mutation")
  3876. }
  3877. oldValue, err := m.oldValue(ctx)
  3878. if err != nil {
  3879. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  3880. }
  3881. return oldValue.StartTime, nil
  3882. }
  3883. // ClearStartTime clears the value of the "start_time" field.
  3884. func (m *BatchMsgMutation) ClearStartTime() {
  3885. m.start_time = nil
  3886. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  3887. }
  3888. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  3889. func (m *BatchMsgMutation) StartTimeCleared() bool {
  3890. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  3891. return ok
  3892. }
  3893. // ResetStartTime resets all changes to the "start_time" field.
  3894. func (m *BatchMsgMutation) ResetStartTime() {
  3895. m.start_time = nil
  3896. delete(m.clearedFields, batchmsg.FieldStartTime)
  3897. }
  3898. // SetStopTime sets the "stop_time" field.
  3899. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  3900. m.stop_time = &t
  3901. }
  3902. // StopTime returns the value of the "stop_time" field in the mutation.
  3903. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  3904. v := m.stop_time
  3905. if v == nil {
  3906. return
  3907. }
  3908. return *v, true
  3909. }
  3910. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  3911. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3913. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  3914. if !m.op.Is(OpUpdateOne) {
  3915. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  3916. }
  3917. if m.id == nil || m.oldValue == nil {
  3918. return v, errors.New("OldStopTime requires an ID field in the mutation")
  3919. }
  3920. oldValue, err := m.oldValue(ctx)
  3921. if err != nil {
  3922. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  3923. }
  3924. return oldValue.StopTime, nil
  3925. }
  3926. // ClearStopTime clears the value of the "stop_time" field.
  3927. func (m *BatchMsgMutation) ClearStopTime() {
  3928. m.stop_time = nil
  3929. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  3930. }
  3931. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  3932. func (m *BatchMsgMutation) StopTimeCleared() bool {
  3933. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  3934. return ok
  3935. }
  3936. // ResetStopTime resets all changes to the "stop_time" field.
  3937. func (m *BatchMsgMutation) ResetStopTime() {
  3938. m.stop_time = nil
  3939. delete(m.clearedFields, batchmsg.FieldStopTime)
  3940. }
  3941. // SetSendTime sets the "send_time" field.
  3942. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  3943. m.send_time = &t
  3944. }
  3945. // SendTime returns the value of the "send_time" field in the mutation.
  3946. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  3947. v := m.send_time
  3948. if v == nil {
  3949. return
  3950. }
  3951. return *v, true
  3952. }
  3953. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  3954. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3956. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  3957. if !m.op.Is(OpUpdateOne) {
  3958. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  3959. }
  3960. if m.id == nil || m.oldValue == nil {
  3961. return v, errors.New("OldSendTime requires an ID field in the mutation")
  3962. }
  3963. oldValue, err := m.oldValue(ctx)
  3964. if err != nil {
  3965. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  3966. }
  3967. return oldValue.SendTime, nil
  3968. }
  3969. // ClearSendTime clears the value of the "send_time" field.
  3970. func (m *BatchMsgMutation) ClearSendTime() {
  3971. m.send_time = nil
  3972. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  3973. }
  3974. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  3975. func (m *BatchMsgMutation) SendTimeCleared() bool {
  3976. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  3977. return ok
  3978. }
  3979. // ResetSendTime resets all changes to the "send_time" field.
  3980. func (m *BatchMsgMutation) ResetSendTime() {
  3981. m.send_time = nil
  3982. delete(m.clearedFields, batchmsg.FieldSendTime)
  3983. }
  3984. // SetType sets the "type" field.
  3985. func (m *BatchMsgMutation) SetType(i int32) {
  3986. m._type = &i
  3987. m.add_type = nil
  3988. }
  3989. // GetType returns the value of the "type" field in the mutation.
  3990. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  3991. v := m._type
  3992. if v == nil {
  3993. return
  3994. }
  3995. return *v, true
  3996. }
  3997. // OldType returns the old "type" field's value of the BatchMsg entity.
  3998. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4000. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4001. if !m.op.Is(OpUpdateOne) {
  4002. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4003. }
  4004. if m.id == nil || m.oldValue == nil {
  4005. return v, errors.New("OldType requires an ID field in the mutation")
  4006. }
  4007. oldValue, err := m.oldValue(ctx)
  4008. if err != nil {
  4009. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4010. }
  4011. return oldValue.Type, nil
  4012. }
  4013. // AddType adds i to the "type" field.
  4014. func (m *BatchMsgMutation) AddType(i int32) {
  4015. if m.add_type != nil {
  4016. *m.add_type += i
  4017. } else {
  4018. m.add_type = &i
  4019. }
  4020. }
  4021. // AddedType returns the value that was added to the "type" field in this mutation.
  4022. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4023. v := m.add_type
  4024. if v == nil {
  4025. return
  4026. }
  4027. return *v, true
  4028. }
  4029. // ClearType clears the value of the "type" field.
  4030. func (m *BatchMsgMutation) ClearType() {
  4031. m._type = nil
  4032. m.add_type = nil
  4033. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4034. }
  4035. // TypeCleared returns if the "type" field was cleared in this mutation.
  4036. func (m *BatchMsgMutation) TypeCleared() bool {
  4037. _, ok := m.clearedFields[batchmsg.FieldType]
  4038. return ok
  4039. }
  4040. // ResetType resets all changes to the "type" field.
  4041. func (m *BatchMsgMutation) ResetType() {
  4042. m._type = nil
  4043. m.add_type = nil
  4044. delete(m.clearedFields, batchmsg.FieldType)
  4045. }
  4046. // SetOrganizationID sets the "organization_id" field.
  4047. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4048. m.organization_id = &u
  4049. m.addorganization_id = nil
  4050. }
  4051. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4052. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4053. v := m.organization_id
  4054. if v == nil {
  4055. return
  4056. }
  4057. return *v, true
  4058. }
  4059. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4060. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4062. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4063. if !m.op.Is(OpUpdateOne) {
  4064. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4065. }
  4066. if m.id == nil || m.oldValue == nil {
  4067. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4068. }
  4069. oldValue, err := m.oldValue(ctx)
  4070. if err != nil {
  4071. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4072. }
  4073. return oldValue.OrganizationID, nil
  4074. }
  4075. // AddOrganizationID adds u to the "organization_id" field.
  4076. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4077. if m.addorganization_id != nil {
  4078. *m.addorganization_id += u
  4079. } else {
  4080. m.addorganization_id = &u
  4081. }
  4082. }
  4083. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4084. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4085. v := m.addorganization_id
  4086. if v == nil {
  4087. return
  4088. }
  4089. return *v, true
  4090. }
  4091. // ResetOrganizationID resets all changes to the "organization_id" field.
  4092. func (m *BatchMsgMutation) ResetOrganizationID() {
  4093. m.organization_id = nil
  4094. m.addorganization_id = nil
  4095. }
  4096. // Where appends a list predicates to the BatchMsgMutation builder.
  4097. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4098. m.predicates = append(m.predicates, ps...)
  4099. }
  4100. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4101. // users can use type-assertion to append predicates that do not depend on any generated package.
  4102. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4103. p := make([]predicate.BatchMsg, len(ps))
  4104. for i := range ps {
  4105. p[i] = ps[i]
  4106. }
  4107. m.Where(p...)
  4108. }
  4109. // Op returns the operation name.
  4110. func (m *BatchMsgMutation) Op() Op {
  4111. return m.op
  4112. }
  4113. // SetOp allows setting the mutation operation.
  4114. func (m *BatchMsgMutation) SetOp(op Op) {
  4115. m.op = op
  4116. }
  4117. // Type returns the node type of this mutation (BatchMsg).
  4118. func (m *BatchMsgMutation) Type() string {
  4119. return m.typ
  4120. }
  4121. // Fields returns all fields that were changed during this mutation. Note that in
  4122. // order to get all numeric fields that were incremented/decremented, call
  4123. // AddedFields().
  4124. func (m *BatchMsgMutation) Fields() []string {
  4125. fields := make([]string, 0, 18)
  4126. if m.created_at != nil {
  4127. fields = append(fields, batchmsg.FieldCreatedAt)
  4128. }
  4129. if m.updated_at != nil {
  4130. fields = append(fields, batchmsg.FieldUpdatedAt)
  4131. }
  4132. if m.deleted_at != nil {
  4133. fields = append(fields, batchmsg.FieldDeletedAt)
  4134. }
  4135. if m.status != nil {
  4136. fields = append(fields, batchmsg.FieldStatus)
  4137. }
  4138. if m.batch_no != nil {
  4139. fields = append(fields, batchmsg.FieldBatchNo)
  4140. }
  4141. if m.task_name != nil {
  4142. fields = append(fields, batchmsg.FieldTaskName)
  4143. }
  4144. if m.fromwxid != nil {
  4145. fields = append(fields, batchmsg.FieldFromwxid)
  4146. }
  4147. if m.msg != nil {
  4148. fields = append(fields, batchmsg.FieldMsg)
  4149. }
  4150. if m.tag != nil {
  4151. fields = append(fields, batchmsg.FieldTag)
  4152. }
  4153. if m.tagids != nil {
  4154. fields = append(fields, batchmsg.FieldTagids)
  4155. }
  4156. if m.total != nil {
  4157. fields = append(fields, batchmsg.FieldTotal)
  4158. }
  4159. if m.success != nil {
  4160. fields = append(fields, batchmsg.FieldSuccess)
  4161. }
  4162. if m.fail != nil {
  4163. fields = append(fields, batchmsg.FieldFail)
  4164. }
  4165. if m.start_time != nil {
  4166. fields = append(fields, batchmsg.FieldStartTime)
  4167. }
  4168. if m.stop_time != nil {
  4169. fields = append(fields, batchmsg.FieldStopTime)
  4170. }
  4171. if m.send_time != nil {
  4172. fields = append(fields, batchmsg.FieldSendTime)
  4173. }
  4174. if m._type != nil {
  4175. fields = append(fields, batchmsg.FieldType)
  4176. }
  4177. if m.organization_id != nil {
  4178. fields = append(fields, batchmsg.FieldOrganizationID)
  4179. }
  4180. return fields
  4181. }
  4182. // Field returns the value of a field with the given name. The second boolean
  4183. // return value indicates that this field was not set, or was not defined in the
  4184. // schema.
  4185. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4186. switch name {
  4187. case batchmsg.FieldCreatedAt:
  4188. return m.CreatedAt()
  4189. case batchmsg.FieldUpdatedAt:
  4190. return m.UpdatedAt()
  4191. case batchmsg.FieldDeletedAt:
  4192. return m.DeletedAt()
  4193. case batchmsg.FieldStatus:
  4194. return m.Status()
  4195. case batchmsg.FieldBatchNo:
  4196. return m.BatchNo()
  4197. case batchmsg.FieldTaskName:
  4198. return m.TaskName()
  4199. case batchmsg.FieldFromwxid:
  4200. return m.Fromwxid()
  4201. case batchmsg.FieldMsg:
  4202. return m.Msg()
  4203. case batchmsg.FieldTag:
  4204. return m.Tag()
  4205. case batchmsg.FieldTagids:
  4206. return m.Tagids()
  4207. case batchmsg.FieldTotal:
  4208. return m.Total()
  4209. case batchmsg.FieldSuccess:
  4210. return m.Success()
  4211. case batchmsg.FieldFail:
  4212. return m.Fail()
  4213. case batchmsg.FieldStartTime:
  4214. return m.StartTime()
  4215. case batchmsg.FieldStopTime:
  4216. return m.StopTime()
  4217. case batchmsg.FieldSendTime:
  4218. return m.SendTime()
  4219. case batchmsg.FieldType:
  4220. return m.GetType()
  4221. case batchmsg.FieldOrganizationID:
  4222. return m.OrganizationID()
  4223. }
  4224. return nil, false
  4225. }
  4226. // OldField returns the old value of the field from the database. An error is
  4227. // returned if the mutation operation is not UpdateOne, or the query to the
  4228. // database failed.
  4229. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4230. switch name {
  4231. case batchmsg.FieldCreatedAt:
  4232. return m.OldCreatedAt(ctx)
  4233. case batchmsg.FieldUpdatedAt:
  4234. return m.OldUpdatedAt(ctx)
  4235. case batchmsg.FieldDeletedAt:
  4236. return m.OldDeletedAt(ctx)
  4237. case batchmsg.FieldStatus:
  4238. return m.OldStatus(ctx)
  4239. case batchmsg.FieldBatchNo:
  4240. return m.OldBatchNo(ctx)
  4241. case batchmsg.FieldTaskName:
  4242. return m.OldTaskName(ctx)
  4243. case batchmsg.FieldFromwxid:
  4244. return m.OldFromwxid(ctx)
  4245. case batchmsg.FieldMsg:
  4246. return m.OldMsg(ctx)
  4247. case batchmsg.FieldTag:
  4248. return m.OldTag(ctx)
  4249. case batchmsg.FieldTagids:
  4250. return m.OldTagids(ctx)
  4251. case batchmsg.FieldTotal:
  4252. return m.OldTotal(ctx)
  4253. case batchmsg.FieldSuccess:
  4254. return m.OldSuccess(ctx)
  4255. case batchmsg.FieldFail:
  4256. return m.OldFail(ctx)
  4257. case batchmsg.FieldStartTime:
  4258. return m.OldStartTime(ctx)
  4259. case batchmsg.FieldStopTime:
  4260. return m.OldStopTime(ctx)
  4261. case batchmsg.FieldSendTime:
  4262. return m.OldSendTime(ctx)
  4263. case batchmsg.FieldType:
  4264. return m.OldType(ctx)
  4265. case batchmsg.FieldOrganizationID:
  4266. return m.OldOrganizationID(ctx)
  4267. }
  4268. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  4269. }
  4270. // SetField sets the value of a field with the given name. It returns an error if
  4271. // the field is not defined in the schema, or if the type mismatched the field
  4272. // type.
  4273. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  4274. switch name {
  4275. case batchmsg.FieldCreatedAt:
  4276. v, ok := value.(time.Time)
  4277. if !ok {
  4278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4279. }
  4280. m.SetCreatedAt(v)
  4281. return nil
  4282. case batchmsg.FieldUpdatedAt:
  4283. v, ok := value.(time.Time)
  4284. if !ok {
  4285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4286. }
  4287. m.SetUpdatedAt(v)
  4288. return nil
  4289. case batchmsg.FieldDeletedAt:
  4290. v, ok := value.(time.Time)
  4291. if !ok {
  4292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4293. }
  4294. m.SetDeletedAt(v)
  4295. return nil
  4296. case batchmsg.FieldStatus:
  4297. v, ok := value.(uint8)
  4298. if !ok {
  4299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4300. }
  4301. m.SetStatus(v)
  4302. return nil
  4303. case batchmsg.FieldBatchNo:
  4304. v, ok := value.(string)
  4305. if !ok {
  4306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4307. }
  4308. m.SetBatchNo(v)
  4309. return nil
  4310. case batchmsg.FieldTaskName:
  4311. v, ok := value.(string)
  4312. if !ok {
  4313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4314. }
  4315. m.SetTaskName(v)
  4316. return nil
  4317. case batchmsg.FieldFromwxid:
  4318. v, ok := value.(string)
  4319. if !ok {
  4320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4321. }
  4322. m.SetFromwxid(v)
  4323. return nil
  4324. case batchmsg.FieldMsg:
  4325. v, ok := value.(string)
  4326. if !ok {
  4327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4328. }
  4329. m.SetMsg(v)
  4330. return nil
  4331. case batchmsg.FieldTag:
  4332. v, ok := value.(string)
  4333. if !ok {
  4334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4335. }
  4336. m.SetTag(v)
  4337. return nil
  4338. case batchmsg.FieldTagids:
  4339. v, ok := value.(string)
  4340. if !ok {
  4341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4342. }
  4343. m.SetTagids(v)
  4344. return nil
  4345. case batchmsg.FieldTotal:
  4346. v, ok := value.(int32)
  4347. if !ok {
  4348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4349. }
  4350. m.SetTotal(v)
  4351. return nil
  4352. case batchmsg.FieldSuccess:
  4353. v, ok := value.(int32)
  4354. if !ok {
  4355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4356. }
  4357. m.SetSuccess(v)
  4358. return nil
  4359. case batchmsg.FieldFail:
  4360. v, ok := value.(int32)
  4361. if !ok {
  4362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4363. }
  4364. m.SetFail(v)
  4365. return nil
  4366. case batchmsg.FieldStartTime:
  4367. v, ok := value.(time.Time)
  4368. if !ok {
  4369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4370. }
  4371. m.SetStartTime(v)
  4372. return nil
  4373. case batchmsg.FieldStopTime:
  4374. v, ok := value.(time.Time)
  4375. if !ok {
  4376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4377. }
  4378. m.SetStopTime(v)
  4379. return nil
  4380. case batchmsg.FieldSendTime:
  4381. v, ok := value.(time.Time)
  4382. if !ok {
  4383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4384. }
  4385. m.SetSendTime(v)
  4386. return nil
  4387. case batchmsg.FieldType:
  4388. v, ok := value.(int32)
  4389. if !ok {
  4390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4391. }
  4392. m.SetType(v)
  4393. return nil
  4394. case batchmsg.FieldOrganizationID:
  4395. v, ok := value.(uint64)
  4396. if !ok {
  4397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4398. }
  4399. m.SetOrganizationID(v)
  4400. return nil
  4401. }
  4402. return fmt.Errorf("unknown BatchMsg field %s", name)
  4403. }
  4404. // AddedFields returns all numeric fields that were incremented/decremented during
  4405. // this mutation.
  4406. func (m *BatchMsgMutation) AddedFields() []string {
  4407. var fields []string
  4408. if m.addstatus != nil {
  4409. fields = append(fields, batchmsg.FieldStatus)
  4410. }
  4411. if m.addtotal != nil {
  4412. fields = append(fields, batchmsg.FieldTotal)
  4413. }
  4414. if m.addsuccess != nil {
  4415. fields = append(fields, batchmsg.FieldSuccess)
  4416. }
  4417. if m.addfail != nil {
  4418. fields = append(fields, batchmsg.FieldFail)
  4419. }
  4420. if m.add_type != nil {
  4421. fields = append(fields, batchmsg.FieldType)
  4422. }
  4423. if m.addorganization_id != nil {
  4424. fields = append(fields, batchmsg.FieldOrganizationID)
  4425. }
  4426. return fields
  4427. }
  4428. // AddedField returns the numeric value that was incremented/decremented on a field
  4429. // with the given name. The second boolean return value indicates that this field
  4430. // was not set, or was not defined in the schema.
  4431. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  4432. switch name {
  4433. case batchmsg.FieldStatus:
  4434. return m.AddedStatus()
  4435. case batchmsg.FieldTotal:
  4436. return m.AddedTotal()
  4437. case batchmsg.FieldSuccess:
  4438. return m.AddedSuccess()
  4439. case batchmsg.FieldFail:
  4440. return m.AddedFail()
  4441. case batchmsg.FieldType:
  4442. return m.AddedType()
  4443. case batchmsg.FieldOrganizationID:
  4444. return m.AddedOrganizationID()
  4445. }
  4446. return nil, false
  4447. }
  4448. // AddField adds the value to the field with the given name. It returns an error if
  4449. // the field is not defined in the schema, or if the type mismatched the field
  4450. // type.
  4451. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  4452. switch name {
  4453. case batchmsg.FieldStatus:
  4454. v, ok := value.(int8)
  4455. if !ok {
  4456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4457. }
  4458. m.AddStatus(v)
  4459. return nil
  4460. case batchmsg.FieldTotal:
  4461. v, ok := value.(int32)
  4462. if !ok {
  4463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4464. }
  4465. m.AddTotal(v)
  4466. return nil
  4467. case batchmsg.FieldSuccess:
  4468. v, ok := value.(int32)
  4469. if !ok {
  4470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4471. }
  4472. m.AddSuccess(v)
  4473. return nil
  4474. case batchmsg.FieldFail:
  4475. v, ok := value.(int32)
  4476. if !ok {
  4477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4478. }
  4479. m.AddFail(v)
  4480. return nil
  4481. case batchmsg.FieldType:
  4482. v, ok := value.(int32)
  4483. if !ok {
  4484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4485. }
  4486. m.AddType(v)
  4487. return nil
  4488. case batchmsg.FieldOrganizationID:
  4489. v, ok := value.(int64)
  4490. if !ok {
  4491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4492. }
  4493. m.AddOrganizationID(v)
  4494. return nil
  4495. }
  4496. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  4497. }
  4498. // ClearedFields returns all nullable fields that were cleared during this
  4499. // mutation.
  4500. func (m *BatchMsgMutation) ClearedFields() []string {
  4501. var fields []string
  4502. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  4503. fields = append(fields, batchmsg.FieldDeletedAt)
  4504. }
  4505. if m.FieldCleared(batchmsg.FieldStatus) {
  4506. fields = append(fields, batchmsg.FieldStatus)
  4507. }
  4508. if m.FieldCleared(batchmsg.FieldBatchNo) {
  4509. fields = append(fields, batchmsg.FieldBatchNo)
  4510. }
  4511. if m.FieldCleared(batchmsg.FieldTaskName) {
  4512. fields = append(fields, batchmsg.FieldTaskName)
  4513. }
  4514. if m.FieldCleared(batchmsg.FieldFromwxid) {
  4515. fields = append(fields, batchmsg.FieldFromwxid)
  4516. }
  4517. if m.FieldCleared(batchmsg.FieldMsg) {
  4518. fields = append(fields, batchmsg.FieldMsg)
  4519. }
  4520. if m.FieldCleared(batchmsg.FieldTag) {
  4521. fields = append(fields, batchmsg.FieldTag)
  4522. }
  4523. if m.FieldCleared(batchmsg.FieldTagids) {
  4524. fields = append(fields, batchmsg.FieldTagids)
  4525. }
  4526. if m.FieldCleared(batchmsg.FieldTotal) {
  4527. fields = append(fields, batchmsg.FieldTotal)
  4528. }
  4529. if m.FieldCleared(batchmsg.FieldSuccess) {
  4530. fields = append(fields, batchmsg.FieldSuccess)
  4531. }
  4532. if m.FieldCleared(batchmsg.FieldFail) {
  4533. fields = append(fields, batchmsg.FieldFail)
  4534. }
  4535. if m.FieldCleared(batchmsg.FieldStartTime) {
  4536. fields = append(fields, batchmsg.FieldStartTime)
  4537. }
  4538. if m.FieldCleared(batchmsg.FieldStopTime) {
  4539. fields = append(fields, batchmsg.FieldStopTime)
  4540. }
  4541. if m.FieldCleared(batchmsg.FieldSendTime) {
  4542. fields = append(fields, batchmsg.FieldSendTime)
  4543. }
  4544. if m.FieldCleared(batchmsg.FieldType) {
  4545. fields = append(fields, batchmsg.FieldType)
  4546. }
  4547. return fields
  4548. }
  4549. // FieldCleared returns a boolean indicating if a field with the given name was
  4550. // cleared in this mutation.
  4551. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  4552. _, ok := m.clearedFields[name]
  4553. return ok
  4554. }
  4555. // ClearField clears the value of the field with the given name. It returns an
  4556. // error if the field is not defined in the schema.
  4557. func (m *BatchMsgMutation) ClearField(name string) error {
  4558. switch name {
  4559. case batchmsg.FieldDeletedAt:
  4560. m.ClearDeletedAt()
  4561. return nil
  4562. case batchmsg.FieldStatus:
  4563. m.ClearStatus()
  4564. return nil
  4565. case batchmsg.FieldBatchNo:
  4566. m.ClearBatchNo()
  4567. return nil
  4568. case batchmsg.FieldTaskName:
  4569. m.ClearTaskName()
  4570. return nil
  4571. case batchmsg.FieldFromwxid:
  4572. m.ClearFromwxid()
  4573. return nil
  4574. case batchmsg.FieldMsg:
  4575. m.ClearMsg()
  4576. return nil
  4577. case batchmsg.FieldTag:
  4578. m.ClearTag()
  4579. return nil
  4580. case batchmsg.FieldTagids:
  4581. m.ClearTagids()
  4582. return nil
  4583. case batchmsg.FieldTotal:
  4584. m.ClearTotal()
  4585. return nil
  4586. case batchmsg.FieldSuccess:
  4587. m.ClearSuccess()
  4588. return nil
  4589. case batchmsg.FieldFail:
  4590. m.ClearFail()
  4591. return nil
  4592. case batchmsg.FieldStartTime:
  4593. m.ClearStartTime()
  4594. return nil
  4595. case batchmsg.FieldStopTime:
  4596. m.ClearStopTime()
  4597. return nil
  4598. case batchmsg.FieldSendTime:
  4599. m.ClearSendTime()
  4600. return nil
  4601. case batchmsg.FieldType:
  4602. m.ClearType()
  4603. return nil
  4604. }
  4605. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  4606. }
  4607. // ResetField resets all changes in the mutation for the field with the given name.
  4608. // It returns an error if the field is not defined in the schema.
  4609. func (m *BatchMsgMutation) ResetField(name string) error {
  4610. switch name {
  4611. case batchmsg.FieldCreatedAt:
  4612. m.ResetCreatedAt()
  4613. return nil
  4614. case batchmsg.FieldUpdatedAt:
  4615. m.ResetUpdatedAt()
  4616. return nil
  4617. case batchmsg.FieldDeletedAt:
  4618. m.ResetDeletedAt()
  4619. return nil
  4620. case batchmsg.FieldStatus:
  4621. m.ResetStatus()
  4622. return nil
  4623. case batchmsg.FieldBatchNo:
  4624. m.ResetBatchNo()
  4625. return nil
  4626. case batchmsg.FieldTaskName:
  4627. m.ResetTaskName()
  4628. return nil
  4629. case batchmsg.FieldFromwxid:
  4630. m.ResetFromwxid()
  4631. return nil
  4632. case batchmsg.FieldMsg:
  4633. m.ResetMsg()
  4634. return nil
  4635. case batchmsg.FieldTag:
  4636. m.ResetTag()
  4637. return nil
  4638. case batchmsg.FieldTagids:
  4639. m.ResetTagids()
  4640. return nil
  4641. case batchmsg.FieldTotal:
  4642. m.ResetTotal()
  4643. return nil
  4644. case batchmsg.FieldSuccess:
  4645. m.ResetSuccess()
  4646. return nil
  4647. case batchmsg.FieldFail:
  4648. m.ResetFail()
  4649. return nil
  4650. case batchmsg.FieldStartTime:
  4651. m.ResetStartTime()
  4652. return nil
  4653. case batchmsg.FieldStopTime:
  4654. m.ResetStopTime()
  4655. return nil
  4656. case batchmsg.FieldSendTime:
  4657. m.ResetSendTime()
  4658. return nil
  4659. case batchmsg.FieldType:
  4660. m.ResetType()
  4661. return nil
  4662. case batchmsg.FieldOrganizationID:
  4663. m.ResetOrganizationID()
  4664. return nil
  4665. }
  4666. return fmt.Errorf("unknown BatchMsg field %s", name)
  4667. }
  4668. // AddedEdges returns all edge names that were set/added in this mutation.
  4669. func (m *BatchMsgMutation) AddedEdges() []string {
  4670. edges := make([]string, 0, 0)
  4671. return edges
  4672. }
  4673. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4674. // name in this mutation.
  4675. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  4676. return nil
  4677. }
  4678. // RemovedEdges returns all edge names that were removed in this mutation.
  4679. func (m *BatchMsgMutation) RemovedEdges() []string {
  4680. edges := make([]string, 0, 0)
  4681. return edges
  4682. }
  4683. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4684. // the given name in this mutation.
  4685. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  4686. return nil
  4687. }
  4688. // ClearedEdges returns all edge names that were cleared in this mutation.
  4689. func (m *BatchMsgMutation) ClearedEdges() []string {
  4690. edges := make([]string, 0, 0)
  4691. return edges
  4692. }
  4693. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4694. // was cleared in this mutation.
  4695. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  4696. return false
  4697. }
  4698. // ClearEdge clears the value of the edge with the given name. It returns an error
  4699. // if that edge is not defined in the schema.
  4700. func (m *BatchMsgMutation) ClearEdge(name string) error {
  4701. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  4702. }
  4703. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4704. // It returns an error if the edge is not defined in the schema.
  4705. func (m *BatchMsgMutation) ResetEdge(name string) error {
  4706. return fmt.Errorf("unknown BatchMsg edge %s", name)
  4707. }
  4708. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  4709. type CategoryMutation struct {
  4710. config
  4711. op Op
  4712. typ string
  4713. id *uint64
  4714. created_at *time.Time
  4715. updated_at *time.Time
  4716. deleted_at *time.Time
  4717. name *string
  4718. organization_id *uint64
  4719. addorganization_id *int64
  4720. clearedFields map[string]struct{}
  4721. done bool
  4722. oldValue func(context.Context) (*Category, error)
  4723. predicates []predicate.Category
  4724. }
  4725. var _ ent.Mutation = (*CategoryMutation)(nil)
  4726. // categoryOption allows management of the mutation configuration using functional options.
  4727. type categoryOption func(*CategoryMutation)
  4728. // newCategoryMutation creates new mutation for the Category entity.
  4729. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  4730. m := &CategoryMutation{
  4731. config: c,
  4732. op: op,
  4733. typ: TypeCategory,
  4734. clearedFields: make(map[string]struct{}),
  4735. }
  4736. for _, opt := range opts {
  4737. opt(m)
  4738. }
  4739. return m
  4740. }
  4741. // withCategoryID sets the ID field of the mutation.
  4742. func withCategoryID(id uint64) categoryOption {
  4743. return func(m *CategoryMutation) {
  4744. var (
  4745. err error
  4746. once sync.Once
  4747. value *Category
  4748. )
  4749. m.oldValue = func(ctx context.Context) (*Category, error) {
  4750. once.Do(func() {
  4751. if m.done {
  4752. err = errors.New("querying old values post mutation is not allowed")
  4753. } else {
  4754. value, err = m.Client().Category.Get(ctx, id)
  4755. }
  4756. })
  4757. return value, err
  4758. }
  4759. m.id = &id
  4760. }
  4761. }
  4762. // withCategory sets the old Category of the mutation.
  4763. func withCategory(node *Category) categoryOption {
  4764. return func(m *CategoryMutation) {
  4765. m.oldValue = func(context.Context) (*Category, error) {
  4766. return node, nil
  4767. }
  4768. m.id = &node.ID
  4769. }
  4770. }
  4771. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4772. // executed in a transaction (ent.Tx), a transactional client is returned.
  4773. func (m CategoryMutation) Client() *Client {
  4774. client := &Client{config: m.config}
  4775. client.init()
  4776. return client
  4777. }
  4778. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4779. // it returns an error otherwise.
  4780. func (m CategoryMutation) Tx() (*Tx, error) {
  4781. if _, ok := m.driver.(*txDriver); !ok {
  4782. return nil, errors.New("ent: mutation is not running in a transaction")
  4783. }
  4784. tx := &Tx{config: m.config}
  4785. tx.init()
  4786. return tx, nil
  4787. }
  4788. // SetID sets the value of the id field. Note that this
  4789. // operation is only accepted on creation of Category entities.
  4790. func (m *CategoryMutation) SetID(id uint64) {
  4791. m.id = &id
  4792. }
  4793. // ID returns the ID value in the mutation. Note that the ID is only available
  4794. // if it was provided to the builder or after it was returned from the database.
  4795. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  4796. if m.id == nil {
  4797. return
  4798. }
  4799. return *m.id, true
  4800. }
  4801. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4802. // That means, if the mutation is applied within a transaction with an isolation level such
  4803. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4804. // or updated by the mutation.
  4805. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  4806. switch {
  4807. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4808. id, exists := m.ID()
  4809. if exists {
  4810. return []uint64{id}, nil
  4811. }
  4812. fallthrough
  4813. case m.op.Is(OpUpdate | OpDelete):
  4814. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  4815. default:
  4816. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4817. }
  4818. }
  4819. // SetCreatedAt sets the "created_at" field.
  4820. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  4821. m.created_at = &t
  4822. }
  4823. // CreatedAt returns the value of the "created_at" field in the mutation.
  4824. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  4825. v := m.created_at
  4826. if v == nil {
  4827. return
  4828. }
  4829. return *v, true
  4830. }
  4831. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  4832. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4834. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4835. if !m.op.Is(OpUpdateOne) {
  4836. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4837. }
  4838. if m.id == nil || m.oldValue == nil {
  4839. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4840. }
  4841. oldValue, err := m.oldValue(ctx)
  4842. if err != nil {
  4843. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4844. }
  4845. return oldValue.CreatedAt, nil
  4846. }
  4847. // ResetCreatedAt resets all changes to the "created_at" field.
  4848. func (m *CategoryMutation) ResetCreatedAt() {
  4849. m.created_at = nil
  4850. }
  4851. // SetUpdatedAt sets the "updated_at" field.
  4852. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  4853. m.updated_at = &t
  4854. }
  4855. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4856. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  4857. v := m.updated_at
  4858. if v == nil {
  4859. return
  4860. }
  4861. return *v, true
  4862. }
  4863. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  4864. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4866. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4867. if !m.op.Is(OpUpdateOne) {
  4868. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4869. }
  4870. if m.id == nil || m.oldValue == nil {
  4871. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4872. }
  4873. oldValue, err := m.oldValue(ctx)
  4874. if err != nil {
  4875. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4876. }
  4877. return oldValue.UpdatedAt, nil
  4878. }
  4879. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4880. func (m *CategoryMutation) ResetUpdatedAt() {
  4881. m.updated_at = nil
  4882. }
  4883. // SetDeletedAt sets the "deleted_at" field.
  4884. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  4885. m.deleted_at = &t
  4886. }
  4887. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4888. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  4889. v := m.deleted_at
  4890. if v == nil {
  4891. return
  4892. }
  4893. return *v, true
  4894. }
  4895. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  4896. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4898. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4899. if !m.op.Is(OpUpdateOne) {
  4900. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4901. }
  4902. if m.id == nil || m.oldValue == nil {
  4903. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4904. }
  4905. oldValue, err := m.oldValue(ctx)
  4906. if err != nil {
  4907. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4908. }
  4909. return oldValue.DeletedAt, nil
  4910. }
  4911. // ClearDeletedAt clears the value of the "deleted_at" field.
  4912. func (m *CategoryMutation) ClearDeletedAt() {
  4913. m.deleted_at = nil
  4914. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  4915. }
  4916. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4917. func (m *CategoryMutation) DeletedAtCleared() bool {
  4918. _, ok := m.clearedFields[category.FieldDeletedAt]
  4919. return ok
  4920. }
  4921. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4922. func (m *CategoryMutation) ResetDeletedAt() {
  4923. m.deleted_at = nil
  4924. delete(m.clearedFields, category.FieldDeletedAt)
  4925. }
  4926. // SetName sets the "name" field.
  4927. func (m *CategoryMutation) SetName(s string) {
  4928. m.name = &s
  4929. }
  4930. // Name returns the value of the "name" field in the mutation.
  4931. func (m *CategoryMutation) Name() (r string, exists bool) {
  4932. v := m.name
  4933. if v == nil {
  4934. return
  4935. }
  4936. return *v, true
  4937. }
  4938. // OldName returns the old "name" field's value of the Category entity.
  4939. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4941. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  4942. if !m.op.Is(OpUpdateOne) {
  4943. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4944. }
  4945. if m.id == nil || m.oldValue == nil {
  4946. return v, errors.New("OldName requires an ID field in the mutation")
  4947. }
  4948. oldValue, err := m.oldValue(ctx)
  4949. if err != nil {
  4950. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4951. }
  4952. return oldValue.Name, nil
  4953. }
  4954. // ResetName resets all changes to the "name" field.
  4955. func (m *CategoryMutation) ResetName() {
  4956. m.name = nil
  4957. }
  4958. // SetOrganizationID sets the "organization_id" field.
  4959. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  4960. m.organization_id = &u
  4961. m.addorganization_id = nil
  4962. }
  4963. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4964. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  4965. v := m.organization_id
  4966. if v == nil {
  4967. return
  4968. }
  4969. return *v, true
  4970. }
  4971. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  4972. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4974. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4975. if !m.op.Is(OpUpdateOne) {
  4976. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4977. }
  4978. if m.id == nil || m.oldValue == nil {
  4979. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4980. }
  4981. oldValue, err := m.oldValue(ctx)
  4982. if err != nil {
  4983. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4984. }
  4985. return oldValue.OrganizationID, nil
  4986. }
  4987. // AddOrganizationID adds u to the "organization_id" field.
  4988. func (m *CategoryMutation) AddOrganizationID(u int64) {
  4989. if m.addorganization_id != nil {
  4990. *m.addorganization_id += u
  4991. } else {
  4992. m.addorganization_id = &u
  4993. }
  4994. }
  4995. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4996. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  4997. v := m.addorganization_id
  4998. if v == nil {
  4999. return
  5000. }
  5001. return *v, true
  5002. }
  5003. // ResetOrganizationID resets all changes to the "organization_id" field.
  5004. func (m *CategoryMutation) ResetOrganizationID() {
  5005. m.organization_id = nil
  5006. m.addorganization_id = nil
  5007. }
  5008. // Where appends a list predicates to the CategoryMutation builder.
  5009. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5010. m.predicates = append(m.predicates, ps...)
  5011. }
  5012. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5013. // users can use type-assertion to append predicates that do not depend on any generated package.
  5014. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5015. p := make([]predicate.Category, len(ps))
  5016. for i := range ps {
  5017. p[i] = ps[i]
  5018. }
  5019. m.Where(p...)
  5020. }
  5021. // Op returns the operation name.
  5022. func (m *CategoryMutation) Op() Op {
  5023. return m.op
  5024. }
  5025. // SetOp allows setting the mutation operation.
  5026. func (m *CategoryMutation) SetOp(op Op) {
  5027. m.op = op
  5028. }
  5029. // Type returns the node type of this mutation (Category).
  5030. func (m *CategoryMutation) Type() string {
  5031. return m.typ
  5032. }
  5033. // Fields returns all fields that were changed during this mutation. Note that in
  5034. // order to get all numeric fields that were incremented/decremented, call
  5035. // AddedFields().
  5036. func (m *CategoryMutation) Fields() []string {
  5037. fields := make([]string, 0, 5)
  5038. if m.created_at != nil {
  5039. fields = append(fields, category.FieldCreatedAt)
  5040. }
  5041. if m.updated_at != nil {
  5042. fields = append(fields, category.FieldUpdatedAt)
  5043. }
  5044. if m.deleted_at != nil {
  5045. fields = append(fields, category.FieldDeletedAt)
  5046. }
  5047. if m.name != nil {
  5048. fields = append(fields, category.FieldName)
  5049. }
  5050. if m.organization_id != nil {
  5051. fields = append(fields, category.FieldOrganizationID)
  5052. }
  5053. return fields
  5054. }
  5055. // Field returns the value of a field with the given name. The second boolean
  5056. // return value indicates that this field was not set, or was not defined in the
  5057. // schema.
  5058. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5059. switch name {
  5060. case category.FieldCreatedAt:
  5061. return m.CreatedAt()
  5062. case category.FieldUpdatedAt:
  5063. return m.UpdatedAt()
  5064. case category.FieldDeletedAt:
  5065. return m.DeletedAt()
  5066. case category.FieldName:
  5067. return m.Name()
  5068. case category.FieldOrganizationID:
  5069. return m.OrganizationID()
  5070. }
  5071. return nil, false
  5072. }
  5073. // OldField returns the old value of the field from the database. An error is
  5074. // returned if the mutation operation is not UpdateOne, or the query to the
  5075. // database failed.
  5076. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5077. switch name {
  5078. case category.FieldCreatedAt:
  5079. return m.OldCreatedAt(ctx)
  5080. case category.FieldUpdatedAt:
  5081. return m.OldUpdatedAt(ctx)
  5082. case category.FieldDeletedAt:
  5083. return m.OldDeletedAt(ctx)
  5084. case category.FieldName:
  5085. return m.OldName(ctx)
  5086. case category.FieldOrganizationID:
  5087. return m.OldOrganizationID(ctx)
  5088. }
  5089. return nil, fmt.Errorf("unknown Category field %s", name)
  5090. }
  5091. // SetField sets the value of a field with the given name. It returns an error if
  5092. // the field is not defined in the schema, or if the type mismatched the field
  5093. // type.
  5094. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5095. switch name {
  5096. case category.FieldCreatedAt:
  5097. v, ok := value.(time.Time)
  5098. if !ok {
  5099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5100. }
  5101. m.SetCreatedAt(v)
  5102. return nil
  5103. case category.FieldUpdatedAt:
  5104. v, ok := value.(time.Time)
  5105. if !ok {
  5106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5107. }
  5108. m.SetUpdatedAt(v)
  5109. return nil
  5110. case category.FieldDeletedAt:
  5111. v, ok := value.(time.Time)
  5112. if !ok {
  5113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5114. }
  5115. m.SetDeletedAt(v)
  5116. return nil
  5117. case category.FieldName:
  5118. v, ok := value.(string)
  5119. if !ok {
  5120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5121. }
  5122. m.SetName(v)
  5123. return nil
  5124. case category.FieldOrganizationID:
  5125. v, ok := value.(uint64)
  5126. if !ok {
  5127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5128. }
  5129. m.SetOrganizationID(v)
  5130. return nil
  5131. }
  5132. return fmt.Errorf("unknown Category field %s", name)
  5133. }
  5134. // AddedFields returns all numeric fields that were incremented/decremented during
  5135. // this mutation.
  5136. func (m *CategoryMutation) AddedFields() []string {
  5137. var fields []string
  5138. if m.addorganization_id != nil {
  5139. fields = append(fields, category.FieldOrganizationID)
  5140. }
  5141. return fields
  5142. }
  5143. // AddedField returns the numeric value that was incremented/decremented on a field
  5144. // with the given name. The second boolean return value indicates that this field
  5145. // was not set, or was not defined in the schema.
  5146. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5147. switch name {
  5148. case category.FieldOrganizationID:
  5149. return m.AddedOrganizationID()
  5150. }
  5151. return nil, false
  5152. }
  5153. // AddField adds the value to the field with the given name. It returns an error if
  5154. // the field is not defined in the schema, or if the type mismatched the field
  5155. // type.
  5156. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5157. switch name {
  5158. case category.FieldOrganizationID:
  5159. v, ok := value.(int64)
  5160. if !ok {
  5161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5162. }
  5163. m.AddOrganizationID(v)
  5164. return nil
  5165. }
  5166. return fmt.Errorf("unknown Category numeric field %s", name)
  5167. }
  5168. // ClearedFields returns all nullable fields that were cleared during this
  5169. // mutation.
  5170. func (m *CategoryMutation) ClearedFields() []string {
  5171. var fields []string
  5172. if m.FieldCleared(category.FieldDeletedAt) {
  5173. fields = append(fields, category.FieldDeletedAt)
  5174. }
  5175. return fields
  5176. }
  5177. // FieldCleared returns a boolean indicating if a field with the given name was
  5178. // cleared in this mutation.
  5179. func (m *CategoryMutation) FieldCleared(name string) bool {
  5180. _, ok := m.clearedFields[name]
  5181. return ok
  5182. }
  5183. // ClearField clears the value of the field with the given name. It returns an
  5184. // error if the field is not defined in the schema.
  5185. func (m *CategoryMutation) ClearField(name string) error {
  5186. switch name {
  5187. case category.FieldDeletedAt:
  5188. m.ClearDeletedAt()
  5189. return nil
  5190. }
  5191. return fmt.Errorf("unknown Category nullable field %s", name)
  5192. }
  5193. // ResetField resets all changes in the mutation for the field with the given name.
  5194. // It returns an error if the field is not defined in the schema.
  5195. func (m *CategoryMutation) ResetField(name string) error {
  5196. switch name {
  5197. case category.FieldCreatedAt:
  5198. m.ResetCreatedAt()
  5199. return nil
  5200. case category.FieldUpdatedAt:
  5201. m.ResetUpdatedAt()
  5202. return nil
  5203. case category.FieldDeletedAt:
  5204. m.ResetDeletedAt()
  5205. return nil
  5206. case category.FieldName:
  5207. m.ResetName()
  5208. return nil
  5209. case category.FieldOrganizationID:
  5210. m.ResetOrganizationID()
  5211. return nil
  5212. }
  5213. return fmt.Errorf("unknown Category field %s", name)
  5214. }
  5215. // AddedEdges returns all edge names that were set/added in this mutation.
  5216. func (m *CategoryMutation) AddedEdges() []string {
  5217. edges := make([]string, 0, 0)
  5218. return edges
  5219. }
  5220. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5221. // name in this mutation.
  5222. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5223. return nil
  5224. }
  5225. // RemovedEdges returns all edge names that were removed in this mutation.
  5226. func (m *CategoryMutation) RemovedEdges() []string {
  5227. edges := make([]string, 0, 0)
  5228. return edges
  5229. }
  5230. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5231. // the given name in this mutation.
  5232. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5233. return nil
  5234. }
  5235. // ClearedEdges returns all edge names that were cleared in this mutation.
  5236. func (m *CategoryMutation) ClearedEdges() []string {
  5237. edges := make([]string, 0, 0)
  5238. return edges
  5239. }
  5240. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5241. // was cleared in this mutation.
  5242. func (m *CategoryMutation) EdgeCleared(name string) bool {
  5243. return false
  5244. }
  5245. // ClearEdge clears the value of the edge with the given name. It returns an error
  5246. // if that edge is not defined in the schema.
  5247. func (m *CategoryMutation) ClearEdge(name string) error {
  5248. return fmt.Errorf("unknown Category unique edge %s", name)
  5249. }
  5250. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5251. // It returns an error if the edge is not defined in the schema.
  5252. func (m *CategoryMutation) ResetEdge(name string) error {
  5253. return fmt.Errorf("unknown Category edge %s", name)
  5254. }
  5255. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  5256. type ChatRecordsMutation struct {
  5257. config
  5258. op Op
  5259. typ string
  5260. id *uint64
  5261. created_at *time.Time
  5262. updated_at *time.Time
  5263. deleted_at *time.Time
  5264. content *string
  5265. content_type *uint8
  5266. addcontent_type *int8
  5267. session_id *uint64
  5268. addsession_id *int64
  5269. user_id *uint64
  5270. adduser_id *int64
  5271. bot_id *uint64
  5272. addbot_id *int64
  5273. bot_type *uint8
  5274. addbot_type *int8
  5275. clearedFields map[string]struct{}
  5276. done bool
  5277. oldValue func(context.Context) (*ChatRecords, error)
  5278. predicates []predicate.ChatRecords
  5279. }
  5280. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  5281. // chatrecordsOption allows management of the mutation configuration using functional options.
  5282. type chatrecordsOption func(*ChatRecordsMutation)
  5283. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  5284. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  5285. m := &ChatRecordsMutation{
  5286. config: c,
  5287. op: op,
  5288. typ: TypeChatRecords,
  5289. clearedFields: make(map[string]struct{}),
  5290. }
  5291. for _, opt := range opts {
  5292. opt(m)
  5293. }
  5294. return m
  5295. }
  5296. // withChatRecordsID sets the ID field of the mutation.
  5297. func withChatRecordsID(id uint64) chatrecordsOption {
  5298. return func(m *ChatRecordsMutation) {
  5299. var (
  5300. err error
  5301. once sync.Once
  5302. value *ChatRecords
  5303. )
  5304. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  5305. once.Do(func() {
  5306. if m.done {
  5307. err = errors.New("querying old values post mutation is not allowed")
  5308. } else {
  5309. value, err = m.Client().ChatRecords.Get(ctx, id)
  5310. }
  5311. })
  5312. return value, err
  5313. }
  5314. m.id = &id
  5315. }
  5316. }
  5317. // withChatRecords sets the old ChatRecords of the mutation.
  5318. func withChatRecords(node *ChatRecords) chatrecordsOption {
  5319. return func(m *ChatRecordsMutation) {
  5320. m.oldValue = func(context.Context) (*ChatRecords, error) {
  5321. return node, nil
  5322. }
  5323. m.id = &node.ID
  5324. }
  5325. }
  5326. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5327. // executed in a transaction (ent.Tx), a transactional client is returned.
  5328. func (m ChatRecordsMutation) Client() *Client {
  5329. client := &Client{config: m.config}
  5330. client.init()
  5331. return client
  5332. }
  5333. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5334. // it returns an error otherwise.
  5335. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  5336. if _, ok := m.driver.(*txDriver); !ok {
  5337. return nil, errors.New("ent: mutation is not running in a transaction")
  5338. }
  5339. tx := &Tx{config: m.config}
  5340. tx.init()
  5341. return tx, nil
  5342. }
  5343. // SetID sets the value of the id field. Note that this
  5344. // operation is only accepted on creation of ChatRecords entities.
  5345. func (m *ChatRecordsMutation) SetID(id uint64) {
  5346. m.id = &id
  5347. }
  5348. // ID returns the ID value in the mutation. Note that the ID is only available
  5349. // if it was provided to the builder or after it was returned from the database.
  5350. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  5351. if m.id == nil {
  5352. return
  5353. }
  5354. return *m.id, true
  5355. }
  5356. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5357. // That means, if the mutation is applied within a transaction with an isolation level such
  5358. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5359. // or updated by the mutation.
  5360. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  5361. switch {
  5362. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5363. id, exists := m.ID()
  5364. if exists {
  5365. return []uint64{id}, nil
  5366. }
  5367. fallthrough
  5368. case m.op.Is(OpUpdate | OpDelete):
  5369. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  5370. default:
  5371. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5372. }
  5373. }
  5374. // SetCreatedAt sets the "created_at" field.
  5375. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  5376. m.created_at = &t
  5377. }
  5378. // CreatedAt returns the value of the "created_at" field in the mutation.
  5379. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  5380. v := m.created_at
  5381. if v == nil {
  5382. return
  5383. }
  5384. return *v, true
  5385. }
  5386. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  5387. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5389. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5390. if !m.op.Is(OpUpdateOne) {
  5391. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5392. }
  5393. if m.id == nil || m.oldValue == nil {
  5394. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5395. }
  5396. oldValue, err := m.oldValue(ctx)
  5397. if err != nil {
  5398. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5399. }
  5400. return oldValue.CreatedAt, nil
  5401. }
  5402. // ResetCreatedAt resets all changes to the "created_at" field.
  5403. func (m *ChatRecordsMutation) ResetCreatedAt() {
  5404. m.created_at = nil
  5405. }
  5406. // SetUpdatedAt sets the "updated_at" field.
  5407. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  5408. m.updated_at = &t
  5409. }
  5410. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5411. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  5412. v := m.updated_at
  5413. if v == nil {
  5414. return
  5415. }
  5416. return *v, true
  5417. }
  5418. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  5419. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5421. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5422. if !m.op.Is(OpUpdateOne) {
  5423. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5424. }
  5425. if m.id == nil || m.oldValue == nil {
  5426. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5427. }
  5428. oldValue, err := m.oldValue(ctx)
  5429. if err != nil {
  5430. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5431. }
  5432. return oldValue.UpdatedAt, nil
  5433. }
  5434. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5435. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  5436. m.updated_at = nil
  5437. }
  5438. // SetDeletedAt sets the "deleted_at" field.
  5439. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  5440. m.deleted_at = &t
  5441. }
  5442. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5443. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  5444. v := m.deleted_at
  5445. if v == nil {
  5446. return
  5447. }
  5448. return *v, true
  5449. }
  5450. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  5451. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5453. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5454. if !m.op.Is(OpUpdateOne) {
  5455. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5456. }
  5457. if m.id == nil || m.oldValue == nil {
  5458. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5459. }
  5460. oldValue, err := m.oldValue(ctx)
  5461. if err != nil {
  5462. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5463. }
  5464. return oldValue.DeletedAt, nil
  5465. }
  5466. // ClearDeletedAt clears the value of the "deleted_at" field.
  5467. func (m *ChatRecordsMutation) ClearDeletedAt() {
  5468. m.deleted_at = nil
  5469. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  5470. }
  5471. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5472. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  5473. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  5474. return ok
  5475. }
  5476. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5477. func (m *ChatRecordsMutation) ResetDeletedAt() {
  5478. m.deleted_at = nil
  5479. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  5480. }
  5481. // SetContent sets the "content" field.
  5482. func (m *ChatRecordsMutation) SetContent(s string) {
  5483. m.content = &s
  5484. }
  5485. // Content returns the value of the "content" field in the mutation.
  5486. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  5487. v := m.content
  5488. if v == nil {
  5489. return
  5490. }
  5491. return *v, true
  5492. }
  5493. // OldContent returns the old "content" field's value of the ChatRecords entity.
  5494. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5496. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  5497. if !m.op.Is(OpUpdateOne) {
  5498. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5499. }
  5500. if m.id == nil || m.oldValue == nil {
  5501. return v, errors.New("OldContent requires an ID field in the mutation")
  5502. }
  5503. oldValue, err := m.oldValue(ctx)
  5504. if err != nil {
  5505. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5506. }
  5507. return oldValue.Content, nil
  5508. }
  5509. // ResetContent resets all changes to the "content" field.
  5510. func (m *ChatRecordsMutation) ResetContent() {
  5511. m.content = nil
  5512. }
  5513. // SetContentType sets the "content_type" field.
  5514. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  5515. m.content_type = &u
  5516. m.addcontent_type = nil
  5517. }
  5518. // ContentType returns the value of the "content_type" field in the mutation.
  5519. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  5520. v := m.content_type
  5521. if v == nil {
  5522. return
  5523. }
  5524. return *v, true
  5525. }
  5526. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  5527. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5529. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  5530. if !m.op.Is(OpUpdateOne) {
  5531. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  5532. }
  5533. if m.id == nil || m.oldValue == nil {
  5534. return v, errors.New("OldContentType requires an ID field in the mutation")
  5535. }
  5536. oldValue, err := m.oldValue(ctx)
  5537. if err != nil {
  5538. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  5539. }
  5540. return oldValue.ContentType, nil
  5541. }
  5542. // AddContentType adds u to the "content_type" field.
  5543. func (m *ChatRecordsMutation) AddContentType(u int8) {
  5544. if m.addcontent_type != nil {
  5545. *m.addcontent_type += u
  5546. } else {
  5547. m.addcontent_type = &u
  5548. }
  5549. }
  5550. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  5551. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  5552. v := m.addcontent_type
  5553. if v == nil {
  5554. return
  5555. }
  5556. return *v, true
  5557. }
  5558. // ResetContentType resets all changes to the "content_type" field.
  5559. func (m *ChatRecordsMutation) ResetContentType() {
  5560. m.content_type = nil
  5561. m.addcontent_type = nil
  5562. }
  5563. // SetSessionID sets the "session_id" field.
  5564. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  5565. m.session_id = &u
  5566. m.addsession_id = nil
  5567. }
  5568. // SessionID returns the value of the "session_id" field in the mutation.
  5569. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  5570. v := m.session_id
  5571. if v == nil {
  5572. return
  5573. }
  5574. return *v, true
  5575. }
  5576. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  5577. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5579. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  5580. if !m.op.Is(OpUpdateOne) {
  5581. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  5582. }
  5583. if m.id == nil || m.oldValue == nil {
  5584. return v, errors.New("OldSessionID requires an ID field in the mutation")
  5585. }
  5586. oldValue, err := m.oldValue(ctx)
  5587. if err != nil {
  5588. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  5589. }
  5590. return oldValue.SessionID, nil
  5591. }
  5592. // AddSessionID adds u to the "session_id" field.
  5593. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  5594. if m.addsession_id != nil {
  5595. *m.addsession_id += u
  5596. } else {
  5597. m.addsession_id = &u
  5598. }
  5599. }
  5600. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  5601. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  5602. v := m.addsession_id
  5603. if v == nil {
  5604. return
  5605. }
  5606. return *v, true
  5607. }
  5608. // ResetSessionID resets all changes to the "session_id" field.
  5609. func (m *ChatRecordsMutation) ResetSessionID() {
  5610. m.session_id = nil
  5611. m.addsession_id = nil
  5612. }
  5613. // SetUserID sets the "user_id" field.
  5614. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  5615. m.user_id = &u
  5616. m.adduser_id = nil
  5617. }
  5618. // UserID returns the value of the "user_id" field in the mutation.
  5619. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  5620. v := m.user_id
  5621. if v == nil {
  5622. return
  5623. }
  5624. return *v, true
  5625. }
  5626. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  5627. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5629. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  5630. if !m.op.Is(OpUpdateOne) {
  5631. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5632. }
  5633. if m.id == nil || m.oldValue == nil {
  5634. return v, errors.New("OldUserID requires an ID field in the mutation")
  5635. }
  5636. oldValue, err := m.oldValue(ctx)
  5637. if err != nil {
  5638. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5639. }
  5640. return oldValue.UserID, nil
  5641. }
  5642. // AddUserID adds u to the "user_id" field.
  5643. func (m *ChatRecordsMutation) AddUserID(u int64) {
  5644. if m.adduser_id != nil {
  5645. *m.adduser_id += u
  5646. } else {
  5647. m.adduser_id = &u
  5648. }
  5649. }
  5650. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  5651. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  5652. v := m.adduser_id
  5653. if v == nil {
  5654. return
  5655. }
  5656. return *v, true
  5657. }
  5658. // ResetUserID resets all changes to the "user_id" field.
  5659. func (m *ChatRecordsMutation) ResetUserID() {
  5660. m.user_id = nil
  5661. m.adduser_id = nil
  5662. }
  5663. // SetBotID sets the "bot_id" field.
  5664. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  5665. m.bot_id = &u
  5666. m.addbot_id = nil
  5667. }
  5668. // BotID returns the value of the "bot_id" field in the mutation.
  5669. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  5670. v := m.bot_id
  5671. if v == nil {
  5672. return
  5673. }
  5674. return *v, true
  5675. }
  5676. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  5677. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5679. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  5680. if !m.op.Is(OpUpdateOne) {
  5681. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  5682. }
  5683. if m.id == nil || m.oldValue == nil {
  5684. return v, errors.New("OldBotID requires an ID field in the mutation")
  5685. }
  5686. oldValue, err := m.oldValue(ctx)
  5687. if err != nil {
  5688. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  5689. }
  5690. return oldValue.BotID, nil
  5691. }
  5692. // AddBotID adds u to the "bot_id" field.
  5693. func (m *ChatRecordsMutation) AddBotID(u int64) {
  5694. if m.addbot_id != nil {
  5695. *m.addbot_id += u
  5696. } else {
  5697. m.addbot_id = &u
  5698. }
  5699. }
  5700. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  5701. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  5702. v := m.addbot_id
  5703. if v == nil {
  5704. return
  5705. }
  5706. return *v, true
  5707. }
  5708. // ResetBotID resets all changes to the "bot_id" field.
  5709. func (m *ChatRecordsMutation) ResetBotID() {
  5710. m.bot_id = nil
  5711. m.addbot_id = nil
  5712. }
  5713. // SetBotType sets the "bot_type" field.
  5714. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  5715. m.bot_type = &u
  5716. m.addbot_type = nil
  5717. }
  5718. // BotType returns the value of the "bot_type" field in the mutation.
  5719. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  5720. v := m.bot_type
  5721. if v == nil {
  5722. return
  5723. }
  5724. return *v, true
  5725. }
  5726. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  5727. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5729. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  5730. if !m.op.Is(OpUpdateOne) {
  5731. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  5732. }
  5733. if m.id == nil || m.oldValue == nil {
  5734. return v, errors.New("OldBotType requires an ID field in the mutation")
  5735. }
  5736. oldValue, err := m.oldValue(ctx)
  5737. if err != nil {
  5738. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  5739. }
  5740. return oldValue.BotType, nil
  5741. }
  5742. // AddBotType adds u to the "bot_type" field.
  5743. func (m *ChatRecordsMutation) AddBotType(u int8) {
  5744. if m.addbot_type != nil {
  5745. *m.addbot_type += u
  5746. } else {
  5747. m.addbot_type = &u
  5748. }
  5749. }
  5750. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  5751. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  5752. v := m.addbot_type
  5753. if v == nil {
  5754. return
  5755. }
  5756. return *v, true
  5757. }
  5758. // ResetBotType resets all changes to the "bot_type" field.
  5759. func (m *ChatRecordsMutation) ResetBotType() {
  5760. m.bot_type = nil
  5761. m.addbot_type = nil
  5762. }
  5763. // Where appends a list predicates to the ChatRecordsMutation builder.
  5764. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  5765. m.predicates = append(m.predicates, ps...)
  5766. }
  5767. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  5768. // users can use type-assertion to append predicates that do not depend on any generated package.
  5769. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  5770. p := make([]predicate.ChatRecords, len(ps))
  5771. for i := range ps {
  5772. p[i] = ps[i]
  5773. }
  5774. m.Where(p...)
  5775. }
  5776. // Op returns the operation name.
  5777. func (m *ChatRecordsMutation) Op() Op {
  5778. return m.op
  5779. }
  5780. // SetOp allows setting the mutation operation.
  5781. func (m *ChatRecordsMutation) SetOp(op Op) {
  5782. m.op = op
  5783. }
  5784. // Type returns the node type of this mutation (ChatRecords).
  5785. func (m *ChatRecordsMutation) Type() string {
  5786. return m.typ
  5787. }
  5788. // Fields returns all fields that were changed during this mutation. Note that in
  5789. // order to get all numeric fields that were incremented/decremented, call
  5790. // AddedFields().
  5791. func (m *ChatRecordsMutation) Fields() []string {
  5792. fields := make([]string, 0, 9)
  5793. if m.created_at != nil {
  5794. fields = append(fields, chatrecords.FieldCreatedAt)
  5795. }
  5796. if m.updated_at != nil {
  5797. fields = append(fields, chatrecords.FieldUpdatedAt)
  5798. }
  5799. if m.deleted_at != nil {
  5800. fields = append(fields, chatrecords.FieldDeletedAt)
  5801. }
  5802. if m.content != nil {
  5803. fields = append(fields, chatrecords.FieldContent)
  5804. }
  5805. if m.content_type != nil {
  5806. fields = append(fields, chatrecords.FieldContentType)
  5807. }
  5808. if m.session_id != nil {
  5809. fields = append(fields, chatrecords.FieldSessionID)
  5810. }
  5811. if m.user_id != nil {
  5812. fields = append(fields, chatrecords.FieldUserID)
  5813. }
  5814. if m.bot_id != nil {
  5815. fields = append(fields, chatrecords.FieldBotID)
  5816. }
  5817. if m.bot_type != nil {
  5818. fields = append(fields, chatrecords.FieldBotType)
  5819. }
  5820. return fields
  5821. }
  5822. // Field returns the value of a field with the given name. The second boolean
  5823. // return value indicates that this field was not set, or was not defined in the
  5824. // schema.
  5825. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  5826. switch name {
  5827. case chatrecords.FieldCreatedAt:
  5828. return m.CreatedAt()
  5829. case chatrecords.FieldUpdatedAt:
  5830. return m.UpdatedAt()
  5831. case chatrecords.FieldDeletedAt:
  5832. return m.DeletedAt()
  5833. case chatrecords.FieldContent:
  5834. return m.Content()
  5835. case chatrecords.FieldContentType:
  5836. return m.ContentType()
  5837. case chatrecords.FieldSessionID:
  5838. return m.SessionID()
  5839. case chatrecords.FieldUserID:
  5840. return m.UserID()
  5841. case chatrecords.FieldBotID:
  5842. return m.BotID()
  5843. case chatrecords.FieldBotType:
  5844. return m.BotType()
  5845. }
  5846. return nil, false
  5847. }
  5848. // OldField returns the old value of the field from the database. An error is
  5849. // returned if the mutation operation is not UpdateOne, or the query to the
  5850. // database failed.
  5851. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5852. switch name {
  5853. case chatrecords.FieldCreatedAt:
  5854. return m.OldCreatedAt(ctx)
  5855. case chatrecords.FieldUpdatedAt:
  5856. return m.OldUpdatedAt(ctx)
  5857. case chatrecords.FieldDeletedAt:
  5858. return m.OldDeletedAt(ctx)
  5859. case chatrecords.FieldContent:
  5860. return m.OldContent(ctx)
  5861. case chatrecords.FieldContentType:
  5862. return m.OldContentType(ctx)
  5863. case chatrecords.FieldSessionID:
  5864. return m.OldSessionID(ctx)
  5865. case chatrecords.FieldUserID:
  5866. return m.OldUserID(ctx)
  5867. case chatrecords.FieldBotID:
  5868. return m.OldBotID(ctx)
  5869. case chatrecords.FieldBotType:
  5870. return m.OldBotType(ctx)
  5871. }
  5872. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  5873. }
  5874. // SetField sets the value of a field with the given name. It returns an error if
  5875. // the field is not defined in the schema, or if the type mismatched the field
  5876. // type.
  5877. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  5878. switch name {
  5879. case chatrecords.FieldCreatedAt:
  5880. v, ok := value.(time.Time)
  5881. if !ok {
  5882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5883. }
  5884. m.SetCreatedAt(v)
  5885. return nil
  5886. case chatrecords.FieldUpdatedAt:
  5887. v, ok := value.(time.Time)
  5888. if !ok {
  5889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5890. }
  5891. m.SetUpdatedAt(v)
  5892. return nil
  5893. case chatrecords.FieldDeletedAt:
  5894. v, ok := value.(time.Time)
  5895. if !ok {
  5896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5897. }
  5898. m.SetDeletedAt(v)
  5899. return nil
  5900. case chatrecords.FieldContent:
  5901. v, ok := value.(string)
  5902. if !ok {
  5903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5904. }
  5905. m.SetContent(v)
  5906. return nil
  5907. case chatrecords.FieldContentType:
  5908. v, ok := value.(uint8)
  5909. if !ok {
  5910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5911. }
  5912. m.SetContentType(v)
  5913. return nil
  5914. case chatrecords.FieldSessionID:
  5915. v, ok := value.(uint64)
  5916. if !ok {
  5917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5918. }
  5919. m.SetSessionID(v)
  5920. return nil
  5921. case chatrecords.FieldUserID:
  5922. v, ok := value.(uint64)
  5923. if !ok {
  5924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5925. }
  5926. m.SetUserID(v)
  5927. return nil
  5928. case chatrecords.FieldBotID:
  5929. v, ok := value.(uint64)
  5930. if !ok {
  5931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5932. }
  5933. m.SetBotID(v)
  5934. return nil
  5935. case chatrecords.FieldBotType:
  5936. v, ok := value.(uint8)
  5937. if !ok {
  5938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5939. }
  5940. m.SetBotType(v)
  5941. return nil
  5942. }
  5943. return fmt.Errorf("unknown ChatRecords field %s", name)
  5944. }
  5945. // AddedFields returns all numeric fields that were incremented/decremented during
  5946. // this mutation.
  5947. func (m *ChatRecordsMutation) AddedFields() []string {
  5948. var fields []string
  5949. if m.addcontent_type != nil {
  5950. fields = append(fields, chatrecords.FieldContentType)
  5951. }
  5952. if m.addsession_id != nil {
  5953. fields = append(fields, chatrecords.FieldSessionID)
  5954. }
  5955. if m.adduser_id != nil {
  5956. fields = append(fields, chatrecords.FieldUserID)
  5957. }
  5958. if m.addbot_id != nil {
  5959. fields = append(fields, chatrecords.FieldBotID)
  5960. }
  5961. if m.addbot_type != nil {
  5962. fields = append(fields, chatrecords.FieldBotType)
  5963. }
  5964. return fields
  5965. }
  5966. // AddedField returns the numeric value that was incremented/decremented on a field
  5967. // with the given name. The second boolean return value indicates that this field
  5968. // was not set, or was not defined in the schema.
  5969. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  5970. switch name {
  5971. case chatrecords.FieldContentType:
  5972. return m.AddedContentType()
  5973. case chatrecords.FieldSessionID:
  5974. return m.AddedSessionID()
  5975. case chatrecords.FieldUserID:
  5976. return m.AddedUserID()
  5977. case chatrecords.FieldBotID:
  5978. return m.AddedBotID()
  5979. case chatrecords.FieldBotType:
  5980. return m.AddedBotType()
  5981. }
  5982. return nil, false
  5983. }
  5984. // AddField adds the value to the field with the given name. It returns an error if
  5985. // the field is not defined in the schema, or if the type mismatched the field
  5986. // type.
  5987. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  5988. switch name {
  5989. case chatrecords.FieldContentType:
  5990. v, ok := value.(int8)
  5991. if !ok {
  5992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5993. }
  5994. m.AddContentType(v)
  5995. return nil
  5996. case chatrecords.FieldSessionID:
  5997. v, ok := value.(int64)
  5998. if !ok {
  5999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6000. }
  6001. m.AddSessionID(v)
  6002. return nil
  6003. case chatrecords.FieldUserID:
  6004. v, ok := value.(int64)
  6005. if !ok {
  6006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6007. }
  6008. m.AddUserID(v)
  6009. return nil
  6010. case chatrecords.FieldBotID:
  6011. v, ok := value.(int64)
  6012. if !ok {
  6013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6014. }
  6015. m.AddBotID(v)
  6016. return nil
  6017. case chatrecords.FieldBotType:
  6018. v, ok := value.(int8)
  6019. if !ok {
  6020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6021. }
  6022. m.AddBotType(v)
  6023. return nil
  6024. }
  6025. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6026. }
  6027. // ClearedFields returns all nullable fields that were cleared during this
  6028. // mutation.
  6029. func (m *ChatRecordsMutation) ClearedFields() []string {
  6030. var fields []string
  6031. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6032. fields = append(fields, chatrecords.FieldDeletedAt)
  6033. }
  6034. return fields
  6035. }
  6036. // FieldCleared returns a boolean indicating if a field with the given name was
  6037. // cleared in this mutation.
  6038. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6039. _, ok := m.clearedFields[name]
  6040. return ok
  6041. }
  6042. // ClearField clears the value of the field with the given name. It returns an
  6043. // error if the field is not defined in the schema.
  6044. func (m *ChatRecordsMutation) ClearField(name string) error {
  6045. switch name {
  6046. case chatrecords.FieldDeletedAt:
  6047. m.ClearDeletedAt()
  6048. return nil
  6049. }
  6050. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6051. }
  6052. // ResetField resets all changes in the mutation for the field with the given name.
  6053. // It returns an error if the field is not defined in the schema.
  6054. func (m *ChatRecordsMutation) ResetField(name string) error {
  6055. switch name {
  6056. case chatrecords.FieldCreatedAt:
  6057. m.ResetCreatedAt()
  6058. return nil
  6059. case chatrecords.FieldUpdatedAt:
  6060. m.ResetUpdatedAt()
  6061. return nil
  6062. case chatrecords.FieldDeletedAt:
  6063. m.ResetDeletedAt()
  6064. return nil
  6065. case chatrecords.FieldContent:
  6066. m.ResetContent()
  6067. return nil
  6068. case chatrecords.FieldContentType:
  6069. m.ResetContentType()
  6070. return nil
  6071. case chatrecords.FieldSessionID:
  6072. m.ResetSessionID()
  6073. return nil
  6074. case chatrecords.FieldUserID:
  6075. m.ResetUserID()
  6076. return nil
  6077. case chatrecords.FieldBotID:
  6078. m.ResetBotID()
  6079. return nil
  6080. case chatrecords.FieldBotType:
  6081. m.ResetBotType()
  6082. return nil
  6083. }
  6084. return fmt.Errorf("unknown ChatRecords field %s", name)
  6085. }
  6086. // AddedEdges returns all edge names that were set/added in this mutation.
  6087. func (m *ChatRecordsMutation) AddedEdges() []string {
  6088. edges := make([]string, 0, 0)
  6089. return edges
  6090. }
  6091. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6092. // name in this mutation.
  6093. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6094. return nil
  6095. }
  6096. // RemovedEdges returns all edge names that were removed in this mutation.
  6097. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6098. edges := make([]string, 0, 0)
  6099. return edges
  6100. }
  6101. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6102. // the given name in this mutation.
  6103. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6104. return nil
  6105. }
  6106. // ClearedEdges returns all edge names that were cleared in this mutation.
  6107. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6108. edges := make([]string, 0, 0)
  6109. return edges
  6110. }
  6111. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6112. // was cleared in this mutation.
  6113. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6114. return false
  6115. }
  6116. // ClearEdge clears the value of the edge with the given name. It returns an error
  6117. // if that edge is not defined in the schema.
  6118. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6119. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6120. }
  6121. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6122. // It returns an error if the edge is not defined in the schema.
  6123. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6124. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6125. }
  6126. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6127. type ChatSessionMutation struct {
  6128. config
  6129. op Op
  6130. typ string
  6131. id *uint64
  6132. created_at *time.Time
  6133. updated_at *time.Time
  6134. deleted_at *time.Time
  6135. name *string
  6136. user_id *uint64
  6137. adduser_id *int64
  6138. bot_id *uint64
  6139. addbot_id *int64
  6140. bot_type *uint8
  6141. addbot_type *int8
  6142. clearedFields map[string]struct{}
  6143. done bool
  6144. oldValue func(context.Context) (*ChatSession, error)
  6145. predicates []predicate.ChatSession
  6146. }
  6147. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6148. // chatsessionOption allows management of the mutation configuration using functional options.
  6149. type chatsessionOption func(*ChatSessionMutation)
  6150. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6151. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6152. m := &ChatSessionMutation{
  6153. config: c,
  6154. op: op,
  6155. typ: TypeChatSession,
  6156. clearedFields: make(map[string]struct{}),
  6157. }
  6158. for _, opt := range opts {
  6159. opt(m)
  6160. }
  6161. return m
  6162. }
  6163. // withChatSessionID sets the ID field of the mutation.
  6164. func withChatSessionID(id uint64) chatsessionOption {
  6165. return func(m *ChatSessionMutation) {
  6166. var (
  6167. err error
  6168. once sync.Once
  6169. value *ChatSession
  6170. )
  6171. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6172. once.Do(func() {
  6173. if m.done {
  6174. err = errors.New("querying old values post mutation is not allowed")
  6175. } else {
  6176. value, err = m.Client().ChatSession.Get(ctx, id)
  6177. }
  6178. })
  6179. return value, err
  6180. }
  6181. m.id = &id
  6182. }
  6183. }
  6184. // withChatSession sets the old ChatSession of the mutation.
  6185. func withChatSession(node *ChatSession) chatsessionOption {
  6186. return func(m *ChatSessionMutation) {
  6187. m.oldValue = func(context.Context) (*ChatSession, error) {
  6188. return node, nil
  6189. }
  6190. m.id = &node.ID
  6191. }
  6192. }
  6193. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6194. // executed in a transaction (ent.Tx), a transactional client is returned.
  6195. func (m ChatSessionMutation) Client() *Client {
  6196. client := &Client{config: m.config}
  6197. client.init()
  6198. return client
  6199. }
  6200. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6201. // it returns an error otherwise.
  6202. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6203. if _, ok := m.driver.(*txDriver); !ok {
  6204. return nil, errors.New("ent: mutation is not running in a transaction")
  6205. }
  6206. tx := &Tx{config: m.config}
  6207. tx.init()
  6208. return tx, nil
  6209. }
  6210. // SetID sets the value of the id field. Note that this
  6211. // operation is only accepted on creation of ChatSession entities.
  6212. func (m *ChatSessionMutation) SetID(id uint64) {
  6213. m.id = &id
  6214. }
  6215. // ID returns the ID value in the mutation. Note that the ID is only available
  6216. // if it was provided to the builder or after it was returned from the database.
  6217. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6218. if m.id == nil {
  6219. return
  6220. }
  6221. return *m.id, true
  6222. }
  6223. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6224. // That means, if the mutation is applied within a transaction with an isolation level such
  6225. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6226. // or updated by the mutation.
  6227. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6228. switch {
  6229. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6230. id, exists := m.ID()
  6231. if exists {
  6232. return []uint64{id}, nil
  6233. }
  6234. fallthrough
  6235. case m.op.Is(OpUpdate | OpDelete):
  6236. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  6237. default:
  6238. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6239. }
  6240. }
  6241. // SetCreatedAt sets the "created_at" field.
  6242. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  6243. m.created_at = &t
  6244. }
  6245. // CreatedAt returns the value of the "created_at" field in the mutation.
  6246. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  6247. v := m.created_at
  6248. if v == nil {
  6249. return
  6250. }
  6251. return *v, true
  6252. }
  6253. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  6254. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6256. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6257. if !m.op.Is(OpUpdateOne) {
  6258. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6259. }
  6260. if m.id == nil || m.oldValue == nil {
  6261. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6262. }
  6263. oldValue, err := m.oldValue(ctx)
  6264. if err != nil {
  6265. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6266. }
  6267. return oldValue.CreatedAt, nil
  6268. }
  6269. // ResetCreatedAt resets all changes to the "created_at" field.
  6270. func (m *ChatSessionMutation) ResetCreatedAt() {
  6271. m.created_at = nil
  6272. }
  6273. // SetUpdatedAt sets the "updated_at" field.
  6274. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  6275. m.updated_at = &t
  6276. }
  6277. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6278. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  6279. v := m.updated_at
  6280. if v == nil {
  6281. return
  6282. }
  6283. return *v, true
  6284. }
  6285. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  6286. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6288. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6289. if !m.op.Is(OpUpdateOne) {
  6290. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6291. }
  6292. if m.id == nil || m.oldValue == nil {
  6293. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6294. }
  6295. oldValue, err := m.oldValue(ctx)
  6296. if err != nil {
  6297. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6298. }
  6299. return oldValue.UpdatedAt, nil
  6300. }
  6301. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6302. func (m *ChatSessionMutation) ResetUpdatedAt() {
  6303. m.updated_at = nil
  6304. }
  6305. // SetDeletedAt sets the "deleted_at" field.
  6306. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  6307. m.deleted_at = &t
  6308. }
  6309. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6310. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  6311. v := m.deleted_at
  6312. if v == nil {
  6313. return
  6314. }
  6315. return *v, true
  6316. }
  6317. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  6318. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6320. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6321. if !m.op.Is(OpUpdateOne) {
  6322. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6323. }
  6324. if m.id == nil || m.oldValue == nil {
  6325. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6326. }
  6327. oldValue, err := m.oldValue(ctx)
  6328. if err != nil {
  6329. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6330. }
  6331. return oldValue.DeletedAt, nil
  6332. }
  6333. // ClearDeletedAt clears the value of the "deleted_at" field.
  6334. func (m *ChatSessionMutation) ClearDeletedAt() {
  6335. m.deleted_at = nil
  6336. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  6337. }
  6338. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6339. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  6340. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  6341. return ok
  6342. }
  6343. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6344. func (m *ChatSessionMutation) ResetDeletedAt() {
  6345. m.deleted_at = nil
  6346. delete(m.clearedFields, chatsession.FieldDeletedAt)
  6347. }
  6348. // SetName sets the "name" field.
  6349. func (m *ChatSessionMutation) SetName(s string) {
  6350. m.name = &s
  6351. }
  6352. // Name returns the value of the "name" field in the mutation.
  6353. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  6354. v := m.name
  6355. if v == nil {
  6356. return
  6357. }
  6358. return *v, true
  6359. }
  6360. // OldName returns the old "name" field's value of the ChatSession entity.
  6361. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6363. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  6364. if !m.op.Is(OpUpdateOne) {
  6365. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6366. }
  6367. if m.id == nil || m.oldValue == nil {
  6368. return v, errors.New("OldName requires an ID field in the mutation")
  6369. }
  6370. oldValue, err := m.oldValue(ctx)
  6371. if err != nil {
  6372. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6373. }
  6374. return oldValue.Name, nil
  6375. }
  6376. // ResetName resets all changes to the "name" field.
  6377. func (m *ChatSessionMutation) ResetName() {
  6378. m.name = nil
  6379. }
  6380. // SetUserID sets the "user_id" field.
  6381. func (m *ChatSessionMutation) SetUserID(u uint64) {
  6382. m.user_id = &u
  6383. m.adduser_id = nil
  6384. }
  6385. // UserID returns the value of the "user_id" field in the mutation.
  6386. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  6387. v := m.user_id
  6388. if v == nil {
  6389. return
  6390. }
  6391. return *v, true
  6392. }
  6393. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  6394. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6396. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6397. if !m.op.Is(OpUpdateOne) {
  6398. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6399. }
  6400. if m.id == nil || m.oldValue == nil {
  6401. return v, errors.New("OldUserID requires an ID field in the mutation")
  6402. }
  6403. oldValue, err := m.oldValue(ctx)
  6404. if err != nil {
  6405. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6406. }
  6407. return oldValue.UserID, nil
  6408. }
  6409. // AddUserID adds u to the "user_id" field.
  6410. func (m *ChatSessionMutation) AddUserID(u int64) {
  6411. if m.adduser_id != nil {
  6412. *m.adduser_id += u
  6413. } else {
  6414. m.adduser_id = &u
  6415. }
  6416. }
  6417. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6418. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  6419. v := m.adduser_id
  6420. if v == nil {
  6421. return
  6422. }
  6423. return *v, true
  6424. }
  6425. // ResetUserID resets all changes to the "user_id" field.
  6426. func (m *ChatSessionMutation) ResetUserID() {
  6427. m.user_id = nil
  6428. m.adduser_id = nil
  6429. }
  6430. // SetBotID sets the "bot_id" field.
  6431. func (m *ChatSessionMutation) SetBotID(u uint64) {
  6432. m.bot_id = &u
  6433. m.addbot_id = nil
  6434. }
  6435. // BotID returns the value of the "bot_id" field in the mutation.
  6436. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  6437. v := m.bot_id
  6438. if v == nil {
  6439. return
  6440. }
  6441. return *v, true
  6442. }
  6443. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  6444. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6446. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6447. if !m.op.Is(OpUpdateOne) {
  6448. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6449. }
  6450. if m.id == nil || m.oldValue == nil {
  6451. return v, errors.New("OldBotID requires an ID field in the mutation")
  6452. }
  6453. oldValue, err := m.oldValue(ctx)
  6454. if err != nil {
  6455. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6456. }
  6457. return oldValue.BotID, nil
  6458. }
  6459. // AddBotID adds u to the "bot_id" field.
  6460. func (m *ChatSessionMutation) AddBotID(u int64) {
  6461. if m.addbot_id != nil {
  6462. *m.addbot_id += u
  6463. } else {
  6464. m.addbot_id = &u
  6465. }
  6466. }
  6467. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6468. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  6469. v := m.addbot_id
  6470. if v == nil {
  6471. return
  6472. }
  6473. return *v, true
  6474. }
  6475. // ResetBotID resets all changes to the "bot_id" field.
  6476. func (m *ChatSessionMutation) ResetBotID() {
  6477. m.bot_id = nil
  6478. m.addbot_id = nil
  6479. }
  6480. // SetBotType sets the "bot_type" field.
  6481. func (m *ChatSessionMutation) SetBotType(u uint8) {
  6482. m.bot_type = &u
  6483. m.addbot_type = nil
  6484. }
  6485. // BotType returns the value of the "bot_type" field in the mutation.
  6486. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  6487. v := m.bot_type
  6488. if v == nil {
  6489. return
  6490. }
  6491. return *v, true
  6492. }
  6493. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  6494. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6496. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6497. if !m.op.Is(OpUpdateOne) {
  6498. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6499. }
  6500. if m.id == nil || m.oldValue == nil {
  6501. return v, errors.New("OldBotType requires an ID field in the mutation")
  6502. }
  6503. oldValue, err := m.oldValue(ctx)
  6504. if err != nil {
  6505. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6506. }
  6507. return oldValue.BotType, nil
  6508. }
  6509. // AddBotType adds u to the "bot_type" field.
  6510. func (m *ChatSessionMutation) AddBotType(u int8) {
  6511. if m.addbot_type != nil {
  6512. *m.addbot_type += u
  6513. } else {
  6514. m.addbot_type = &u
  6515. }
  6516. }
  6517. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6518. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  6519. v := m.addbot_type
  6520. if v == nil {
  6521. return
  6522. }
  6523. return *v, true
  6524. }
  6525. // ResetBotType resets all changes to the "bot_type" field.
  6526. func (m *ChatSessionMutation) ResetBotType() {
  6527. m.bot_type = nil
  6528. m.addbot_type = nil
  6529. }
  6530. // Where appends a list predicates to the ChatSessionMutation builder.
  6531. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  6532. m.predicates = append(m.predicates, ps...)
  6533. }
  6534. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  6535. // users can use type-assertion to append predicates that do not depend on any generated package.
  6536. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  6537. p := make([]predicate.ChatSession, len(ps))
  6538. for i := range ps {
  6539. p[i] = ps[i]
  6540. }
  6541. m.Where(p...)
  6542. }
  6543. // Op returns the operation name.
  6544. func (m *ChatSessionMutation) Op() Op {
  6545. return m.op
  6546. }
  6547. // SetOp allows setting the mutation operation.
  6548. func (m *ChatSessionMutation) SetOp(op Op) {
  6549. m.op = op
  6550. }
  6551. // Type returns the node type of this mutation (ChatSession).
  6552. func (m *ChatSessionMutation) Type() string {
  6553. return m.typ
  6554. }
  6555. // Fields returns all fields that were changed during this mutation. Note that in
  6556. // order to get all numeric fields that were incremented/decremented, call
  6557. // AddedFields().
  6558. func (m *ChatSessionMutation) Fields() []string {
  6559. fields := make([]string, 0, 7)
  6560. if m.created_at != nil {
  6561. fields = append(fields, chatsession.FieldCreatedAt)
  6562. }
  6563. if m.updated_at != nil {
  6564. fields = append(fields, chatsession.FieldUpdatedAt)
  6565. }
  6566. if m.deleted_at != nil {
  6567. fields = append(fields, chatsession.FieldDeletedAt)
  6568. }
  6569. if m.name != nil {
  6570. fields = append(fields, chatsession.FieldName)
  6571. }
  6572. if m.user_id != nil {
  6573. fields = append(fields, chatsession.FieldUserID)
  6574. }
  6575. if m.bot_id != nil {
  6576. fields = append(fields, chatsession.FieldBotID)
  6577. }
  6578. if m.bot_type != nil {
  6579. fields = append(fields, chatsession.FieldBotType)
  6580. }
  6581. return fields
  6582. }
  6583. // Field returns the value of a field with the given name. The second boolean
  6584. // return value indicates that this field was not set, or was not defined in the
  6585. // schema.
  6586. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  6587. switch name {
  6588. case chatsession.FieldCreatedAt:
  6589. return m.CreatedAt()
  6590. case chatsession.FieldUpdatedAt:
  6591. return m.UpdatedAt()
  6592. case chatsession.FieldDeletedAt:
  6593. return m.DeletedAt()
  6594. case chatsession.FieldName:
  6595. return m.Name()
  6596. case chatsession.FieldUserID:
  6597. return m.UserID()
  6598. case chatsession.FieldBotID:
  6599. return m.BotID()
  6600. case chatsession.FieldBotType:
  6601. return m.BotType()
  6602. }
  6603. return nil, false
  6604. }
  6605. // OldField returns the old value of the field from the database. An error is
  6606. // returned if the mutation operation is not UpdateOne, or the query to the
  6607. // database failed.
  6608. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6609. switch name {
  6610. case chatsession.FieldCreatedAt:
  6611. return m.OldCreatedAt(ctx)
  6612. case chatsession.FieldUpdatedAt:
  6613. return m.OldUpdatedAt(ctx)
  6614. case chatsession.FieldDeletedAt:
  6615. return m.OldDeletedAt(ctx)
  6616. case chatsession.FieldName:
  6617. return m.OldName(ctx)
  6618. case chatsession.FieldUserID:
  6619. return m.OldUserID(ctx)
  6620. case chatsession.FieldBotID:
  6621. return m.OldBotID(ctx)
  6622. case chatsession.FieldBotType:
  6623. return m.OldBotType(ctx)
  6624. }
  6625. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  6626. }
  6627. // SetField sets the value of a field with the given name. It returns an error if
  6628. // the field is not defined in the schema, or if the type mismatched the field
  6629. // type.
  6630. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  6631. switch name {
  6632. case chatsession.FieldCreatedAt:
  6633. v, ok := value.(time.Time)
  6634. if !ok {
  6635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6636. }
  6637. m.SetCreatedAt(v)
  6638. return nil
  6639. case chatsession.FieldUpdatedAt:
  6640. v, ok := value.(time.Time)
  6641. if !ok {
  6642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6643. }
  6644. m.SetUpdatedAt(v)
  6645. return nil
  6646. case chatsession.FieldDeletedAt:
  6647. v, ok := value.(time.Time)
  6648. if !ok {
  6649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6650. }
  6651. m.SetDeletedAt(v)
  6652. return nil
  6653. case chatsession.FieldName:
  6654. v, ok := value.(string)
  6655. if !ok {
  6656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6657. }
  6658. m.SetName(v)
  6659. return nil
  6660. case chatsession.FieldUserID:
  6661. v, ok := value.(uint64)
  6662. if !ok {
  6663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6664. }
  6665. m.SetUserID(v)
  6666. return nil
  6667. case chatsession.FieldBotID:
  6668. v, ok := value.(uint64)
  6669. if !ok {
  6670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6671. }
  6672. m.SetBotID(v)
  6673. return nil
  6674. case chatsession.FieldBotType:
  6675. v, ok := value.(uint8)
  6676. if !ok {
  6677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6678. }
  6679. m.SetBotType(v)
  6680. return nil
  6681. }
  6682. return fmt.Errorf("unknown ChatSession field %s", name)
  6683. }
  6684. // AddedFields returns all numeric fields that were incremented/decremented during
  6685. // this mutation.
  6686. func (m *ChatSessionMutation) AddedFields() []string {
  6687. var fields []string
  6688. if m.adduser_id != nil {
  6689. fields = append(fields, chatsession.FieldUserID)
  6690. }
  6691. if m.addbot_id != nil {
  6692. fields = append(fields, chatsession.FieldBotID)
  6693. }
  6694. if m.addbot_type != nil {
  6695. fields = append(fields, chatsession.FieldBotType)
  6696. }
  6697. return fields
  6698. }
  6699. // AddedField returns the numeric value that was incremented/decremented on a field
  6700. // with the given name. The second boolean return value indicates that this field
  6701. // was not set, or was not defined in the schema.
  6702. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  6703. switch name {
  6704. case chatsession.FieldUserID:
  6705. return m.AddedUserID()
  6706. case chatsession.FieldBotID:
  6707. return m.AddedBotID()
  6708. case chatsession.FieldBotType:
  6709. return m.AddedBotType()
  6710. }
  6711. return nil, false
  6712. }
  6713. // AddField adds the value to the field with the given name. It returns an error if
  6714. // the field is not defined in the schema, or if the type mismatched the field
  6715. // type.
  6716. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  6717. switch name {
  6718. case chatsession.FieldUserID:
  6719. v, ok := value.(int64)
  6720. if !ok {
  6721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6722. }
  6723. m.AddUserID(v)
  6724. return nil
  6725. case chatsession.FieldBotID:
  6726. v, ok := value.(int64)
  6727. if !ok {
  6728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6729. }
  6730. m.AddBotID(v)
  6731. return nil
  6732. case chatsession.FieldBotType:
  6733. v, ok := value.(int8)
  6734. if !ok {
  6735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6736. }
  6737. m.AddBotType(v)
  6738. return nil
  6739. }
  6740. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  6741. }
  6742. // ClearedFields returns all nullable fields that were cleared during this
  6743. // mutation.
  6744. func (m *ChatSessionMutation) ClearedFields() []string {
  6745. var fields []string
  6746. if m.FieldCleared(chatsession.FieldDeletedAt) {
  6747. fields = append(fields, chatsession.FieldDeletedAt)
  6748. }
  6749. return fields
  6750. }
  6751. // FieldCleared returns a boolean indicating if a field with the given name was
  6752. // cleared in this mutation.
  6753. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  6754. _, ok := m.clearedFields[name]
  6755. return ok
  6756. }
  6757. // ClearField clears the value of the field with the given name. It returns an
  6758. // error if the field is not defined in the schema.
  6759. func (m *ChatSessionMutation) ClearField(name string) error {
  6760. switch name {
  6761. case chatsession.FieldDeletedAt:
  6762. m.ClearDeletedAt()
  6763. return nil
  6764. }
  6765. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  6766. }
  6767. // ResetField resets all changes in the mutation for the field with the given name.
  6768. // It returns an error if the field is not defined in the schema.
  6769. func (m *ChatSessionMutation) ResetField(name string) error {
  6770. switch name {
  6771. case chatsession.FieldCreatedAt:
  6772. m.ResetCreatedAt()
  6773. return nil
  6774. case chatsession.FieldUpdatedAt:
  6775. m.ResetUpdatedAt()
  6776. return nil
  6777. case chatsession.FieldDeletedAt:
  6778. m.ResetDeletedAt()
  6779. return nil
  6780. case chatsession.FieldName:
  6781. m.ResetName()
  6782. return nil
  6783. case chatsession.FieldUserID:
  6784. m.ResetUserID()
  6785. return nil
  6786. case chatsession.FieldBotID:
  6787. m.ResetBotID()
  6788. return nil
  6789. case chatsession.FieldBotType:
  6790. m.ResetBotType()
  6791. return nil
  6792. }
  6793. return fmt.Errorf("unknown ChatSession field %s", name)
  6794. }
  6795. // AddedEdges returns all edge names that were set/added in this mutation.
  6796. func (m *ChatSessionMutation) AddedEdges() []string {
  6797. edges := make([]string, 0, 0)
  6798. return edges
  6799. }
  6800. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6801. // name in this mutation.
  6802. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  6803. return nil
  6804. }
  6805. // RemovedEdges returns all edge names that were removed in this mutation.
  6806. func (m *ChatSessionMutation) RemovedEdges() []string {
  6807. edges := make([]string, 0, 0)
  6808. return edges
  6809. }
  6810. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6811. // the given name in this mutation.
  6812. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  6813. return nil
  6814. }
  6815. // ClearedEdges returns all edge names that were cleared in this mutation.
  6816. func (m *ChatSessionMutation) ClearedEdges() []string {
  6817. edges := make([]string, 0, 0)
  6818. return edges
  6819. }
  6820. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6821. // was cleared in this mutation.
  6822. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  6823. return false
  6824. }
  6825. // ClearEdge clears the value of the edge with the given name. It returns an error
  6826. // if that edge is not defined in the schema.
  6827. func (m *ChatSessionMutation) ClearEdge(name string) error {
  6828. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  6829. }
  6830. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6831. // It returns an error if the edge is not defined in the schema.
  6832. func (m *ChatSessionMutation) ResetEdge(name string) error {
  6833. return fmt.Errorf("unknown ChatSession edge %s", name)
  6834. }
  6835. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  6836. type ContactMutation struct {
  6837. config
  6838. op Op
  6839. typ string
  6840. id *uint64
  6841. created_at *time.Time
  6842. updated_at *time.Time
  6843. status *uint8
  6844. addstatus *int8
  6845. deleted_at *time.Time
  6846. wx_wxid *string
  6847. _type *int
  6848. add_type *int
  6849. wxid *string
  6850. account *string
  6851. nickname *string
  6852. markname *string
  6853. headimg *string
  6854. sex *int
  6855. addsex *int
  6856. starrole *string
  6857. dontseeit *int
  6858. adddontseeit *int
  6859. dontseeme *int
  6860. adddontseeme *int
  6861. lag *string
  6862. gid *string
  6863. gname *string
  6864. v3 *string
  6865. organization_id *uint64
  6866. addorganization_id *int64
  6867. clearedFields map[string]struct{}
  6868. contact_relationships map[uint64]struct{}
  6869. removedcontact_relationships map[uint64]struct{}
  6870. clearedcontact_relationships bool
  6871. contact_messages map[uint64]struct{}
  6872. removedcontact_messages map[uint64]struct{}
  6873. clearedcontact_messages bool
  6874. done bool
  6875. oldValue func(context.Context) (*Contact, error)
  6876. predicates []predicate.Contact
  6877. }
  6878. var _ ent.Mutation = (*ContactMutation)(nil)
  6879. // contactOption allows management of the mutation configuration using functional options.
  6880. type contactOption func(*ContactMutation)
  6881. // newContactMutation creates new mutation for the Contact entity.
  6882. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  6883. m := &ContactMutation{
  6884. config: c,
  6885. op: op,
  6886. typ: TypeContact,
  6887. clearedFields: make(map[string]struct{}),
  6888. }
  6889. for _, opt := range opts {
  6890. opt(m)
  6891. }
  6892. return m
  6893. }
  6894. // withContactID sets the ID field of the mutation.
  6895. func withContactID(id uint64) contactOption {
  6896. return func(m *ContactMutation) {
  6897. var (
  6898. err error
  6899. once sync.Once
  6900. value *Contact
  6901. )
  6902. m.oldValue = func(ctx context.Context) (*Contact, error) {
  6903. once.Do(func() {
  6904. if m.done {
  6905. err = errors.New("querying old values post mutation is not allowed")
  6906. } else {
  6907. value, err = m.Client().Contact.Get(ctx, id)
  6908. }
  6909. })
  6910. return value, err
  6911. }
  6912. m.id = &id
  6913. }
  6914. }
  6915. // withContact sets the old Contact of the mutation.
  6916. func withContact(node *Contact) contactOption {
  6917. return func(m *ContactMutation) {
  6918. m.oldValue = func(context.Context) (*Contact, error) {
  6919. return node, nil
  6920. }
  6921. m.id = &node.ID
  6922. }
  6923. }
  6924. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6925. // executed in a transaction (ent.Tx), a transactional client is returned.
  6926. func (m ContactMutation) Client() *Client {
  6927. client := &Client{config: m.config}
  6928. client.init()
  6929. return client
  6930. }
  6931. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6932. // it returns an error otherwise.
  6933. func (m ContactMutation) Tx() (*Tx, error) {
  6934. if _, ok := m.driver.(*txDriver); !ok {
  6935. return nil, errors.New("ent: mutation is not running in a transaction")
  6936. }
  6937. tx := &Tx{config: m.config}
  6938. tx.init()
  6939. return tx, nil
  6940. }
  6941. // SetID sets the value of the id field. Note that this
  6942. // operation is only accepted on creation of Contact entities.
  6943. func (m *ContactMutation) SetID(id uint64) {
  6944. m.id = &id
  6945. }
  6946. // ID returns the ID value in the mutation. Note that the ID is only available
  6947. // if it was provided to the builder or after it was returned from the database.
  6948. func (m *ContactMutation) ID() (id uint64, exists bool) {
  6949. if m.id == nil {
  6950. return
  6951. }
  6952. return *m.id, true
  6953. }
  6954. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6955. // That means, if the mutation is applied within a transaction with an isolation level such
  6956. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6957. // or updated by the mutation.
  6958. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  6959. switch {
  6960. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6961. id, exists := m.ID()
  6962. if exists {
  6963. return []uint64{id}, nil
  6964. }
  6965. fallthrough
  6966. case m.op.Is(OpUpdate | OpDelete):
  6967. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  6968. default:
  6969. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6970. }
  6971. }
  6972. // SetCreatedAt sets the "created_at" field.
  6973. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  6974. m.created_at = &t
  6975. }
  6976. // CreatedAt returns the value of the "created_at" field in the mutation.
  6977. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  6978. v := m.created_at
  6979. if v == nil {
  6980. return
  6981. }
  6982. return *v, true
  6983. }
  6984. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  6985. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6987. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6988. if !m.op.Is(OpUpdateOne) {
  6989. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6990. }
  6991. if m.id == nil || m.oldValue == nil {
  6992. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6993. }
  6994. oldValue, err := m.oldValue(ctx)
  6995. if err != nil {
  6996. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6997. }
  6998. return oldValue.CreatedAt, nil
  6999. }
  7000. // ResetCreatedAt resets all changes to the "created_at" field.
  7001. func (m *ContactMutation) ResetCreatedAt() {
  7002. m.created_at = nil
  7003. }
  7004. // SetUpdatedAt sets the "updated_at" field.
  7005. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7006. m.updated_at = &t
  7007. }
  7008. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7009. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7010. v := m.updated_at
  7011. if v == nil {
  7012. return
  7013. }
  7014. return *v, true
  7015. }
  7016. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7017. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7019. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7020. if !m.op.Is(OpUpdateOne) {
  7021. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7022. }
  7023. if m.id == nil || m.oldValue == nil {
  7024. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7025. }
  7026. oldValue, err := m.oldValue(ctx)
  7027. if err != nil {
  7028. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7029. }
  7030. return oldValue.UpdatedAt, nil
  7031. }
  7032. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7033. func (m *ContactMutation) ResetUpdatedAt() {
  7034. m.updated_at = nil
  7035. }
  7036. // SetStatus sets the "status" field.
  7037. func (m *ContactMutation) SetStatus(u uint8) {
  7038. m.status = &u
  7039. m.addstatus = nil
  7040. }
  7041. // Status returns the value of the "status" field in the mutation.
  7042. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7043. v := m.status
  7044. if v == nil {
  7045. return
  7046. }
  7047. return *v, true
  7048. }
  7049. // OldStatus returns the old "status" field's value of the Contact entity.
  7050. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7052. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7053. if !m.op.Is(OpUpdateOne) {
  7054. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7055. }
  7056. if m.id == nil || m.oldValue == nil {
  7057. return v, errors.New("OldStatus requires an ID field in the mutation")
  7058. }
  7059. oldValue, err := m.oldValue(ctx)
  7060. if err != nil {
  7061. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7062. }
  7063. return oldValue.Status, nil
  7064. }
  7065. // AddStatus adds u to the "status" field.
  7066. func (m *ContactMutation) AddStatus(u int8) {
  7067. if m.addstatus != nil {
  7068. *m.addstatus += u
  7069. } else {
  7070. m.addstatus = &u
  7071. }
  7072. }
  7073. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7074. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7075. v := m.addstatus
  7076. if v == nil {
  7077. return
  7078. }
  7079. return *v, true
  7080. }
  7081. // ClearStatus clears the value of the "status" field.
  7082. func (m *ContactMutation) ClearStatus() {
  7083. m.status = nil
  7084. m.addstatus = nil
  7085. m.clearedFields[contact.FieldStatus] = struct{}{}
  7086. }
  7087. // StatusCleared returns if the "status" field was cleared in this mutation.
  7088. func (m *ContactMutation) StatusCleared() bool {
  7089. _, ok := m.clearedFields[contact.FieldStatus]
  7090. return ok
  7091. }
  7092. // ResetStatus resets all changes to the "status" field.
  7093. func (m *ContactMutation) ResetStatus() {
  7094. m.status = nil
  7095. m.addstatus = nil
  7096. delete(m.clearedFields, contact.FieldStatus)
  7097. }
  7098. // SetDeletedAt sets the "deleted_at" field.
  7099. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7100. m.deleted_at = &t
  7101. }
  7102. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7103. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7104. v := m.deleted_at
  7105. if v == nil {
  7106. return
  7107. }
  7108. return *v, true
  7109. }
  7110. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7111. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7113. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7114. if !m.op.Is(OpUpdateOne) {
  7115. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7116. }
  7117. if m.id == nil || m.oldValue == nil {
  7118. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7119. }
  7120. oldValue, err := m.oldValue(ctx)
  7121. if err != nil {
  7122. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7123. }
  7124. return oldValue.DeletedAt, nil
  7125. }
  7126. // ClearDeletedAt clears the value of the "deleted_at" field.
  7127. func (m *ContactMutation) ClearDeletedAt() {
  7128. m.deleted_at = nil
  7129. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7130. }
  7131. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7132. func (m *ContactMutation) DeletedAtCleared() bool {
  7133. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7134. return ok
  7135. }
  7136. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7137. func (m *ContactMutation) ResetDeletedAt() {
  7138. m.deleted_at = nil
  7139. delete(m.clearedFields, contact.FieldDeletedAt)
  7140. }
  7141. // SetWxWxid sets the "wx_wxid" field.
  7142. func (m *ContactMutation) SetWxWxid(s string) {
  7143. m.wx_wxid = &s
  7144. }
  7145. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7146. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7147. v := m.wx_wxid
  7148. if v == nil {
  7149. return
  7150. }
  7151. return *v, true
  7152. }
  7153. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7154. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7156. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7157. if !m.op.Is(OpUpdateOne) {
  7158. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7159. }
  7160. if m.id == nil || m.oldValue == nil {
  7161. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7162. }
  7163. oldValue, err := m.oldValue(ctx)
  7164. if err != nil {
  7165. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7166. }
  7167. return oldValue.WxWxid, nil
  7168. }
  7169. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7170. func (m *ContactMutation) ResetWxWxid() {
  7171. m.wx_wxid = nil
  7172. }
  7173. // SetType sets the "type" field.
  7174. func (m *ContactMutation) SetType(i int) {
  7175. m._type = &i
  7176. m.add_type = nil
  7177. }
  7178. // GetType returns the value of the "type" field in the mutation.
  7179. func (m *ContactMutation) GetType() (r int, exists bool) {
  7180. v := m._type
  7181. if v == nil {
  7182. return
  7183. }
  7184. return *v, true
  7185. }
  7186. // OldType returns the old "type" field's value of the Contact entity.
  7187. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7189. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7190. if !m.op.Is(OpUpdateOne) {
  7191. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7192. }
  7193. if m.id == nil || m.oldValue == nil {
  7194. return v, errors.New("OldType requires an ID field in the mutation")
  7195. }
  7196. oldValue, err := m.oldValue(ctx)
  7197. if err != nil {
  7198. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7199. }
  7200. return oldValue.Type, nil
  7201. }
  7202. // AddType adds i to the "type" field.
  7203. func (m *ContactMutation) AddType(i int) {
  7204. if m.add_type != nil {
  7205. *m.add_type += i
  7206. } else {
  7207. m.add_type = &i
  7208. }
  7209. }
  7210. // AddedType returns the value that was added to the "type" field in this mutation.
  7211. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7212. v := m.add_type
  7213. if v == nil {
  7214. return
  7215. }
  7216. return *v, true
  7217. }
  7218. // ClearType clears the value of the "type" field.
  7219. func (m *ContactMutation) ClearType() {
  7220. m._type = nil
  7221. m.add_type = nil
  7222. m.clearedFields[contact.FieldType] = struct{}{}
  7223. }
  7224. // TypeCleared returns if the "type" field was cleared in this mutation.
  7225. func (m *ContactMutation) TypeCleared() bool {
  7226. _, ok := m.clearedFields[contact.FieldType]
  7227. return ok
  7228. }
  7229. // ResetType resets all changes to the "type" field.
  7230. func (m *ContactMutation) ResetType() {
  7231. m._type = nil
  7232. m.add_type = nil
  7233. delete(m.clearedFields, contact.FieldType)
  7234. }
  7235. // SetWxid sets the "wxid" field.
  7236. func (m *ContactMutation) SetWxid(s string) {
  7237. m.wxid = &s
  7238. }
  7239. // Wxid returns the value of the "wxid" field in the mutation.
  7240. func (m *ContactMutation) Wxid() (r string, exists bool) {
  7241. v := m.wxid
  7242. if v == nil {
  7243. return
  7244. }
  7245. return *v, true
  7246. }
  7247. // OldWxid returns the old "wxid" field's value of the Contact entity.
  7248. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7250. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  7251. if !m.op.Is(OpUpdateOne) {
  7252. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  7253. }
  7254. if m.id == nil || m.oldValue == nil {
  7255. return v, errors.New("OldWxid requires an ID field in the mutation")
  7256. }
  7257. oldValue, err := m.oldValue(ctx)
  7258. if err != nil {
  7259. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  7260. }
  7261. return oldValue.Wxid, nil
  7262. }
  7263. // ResetWxid resets all changes to the "wxid" field.
  7264. func (m *ContactMutation) ResetWxid() {
  7265. m.wxid = nil
  7266. }
  7267. // SetAccount sets the "account" field.
  7268. func (m *ContactMutation) SetAccount(s string) {
  7269. m.account = &s
  7270. }
  7271. // Account returns the value of the "account" field in the mutation.
  7272. func (m *ContactMutation) Account() (r string, exists bool) {
  7273. v := m.account
  7274. if v == nil {
  7275. return
  7276. }
  7277. return *v, true
  7278. }
  7279. // OldAccount returns the old "account" field's value of the Contact entity.
  7280. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7282. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  7283. if !m.op.Is(OpUpdateOne) {
  7284. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  7285. }
  7286. if m.id == nil || m.oldValue == nil {
  7287. return v, errors.New("OldAccount requires an ID field in the mutation")
  7288. }
  7289. oldValue, err := m.oldValue(ctx)
  7290. if err != nil {
  7291. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  7292. }
  7293. return oldValue.Account, nil
  7294. }
  7295. // ResetAccount resets all changes to the "account" field.
  7296. func (m *ContactMutation) ResetAccount() {
  7297. m.account = nil
  7298. }
  7299. // SetNickname sets the "nickname" field.
  7300. func (m *ContactMutation) SetNickname(s string) {
  7301. m.nickname = &s
  7302. }
  7303. // Nickname returns the value of the "nickname" field in the mutation.
  7304. func (m *ContactMutation) Nickname() (r string, exists bool) {
  7305. v := m.nickname
  7306. if v == nil {
  7307. return
  7308. }
  7309. return *v, true
  7310. }
  7311. // OldNickname returns the old "nickname" field's value of the Contact entity.
  7312. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7314. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  7315. if !m.op.Is(OpUpdateOne) {
  7316. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  7317. }
  7318. if m.id == nil || m.oldValue == nil {
  7319. return v, errors.New("OldNickname requires an ID field in the mutation")
  7320. }
  7321. oldValue, err := m.oldValue(ctx)
  7322. if err != nil {
  7323. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  7324. }
  7325. return oldValue.Nickname, nil
  7326. }
  7327. // ResetNickname resets all changes to the "nickname" field.
  7328. func (m *ContactMutation) ResetNickname() {
  7329. m.nickname = nil
  7330. }
  7331. // SetMarkname sets the "markname" field.
  7332. func (m *ContactMutation) SetMarkname(s string) {
  7333. m.markname = &s
  7334. }
  7335. // Markname returns the value of the "markname" field in the mutation.
  7336. func (m *ContactMutation) Markname() (r string, exists bool) {
  7337. v := m.markname
  7338. if v == nil {
  7339. return
  7340. }
  7341. return *v, true
  7342. }
  7343. // OldMarkname returns the old "markname" field's value of the Contact entity.
  7344. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7346. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  7347. if !m.op.Is(OpUpdateOne) {
  7348. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  7349. }
  7350. if m.id == nil || m.oldValue == nil {
  7351. return v, errors.New("OldMarkname requires an ID field in the mutation")
  7352. }
  7353. oldValue, err := m.oldValue(ctx)
  7354. if err != nil {
  7355. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  7356. }
  7357. return oldValue.Markname, nil
  7358. }
  7359. // ResetMarkname resets all changes to the "markname" field.
  7360. func (m *ContactMutation) ResetMarkname() {
  7361. m.markname = nil
  7362. }
  7363. // SetHeadimg sets the "headimg" field.
  7364. func (m *ContactMutation) SetHeadimg(s string) {
  7365. m.headimg = &s
  7366. }
  7367. // Headimg returns the value of the "headimg" field in the mutation.
  7368. func (m *ContactMutation) Headimg() (r string, exists bool) {
  7369. v := m.headimg
  7370. if v == nil {
  7371. return
  7372. }
  7373. return *v, true
  7374. }
  7375. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  7376. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7378. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  7379. if !m.op.Is(OpUpdateOne) {
  7380. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  7381. }
  7382. if m.id == nil || m.oldValue == nil {
  7383. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  7384. }
  7385. oldValue, err := m.oldValue(ctx)
  7386. if err != nil {
  7387. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  7388. }
  7389. return oldValue.Headimg, nil
  7390. }
  7391. // ResetHeadimg resets all changes to the "headimg" field.
  7392. func (m *ContactMutation) ResetHeadimg() {
  7393. m.headimg = nil
  7394. }
  7395. // SetSex sets the "sex" field.
  7396. func (m *ContactMutation) SetSex(i int) {
  7397. m.sex = &i
  7398. m.addsex = nil
  7399. }
  7400. // Sex returns the value of the "sex" field in the mutation.
  7401. func (m *ContactMutation) Sex() (r int, exists bool) {
  7402. v := m.sex
  7403. if v == nil {
  7404. return
  7405. }
  7406. return *v, true
  7407. }
  7408. // OldSex returns the old "sex" field's value of the Contact entity.
  7409. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7411. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  7412. if !m.op.Is(OpUpdateOne) {
  7413. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  7414. }
  7415. if m.id == nil || m.oldValue == nil {
  7416. return v, errors.New("OldSex requires an ID field in the mutation")
  7417. }
  7418. oldValue, err := m.oldValue(ctx)
  7419. if err != nil {
  7420. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  7421. }
  7422. return oldValue.Sex, nil
  7423. }
  7424. // AddSex adds i to the "sex" field.
  7425. func (m *ContactMutation) AddSex(i int) {
  7426. if m.addsex != nil {
  7427. *m.addsex += i
  7428. } else {
  7429. m.addsex = &i
  7430. }
  7431. }
  7432. // AddedSex returns the value that was added to the "sex" field in this mutation.
  7433. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  7434. v := m.addsex
  7435. if v == nil {
  7436. return
  7437. }
  7438. return *v, true
  7439. }
  7440. // ResetSex resets all changes to the "sex" field.
  7441. func (m *ContactMutation) ResetSex() {
  7442. m.sex = nil
  7443. m.addsex = nil
  7444. }
  7445. // SetStarrole sets the "starrole" field.
  7446. func (m *ContactMutation) SetStarrole(s string) {
  7447. m.starrole = &s
  7448. }
  7449. // Starrole returns the value of the "starrole" field in the mutation.
  7450. func (m *ContactMutation) Starrole() (r string, exists bool) {
  7451. v := m.starrole
  7452. if v == nil {
  7453. return
  7454. }
  7455. return *v, true
  7456. }
  7457. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  7458. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7460. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  7461. if !m.op.Is(OpUpdateOne) {
  7462. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  7463. }
  7464. if m.id == nil || m.oldValue == nil {
  7465. return v, errors.New("OldStarrole requires an ID field in the mutation")
  7466. }
  7467. oldValue, err := m.oldValue(ctx)
  7468. if err != nil {
  7469. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  7470. }
  7471. return oldValue.Starrole, nil
  7472. }
  7473. // ResetStarrole resets all changes to the "starrole" field.
  7474. func (m *ContactMutation) ResetStarrole() {
  7475. m.starrole = nil
  7476. }
  7477. // SetDontseeit sets the "dontseeit" field.
  7478. func (m *ContactMutation) SetDontseeit(i int) {
  7479. m.dontseeit = &i
  7480. m.adddontseeit = nil
  7481. }
  7482. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  7483. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  7484. v := m.dontseeit
  7485. if v == nil {
  7486. return
  7487. }
  7488. return *v, true
  7489. }
  7490. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  7491. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7493. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  7494. if !m.op.Is(OpUpdateOne) {
  7495. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  7496. }
  7497. if m.id == nil || m.oldValue == nil {
  7498. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  7499. }
  7500. oldValue, err := m.oldValue(ctx)
  7501. if err != nil {
  7502. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  7503. }
  7504. return oldValue.Dontseeit, nil
  7505. }
  7506. // AddDontseeit adds i to the "dontseeit" field.
  7507. func (m *ContactMutation) AddDontseeit(i int) {
  7508. if m.adddontseeit != nil {
  7509. *m.adddontseeit += i
  7510. } else {
  7511. m.adddontseeit = &i
  7512. }
  7513. }
  7514. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  7515. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  7516. v := m.adddontseeit
  7517. if v == nil {
  7518. return
  7519. }
  7520. return *v, true
  7521. }
  7522. // ResetDontseeit resets all changes to the "dontseeit" field.
  7523. func (m *ContactMutation) ResetDontseeit() {
  7524. m.dontseeit = nil
  7525. m.adddontseeit = nil
  7526. }
  7527. // SetDontseeme sets the "dontseeme" field.
  7528. func (m *ContactMutation) SetDontseeme(i int) {
  7529. m.dontseeme = &i
  7530. m.adddontseeme = nil
  7531. }
  7532. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  7533. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  7534. v := m.dontseeme
  7535. if v == nil {
  7536. return
  7537. }
  7538. return *v, true
  7539. }
  7540. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  7541. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7543. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  7544. if !m.op.Is(OpUpdateOne) {
  7545. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  7546. }
  7547. if m.id == nil || m.oldValue == nil {
  7548. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  7549. }
  7550. oldValue, err := m.oldValue(ctx)
  7551. if err != nil {
  7552. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  7553. }
  7554. return oldValue.Dontseeme, nil
  7555. }
  7556. // AddDontseeme adds i to the "dontseeme" field.
  7557. func (m *ContactMutation) AddDontseeme(i int) {
  7558. if m.adddontseeme != nil {
  7559. *m.adddontseeme += i
  7560. } else {
  7561. m.adddontseeme = &i
  7562. }
  7563. }
  7564. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  7565. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  7566. v := m.adddontseeme
  7567. if v == nil {
  7568. return
  7569. }
  7570. return *v, true
  7571. }
  7572. // ResetDontseeme resets all changes to the "dontseeme" field.
  7573. func (m *ContactMutation) ResetDontseeme() {
  7574. m.dontseeme = nil
  7575. m.adddontseeme = nil
  7576. }
  7577. // SetLag sets the "lag" field.
  7578. func (m *ContactMutation) SetLag(s string) {
  7579. m.lag = &s
  7580. }
  7581. // Lag returns the value of the "lag" field in the mutation.
  7582. func (m *ContactMutation) Lag() (r string, exists bool) {
  7583. v := m.lag
  7584. if v == nil {
  7585. return
  7586. }
  7587. return *v, true
  7588. }
  7589. // OldLag returns the old "lag" field's value of the Contact entity.
  7590. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7592. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  7593. if !m.op.Is(OpUpdateOne) {
  7594. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  7595. }
  7596. if m.id == nil || m.oldValue == nil {
  7597. return v, errors.New("OldLag requires an ID field in the mutation")
  7598. }
  7599. oldValue, err := m.oldValue(ctx)
  7600. if err != nil {
  7601. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  7602. }
  7603. return oldValue.Lag, nil
  7604. }
  7605. // ResetLag resets all changes to the "lag" field.
  7606. func (m *ContactMutation) ResetLag() {
  7607. m.lag = nil
  7608. }
  7609. // SetGid sets the "gid" field.
  7610. func (m *ContactMutation) SetGid(s string) {
  7611. m.gid = &s
  7612. }
  7613. // Gid returns the value of the "gid" field in the mutation.
  7614. func (m *ContactMutation) Gid() (r string, exists bool) {
  7615. v := m.gid
  7616. if v == nil {
  7617. return
  7618. }
  7619. return *v, true
  7620. }
  7621. // OldGid returns the old "gid" field's value of the Contact entity.
  7622. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7624. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  7625. if !m.op.Is(OpUpdateOne) {
  7626. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  7627. }
  7628. if m.id == nil || m.oldValue == nil {
  7629. return v, errors.New("OldGid requires an ID field in the mutation")
  7630. }
  7631. oldValue, err := m.oldValue(ctx)
  7632. if err != nil {
  7633. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  7634. }
  7635. return oldValue.Gid, nil
  7636. }
  7637. // ResetGid resets all changes to the "gid" field.
  7638. func (m *ContactMutation) ResetGid() {
  7639. m.gid = nil
  7640. }
  7641. // SetGname sets the "gname" field.
  7642. func (m *ContactMutation) SetGname(s string) {
  7643. m.gname = &s
  7644. }
  7645. // Gname returns the value of the "gname" field in the mutation.
  7646. func (m *ContactMutation) Gname() (r string, exists bool) {
  7647. v := m.gname
  7648. if v == nil {
  7649. return
  7650. }
  7651. return *v, true
  7652. }
  7653. // OldGname returns the old "gname" field's value of the Contact entity.
  7654. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7656. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  7657. if !m.op.Is(OpUpdateOne) {
  7658. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  7659. }
  7660. if m.id == nil || m.oldValue == nil {
  7661. return v, errors.New("OldGname requires an ID field in the mutation")
  7662. }
  7663. oldValue, err := m.oldValue(ctx)
  7664. if err != nil {
  7665. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  7666. }
  7667. return oldValue.Gname, nil
  7668. }
  7669. // ResetGname resets all changes to the "gname" field.
  7670. func (m *ContactMutation) ResetGname() {
  7671. m.gname = nil
  7672. }
  7673. // SetV3 sets the "v3" field.
  7674. func (m *ContactMutation) SetV3(s string) {
  7675. m.v3 = &s
  7676. }
  7677. // V3 returns the value of the "v3" field in the mutation.
  7678. func (m *ContactMutation) V3() (r string, exists bool) {
  7679. v := m.v3
  7680. if v == nil {
  7681. return
  7682. }
  7683. return *v, true
  7684. }
  7685. // OldV3 returns the old "v3" field's value of the Contact entity.
  7686. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7688. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  7689. if !m.op.Is(OpUpdateOne) {
  7690. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  7691. }
  7692. if m.id == nil || m.oldValue == nil {
  7693. return v, errors.New("OldV3 requires an ID field in the mutation")
  7694. }
  7695. oldValue, err := m.oldValue(ctx)
  7696. if err != nil {
  7697. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  7698. }
  7699. return oldValue.V3, nil
  7700. }
  7701. // ResetV3 resets all changes to the "v3" field.
  7702. func (m *ContactMutation) ResetV3() {
  7703. m.v3 = nil
  7704. }
  7705. // SetOrganizationID sets the "organization_id" field.
  7706. func (m *ContactMutation) SetOrganizationID(u uint64) {
  7707. m.organization_id = &u
  7708. m.addorganization_id = nil
  7709. }
  7710. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7711. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  7712. v := m.organization_id
  7713. if v == nil {
  7714. return
  7715. }
  7716. return *v, true
  7717. }
  7718. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  7719. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7721. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7722. if !m.op.Is(OpUpdateOne) {
  7723. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7724. }
  7725. if m.id == nil || m.oldValue == nil {
  7726. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7727. }
  7728. oldValue, err := m.oldValue(ctx)
  7729. if err != nil {
  7730. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7731. }
  7732. return oldValue.OrganizationID, nil
  7733. }
  7734. // AddOrganizationID adds u to the "organization_id" field.
  7735. func (m *ContactMutation) AddOrganizationID(u int64) {
  7736. if m.addorganization_id != nil {
  7737. *m.addorganization_id += u
  7738. } else {
  7739. m.addorganization_id = &u
  7740. }
  7741. }
  7742. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7743. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  7744. v := m.addorganization_id
  7745. if v == nil {
  7746. return
  7747. }
  7748. return *v, true
  7749. }
  7750. // ClearOrganizationID clears the value of the "organization_id" field.
  7751. func (m *ContactMutation) ClearOrganizationID() {
  7752. m.organization_id = nil
  7753. m.addorganization_id = nil
  7754. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  7755. }
  7756. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7757. func (m *ContactMutation) OrganizationIDCleared() bool {
  7758. _, ok := m.clearedFields[contact.FieldOrganizationID]
  7759. return ok
  7760. }
  7761. // ResetOrganizationID resets all changes to the "organization_id" field.
  7762. func (m *ContactMutation) ResetOrganizationID() {
  7763. m.organization_id = nil
  7764. m.addorganization_id = nil
  7765. delete(m.clearedFields, contact.FieldOrganizationID)
  7766. }
  7767. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  7768. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  7769. if m.contact_relationships == nil {
  7770. m.contact_relationships = make(map[uint64]struct{})
  7771. }
  7772. for i := range ids {
  7773. m.contact_relationships[ids[i]] = struct{}{}
  7774. }
  7775. }
  7776. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  7777. func (m *ContactMutation) ClearContactRelationships() {
  7778. m.clearedcontact_relationships = true
  7779. }
  7780. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  7781. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  7782. return m.clearedcontact_relationships
  7783. }
  7784. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  7785. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  7786. if m.removedcontact_relationships == nil {
  7787. m.removedcontact_relationships = make(map[uint64]struct{})
  7788. }
  7789. for i := range ids {
  7790. delete(m.contact_relationships, ids[i])
  7791. m.removedcontact_relationships[ids[i]] = struct{}{}
  7792. }
  7793. }
  7794. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  7795. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  7796. for id := range m.removedcontact_relationships {
  7797. ids = append(ids, id)
  7798. }
  7799. return
  7800. }
  7801. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  7802. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  7803. for id := range m.contact_relationships {
  7804. ids = append(ids, id)
  7805. }
  7806. return
  7807. }
  7808. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  7809. func (m *ContactMutation) ResetContactRelationships() {
  7810. m.contact_relationships = nil
  7811. m.clearedcontact_relationships = false
  7812. m.removedcontact_relationships = nil
  7813. }
  7814. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  7815. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  7816. if m.contact_messages == nil {
  7817. m.contact_messages = make(map[uint64]struct{})
  7818. }
  7819. for i := range ids {
  7820. m.contact_messages[ids[i]] = struct{}{}
  7821. }
  7822. }
  7823. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  7824. func (m *ContactMutation) ClearContactMessages() {
  7825. m.clearedcontact_messages = true
  7826. }
  7827. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  7828. func (m *ContactMutation) ContactMessagesCleared() bool {
  7829. return m.clearedcontact_messages
  7830. }
  7831. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  7832. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  7833. if m.removedcontact_messages == nil {
  7834. m.removedcontact_messages = make(map[uint64]struct{})
  7835. }
  7836. for i := range ids {
  7837. delete(m.contact_messages, ids[i])
  7838. m.removedcontact_messages[ids[i]] = struct{}{}
  7839. }
  7840. }
  7841. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  7842. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  7843. for id := range m.removedcontact_messages {
  7844. ids = append(ids, id)
  7845. }
  7846. return
  7847. }
  7848. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  7849. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  7850. for id := range m.contact_messages {
  7851. ids = append(ids, id)
  7852. }
  7853. return
  7854. }
  7855. // ResetContactMessages resets all changes to the "contact_messages" edge.
  7856. func (m *ContactMutation) ResetContactMessages() {
  7857. m.contact_messages = nil
  7858. m.clearedcontact_messages = false
  7859. m.removedcontact_messages = nil
  7860. }
  7861. // Where appends a list predicates to the ContactMutation builder.
  7862. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  7863. m.predicates = append(m.predicates, ps...)
  7864. }
  7865. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  7866. // users can use type-assertion to append predicates that do not depend on any generated package.
  7867. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  7868. p := make([]predicate.Contact, len(ps))
  7869. for i := range ps {
  7870. p[i] = ps[i]
  7871. }
  7872. m.Where(p...)
  7873. }
  7874. // Op returns the operation name.
  7875. func (m *ContactMutation) Op() Op {
  7876. return m.op
  7877. }
  7878. // SetOp allows setting the mutation operation.
  7879. func (m *ContactMutation) SetOp(op Op) {
  7880. m.op = op
  7881. }
  7882. // Type returns the node type of this mutation (Contact).
  7883. func (m *ContactMutation) Type() string {
  7884. return m.typ
  7885. }
  7886. // Fields returns all fields that were changed during this mutation. Note that in
  7887. // order to get all numeric fields that were incremented/decremented, call
  7888. // AddedFields().
  7889. func (m *ContactMutation) Fields() []string {
  7890. fields := make([]string, 0, 20)
  7891. if m.created_at != nil {
  7892. fields = append(fields, contact.FieldCreatedAt)
  7893. }
  7894. if m.updated_at != nil {
  7895. fields = append(fields, contact.FieldUpdatedAt)
  7896. }
  7897. if m.status != nil {
  7898. fields = append(fields, contact.FieldStatus)
  7899. }
  7900. if m.deleted_at != nil {
  7901. fields = append(fields, contact.FieldDeletedAt)
  7902. }
  7903. if m.wx_wxid != nil {
  7904. fields = append(fields, contact.FieldWxWxid)
  7905. }
  7906. if m._type != nil {
  7907. fields = append(fields, contact.FieldType)
  7908. }
  7909. if m.wxid != nil {
  7910. fields = append(fields, contact.FieldWxid)
  7911. }
  7912. if m.account != nil {
  7913. fields = append(fields, contact.FieldAccount)
  7914. }
  7915. if m.nickname != nil {
  7916. fields = append(fields, contact.FieldNickname)
  7917. }
  7918. if m.markname != nil {
  7919. fields = append(fields, contact.FieldMarkname)
  7920. }
  7921. if m.headimg != nil {
  7922. fields = append(fields, contact.FieldHeadimg)
  7923. }
  7924. if m.sex != nil {
  7925. fields = append(fields, contact.FieldSex)
  7926. }
  7927. if m.starrole != nil {
  7928. fields = append(fields, contact.FieldStarrole)
  7929. }
  7930. if m.dontseeit != nil {
  7931. fields = append(fields, contact.FieldDontseeit)
  7932. }
  7933. if m.dontseeme != nil {
  7934. fields = append(fields, contact.FieldDontseeme)
  7935. }
  7936. if m.lag != nil {
  7937. fields = append(fields, contact.FieldLag)
  7938. }
  7939. if m.gid != nil {
  7940. fields = append(fields, contact.FieldGid)
  7941. }
  7942. if m.gname != nil {
  7943. fields = append(fields, contact.FieldGname)
  7944. }
  7945. if m.v3 != nil {
  7946. fields = append(fields, contact.FieldV3)
  7947. }
  7948. if m.organization_id != nil {
  7949. fields = append(fields, contact.FieldOrganizationID)
  7950. }
  7951. return fields
  7952. }
  7953. // Field returns the value of a field with the given name. The second boolean
  7954. // return value indicates that this field was not set, or was not defined in the
  7955. // schema.
  7956. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  7957. switch name {
  7958. case contact.FieldCreatedAt:
  7959. return m.CreatedAt()
  7960. case contact.FieldUpdatedAt:
  7961. return m.UpdatedAt()
  7962. case contact.FieldStatus:
  7963. return m.Status()
  7964. case contact.FieldDeletedAt:
  7965. return m.DeletedAt()
  7966. case contact.FieldWxWxid:
  7967. return m.WxWxid()
  7968. case contact.FieldType:
  7969. return m.GetType()
  7970. case contact.FieldWxid:
  7971. return m.Wxid()
  7972. case contact.FieldAccount:
  7973. return m.Account()
  7974. case contact.FieldNickname:
  7975. return m.Nickname()
  7976. case contact.FieldMarkname:
  7977. return m.Markname()
  7978. case contact.FieldHeadimg:
  7979. return m.Headimg()
  7980. case contact.FieldSex:
  7981. return m.Sex()
  7982. case contact.FieldStarrole:
  7983. return m.Starrole()
  7984. case contact.FieldDontseeit:
  7985. return m.Dontseeit()
  7986. case contact.FieldDontseeme:
  7987. return m.Dontseeme()
  7988. case contact.FieldLag:
  7989. return m.Lag()
  7990. case contact.FieldGid:
  7991. return m.Gid()
  7992. case contact.FieldGname:
  7993. return m.Gname()
  7994. case contact.FieldV3:
  7995. return m.V3()
  7996. case contact.FieldOrganizationID:
  7997. return m.OrganizationID()
  7998. }
  7999. return nil, false
  8000. }
  8001. // OldField returns the old value of the field from the database. An error is
  8002. // returned if the mutation operation is not UpdateOne, or the query to the
  8003. // database failed.
  8004. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8005. switch name {
  8006. case contact.FieldCreatedAt:
  8007. return m.OldCreatedAt(ctx)
  8008. case contact.FieldUpdatedAt:
  8009. return m.OldUpdatedAt(ctx)
  8010. case contact.FieldStatus:
  8011. return m.OldStatus(ctx)
  8012. case contact.FieldDeletedAt:
  8013. return m.OldDeletedAt(ctx)
  8014. case contact.FieldWxWxid:
  8015. return m.OldWxWxid(ctx)
  8016. case contact.FieldType:
  8017. return m.OldType(ctx)
  8018. case contact.FieldWxid:
  8019. return m.OldWxid(ctx)
  8020. case contact.FieldAccount:
  8021. return m.OldAccount(ctx)
  8022. case contact.FieldNickname:
  8023. return m.OldNickname(ctx)
  8024. case contact.FieldMarkname:
  8025. return m.OldMarkname(ctx)
  8026. case contact.FieldHeadimg:
  8027. return m.OldHeadimg(ctx)
  8028. case contact.FieldSex:
  8029. return m.OldSex(ctx)
  8030. case contact.FieldStarrole:
  8031. return m.OldStarrole(ctx)
  8032. case contact.FieldDontseeit:
  8033. return m.OldDontseeit(ctx)
  8034. case contact.FieldDontseeme:
  8035. return m.OldDontseeme(ctx)
  8036. case contact.FieldLag:
  8037. return m.OldLag(ctx)
  8038. case contact.FieldGid:
  8039. return m.OldGid(ctx)
  8040. case contact.FieldGname:
  8041. return m.OldGname(ctx)
  8042. case contact.FieldV3:
  8043. return m.OldV3(ctx)
  8044. case contact.FieldOrganizationID:
  8045. return m.OldOrganizationID(ctx)
  8046. }
  8047. return nil, fmt.Errorf("unknown Contact field %s", name)
  8048. }
  8049. // SetField sets the value of a field with the given name. It returns an error if
  8050. // the field is not defined in the schema, or if the type mismatched the field
  8051. // type.
  8052. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8053. switch name {
  8054. case contact.FieldCreatedAt:
  8055. v, ok := value.(time.Time)
  8056. if !ok {
  8057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8058. }
  8059. m.SetCreatedAt(v)
  8060. return nil
  8061. case contact.FieldUpdatedAt:
  8062. v, ok := value.(time.Time)
  8063. if !ok {
  8064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8065. }
  8066. m.SetUpdatedAt(v)
  8067. return nil
  8068. case contact.FieldStatus:
  8069. v, ok := value.(uint8)
  8070. if !ok {
  8071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8072. }
  8073. m.SetStatus(v)
  8074. return nil
  8075. case contact.FieldDeletedAt:
  8076. v, ok := value.(time.Time)
  8077. if !ok {
  8078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8079. }
  8080. m.SetDeletedAt(v)
  8081. return nil
  8082. case contact.FieldWxWxid:
  8083. v, ok := value.(string)
  8084. if !ok {
  8085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8086. }
  8087. m.SetWxWxid(v)
  8088. return nil
  8089. case contact.FieldType:
  8090. v, ok := value.(int)
  8091. if !ok {
  8092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8093. }
  8094. m.SetType(v)
  8095. return nil
  8096. case contact.FieldWxid:
  8097. v, ok := value.(string)
  8098. if !ok {
  8099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8100. }
  8101. m.SetWxid(v)
  8102. return nil
  8103. case contact.FieldAccount:
  8104. v, ok := value.(string)
  8105. if !ok {
  8106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8107. }
  8108. m.SetAccount(v)
  8109. return nil
  8110. case contact.FieldNickname:
  8111. v, ok := value.(string)
  8112. if !ok {
  8113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8114. }
  8115. m.SetNickname(v)
  8116. return nil
  8117. case contact.FieldMarkname:
  8118. v, ok := value.(string)
  8119. if !ok {
  8120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8121. }
  8122. m.SetMarkname(v)
  8123. return nil
  8124. case contact.FieldHeadimg:
  8125. v, ok := value.(string)
  8126. if !ok {
  8127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8128. }
  8129. m.SetHeadimg(v)
  8130. return nil
  8131. case contact.FieldSex:
  8132. v, ok := value.(int)
  8133. if !ok {
  8134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8135. }
  8136. m.SetSex(v)
  8137. return nil
  8138. case contact.FieldStarrole:
  8139. v, ok := value.(string)
  8140. if !ok {
  8141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8142. }
  8143. m.SetStarrole(v)
  8144. return nil
  8145. case contact.FieldDontseeit:
  8146. v, ok := value.(int)
  8147. if !ok {
  8148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8149. }
  8150. m.SetDontseeit(v)
  8151. return nil
  8152. case contact.FieldDontseeme:
  8153. v, ok := value.(int)
  8154. if !ok {
  8155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8156. }
  8157. m.SetDontseeme(v)
  8158. return nil
  8159. case contact.FieldLag:
  8160. v, ok := value.(string)
  8161. if !ok {
  8162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8163. }
  8164. m.SetLag(v)
  8165. return nil
  8166. case contact.FieldGid:
  8167. v, ok := value.(string)
  8168. if !ok {
  8169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8170. }
  8171. m.SetGid(v)
  8172. return nil
  8173. case contact.FieldGname:
  8174. v, ok := value.(string)
  8175. if !ok {
  8176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8177. }
  8178. m.SetGname(v)
  8179. return nil
  8180. case contact.FieldV3:
  8181. v, ok := value.(string)
  8182. if !ok {
  8183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8184. }
  8185. m.SetV3(v)
  8186. return nil
  8187. case contact.FieldOrganizationID:
  8188. v, ok := value.(uint64)
  8189. if !ok {
  8190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8191. }
  8192. m.SetOrganizationID(v)
  8193. return nil
  8194. }
  8195. return fmt.Errorf("unknown Contact field %s", name)
  8196. }
  8197. // AddedFields returns all numeric fields that were incremented/decremented during
  8198. // this mutation.
  8199. func (m *ContactMutation) AddedFields() []string {
  8200. var fields []string
  8201. if m.addstatus != nil {
  8202. fields = append(fields, contact.FieldStatus)
  8203. }
  8204. if m.add_type != nil {
  8205. fields = append(fields, contact.FieldType)
  8206. }
  8207. if m.addsex != nil {
  8208. fields = append(fields, contact.FieldSex)
  8209. }
  8210. if m.adddontseeit != nil {
  8211. fields = append(fields, contact.FieldDontseeit)
  8212. }
  8213. if m.adddontseeme != nil {
  8214. fields = append(fields, contact.FieldDontseeme)
  8215. }
  8216. if m.addorganization_id != nil {
  8217. fields = append(fields, contact.FieldOrganizationID)
  8218. }
  8219. return fields
  8220. }
  8221. // AddedField returns the numeric value that was incremented/decremented on a field
  8222. // with the given name. The second boolean return value indicates that this field
  8223. // was not set, or was not defined in the schema.
  8224. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8225. switch name {
  8226. case contact.FieldStatus:
  8227. return m.AddedStatus()
  8228. case contact.FieldType:
  8229. return m.AddedType()
  8230. case contact.FieldSex:
  8231. return m.AddedSex()
  8232. case contact.FieldDontseeit:
  8233. return m.AddedDontseeit()
  8234. case contact.FieldDontseeme:
  8235. return m.AddedDontseeme()
  8236. case contact.FieldOrganizationID:
  8237. return m.AddedOrganizationID()
  8238. }
  8239. return nil, false
  8240. }
  8241. // AddField adds the value to the field with the given name. It returns an error if
  8242. // the field is not defined in the schema, or if the type mismatched the field
  8243. // type.
  8244. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  8245. switch name {
  8246. case contact.FieldStatus:
  8247. v, ok := value.(int8)
  8248. if !ok {
  8249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8250. }
  8251. m.AddStatus(v)
  8252. return nil
  8253. case contact.FieldType:
  8254. v, ok := value.(int)
  8255. if !ok {
  8256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8257. }
  8258. m.AddType(v)
  8259. return nil
  8260. case contact.FieldSex:
  8261. v, ok := value.(int)
  8262. if !ok {
  8263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8264. }
  8265. m.AddSex(v)
  8266. return nil
  8267. case contact.FieldDontseeit:
  8268. v, ok := value.(int)
  8269. if !ok {
  8270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8271. }
  8272. m.AddDontseeit(v)
  8273. return nil
  8274. case contact.FieldDontseeme:
  8275. v, ok := value.(int)
  8276. if !ok {
  8277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8278. }
  8279. m.AddDontseeme(v)
  8280. return nil
  8281. case contact.FieldOrganizationID:
  8282. v, ok := value.(int64)
  8283. if !ok {
  8284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8285. }
  8286. m.AddOrganizationID(v)
  8287. return nil
  8288. }
  8289. return fmt.Errorf("unknown Contact numeric field %s", name)
  8290. }
  8291. // ClearedFields returns all nullable fields that were cleared during this
  8292. // mutation.
  8293. func (m *ContactMutation) ClearedFields() []string {
  8294. var fields []string
  8295. if m.FieldCleared(contact.FieldStatus) {
  8296. fields = append(fields, contact.FieldStatus)
  8297. }
  8298. if m.FieldCleared(contact.FieldDeletedAt) {
  8299. fields = append(fields, contact.FieldDeletedAt)
  8300. }
  8301. if m.FieldCleared(contact.FieldType) {
  8302. fields = append(fields, contact.FieldType)
  8303. }
  8304. if m.FieldCleared(contact.FieldOrganizationID) {
  8305. fields = append(fields, contact.FieldOrganizationID)
  8306. }
  8307. return fields
  8308. }
  8309. // FieldCleared returns a boolean indicating if a field with the given name was
  8310. // cleared in this mutation.
  8311. func (m *ContactMutation) FieldCleared(name string) bool {
  8312. _, ok := m.clearedFields[name]
  8313. return ok
  8314. }
  8315. // ClearField clears the value of the field with the given name. It returns an
  8316. // error if the field is not defined in the schema.
  8317. func (m *ContactMutation) ClearField(name string) error {
  8318. switch name {
  8319. case contact.FieldStatus:
  8320. m.ClearStatus()
  8321. return nil
  8322. case contact.FieldDeletedAt:
  8323. m.ClearDeletedAt()
  8324. return nil
  8325. case contact.FieldType:
  8326. m.ClearType()
  8327. return nil
  8328. case contact.FieldOrganizationID:
  8329. m.ClearOrganizationID()
  8330. return nil
  8331. }
  8332. return fmt.Errorf("unknown Contact nullable field %s", name)
  8333. }
  8334. // ResetField resets all changes in the mutation for the field with the given name.
  8335. // It returns an error if the field is not defined in the schema.
  8336. func (m *ContactMutation) ResetField(name string) error {
  8337. switch name {
  8338. case contact.FieldCreatedAt:
  8339. m.ResetCreatedAt()
  8340. return nil
  8341. case contact.FieldUpdatedAt:
  8342. m.ResetUpdatedAt()
  8343. return nil
  8344. case contact.FieldStatus:
  8345. m.ResetStatus()
  8346. return nil
  8347. case contact.FieldDeletedAt:
  8348. m.ResetDeletedAt()
  8349. return nil
  8350. case contact.FieldWxWxid:
  8351. m.ResetWxWxid()
  8352. return nil
  8353. case contact.FieldType:
  8354. m.ResetType()
  8355. return nil
  8356. case contact.FieldWxid:
  8357. m.ResetWxid()
  8358. return nil
  8359. case contact.FieldAccount:
  8360. m.ResetAccount()
  8361. return nil
  8362. case contact.FieldNickname:
  8363. m.ResetNickname()
  8364. return nil
  8365. case contact.FieldMarkname:
  8366. m.ResetMarkname()
  8367. return nil
  8368. case contact.FieldHeadimg:
  8369. m.ResetHeadimg()
  8370. return nil
  8371. case contact.FieldSex:
  8372. m.ResetSex()
  8373. return nil
  8374. case contact.FieldStarrole:
  8375. m.ResetStarrole()
  8376. return nil
  8377. case contact.FieldDontseeit:
  8378. m.ResetDontseeit()
  8379. return nil
  8380. case contact.FieldDontseeme:
  8381. m.ResetDontseeme()
  8382. return nil
  8383. case contact.FieldLag:
  8384. m.ResetLag()
  8385. return nil
  8386. case contact.FieldGid:
  8387. m.ResetGid()
  8388. return nil
  8389. case contact.FieldGname:
  8390. m.ResetGname()
  8391. return nil
  8392. case contact.FieldV3:
  8393. m.ResetV3()
  8394. return nil
  8395. case contact.FieldOrganizationID:
  8396. m.ResetOrganizationID()
  8397. return nil
  8398. }
  8399. return fmt.Errorf("unknown Contact field %s", name)
  8400. }
  8401. // AddedEdges returns all edge names that were set/added in this mutation.
  8402. func (m *ContactMutation) AddedEdges() []string {
  8403. edges := make([]string, 0, 2)
  8404. if m.contact_relationships != nil {
  8405. edges = append(edges, contact.EdgeContactRelationships)
  8406. }
  8407. if m.contact_messages != nil {
  8408. edges = append(edges, contact.EdgeContactMessages)
  8409. }
  8410. return edges
  8411. }
  8412. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8413. // name in this mutation.
  8414. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  8415. switch name {
  8416. case contact.EdgeContactRelationships:
  8417. ids := make([]ent.Value, 0, len(m.contact_relationships))
  8418. for id := range m.contact_relationships {
  8419. ids = append(ids, id)
  8420. }
  8421. return ids
  8422. case contact.EdgeContactMessages:
  8423. ids := make([]ent.Value, 0, len(m.contact_messages))
  8424. for id := range m.contact_messages {
  8425. ids = append(ids, id)
  8426. }
  8427. return ids
  8428. }
  8429. return nil
  8430. }
  8431. // RemovedEdges returns all edge names that were removed in this mutation.
  8432. func (m *ContactMutation) RemovedEdges() []string {
  8433. edges := make([]string, 0, 2)
  8434. if m.removedcontact_relationships != nil {
  8435. edges = append(edges, contact.EdgeContactRelationships)
  8436. }
  8437. if m.removedcontact_messages != nil {
  8438. edges = append(edges, contact.EdgeContactMessages)
  8439. }
  8440. return edges
  8441. }
  8442. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8443. // the given name in this mutation.
  8444. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  8445. switch name {
  8446. case contact.EdgeContactRelationships:
  8447. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  8448. for id := range m.removedcontact_relationships {
  8449. ids = append(ids, id)
  8450. }
  8451. return ids
  8452. case contact.EdgeContactMessages:
  8453. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  8454. for id := range m.removedcontact_messages {
  8455. ids = append(ids, id)
  8456. }
  8457. return ids
  8458. }
  8459. return nil
  8460. }
  8461. // ClearedEdges returns all edge names that were cleared in this mutation.
  8462. func (m *ContactMutation) ClearedEdges() []string {
  8463. edges := make([]string, 0, 2)
  8464. if m.clearedcontact_relationships {
  8465. edges = append(edges, contact.EdgeContactRelationships)
  8466. }
  8467. if m.clearedcontact_messages {
  8468. edges = append(edges, contact.EdgeContactMessages)
  8469. }
  8470. return edges
  8471. }
  8472. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8473. // was cleared in this mutation.
  8474. func (m *ContactMutation) EdgeCleared(name string) bool {
  8475. switch name {
  8476. case contact.EdgeContactRelationships:
  8477. return m.clearedcontact_relationships
  8478. case contact.EdgeContactMessages:
  8479. return m.clearedcontact_messages
  8480. }
  8481. return false
  8482. }
  8483. // ClearEdge clears the value of the edge with the given name. It returns an error
  8484. // if that edge is not defined in the schema.
  8485. func (m *ContactMutation) ClearEdge(name string) error {
  8486. switch name {
  8487. }
  8488. return fmt.Errorf("unknown Contact unique edge %s", name)
  8489. }
  8490. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8491. // It returns an error if the edge is not defined in the schema.
  8492. func (m *ContactMutation) ResetEdge(name string) error {
  8493. switch name {
  8494. case contact.EdgeContactRelationships:
  8495. m.ResetContactRelationships()
  8496. return nil
  8497. case contact.EdgeContactMessages:
  8498. m.ResetContactMessages()
  8499. return nil
  8500. }
  8501. return fmt.Errorf("unknown Contact edge %s", name)
  8502. }
  8503. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  8504. type EmployeeMutation struct {
  8505. config
  8506. op Op
  8507. typ string
  8508. id *uint64
  8509. created_at *time.Time
  8510. updated_at *time.Time
  8511. deleted_at *time.Time
  8512. title *string
  8513. avatar *string
  8514. tags *string
  8515. hire_count *int
  8516. addhire_count *int
  8517. service_count *int
  8518. addservice_count *int
  8519. achievement_count *int
  8520. addachievement_count *int
  8521. intro *string
  8522. estimate *string
  8523. skill *string
  8524. ability_type *string
  8525. scene *string
  8526. switch_in *string
  8527. video_url *string
  8528. organization_id *uint64
  8529. addorganization_id *int64
  8530. category_id *uint64
  8531. addcategory_id *int64
  8532. api_base *string
  8533. api_key *string
  8534. ai_info *string
  8535. is_vip *int
  8536. addis_vip *int
  8537. chat_url *string
  8538. clearedFields map[string]struct{}
  8539. em_work_experiences map[uint64]struct{}
  8540. removedem_work_experiences map[uint64]struct{}
  8541. clearedem_work_experiences bool
  8542. em_tutorial map[uint64]struct{}
  8543. removedem_tutorial map[uint64]struct{}
  8544. clearedem_tutorial bool
  8545. done bool
  8546. oldValue func(context.Context) (*Employee, error)
  8547. predicates []predicate.Employee
  8548. }
  8549. var _ ent.Mutation = (*EmployeeMutation)(nil)
  8550. // employeeOption allows management of the mutation configuration using functional options.
  8551. type employeeOption func(*EmployeeMutation)
  8552. // newEmployeeMutation creates new mutation for the Employee entity.
  8553. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  8554. m := &EmployeeMutation{
  8555. config: c,
  8556. op: op,
  8557. typ: TypeEmployee,
  8558. clearedFields: make(map[string]struct{}),
  8559. }
  8560. for _, opt := range opts {
  8561. opt(m)
  8562. }
  8563. return m
  8564. }
  8565. // withEmployeeID sets the ID field of the mutation.
  8566. func withEmployeeID(id uint64) employeeOption {
  8567. return func(m *EmployeeMutation) {
  8568. var (
  8569. err error
  8570. once sync.Once
  8571. value *Employee
  8572. )
  8573. m.oldValue = func(ctx context.Context) (*Employee, error) {
  8574. once.Do(func() {
  8575. if m.done {
  8576. err = errors.New("querying old values post mutation is not allowed")
  8577. } else {
  8578. value, err = m.Client().Employee.Get(ctx, id)
  8579. }
  8580. })
  8581. return value, err
  8582. }
  8583. m.id = &id
  8584. }
  8585. }
  8586. // withEmployee sets the old Employee of the mutation.
  8587. func withEmployee(node *Employee) employeeOption {
  8588. return func(m *EmployeeMutation) {
  8589. m.oldValue = func(context.Context) (*Employee, error) {
  8590. return node, nil
  8591. }
  8592. m.id = &node.ID
  8593. }
  8594. }
  8595. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8596. // executed in a transaction (ent.Tx), a transactional client is returned.
  8597. func (m EmployeeMutation) Client() *Client {
  8598. client := &Client{config: m.config}
  8599. client.init()
  8600. return client
  8601. }
  8602. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8603. // it returns an error otherwise.
  8604. func (m EmployeeMutation) Tx() (*Tx, error) {
  8605. if _, ok := m.driver.(*txDriver); !ok {
  8606. return nil, errors.New("ent: mutation is not running in a transaction")
  8607. }
  8608. tx := &Tx{config: m.config}
  8609. tx.init()
  8610. return tx, nil
  8611. }
  8612. // SetID sets the value of the id field. Note that this
  8613. // operation is only accepted on creation of Employee entities.
  8614. func (m *EmployeeMutation) SetID(id uint64) {
  8615. m.id = &id
  8616. }
  8617. // ID returns the ID value in the mutation. Note that the ID is only available
  8618. // if it was provided to the builder or after it was returned from the database.
  8619. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  8620. if m.id == nil {
  8621. return
  8622. }
  8623. return *m.id, true
  8624. }
  8625. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8626. // That means, if the mutation is applied within a transaction with an isolation level such
  8627. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8628. // or updated by the mutation.
  8629. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  8630. switch {
  8631. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8632. id, exists := m.ID()
  8633. if exists {
  8634. return []uint64{id}, nil
  8635. }
  8636. fallthrough
  8637. case m.op.Is(OpUpdate | OpDelete):
  8638. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  8639. default:
  8640. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8641. }
  8642. }
  8643. // SetCreatedAt sets the "created_at" field.
  8644. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  8645. m.created_at = &t
  8646. }
  8647. // CreatedAt returns the value of the "created_at" field in the mutation.
  8648. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  8649. v := m.created_at
  8650. if v == nil {
  8651. return
  8652. }
  8653. return *v, true
  8654. }
  8655. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  8656. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8658. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8659. if !m.op.Is(OpUpdateOne) {
  8660. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8661. }
  8662. if m.id == nil || m.oldValue == nil {
  8663. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8664. }
  8665. oldValue, err := m.oldValue(ctx)
  8666. if err != nil {
  8667. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8668. }
  8669. return oldValue.CreatedAt, nil
  8670. }
  8671. // ResetCreatedAt resets all changes to the "created_at" field.
  8672. func (m *EmployeeMutation) ResetCreatedAt() {
  8673. m.created_at = nil
  8674. }
  8675. // SetUpdatedAt sets the "updated_at" field.
  8676. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  8677. m.updated_at = &t
  8678. }
  8679. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8680. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  8681. v := m.updated_at
  8682. if v == nil {
  8683. return
  8684. }
  8685. return *v, true
  8686. }
  8687. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  8688. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8690. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8691. if !m.op.Is(OpUpdateOne) {
  8692. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8693. }
  8694. if m.id == nil || m.oldValue == nil {
  8695. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8696. }
  8697. oldValue, err := m.oldValue(ctx)
  8698. if err != nil {
  8699. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8700. }
  8701. return oldValue.UpdatedAt, nil
  8702. }
  8703. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8704. func (m *EmployeeMutation) ResetUpdatedAt() {
  8705. m.updated_at = nil
  8706. }
  8707. // SetDeletedAt sets the "deleted_at" field.
  8708. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  8709. m.deleted_at = &t
  8710. }
  8711. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8712. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  8713. v := m.deleted_at
  8714. if v == nil {
  8715. return
  8716. }
  8717. return *v, true
  8718. }
  8719. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  8720. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8722. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8723. if !m.op.Is(OpUpdateOne) {
  8724. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8725. }
  8726. if m.id == nil || m.oldValue == nil {
  8727. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8728. }
  8729. oldValue, err := m.oldValue(ctx)
  8730. if err != nil {
  8731. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8732. }
  8733. return oldValue.DeletedAt, nil
  8734. }
  8735. // ClearDeletedAt clears the value of the "deleted_at" field.
  8736. func (m *EmployeeMutation) ClearDeletedAt() {
  8737. m.deleted_at = nil
  8738. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  8739. }
  8740. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8741. func (m *EmployeeMutation) DeletedAtCleared() bool {
  8742. _, ok := m.clearedFields[employee.FieldDeletedAt]
  8743. return ok
  8744. }
  8745. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8746. func (m *EmployeeMutation) ResetDeletedAt() {
  8747. m.deleted_at = nil
  8748. delete(m.clearedFields, employee.FieldDeletedAt)
  8749. }
  8750. // SetTitle sets the "title" field.
  8751. func (m *EmployeeMutation) SetTitle(s string) {
  8752. m.title = &s
  8753. }
  8754. // Title returns the value of the "title" field in the mutation.
  8755. func (m *EmployeeMutation) Title() (r string, exists bool) {
  8756. v := m.title
  8757. if v == nil {
  8758. return
  8759. }
  8760. return *v, true
  8761. }
  8762. // OldTitle returns the old "title" field's value of the Employee entity.
  8763. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8765. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  8766. if !m.op.Is(OpUpdateOne) {
  8767. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  8768. }
  8769. if m.id == nil || m.oldValue == nil {
  8770. return v, errors.New("OldTitle requires an ID field in the mutation")
  8771. }
  8772. oldValue, err := m.oldValue(ctx)
  8773. if err != nil {
  8774. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  8775. }
  8776. return oldValue.Title, nil
  8777. }
  8778. // ResetTitle resets all changes to the "title" field.
  8779. func (m *EmployeeMutation) ResetTitle() {
  8780. m.title = nil
  8781. }
  8782. // SetAvatar sets the "avatar" field.
  8783. func (m *EmployeeMutation) SetAvatar(s string) {
  8784. m.avatar = &s
  8785. }
  8786. // Avatar returns the value of the "avatar" field in the mutation.
  8787. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  8788. v := m.avatar
  8789. if v == nil {
  8790. return
  8791. }
  8792. return *v, true
  8793. }
  8794. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  8795. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8797. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  8798. if !m.op.Is(OpUpdateOne) {
  8799. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  8800. }
  8801. if m.id == nil || m.oldValue == nil {
  8802. return v, errors.New("OldAvatar requires an ID field in the mutation")
  8803. }
  8804. oldValue, err := m.oldValue(ctx)
  8805. if err != nil {
  8806. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  8807. }
  8808. return oldValue.Avatar, nil
  8809. }
  8810. // ResetAvatar resets all changes to the "avatar" field.
  8811. func (m *EmployeeMutation) ResetAvatar() {
  8812. m.avatar = nil
  8813. }
  8814. // SetTags sets the "tags" field.
  8815. func (m *EmployeeMutation) SetTags(s string) {
  8816. m.tags = &s
  8817. }
  8818. // Tags returns the value of the "tags" field in the mutation.
  8819. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  8820. v := m.tags
  8821. if v == nil {
  8822. return
  8823. }
  8824. return *v, true
  8825. }
  8826. // OldTags returns the old "tags" field's value of the Employee entity.
  8827. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8829. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  8830. if !m.op.Is(OpUpdateOne) {
  8831. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  8832. }
  8833. if m.id == nil || m.oldValue == nil {
  8834. return v, errors.New("OldTags requires an ID field in the mutation")
  8835. }
  8836. oldValue, err := m.oldValue(ctx)
  8837. if err != nil {
  8838. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  8839. }
  8840. return oldValue.Tags, nil
  8841. }
  8842. // ResetTags resets all changes to the "tags" field.
  8843. func (m *EmployeeMutation) ResetTags() {
  8844. m.tags = nil
  8845. }
  8846. // SetHireCount sets the "hire_count" field.
  8847. func (m *EmployeeMutation) SetHireCount(i int) {
  8848. m.hire_count = &i
  8849. m.addhire_count = nil
  8850. }
  8851. // HireCount returns the value of the "hire_count" field in the mutation.
  8852. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  8853. v := m.hire_count
  8854. if v == nil {
  8855. return
  8856. }
  8857. return *v, true
  8858. }
  8859. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  8860. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8862. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  8863. if !m.op.Is(OpUpdateOne) {
  8864. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  8865. }
  8866. if m.id == nil || m.oldValue == nil {
  8867. return v, errors.New("OldHireCount requires an ID field in the mutation")
  8868. }
  8869. oldValue, err := m.oldValue(ctx)
  8870. if err != nil {
  8871. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  8872. }
  8873. return oldValue.HireCount, nil
  8874. }
  8875. // AddHireCount adds i to the "hire_count" field.
  8876. func (m *EmployeeMutation) AddHireCount(i int) {
  8877. if m.addhire_count != nil {
  8878. *m.addhire_count += i
  8879. } else {
  8880. m.addhire_count = &i
  8881. }
  8882. }
  8883. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  8884. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  8885. v := m.addhire_count
  8886. if v == nil {
  8887. return
  8888. }
  8889. return *v, true
  8890. }
  8891. // ResetHireCount resets all changes to the "hire_count" field.
  8892. func (m *EmployeeMutation) ResetHireCount() {
  8893. m.hire_count = nil
  8894. m.addhire_count = nil
  8895. }
  8896. // SetServiceCount sets the "service_count" field.
  8897. func (m *EmployeeMutation) SetServiceCount(i int) {
  8898. m.service_count = &i
  8899. m.addservice_count = nil
  8900. }
  8901. // ServiceCount returns the value of the "service_count" field in the mutation.
  8902. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  8903. v := m.service_count
  8904. if v == nil {
  8905. return
  8906. }
  8907. return *v, true
  8908. }
  8909. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  8910. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8912. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  8913. if !m.op.Is(OpUpdateOne) {
  8914. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  8915. }
  8916. if m.id == nil || m.oldValue == nil {
  8917. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  8918. }
  8919. oldValue, err := m.oldValue(ctx)
  8920. if err != nil {
  8921. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  8922. }
  8923. return oldValue.ServiceCount, nil
  8924. }
  8925. // AddServiceCount adds i to the "service_count" field.
  8926. func (m *EmployeeMutation) AddServiceCount(i int) {
  8927. if m.addservice_count != nil {
  8928. *m.addservice_count += i
  8929. } else {
  8930. m.addservice_count = &i
  8931. }
  8932. }
  8933. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  8934. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  8935. v := m.addservice_count
  8936. if v == nil {
  8937. return
  8938. }
  8939. return *v, true
  8940. }
  8941. // ResetServiceCount resets all changes to the "service_count" field.
  8942. func (m *EmployeeMutation) ResetServiceCount() {
  8943. m.service_count = nil
  8944. m.addservice_count = nil
  8945. }
  8946. // SetAchievementCount sets the "achievement_count" field.
  8947. func (m *EmployeeMutation) SetAchievementCount(i int) {
  8948. m.achievement_count = &i
  8949. m.addachievement_count = nil
  8950. }
  8951. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  8952. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  8953. v := m.achievement_count
  8954. if v == nil {
  8955. return
  8956. }
  8957. return *v, true
  8958. }
  8959. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  8960. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8962. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  8963. if !m.op.Is(OpUpdateOne) {
  8964. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  8965. }
  8966. if m.id == nil || m.oldValue == nil {
  8967. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  8968. }
  8969. oldValue, err := m.oldValue(ctx)
  8970. if err != nil {
  8971. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  8972. }
  8973. return oldValue.AchievementCount, nil
  8974. }
  8975. // AddAchievementCount adds i to the "achievement_count" field.
  8976. func (m *EmployeeMutation) AddAchievementCount(i int) {
  8977. if m.addachievement_count != nil {
  8978. *m.addachievement_count += i
  8979. } else {
  8980. m.addachievement_count = &i
  8981. }
  8982. }
  8983. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  8984. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  8985. v := m.addachievement_count
  8986. if v == nil {
  8987. return
  8988. }
  8989. return *v, true
  8990. }
  8991. // ResetAchievementCount resets all changes to the "achievement_count" field.
  8992. func (m *EmployeeMutation) ResetAchievementCount() {
  8993. m.achievement_count = nil
  8994. m.addachievement_count = nil
  8995. }
  8996. // SetIntro sets the "intro" field.
  8997. func (m *EmployeeMutation) SetIntro(s string) {
  8998. m.intro = &s
  8999. }
  9000. // Intro returns the value of the "intro" field in the mutation.
  9001. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  9002. v := m.intro
  9003. if v == nil {
  9004. return
  9005. }
  9006. return *v, true
  9007. }
  9008. // OldIntro returns the old "intro" field's value of the Employee entity.
  9009. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9011. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  9012. if !m.op.Is(OpUpdateOne) {
  9013. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  9014. }
  9015. if m.id == nil || m.oldValue == nil {
  9016. return v, errors.New("OldIntro requires an ID field in the mutation")
  9017. }
  9018. oldValue, err := m.oldValue(ctx)
  9019. if err != nil {
  9020. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  9021. }
  9022. return oldValue.Intro, nil
  9023. }
  9024. // ResetIntro resets all changes to the "intro" field.
  9025. func (m *EmployeeMutation) ResetIntro() {
  9026. m.intro = nil
  9027. }
  9028. // SetEstimate sets the "estimate" field.
  9029. func (m *EmployeeMutation) SetEstimate(s string) {
  9030. m.estimate = &s
  9031. }
  9032. // Estimate returns the value of the "estimate" field in the mutation.
  9033. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  9034. v := m.estimate
  9035. if v == nil {
  9036. return
  9037. }
  9038. return *v, true
  9039. }
  9040. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  9041. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9043. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  9044. if !m.op.Is(OpUpdateOne) {
  9045. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  9046. }
  9047. if m.id == nil || m.oldValue == nil {
  9048. return v, errors.New("OldEstimate requires an ID field in the mutation")
  9049. }
  9050. oldValue, err := m.oldValue(ctx)
  9051. if err != nil {
  9052. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  9053. }
  9054. return oldValue.Estimate, nil
  9055. }
  9056. // ResetEstimate resets all changes to the "estimate" field.
  9057. func (m *EmployeeMutation) ResetEstimate() {
  9058. m.estimate = nil
  9059. }
  9060. // SetSkill sets the "skill" field.
  9061. func (m *EmployeeMutation) SetSkill(s string) {
  9062. m.skill = &s
  9063. }
  9064. // Skill returns the value of the "skill" field in the mutation.
  9065. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  9066. v := m.skill
  9067. if v == nil {
  9068. return
  9069. }
  9070. return *v, true
  9071. }
  9072. // OldSkill returns the old "skill" field's value of the Employee entity.
  9073. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9075. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  9076. if !m.op.Is(OpUpdateOne) {
  9077. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  9078. }
  9079. if m.id == nil || m.oldValue == nil {
  9080. return v, errors.New("OldSkill requires an ID field in the mutation")
  9081. }
  9082. oldValue, err := m.oldValue(ctx)
  9083. if err != nil {
  9084. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  9085. }
  9086. return oldValue.Skill, nil
  9087. }
  9088. // ResetSkill resets all changes to the "skill" field.
  9089. func (m *EmployeeMutation) ResetSkill() {
  9090. m.skill = nil
  9091. }
  9092. // SetAbilityType sets the "ability_type" field.
  9093. func (m *EmployeeMutation) SetAbilityType(s string) {
  9094. m.ability_type = &s
  9095. }
  9096. // AbilityType returns the value of the "ability_type" field in the mutation.
  9097. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  9098. v := m.ability_type
  9099. if v == nil {
  9100. return
  9101. }
  9102. return *v, true
  9103. }
  9104. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  9105. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9107. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  9108. if !m.op.Is(OpUpdateOne) {
  9109. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  9110. }
  9111. if m.id == nil || m.oldValue == nil {
  9112. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  9113. }
  9114. oldValue, err := m.oldValue(ctx)
  9115. if err != nil {
  9116. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  9117. }
  9118. return oldValue.AbilityType, nil
  9119. }
  9120. // ResetAbilityType resets all changes to the "ability_type" field.
  9121. func (m *EmployeeMutation) ResetAbilityType() {
  9122. m.ability_type = nil
  9123. }
  9124. // SetScene sets the "scene" field.
  9125. func (m *EmployeeMutation) SetScene(s string) {
  9126. m.scene = &s
  9127. }
  9128. // Scene returns the value of the "scene" field in the mutation.
  9129. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  9130. v := m.scene
  9131. if v == nil {
  9132. return
  9133. }
  9134. return *v, true
  9135. }
  9136. // OldScene returns the old "scene" field's value of the Employee entity.
  9137. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9139. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  9140. if !m.op.Is(OpUpdateOne) {
  9141. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  9142. }
  9143. if m.id == nil || m.oldValue == nil {
  9144. return v, errors.New("OldScene requires an ID field in the mutation")
  9145. }
  9146. oldValue, err := m.oldValue(ctx)
  9147. if err != nil {
  9148. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  9149. }
  9150. return oldValue.Scene, nil
  9151. }
  9152. // ResetScene resets all changes to the "scene" field.
  9153. func (m *EmployeeMutation) ResetScene() {
  9154. m.scene = nil
  9155. }
  9156. // SetSwitchIn sets the "switch_in" field.
  9157. func (m *EmployeeMutation) SetSwitchIn(s string) {
  9158. m.switch_in = &s
  9159. }
  9160. // SwitchIn returns the value of the "switch_in" field in the mutation.
  9161. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  9162. v := m.switch_in
  9163. if v == nil {
  9164. return
  9165. }
  9166. return *v, true
  9167. }
  9168. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  9169. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9171. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  9172. if !m.op.Is(OpUpdateOne) {
  9173. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  9174. }
  9175. if m.id == nil || m.oldValue == nil {
  9176. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  9177. }
  9178. oldValue, err := m.oldValue(ctx)
  9179. if err != nil {
  9180. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  9181. }
  9182. return oldValue.SwitchIn, nil
  9183. }
  9184. // ResetSwitchIn resets all changes to the "switch_in" field.
  9185. func (m *EmployeeMutation) ResetSwitchIn() {
  9186. m.switch_in = nil
  9187. }
  9188. // SetVideoURL sets the "video_url" field.
  9189. func (m *EmployeeMutation) SetVideoURL(s string) {
  9190. m.video_url = &s
  9191. }
  9192. // VideoURL returns the value of the "video_url" field in the mutation.
  9193. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  9194. v := m.video_url
  9195. if v == nil {
  9196. return
  9197. }
  9198. return *v, true
  9199. }
  9200. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  9201. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9203. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  9204. if !m.op.Is(OpUpdateOne) {
  9205. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  9206. }
  9207. if m.id == nil || m.oldValue == nil {
  9208. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  9209. }
  9210. oldValue, err := m.oldValue(ctx)
  9211. if err != nil {
  9212. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  9213. }
  9214. return oldValue.VideoURL, nil
  9215. }
  9216. // ResetVideoURL resets all changes to the "video_url" field.
  9217. func (m *EmployeeMutation) ResetVideoURL() {
  9218. m.video_url = nil
  9219. }
  9220. // SetOrganizationID sets the "organization_id" field.
  9221. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  9222. m.organization_id = &u
  9223. m.addorganization_id = nil
  9224. }
  9225. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9226. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  9227. v := m.organization_id
  9228. if v == nil {
  9229. return
  9230. }
  9231. return *v, true
  9232. }
  9233. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  9234. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9236. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9237. if !m.op.Is(OpUpdateOne) {
  9238. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9239. }
  9240. if m.id == nil || m.oldValue == nil {
  9241. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9242. }
  9243. oldValue, err := m.oldValue(ctx)
  9244. if err != nil {
  9245. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9246. }
  9247. return oldValue.OrganizationID, nil
  9248. }
  9249. // AddOrganizationID adds u to the "organization_id" field.
  9250. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  9251. if m.addorganization_id != nil {
  9252. *m.addorganization_id += u
  9253. } else {
  9254. m.addorganization_id = &u
  9255. }
  9256. }
  9257. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9258. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  9259. v := m.addorganization_id
  9260. if v == nil {
  9261. return
  9262. }
  9263. return *v, true
  9264. }
  9265. // ResetOrganizationID resets all changes to the "organization_id" field.
  9266. func (m *EmployeeMutation) ResetOrganizationID() {
  9267. m.organization_id = nil
  9268. m.addorganization_id = nil
  9269. }
  9270. // SetCategoryID sets the "category_id" field.
  9271. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  9272. m.category_id = &u
  9273. m.addcategory_id = nil
  9274. }
  9275. // CategoryID returns the value of the "category_id" field in the mutation.
  9276. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  9277. v := m.category_id
  9278. if v == nil {
  9279. return
  9280. }
  9281. return *v, true
  9282. }
  9283. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  9284. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9286. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  9287. if !m.op.Is(OpUpdateOne) {
  9288. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  9289. }
  9290. if m.id == nil || m.oldValue == nil {
  9291. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  9292. }
  9293. oldValue, err := m.oldValue(ctx)
  9294. if err != nil {
  9295. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  9296. }
  9297. return oldValue.CategoryID, nil
  9298. }
  9299. // AddCategoryID adds u to the "category_id" field.
  9300. func (m *EmployeeMutation) AddCategoryID(u int64) {
  9301. if m.addcategory_id != nil {
  9302. *m.addcategory_id += u
  9303. } else {
  9304. m.addcategory_id = &u
  9305. }
  9306. }
  9307. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  9308. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  9309. v := m.addcategory_id
  9310. if v == nil {
  9311. return
  9312. }
  9313. return *v, true
  9314. }
  9315. // ResetCategoryID resets all changes to the "category_id" field.
  9316. func (m *EmployeeMutation) ResetCategoryID() {
  9317. m.category_id = nil
  9318. m.addcategory_id = nil
  9319. }
  9320. // SetAPIBase sets the "api_base" field.
  9321. func (m *EmployeeMutation) SetAPIBase(s string) {
  9322. m.api_base = &s
  9323. }
  9324. // APIBase returns the value of the "api_base" field in the mutation.
  9325. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  9326. v := m.api_base
  9327. if v == nil {
  9328. return
  9329. }
  9330. return *v, true
  9331. }
  9332. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  9333. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9335. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  9336. if !m.op.Is(OpUpdateOne) {
  9337. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  9338. }
  9339. if m.id == nil || m.oldValue == nil {
  9340. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  9341. }
  9342. oldValue, err := m.oldValue(ctx)
  9343. if err != nil {
  9344. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  9345. }
  9346. return oldValue.APIBase, nil
  9347. }
  9348. // ResetAPIBase resets all changes to the "api_base" field.
  9349. func (m *EmployeeMutation) ResetAPIBase() {
  9350. m.api_base = nil
  9351. }
  9352. // SetAPIKey sets the "api_key" field.
  9353. func (m *EmployeeMutation) SetAPIKey(s string) {
  9354. m.api_key = &s
  9355. }
  9356. // APIKey returns the value of the "api_key" field in the mutation.
  9357. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  9358. v := m.api_key
  9359. if v == nil {
  9360. return
  9361. }
  9362. return *v, true
  9363. }
  9364. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  9365. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9367. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  9368. if !m.op.Is(OpUpdateOne) {
  9369. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  9370. }
  9371. if m.id == nil || m.oldValue == nil {
  9372. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  9373. }
  9374. oldValue, err := m.oldValue(ctx)
  9375. if err != nil {
  9376. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  9377. }
  9378. return oldValue.APIKey, nil
  9379. }
  9380. // ResetAPIKey resets all changes to the "api_key" field.
  9381. func (m *EmployeeMutation) ResetAPIKey() {
  9382. m.api_key = nil
  9383. }
  9384. // SetAiInfo sets the "ai_info" field.
  9385. func (m *EmployeeMutation) SetAiInfo(s string) {
  9386. m.ai_info = &s
  9387. }
  9388. // AiInfo returns the value of the "ai_info" field in the mutation.
  9389. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  9390. v := m.ai_info
  9391. if v == nil {
  9392. return
  9393. }
  9394. return *v, true
  9395. }
  9396. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  9397. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9399. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  9400. if !m.op.Is(OpUpdateOne) {
  9401. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  9402. }
  9403. if m.id == nil || m.oldValue == nil {
  9404. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  9405. }
  9406. oldValue, err := m.oldValue(ctx)
  9407. if err != nil {
  9408. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  9409. }
  9410. return oldValue.AiInfo, nil
  9411. }
  9412. // ClearAiInfo clears the value of the "ai_info" field.
  9413. func (m *EmployeeMutation) ClearAiInfo() {
  9414. m.ai_info = nil
  9415. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  9416. }
  9417. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  9418. func (m *EmployeeMutation) AiInfoCleared() bool {
  9419. _, ok := m.clearedFields[employee.FieldAiInfo]
  9420. return ok
  9421. }
  9422. // ResetAiInfo resets all changes to the "ai_info" field.
  9423. func (m *EmployeeMutation) ResetAiInfo() {
  9424. m.ai_info = nil
  9425. delete(m.clearedFields, employee.FieldAiInfo)
  9426. }
  9427. // SetIsVip sets the "is_vip" field.
  9428. func (m *EmployeeMutation) SetIsVip(i int) {
  9429. m.is_vip = &i
  9430. m.addis_vip = nil
  9431. }
  9432. // IsVip returns the value of the "is_vip" field in the mutation.
  9433. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  9434. v := m.is_vip
  9435. if v == nil {
  9436. return
  9437. }
  9438. return *v, true
  9439. }
  9440. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  9441. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9443. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  9444. if !m.op.Is(OpUpdateOne) {
  9445. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  9446. }
  9447. if m.id == nil || m.oldValue == nil {
  9448. return v, errors.New("OldIsVip requires an ID field in the mutation")
  9449. }
  9450. oldValue, err := m.oldValue(ctx)
  9451. if err != nil {
  9452. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  9453. }
  9454. return oldValue.IsVip, nil
  9455. }
  9456. // AddIsVip adds i to the "is_vip" field.
  9457. func (m *EmployeeMutation) AddIsVip(i int) {
  9458. if m.addis_vip != nil {
  9459. *m.addis_vip += i
  9460. } else {
  9461. m.addis_vip = &i
  9462. }
  9463. }
  9464. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  9465. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  9466. v := m.addis_vip
  9467. if v == nil {
  9468. return
  9469. }
  9470. return *v, true
  9471. }
  9472. // ResetIsVip resets all changes to the "is_vip" field.
  9473. func (m *EmployeeMutation) ResetIsVip() {
  9474. m.is_vip = nil
  9475. m.addis_vip = nil
  9476. }
  9477. // SetChatURL sets the "chat_url" field.
  9478. func (m *EmployeeMutation) SetChatURL(s string) {
  9479. m.chat_url = &s
  9480. }
  9481. // ChatURL returns the value of the "chat_url" field in the mutation.
  9482. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  9483. v := m.chat_url
  9484. if v == nil {
  9485. return
  9486. }
  9487. return *v, true
  9488. }
  9489. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  9490. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9492. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  9493. if !m.op.Is(OpUpdateOne) {
  9494. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  9495. }
  9496. if m.id == nil || m.oldValue == nil {
  9497. return v, errors.New("OldChatURL requires an ID field in the mutation")
  9498. }
  9499. oldValue, err := m.oldValue(ctx)
  9500. if err != nil {
  9501. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  9502. }
  9503. return oldValue.ChatURL, nil
  9504. }
  9505. // ResetChatURL resets all changes to the "chat_url" field.
  9506. func (m *EmployeeMutation) ResetChatURL() {
  9507. m.chat_url = nil
  9508. }
  9509. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  9510. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  9511. if m.em_work_experiences == nil {
  9512. m.em_work_experiences = make(map[uint64]struct{})
  9513. }
  9514. for i := range ids {
  9515. m.em_work_experiences[ids[i]] = struct{}{}
  9516. }
  9517. }
  9518. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  9519. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  9520. m.clearedem_work_experiences = true
  9521. }
  9522. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  9523. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  9524. return m.clearedem_work_experiences
  9525. }
  9526. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  9527. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  9528. if m.removedem_work_experiences == nil {
  9529. m.removedem_work_experiences = make(map[uint64]struct{})
  9530. }
  9531. for i := range ids {
  9532. delete(m.em_work_experiences, ids[i])
  9533. m.removedem_work_experiences[ids[i]] = struct{}{}
  9534. }
  9535. }
  9536. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  9537. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  9538. for id := range m.removedem_work_experiences {
  9539. ids = append(ids, id)
  9540. }
  9541. return
  9542. }
  9543. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  9544. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  9545. for id := range m.em_work_experiences {
  9546. ids = append(ids, id)
  9547. }
  9548. return
  9549. }
  9550. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  9551. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  9552. m.em_work_experiences = nil
  9553. m.clearedem_work_experiences = false
  9554. m.removedem_work_experiences = nil
  9555. }
  9556. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  9557. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  9558. if m.em_tutorial == nil {
  9559. m.em_tutorial = make(map[uint64]struct{})
  9560. }
  9561. for i := range ids {
  9562. m.em_tutorial[ids[i]] = struct{}{}
  9563. }
  9564. }
  9565. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  9566. func (m *EmployeeMutation) ClearEmTutorial() {
  9567. m.clearedem_tutorial = true
  9568. }
  9569. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  9570. func (m *EmployeeMutation) EmTutorialCleared() bool {
  9571. return m.clearedem_tutorial
  9572. }
  9573. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  9574. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  9575. if m.removedem_tutorial == nil {
  9576. m.removedem_tutorial = make(map[uint64]struct{})
  9577. }
  9578. for i := range ids {
  9579. delete(m.em_tutorial, ids[i])
  9580. m.removedem_tutorial[ids[i]] = struct{}{}
  9581. }
  9582. }
  9583. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  9584. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  9585. for id := range m.removedem_tutorial {
  9586. ids = append(ids, id)
  9587. }
  9588. return
  9589. }
  9590. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  9591. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  9592. for id := range m.em_tutorial {
  9593. ids = append(ids, id)
  9594. }
  9595. return
  9596. }
  9597. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  9598. func (m *EmployeeMutation) ResetEmTutorial() {
  9599. m.em_tutorial = nil
  9600. m.clearedem_tutorial = false
  9601. m.removedem_tutorial = nil
  9602. }
  9603. // Where appends a list predicates to the EmployeeMutation builder.
  9604. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  9605. m.predicates = append(m.predicates, ps...)
  9606. }
  9607. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  9608. // users can use type-assertion to append predicates that do not depend on any generated package.
  9609. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  9610. p := make([]predicate.Employee, len(ps))
  9611. for i := range ps {
  9612. p[i] = ps[i]
  9613. }
  9614. m.Where(p...)
  9615. }
  9616. // Op returns the operation name.
  9617. func (m *EmployeeMutation) Op() Op {
  9618. return m.op
  9619. }
  9620. // SetOp allows setting the mutation operation.
  9621. func (m *EmployeeMutation) SetOp(op Op) {
  9622. m.op = op
  9623. }
  9624. // Type returns the node type of this mutation (Employee).
  9625. func (m *EmployeeMutation) Type() string {
  9626. return m.typ
  9627. }
  9628. // Fields returns all fields that were changed during this mutation. Note that in
  9629. // order to get all numeric fields that were incremented/decremented, call
  9630. // AddedFields().
  9631. func (m *EmployeeMutation) Fields() []string {
  9632. fields := make([]string, 0, 23)
  9633. if m.created_at != nil {
  9634. fields = append(fields, employee.FieldCreatedAt)
  9635. }
  9636. if m.updated_at != nil {
  9637. fields = append(fields, employee.FieldUpdatedAt)
  9638. }
  9639. if m.deleted_at != nil {
  9640. fields = append(fields, employee.FieldDeletedAt)
  9641. }
  9642. if m.title != nil {
  9643. fields = append(fields, employee.FieldTitle)
  9644. }
  9645. if m.avatar != nil {
  9646. fields = append(fields, employee.FieldAvatar)
  9647. }
  9648. if m.tags != nil {
  9649. fields = append(fields, employee.FieldTags)
  9650. }
  9651. if m.hire_count != nil {
  9652. fields = append(fields, employee.FieldHireCount)
  9653. }
  9654. if m.service_count != nil {
  9655. fields = append(fields, employee.FieldServiceCount)
  9656. }
  9657. if m.achievement_count != nil {
  9658. fields = append(fields, employee.FieldAchievementCount)
  9659. }
  9660. if m.intro != nil {
  9661. fields = append(fields, employee.FieldIntro)
  9662. }
  9663. if m.estimate != nil {
  9664. fields = append(fields, employee.FieldEstimate)
  9665. }
  9666. if m.skill != nil {
  9667. fields = append(fields, employee.FieldSkill)
  9668. }
  9669. if m.ability_type != nil {
  9670. fields = append(fields, employee.FieldAbilityType)
  9671. }
  9672. if m.scene != nil {
  9673. fields = append(fields, employee.FieldScene)
  9674. }
  9675. if m.switch_in != nil {
  9676. fields = append(fields, employee.FieldSwitchIn)
  9677. }
  9678. if m.video_url != nil {
  9679. fields = append(fields, employee.FieldVideoURL)
  9680. }
  9681. if m.organization_id != nil {
  9682. fields = append(fields, employee.FieldOrganizationID)
  9683. }
  9684. if m.category_id != nil {
  9685. fields = append(fields, employee.FieldCategoryID)
  9686. }
  9687. if m.api_base != nil {
  9688. fields = append(fields, employee.FieldAPIBase)
  9689. }
  9690. if m.api_key != nil {
  9691. fields = append(fields, employee.FieldAPIKey)
  9692. }
  9693. if m.ai_info != nil {
  9694. fields = append(fields, employee.FieldAiInfo)
  9695. }
  9696. if m.is_vip != nil {
  9697. fields = append(fields, employee.FieldIsVip)
  9698. }
  9699. if m.chat_url != nil {
  9700. fields = append(fields, employee.FieldChatURL)
  9701. }
  9702. return fields
  9703. }
  9704. // Field returns the value of a field with the given name. The second boolean
  9705. // return value indicates that this field was not set, or was not defined in the
  9706. // schema.
  9707. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  9708. switch name {
  9709. case employee.FieldCreatedAt:
  9710. return m.CreatedAt()
  9711. case employee.FieldUpdatedAt:
  9712. return m.UpdatedAt()
  9713. case employee.FieldDeletedAt:
  9714. return m.DeletedAt()
  9715. case employee.FieldTitle:
  9716. return m.Title()
  9717. case employee.FieldAvatar:
  9718. return m.Avatar()
  9719. case employee.FieldTags:
  9720. return m.Tags()
  9721. case employee.FieldHireCount:
  9722. return m.HireCount()
  9723. case employee.FieldServiceCount:
  9724. return m.ServiceCount()
  9725. case employee.FieldAchievementCount:
  9726. return m.AchievementCount()
  9727. case employee.FieldIntro:
  9728. return m.Intro()
  9729. case employee.FieldEstimate:
  9730. return m.Estimate()
  9731. case employee.FieldSkill:
  9732. return m.Skill()
  9733. case employee.FieldAbilityType:
  9734. return m.AbilityType()
  9735. case employee.FieldScene:
  9736. return m.Scene()
  9737. case employee.FieldSwitchIn:
  9738. return m.SwitchIn()
  9739. case employee.FieldVideoURL:
  9740. return m.VideoURL()
  9741. case employee.FieldOrganizationID:
  9742. return m.OrganizationID()
  9743. case employee.FieldCategoryID:
  9744. return m.CategoryID()
  9745. case employee.FieldAPIBase:
  9746. return m.APIBase()
  9747. case employee.FieldAPIKey:
  9748. return m.APIKey()
  9749. case employee.FieldAiInfo:
  9750. return m.AiInfo()
  9751. case employee.FieldIsVip:
  9752. return m.IsVip()
  9753. case employee.FieldChatURL:
  9754. return m.ChatURL()
  9755. }
  9756. return nil, false
  9757. }
  9758. // OldField returns the old value of the field from the database. An error is
  9759. // returned if the mutation operation is not UpdateOne, or the query to the
  9760. // database failed.
  9761. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9762. switch name {
  9763. case employee.FieldCreatedAt:
  9764. return m.OldCreatedAt(ctx)
  9765. case employee.FieldUpdatedAt:
  9766. return m.OldUpdatedAt(ctx)
  9767. case employee.FieldDeletedAt:
  9768. return m.OldDeletedAt(ctx)
  9769. case employee.FieldTitle:
  9770. return m.OldTitle(ctx)
  9771. case employee.FieldAvatar:
  9772. return m.OldAvatar(ctx)
  9773. case employee.FieldTags:
  9774. return m.OldTags(ctx)
  9775. case employee.FieldHireCount:
  9776. return m.OldHireCount(ctx)
  9777. case employee.FieldServiceCount:
  9778. return m.OldServiceCount(ctx)
  9779. case employee.FieldAchievementCount:
  9780. return m.OldAchievementCount(ctx)
  9781. case employee.FieldIntro:
  9782. return m.OldIntro(ctx)
  9783. case employee.FieldEstimate:
  9784. return m.OldEstimate(ctx)
  9785. case employee.FieldSkill:
  9786. return m.OldSkill(ctx)
  9787. case employee.FieldAbilityType:
  9788. return m.OldAbilityType(ctx)
  9789. case employee.FieldScene:
  9790. return m.OldScene(ctx)
  9791. case employee.FieldSwitchIn:
  9792. return m.OldSwitchIn(ctx)
  9793. case employee.FieldVideoURL:
  9794. return m.OldVideoURL(ctx)
  9795. case employee.FieldOrganizationID:
  9796. return m.OldOrganizationID(ctx)
  9797. case employee.FieldCategoryID:
  9798. return m.OldCategoryID(ctx)
  9799. case employee.FieldAPIBase:
  9800. return m.OldAPIBase(ctx)
  9801. case employee.FieldAPIKey:
  9802. return m.OldAPIKey(ctx)
  9803. case employee.FieldAiInfo:
  9804. return m.OldAiInfo(ctx)
  9805. case employee.FieldIsVip:
  9806. return m.OldIsVip(ctx)
  9807. case employee.FieldChatURL:
  9808. return m.OldChatURL(ctx)
  9809. }
  9810. return nil, fmt.Errorf("unknown Employee field %s", name)
  9811. }
  9812. // SetField sets the value of a field with the given name. It returns an error if
  9813. // the field is not defined in the schema, or if the type mismatched the field
  9814. // type.
  9815. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  9816. switch name {
  9817. case employee.FieldCreatedAt:
  9818. v, ok := value.(time.Time)
  9819. if !ok {
  9820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9821. }
  9822. m.SetCreatedAt(v)
  9823. return nil
  9824. case employee.FieldUpdatedAt:
  9825. v, ok := value.(time.Time)
  9826. if !ok {
  9827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9828. }
  9829. m.SetUpdatedAt(v)
  9830. return nil
  9831. case employee.FieldDeletedAt:
  9832. v, ok := value.(time.Time)
  9833. if !ok {
  9834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9835. }
  9836. m.SetDeletedAt(v)
  9837. return nil
  9838. case employee.FieldTitle:
  9839. v, ok := value.(string)
  9840. if !ok {
  9841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9842. }
  9843. m.SetTitle(v)
  9844. return nil
  9845. case employee.FieldAvatar:
  9846. v, ok := value.(string)
  9847. if !ok {
  9848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9849. }
  9850. m.SetAvatar(v)
  9851. return nil
  9852. case employee.FieldTags:
  9853. v, ok := value.(string)
  9854. if !ok {
  9855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9856. }
  9857. m.SetTags(v)
  9858. return nil
  9859. case employee.FieldHireCount:
  9860. v, ok := value.(int)
  9861. if !ok {
  9862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9863. }
  9864. m.SetHireCount(v)
  9865. return nil
  9866. case employee.FieldServiceCount:
  9867. v, ok := value.(int)
  9868. if !ok {
  9869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9870. }
  9871. m.SetServiceCount(v)
  9872. return nil
  9873. case employee.FieldAchievementCount:
  9874. v, ok := value.(int)
  9875. if !ok {
  9876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9877. }
  9878. m.SetAchievementCount(v)
  9879. return nil
  9880. case employee.FieldIntro:
  9881. v, ok := value.(string)
  9882. if !ok {
  9883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9884. }
  9885. m.SetIntro(v)
  9886. return nil
  9887. case employee.FieldEstimate:
  9888. v, ok := value.(string)
  9889. if !ok {
  9890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9891. }
  9892. m.SetEstimate(v)
  9893. return nil
  9894. case employee.FieldSkill:
  9895. v, ok := value.(string)
  9896. if !ok {
  9897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9898. }
  9899. m.SetSkill(v)
  9900. return nil
  9901. case employee.FieldAbilityType:
  9902. v, ok := value.(string)
  9903. if !ok {
  9904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9905. }
  9906. m.SetAbilityType(v)
  9907. return nil
  9908. case employee.FieldScene:
  9909. v, ok := value.(string)
  9910. if !ok {
  9911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9912. }
  9913. m.SetScene(v)
  9914. return nil
  9915. case employee.FieldSwitchIn:
  9916. v, ok := value.(string)
  9917. if !ok {
  9918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9919. }
  9920. m.SetSwitchIn(v)
  9921. return nil
  9922. case employee.FieldVideoURL:
  9923. v, ok := value.(string)
  9924. if !ok {
  9925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9926. }
  9927. m.SetVideoURL(v)
  9928. return nil
  9929. case employee.FieldOrganizationID:
  9930. v, ok := value.(uint64)
  9931. if !ok {
  9932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9933. }
  9934. m.SetOrganizationID(v)
  9935. return nil
  9936. case employee.FieldCategoryID:
  9937. v, ok := value.(uint64)
  9938. if !ok {
  9939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9940. }
  9941. m.SetCategoryID(v)
  9942. return nil
  9943. case employee.FieldAPIBase:
  9944. v, ok := value.(string)
  9945. if !ok {
  9946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9947. }
  9948. m.SetAPIBase(v)
  9949. return nil
  9950. case employee.FieldAPIKey:
  9951. v, ok := value.(string)
  9952. if !ok {
  9953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9954. }
  9955. m.SetAPIKey(v)
  9956. return nil
  9957. case employee.FieldAiInfo:
  9958. v, ok := value.(string)
  9959. if !ok {
  9960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9961. }
  9962. m.SetAiInfo(v)
  9963. return nil
  9964. case employee.FieldIsVip:
  9965. v, ok := value.(int)
  9966. if !ok {
  9967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9968. }
  9969. m.SetIsVip(v)
  9970. return nil
  9971. case employee.FieldChatURL:
  9972. v, ok := value.(string)
  9973. if !ok {
  9974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9975. }
  9976. m.SetChatURL(v)
  9977. return nil
  9978. }
  9979. return fmt.Errorf("unknown Employee field %s", name)
  9980. }
  9981. // AddedFields returns all numeric fields that were incremented/decremented during
  9982. // this mutation.
  9983. func (m *EmployeeMutation) AddedFields() []string {
  9984. var fields []string
  9985. if m.addhire_count != nil {
  9986. fields = append(fields, employee.FieldHireCount)
  9987. }
  9988. if m.addservice_count != nil {
  9989. fields = append(fields, employee.FieldServiceCount)
  9990. }
  9991. if m.addachievement_count != nil {
  9992. fields = append(fields, employee.FieldAchievementCount)
  9993. }
  9994. if m.addorganization_id != nil {
  9995. fields = append(fields, employee.FieldOrganizationID)
  9996. }
  9997. if m.addcategory_id != nil {
  9998. fields = append(fields, employee.FieldCategoryID)
  9999. }
  10000. if m.addis_vip != nil {
  10001. fields = append(fields, employee.FieldIsVip)
  10002. }
  10003. return fields
  10004. }
  10005. // AddedField returns the numeric value that was incremented/decremented on a field
  10006. // with the given name. The second boolean return value indicates that this field
  10007. // was not set, or was not defined in the schema.
  10008. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  10009. switch name {
  10010. case employee.FieldHireCount:
  10011. return m.AddedHireCount()
  10012. case employee.FieldServiceCount:
  10013. return m.AddedServiceCount()
  10014. case employee.FieldAchievementCount:
  10015. return m.AddedAchievementCount()
  10016. case employee.FieldOrganizationID:
  10017. return m.AddedOrganizationID()
  10018. case employee.FieldCategoryID:
  10019. return m.AddedCategoryID()
  10020. case employee.FieldIsVip:
  10021. return m.AddedIsVip()
  10022. }
  10023. return nil, false
  10024. }
  10025. // AddField adds the value to the field with the given name. It returns an error if
  10026. // the field is not defined in the schema, or if the type mismatched the field
  10027. // type.
  10028. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  10029. switch name {
  10030. case employee.FieldHireCount:
  10031. v, ok := value.(int)
  10032. if !ok {
  10033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10034. }
  10035. m.AddHireCount(v)
  10036. return nil
  10037. case employee.FieldServiceCount:
  10038. v, ok := value.(int)
  10039. if !ok {
  10040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10041. }
  10042. m.AddServiceCount(v)
  10043. return nil
  10044. case employee.FieldAchievementCount:
  10045. v, ok := value.(int)
  10046. if !ok {
  10047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10048. }
  10049. m.AddAchievementCount(v)
  10050. return nil
  10051. case employee.FieldOrganizationID:
  10052. v, ok := value.(int64)
  10053. if !ok {
  10054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10055. }
  10056. m.AddOrganizationID(v)
  10057. return nil
  10058. case employee.FieldCategoryID:
  10059. v, ok := value.(int64)
  10060. if !ok {
  10061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10062. }
  10063. m.AddCategoryID(v)
  10064. return nil
  10065. case employee.FieldIsVip:
  10066. v, ok := value.(int)
  10067. if !ok {
  10068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10069. }
  10070. m.AddIsVip(v)
  10071. return nil
  10072. }
  10073. return fmt.Errorf("unknown Employee numeric field %s", name)
  10074. }
  10075. // ClearedFields returns all nullable fields that were cleared during this
  10076. // mutation.
  10077. func (m *EmployeeMutation) ClearedFields() []string {
  10078. var fields []string
  10079. if m.FieldCleared(employee.FieldDeletedAt) {
  10080. fields = append(fields, employee.FieldDeletedAt)
  10081. }
  10082. if m.FieldCleared(employee.FieldAiInfo) {
  10083. fields = append(fields, employee.FieldAiInfo)
  10084. }
  10085. return fields
  10086. }
  10087. // FieldCleared returns a boolean indicating if a field with the given name was
  10088. // cleared in this mutation.
  10089. func (m *EmployeeMutation) FieldCleared(name string) bool {
  10090. _, ok := m.clearedFields[name]
  10091. return ok
  10092. }
  10093. // ClearField clears the value of the field with the given name. It returns an
  10094. // error if the field is not defined in the schema.
  10095. func (m *EmployeeMutation) ClearField(name string) error {
  10096. switch name {
  10097. case employee.FieldDeletedAt:
  10098. m.ClearDeletedAt()
  10099. return nil
  10100. case employee.FieldAiInfo:
  10101. m.ClearAiInfo()
  10102. return nil
  10103. }
  10104. return fmt.Errorf("unknown Employee nullable field %s", name)
  10105. }
  10106. // ResetField resets all changes in the mutation for the field with the given name.
  10107. // It returns an error if the field is not defined in the schema.
  10108. func (m *EmployeeMutation) ResetField(name string) error {
  10109. switch name {
  10110. case employee.FieldCreatedAt:
  10111. m.ResetCreatedAt()
  10112. return nil
  10113. case employee.FieldUpdatedAt:
  10114. m.ResetUpdatedAt()
  10115. return nil
  10116. case employee.FieldDeletedAt:
  10117. m.ResetDeletedAt()
  10118. return nil
  10119. case employee.FieldTitle:
  10120. m.ResetTitle()
  10121. return nil
  10122. case employee.FieldAvatar:
  10123. m.ResetAvatar()
  10124. return nil
  10125. case employee.FieldTags:
  10126. m.ResetTags()
  10127. return nil
  10128. case employee.FieldHireCount:
  10129. m.ResetHireCount()
  10130. return nil
  10131. case employee.FieldServiceCount:
  10132. m.ResetServiceCount()
  10133. return nil
  10134. case employee.FieldAchievementCount:
  10135. m.ResetAchievementCount()
  10136. return nil
  10137. case employee.FieldIntro:
  10138. m.ResetIntro()
  10139. return nil
  10140. case employee.FieldEstimate:
  10141. m.ResetEstimate()
  10142. return nil
  10143. case employee.FieldSkill:
  10144. m.ResetSkill()
  10145. return nil
  10146. case employee.FieldAbilityType:
  10147. m.ResetAbilityType()
  10148. return nil
  10149. case employee.FieldScene:
  10150. m.ResetScene()
  10151. return nil
  10152. case employee.FieldSwitchIn:
  10153. m.ResetSwitchIn()
  10154. return nil
  10155. case employee.FieldVideoURL:
  10156. m.ResetVideoURL()
  10157. return nil
  10158. case employee.FieldOrganizationID:
  10159. m.ResetOrganizationID()
  10160. return nil
  10161. case employee.FieldCategoryID:
  10162. m.ResetCategoryID()
  10163. return nil
  10164. case employee.FieldAPIBase:
  10165. m.ResetAPIBase()
  10166. return nil
  10167. case employee.FieldAPIKey:
  10168. m.ResetAPIKey()
  10169. return nil
  10170. case employee.FieldAiInfo:
  10171. m.ResetAiInfo()
  10172. return nil
  10173. case employee.FieldIsVip:
  10174. m.ResetIsVip()
  10175. return nil
  10176. case employee.FieldChatURL:
  10177. m.ResetChatURL()
  10178. return nil
  10179. }
  10180. return fmt.Errorf("unknown Employee field %s", name)
  10181. }
  10182. // AddedEdges returns all edge names that were set/added in this mutation.
  10183. func (m *EmployeeMutation) AddedEdges() []string {
  10184. edges := make([]string, 0, 2)
  10185. if m.em_work_experiences != nil {
  10186. edges = append(edges, employee.EdgeEmWorkExperiences)
  10187. }
  10188. if m.em_tutorial != nil {
  10189. edges = append(edges, employee.EdgeEmTutorial)
  10190. }
  10191. return edges
  10192. }
  10193. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10194. // name in this mutation.
  10195. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  10196. switch name {
  10197. case employee.EdgeEmWorkExperiences:
  10198. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  10199. for id := range m.em_work_experiences {
  10200. ids = append(ids, id)
  10201. }
  10202. return ids
  10203. case employee.EdgeEmTutorial:
  10204. ids := make([]ent.Value, 0, len(m.em_tutorial))
  10205. for id := range m.em_tutorial {
  10206. ids = append(ids, id)
  10207. }
  10208. return ids
  10209. }
  10210. return nil
  10211. }
  10212. // RemovedEdges returns all edge names that were removed in this mutation.
  10213. func (m *EmployeeMutation) RemovedEdges() []string {
  10214. edges := make([]string, 0, 2)
  10215. if m.removedem_work_experiences != nil {
  10216. edges = append(edges, employee.EdgeEmWorkExperiences)
  10217. }
  10218. if m.removedem_tutorial != nil {
  10219. edges = append(edges, employee.EdgeEmTutorial)
  10220. }
  10221. return edges
  10222. }
  10223. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10224. // the given name in this mutation.
  10225. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  10226. switch name {
  10227. case employee.EdgeEmWorkExperiences:
  10228. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  10229. for id := range m.removedem_work_experiences {
  10230. ids = append(ids, id)
  10231. }
  10232. return ids
  10233. case employee.EdgeEmTutorial:
  10234. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  10235. for id := range m.removedem_tutorial {
  10236. ids = append(ids, id)
  10237. }
  10238. return ids
  10239. }
  10240. return nil
  10241. }
  10242. // ClearedEdges returns all edge names that were cleared in this mutation.
  10243. func (m *EmployeeMutation) ClearedEdges() []string {
  10244. edges := make([]string, 0, 2)
  10245. if m.clearedem_work_experiences {
  10246. edges = append(edges, employee.EdgeEmWorkExperiences)
  10247. }
  10248. if m.clearedem_tutorial {
  10249. edges = append(edges, employee.EdgeEmTutorial)
  10250. }
  10251. return edges
  10252. }
  10253. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10254. // was cleared in this mutation.
  10255. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  10256. switch name {
  10257. case employee.EdgeEmWorkExperiences:
  10258. return m.clearedem_work_experiences
  10259. case employee.EdgeEmTutorial:
  10260. return m.clearedem_tutorial
  10261. }
  10262. return false
  10263. }
  10264. // ClearEdge clears the value of the edge with the given name. It returns an error
  10265. // if that edge is not defined in the schema.
  10266. func (m *EmployeeMutation) ClearEdge(name string) error {
  10267. switch name {
  10268. }
  10269. return fmt.Errorf("unknown Employee unique edge %s", name)
  10270. }
  10271. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10272. // It returns an error if the edge is not defined in the schema.
  10273. func (m *EmployeeMutation) ResetEdge(name string) error {
  10274. switch name {
  10275. case employee.EdgeEmWorkExperiences:
  10276. m.ResetEmWorkExperiences()
  10277. return nil
  10278. case employee.EdgeEmTutorial:
  10279. m.ResetEmTutorial()
  10280. return nil
  10281. }
  10282. return fmt.Errorf("unknown Employee edge %s", name)
  10283. }
  10284. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  10285. type EmployeeConfigMutation struct {
  10286. config
  10287. op Op
  10288. typ string
  10289. id *uint64
  10290. created_at *time.Time
  10291. updated_at *time.Time
  10292. deleted_at *time.Time
  10293. stype *string
  10294. title *string
  10295. photo *string
  10296. organization_id *uint64
  10297. addorganization_id *int64
  10298. clearedFields map[string]struct{}
  10299. done bool
  10300. oldValue func(context.Context) (*EmployeeConfig, error)
  10301. predicates []predicate.EmployeeConfig
  10302. }
  10303. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  10304. // employeeconfigOption allows management of the mutation configuration using functional options.
  10305. type employeeconfigOption func(*EmployeeConfigMutation)
  10306. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  10307. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  10308. m := &EmployeeConfigMutation{
  10309. config: c,
  10310. op: op,
  10311. typ: TypeEmployeeConfig,
  10312. clearedFields: make(map[string]struct{}),
  10313. }
  10314. for _, opt := range opts {
  10315. opt(m)
  10316. }
  10317. return m
  10318. }
  10319. // withEmployeeConfigID sets the ID field of the mutation.
  10320. func withEmployeeConfigID(id uint64) employeeconfigOption {
  10321. return func(m *EmployeeConfigMutation) {
  10322. var (
  10323. err error
  10324. once sync.Once
  10325. value *EmployeeConfig
  10326. )
  10327. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  10328. once.Do(func() {
  10329. if m.done {
  10330. err = errors.New("querying old values post mutation is not allowed")
  10331. } else {
  10332. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  10333. }
  10334. })
  10335. return value, err
  10336. }
  10337. m.id = &id
  10338. }
  10339. }
  10340. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  10341. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  10342. return func(m *EmployeeConfigMutation) {
  10343. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  10344. return node, nil
  10345. }
  10346. m.id = &node.ID
  10347. }
  10348. }
  10349. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10350. // executed in a transaction (ent.Tx), a transactional client is returned.
  10351. func (m EmployeeConfigMutation) Client() *Client {
  10352. client := &Client{config: m.config}
  10353. client.init()
  10354. return client
  10355. }
  10356. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10357. // it returns an error otherwise.
  10358. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  10359. if _, ok := m.driver.(*txDriver); !ok {
  10360. return nil, errors.New("ent: mutation is not running in a transaction")
  10361. }
  10362. tx := &Tx{config: m.config}
  10363. tx.init()
  10364. return tx, nil
  10365. }
  10366. // SetID sets the value of the id field. Note that this
  10367. // operation is only accepted on creation of EmployeeConfig entities.
  10368. func (m *EmployeeConfigMutation) SetID(id uint64) {
  10369. m.id = &id
  10370. }
  10371. // ID returns the ID value in the mutation. Note that the ID is only available
  10372. // if it was provided to the builder or after it was returned from the database.
  10373. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  10374. if m.id == nil {
  10375. return
  10376. }
  10377. return *m.id, true
  10378. }
  10379. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10380. // That means, if the mutation is applied within a transaction with an isolation level such
  10381. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10382. // or updated by the mutation.
  10383. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  10384. switch {
  10385. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10386. id, exists := m.ID()
  10387. if exists {
  10388. return []uint64{id}, nil
  10389. }
  10390. fallthrough
  10391. case m.op.Is(OpUpdate | OpDelete):
  10392. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  10393. default:
  10394. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10395. }
  10396. }
  10397. // SetCreatedAt sets the "created_at" field.
  10398. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  10399. m.created_at = &t
  10400. }
  10401. // CreatedAt returns the value of the "created_at" field in the mutation.
  10402. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  10403. v := m.created_at
  10404. if v == nil {
  10405. return
  10406. }
  10407. return *v, true
  10408. }
  10409. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  10410. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10412. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10413. if !m.op.Is(OpUpdateOne) {
  10414. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10415. }
  10416. if m.id == nil || m.oldValue == nil {
  10417. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10418. }
  10419. oldValue, err := m.oldValue(ctx)
  10420. if err != nil {
  10421. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10422. }
  10423. return oldValue.CreatedAt, nil
  10424. }
  10425. // ResetCreatedAt resets all changes to the "created_at" field.
  10426. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  10427. m.created_at = nil
  10428. }
  10429. // SetUpdatedAt sets the "updated_at" field.
  10430. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  10431. m.updated_at = &t
  10432. }
  10433. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10434. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  10435. v := m.updated_at
  10436. if v == nil {
  10437. return
  10438. }
  10439. return *v, true
  10440. }
  10441. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  10442. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10444. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10445. if !m.op.Is(OpUpdateOne) {
  10446. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10447. }
  10448. if m.id == nil || m.oldValue == nil {
  10449. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10450. }
  10451. oldValue, err := m.oldValue(ctx)
  10452. if err != nil {
  10453. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10454. }
  10455. return oldValue.UpdatedAt, nil
  10456. }
  10457. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10458. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  10459. m.updated_at = nil
  10460. }
  10461. // SetDeletedAt sets the "deleted_at" field.
  10462. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  10463. m.deleted_at = &t
  10464. }
  10465. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10466. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  10467. v := m.deleted_at
  10468. if v == nil {
  10469. return
  10470. }
  10471. return *v, true
  10472. }
  10473. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  10474. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10476. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10477. if !m.op.Is(OpUpdateOne) {
  10478. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10479. }
  10480. if m.id == nil || m.oldValue == nil {
  10481. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10482. }
  10483. oldValue, err := m.oldValue(ctx)
  10484. if err != nil {
  10485. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10486. }
  10487. return oldValue.DeletedAt, nil
  10488. }
  10489. // ClearDeletedAt clears the value of the "deleted_at" field.
  10490. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  10491. m.deleted_at = nil
  10492. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  10493. }
  10494. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10495. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  10496. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  10497. return ok
  10498. }
  10499. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10500. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  10501. m.deleted_at = nil
  10502. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  10503. }
  10504. // SetStype sets the "stype" field.
  10505. func (m *EmployeeConfigMutation) SetStype(s string) {
  10506. m.stype = &s
  10507. }
  10508. // Stype returns the value of the "stype" field in the mutation.
  10509. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  10510. v := m.stype
  10511. if v == nil {
  10512. return
  10513. }
  10514. return *v, true
  10515. }
  10516. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  10517. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10519. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  10520. if !m.op.Is(OpUpdateOne) {
  10521. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  10522. }
  10523. if m.id == nil || m.oldValue == nil {
  10524. return v, errors.New("OldStype requires an ID field in the mutation")
  10525. }
  10526. oldValue, err := m.oldValue(ctx)
  10527. if err != nil {
  10528. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  10529. }
  10530. return oldValue.Stype, nil
  10531. }
  10532. // ResetStype resets all changes to the "stype" field.
  10533. func (m *EmployeeConfigMutation) ResetStype() {
  10534. m.stype = nil
  10535. }
  10536. // SetTitle sets the "title" field.
  10537. func (m *EmployeeConfigMutation) SetTitle(s string) {
  10538. m.title = &s
  10539. }
  10540. // Title returns the value of the "title" field in the mutation.
  10541. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  10542. v := m.title
  10543. if v == nil {
  10544. return
  10545. }
  10546. return *v, true
  10547. }
  10548. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  10549. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10551. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  10552. if !m.op.Is(OpUpdateOne) {
  10553. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  10554. }
  10555. if m.id == nil || m.oldValue == nil {
  10556. return v, errors.New("OldTitle requires an ID field in the mutation")
  10557. }
  10558. oldValue, err := m.oldValue(ctx)
  10559. if err != nil {
  10560. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  10561. }
  10562. return oldValue.Title, nil
  10563. }
  10564. // ResetTitle resets all changes to the "title" field.
  10565. func (m *EmployeeConfigMutation) ResetTitle() {
  10566. m.title = nil
  10567. }
  10568. // SetPhoto sets the "photo" field.
  10569. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  10570. m.photo = &s
  10571. }
  10572. // Photo returns the value of the "photo" field in the mutation.
  10573. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  10574. v := m.photo
  10575. if v == nil {
  10576. return
  10577. }
  10578. return *v, true
  10579. }
  10580. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  10581. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10583. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  10584. if !m.op.Is(OpUpdateOne) {
  10585. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  10586. }
  10587. if m.id == nil || m.oldValue == nil {
  10588. return v, errors.New("OldPhoto requires an ID field in the mutation")
  10589. }
  10590. oldValue, err := m.oldValue(ctx)
  10591. if err != nil {
  10592. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  10593. }
  10594. return oldValue.Photo, nil
  10595. }
  10596. // ResetPhoto resets all changes to the "photo" field.
  10597. func (m *EmployeeConfigMutation) ResetPhoto() {
  10598. m.photo = nil
  10599. }
  10600. // SetOrganizationID sets the "organization_id" field.
  10601. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  10602. m.organization_id = &u
  10603. m.addorganization_id = nil
  10604. }
  10605. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10606. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  10607. v := m.organization_id
  10608. if v == nil {
  10609. return
  10610. }
  10611. return *v, true
  10612. }
  10613. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  10614. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10616. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10617. if !m.op.Is(OpUpdateOne) {
  10618. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10619. }
  10620. if m.id == nil || m.oldValue == nil {
  10621. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10622. }
  10623. oldValue, err := m.oldValue(ctx)
  10624. if err != nil {
  10625. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10626. }
  10627. return oldValue.OrganizationID, nil
  10628. }
  10629. // AddOrganizationID adds u to the "organization_id" field.
  10630. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  10631. if m.addorganization_id != nil {
  10632. *m.addorganization_id += u
  10633. } else {
  10634. m.addorganization_id = &u
  10635. }
  10636. }
  10637. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10638. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  10639. v := m.addorganization_id
  10640. if v == nil {
  10641. return
  10642. }
  10643. return *v, true
  10644. }
  10645. // ClearOrganizationID clears the value of the "organization_id" field.
  10646. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  10647. m.organization_id = nil
  10648. m.addorganization_id = nil
  10649. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  10650. }
  10651. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10652. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  10653. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  10654. return ok
  10655. }
  10656. // ResetOrganizationID resets all changes to the "organization_id" field.
  10657. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  10658. m.organization_id = nil
  10659. m.addorganization_id = nil
  10660. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  10661. }
  10662. // Where appends a list predicates to the EmployeeConfigMutation builder.
  10663. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  10664. m.predicates = append(m.predicates, ps...)
  10665. }
  10666. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  10667. // users can use type-assertion to append predicates that do not depend on any generated package.
  10668. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  10669. p := make([]predicate.EmployeeConfig, len(ps))
  10670. for i := range ps {
  10671. p[i] = ps[i]
  10672. }
  10673. m.Where(p...)
  10674. }
  10675. // Op returns the operation name.
  10676. func (m *EmployeeConfigMutation) Op() Op {
  10677. return m.op
  10678. }
  10679. // SetOp allows setting the mutation operation.
  10680. func (m *EmployeeConfigMutation) SetOp(op Op) {
  10681. m.op = op
  10682. }
  10683. // Type returns the node type of this mutation (EmployeeConfig).
  10684. func (m *EmployeeConfigMutation) Type() string {
  10685. return m.typ
  10686. }
  10687. // Fields returns all fields that were changed during this mutation. Note that in
  10688. // order to get all numeric fields that were incremented/decremented, call
  10689. // AddedFields().
  10690. func (m *EmployeeConfigMutation) Fields() []string {
  10691. fields := make([]string, 0, 7)
  10692. if m.created_at != nil {
  10693. fields = append(fields, employeeconfig.FieldCreatedAt)
  10694. }
  10695. if m.updated_at != nil {
  10696. fields = append(fields, employeeconfig.FieldUpdatedAt)
  10697. }
  10698. if m.deleted_at != nil {
  10699. fields = append(fields, employeeconfig.FieldDeletedAt)
  10700. }
  10701. if m.stype != nil {
  10702. fields = append(fields, employeeconfig.FieldStype)
  10703. }
  10704. if m.title != nil {
  10705. fields = append(fields, employeeconfig.FieldTitle)
  10706. }
  10707. if m.photo != nil {
  10708. fields = append(fields, employeeconfig.FieldPhoto)
  10709. }
  10710. if m.organization_id != nil {
  10711. fields = append(fields, employeeconfig.FieldOrganizationID)
  10712. }
  10713. return fields
  10714. }
  10715. // Field returns the value of a field with the given name. The second boolean
  10716. // return value indicates that this field was not set, or was not defined in the
  10717. // schema.
  10718. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  10719. switch name {
  10720. case employeeconfig.FieldCreatedAt:
  10721. return m.CreatedAt()
  10722. case employeeconfig.FieldUpdatedAt:
  10723. return m.UpdatedAt()
  10724. case employeeconfig.FieldDeletedAt:
  10725. return m.DeletedAt()
  10726. case employeeconfig.FieldStype:
  10727. return m.Stype()
  10728. case employeeconfig.FieldTitle:
  10729. return m.Title()
  10730. case employeeconfig.FieldPhoto:
  10731. return m.Photo()
  10732. case employeeconfig.FieldOrganizationID:
  10733. return m.OrganizationID()
  10734. }
  10735. return nil, false
  10736. }
  10737. // OldField returns the old value of the field from the database. An error is
  10738. // returned if the mutation operation is not UpdateOne, or the query to the
  10739. // database failed.
  10740. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10741. switch name {
  10742. case employeeconfig.FieldCreatedAt:
  10743. return m.OldCreatedAt(ctx)
  10744. case employeeconfig.FieldUpdatedAt:
  10745. return m.OldUpdatedAt(ctx)
  10746. case employeeconfig.FieldDeletedAt:
  10747. return m.OldDeletedAt(ctx)
  10748. case employeeconfig.FieldStype:
  10749. return m.OldStype(ctx)
  10750. case employeeconfig.FieldTitle:
  10751. return m.OldTitle(ctx)
  10752. case employeeconfig.FieldPhoto:
  10753. return m.OldPhoto(ctx)
  10754. case employeeconfig.FieldOrganizationID:
  10755. return m.OldOrganizationID(ctx)
  10756. }
  10757. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  10758. }
  10759. // SetField sets the value of a field with the given name. It returns an error if
  10760. // the field is not defined in the schema, or if the type mismatched the field
  10761. // type.
  10762. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  10763. switch name {
  10764. case employeeconfig.FieldCreatedAt:
  10765. v, ok := value.(time.Time)
  10766. if !ok {
  10767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10768. }
  10769. m.SetCreatedAt(v)
  10770. return nil
  10771. case employeeconfig.FieldUpdatedAt:
  10772. v, ok := value.(time.Time)
  10773. if !ok {
  10774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10775. }
  10776. m.SetUpdatedAt(v)
  10777. return nil
  10778. case employeeconfig.FieldDeletedAt:
  10779. v, ok := value.(time.Time)
  10780. if !ok {
  10781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10782. }
  10783. m.SetDeletedAt(v)
  10784. return nil
  10785. case employeeconfig.FieldStype:
  10786. v, ok := value.(string)
  10787. if !ok {
  10788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10789. }
  10790. m.SetStype(v)
  10791. return nil
  10792. case employeeconfig.FieldTitle:
  10793. v, ok := value.(string)
  10794. if !ok {
  10795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10796. }
  10797. m.SetTitle(v)
  10798. return nil
  10799. case employeeconfig.FieldPhoto:
  10800. v, ok := value.(string)
  10801. if !ok {
  10802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10803. }
  10804. m.SetPhoto(v)
  10805. return nil
  10806. case employeeconfig.FieldOrganizationID:
  10807. v, ok := value.(uint64)
  10808. if !ok {
  10809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10810. }
  10811. m.SetOrganizationID(v)
  10812. return nil
  10813. }
  10814. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10815. }
  10816. // AddedFields returns all numeric fields that were incremented/decremented during
  10817. // this mutation.
  10818. func (m *EmployeeConfigMutation) AddedFields() []string {
  10819. var fields []string
  10820. if m.addorganization_id != nil {
  10821. fields = append(fields, employeeconfig.FieldOrganizationID)
  10822. }
  10823. return fields
  10824. }
  10825. // AddedField returns the numeric value that was incremented/decremented on a field
  10826. // with the given name. The second boolean return value indicates that this field
  10827. // was not set, or was not defined in the schema.
  10828. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  10829. switch name {
  10830. case employeeconfig.FieldOrganizationID:
  10831. return m.AddedOrganizationID()
  10832. }
  10833. return nil, false
  10834. }
  10835. // AddField adds the value to the field with the given name. It returns an error if
  10836. // the field is not defined in the schema, or if the type mismatched the field
  10837. // type.
  10838. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  10839. switch name {
  10840. case employeeconfig.FieldOrganizationID:
  10841. v, ok := value.(int64)
  10842. if !ok {
  10843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10844. }
  10845. m.AddOrganizationID(v)
  10846. return nil
  10847. }
  10848. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  10849. }
  10850. // ClearedFields returns all nullable fields that were cleared during this
  10851. // mutation.
  10852. func (m *EmployeeConfigMutation) ClearedFields() []string {
  10853. var fields []string
  10854. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  10855. fields = append(fields, employeeconfig.FieldDeletedAt)
  10856. }
  10857. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  10858. fields = append(fields, employeeconfig.FieldOrganizationID)
  10859. }
  10860. return fields
  10861. }
  10862. // FieldCleared returns a boolean indicating if a field with the given name was
  10863. // cleared in this mutation.
  10864. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  10865. _, ok := m.clearedFields[name]
  10866. return ok
  10867. }
  10868. // ClearField clears the value of the field with the given name. It returns an
  10869. // error if the field is not defined in the schema.
  10870. func (m *EmployeeConfigMutation) ClearField(name string) error {
  10871. switch name {
  10872. case employeeconfig.FieldDeletedAt:
  10873. m.ClearDeletedAt()
  10874. return nil
  10875. case employeeconfig.FieldOrganizationID:
  10876. m.ClearOrganizationID()
  10877. return nil
  10878. }
  10879. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  10880. }
  10881. // ResetField resets all changes in the mutation for the field with the given name.
  10882. // It returns an error if the field is not defined in the schema.
  10883. func (m *EmployeeConfigMutation) ResetField(name string) error {
  10884. switch name {
  10885. case employeeconfig.FieldCreatedAt:
  10886. m.ResetCreatedAt()
  10887. return nil
  10888. case employeeconfig.FieldUpdatedAt:
  10889. m.ResetUpdatedAt()
  10890. return nil
  10891. case employeeconfig.FieldDeletedAt:
  10892. m.ResetDeletedAt()
  10893. return nil
  10894. case employeeconfig.FieldStype:
  10895. m.ResetStype()
  10896. return nil
  10897. case employeeconfig.FieldTitle:
  10898. m.ResetTitle()
  10899. return nil
  10900. case employeeconfig.FieldPhoto:
  10901. m.ResetPhoto()
  10902. return nil
  10903. case employeeconfig.FieldOrganizationID:
  10904. m.ResetOrganizationID()
  10905. return nil
  10906. }
  10907. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10908. }
  10909. // AddedEdges returns all edge names that were set/added in this mutation.
  10910. func (m *EmployeeConfigMutation) AddedEdges() []string {
  10911. edges := make([]string, 0, 0)
  10912. return edges
  10913. }
  10914. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10915. // name in this mutation.
  10916. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  10917. return nil
  10918. }
  10919. // RemovedEdges returns all edge names that were removed in this mutation.
  10920. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  10921. edges := make([]string, 0, 0)
  10922. return edges
  10923. }
  10924. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10925. // the given name in this mutation.
  10926. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  10927. return nil
  10928. }
  10929. // ClearedEdges returns all edge names that were cleared in this mutation.
  10930. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  10931. edges := make([]string, 0, 0)
  10932. return edges
  10933. }
  10934. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10935. // was cleared in this mutation.
  10936. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  10937. return false
  10938. }
  10939. // ClearEdge clears the value of the edge with the given name. It returns an error
  10940. // if that edge is not defined in the schema.
  10941. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  10942. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  10943. }
  10944. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10945. // It returns an error if the edge is not defined in the schema.
  10946. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  10947. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  10948. }
  10949. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  10950. type LabelMutation struct {
  10951. config
  10952. op Op
  10953. typ string
  10954. id *uint64
  10955. created_at *time.Time
  10956. updated_at *time.Time
  10957. status *uint8
  10958. addstatus *int8
  10959. _type *int
  10960. add_type *int
  10961. name *string
  10962. from *int
  10963. addfrom *int
  10964. mode *int
  10965. addmode *int
  10966. conditions *string
  10967. organization_id *uint64
  10968. addorganization_id *int64
  10969. clearedFields map[string]struct{}
  10970. label_relationships map[uint64]struct{}
  10971. removedlabel_relationships map[uint64]struct{}
  10972. clearedlabel_relationships bool
  10973. done bool
  10974. oldValue func(context.Context) (*Label, error)
  10975. predicates []predicate.Label
  10976. }
  10977. var _ ent.Mutation = (*LabelMutation)(nil)
  10978. // labelOption allows management of the mutation configuration using functional options.
  10979. type labelOption func(*LabelMutation)
  10980. // newLabelMutation creates new mutation for the Label entity.
  10981. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  10982. m := &LabelMutation{
  10983. config: c,
  10984. op: op,
  10985. typ: TypeLabel,
  10986. clearedFields: make(map[string]struct{}),
  10987. }
  10988. for _, opt := range opts {
  10989. opt(m)
  10990. }
  10991. return m
  10992. }
  10993. // withLabelID sets the ID field of the mutation.
  10994. func withLabelID(id uint64) labelOption {
  10995. return func(m *LabelMutation) {
  10996. var (
  10997. err error
  10998. once sync.Once
  10999. value *Label
  11000. )
  11001. m.oldValue = func(ctx context.Context) (*Label, error) {
  11002. once.Do(func() {
  11003. if m.done {
  11004. err = errors.New("querying old values post mutation is not allowed")
  11005. } else {
  11006. value, err = m.Client().Label.Get(ctx, id)
  11007. }
  11008. })
  11009. return value, err
  11010. }
  11011. m.id = &id
  11012. }
  11013. }
  11014. // withLabel sets the old Label of the mutation.
  11015. func withLabel(node *Label) labelOption {
  11016. return func(m *LabelMutation) {
  11017. m.oldValue = func(context.Context) (*Label, error) {
  11018. return node, nil
  11019. }
  11020. m.id = &node.ID
  11021. }
  11022. }
  11023. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11024. // executed in a transaction (ent.Tx), a transactional client is returned.
  11025. func (m LabelMutation) Client() *Client {
  11026. client := &Client{config: m.config}
  11027. client.init()
  11028. return client
  11029. }
  11030. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11031. // it returns an error otherwise.
  11032. func (m LabelMutation) Tx() (*Tx, error) {
  11033. if _, ok := m.driver.(*txDriver); !ok {
  11034. return nil, errors.New("ent: mutation is not running in a transaction")
  11035. }
  11036. tx := &Tx{config: m.config}
  11037. tx.init()
  11038. return tx, nil
  11039. }
  11040. // SetID sets the value of the id field. Note that this
  11041. // operation is only accepted on creation of Label entities.
  11042. func (m *LabelMutation) SetID(id uint64) {
  11043. m.id = &id
  11044. }
  11045. // ID returns the ID value in the mutation. Note that the ID is only available
  11046. // if it was provided to the builder or after it was returned from the database.
  11047. func (m *LabelMutation) ID() (id uint64, exists bool) {
  11048. if m.id == nil {
  11049. return
  11050. }
  11051. return *m.id, true
  11052. }
  11053. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11054. // That means, if the mutation is applied within a transaction with an isolation level such
  11055. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11056. // or updated by the mutation.
  11057. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  11058. switch {
  11059. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11060. id, exists := m.ID()
  11061. if exists {
  11062. return []uint64{id}, nil
  11063. }
  11064. fallthrough
  11065. case m.op.Is(OpUpdate | OpDelete):
  11066. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  11067. default:
  11068. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11069. }
  11070. }
  11071. // SetCreatedAt sets the "created_at" field.
  11072. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  11073. m.created_at = &t
  11074. }
  11075. // CreatedAt returns the value of the "created_at" field in the mutation.
  11076. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  11077. v := m.created_at
  11078. if v == nil {
  11079. return
  11080. }
  11081. return *v, true
  11082. }
  11083. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  11084. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11086. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11087. if !m.op.Is(OpUpdateOne) {
  11088. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11089. }
  11090. if m.id == nil || m.oldValue == nil {
  11091. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11092. }
  11093. oldValue, err := m.oldValue(ctx)
  11094. if err != nil {
  11095. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11096. }
  11097. return oldValue.CreatedAt, nil
  11098. }
  11099. // ResetCreatedAt resets all changes to the "created_at" field.
  11100. func (m *LabelMutation) ResetCreatedAt() {
  11101. m.created_at = nil
  11102. }
  11103. // SetUpdatedAt sets the "updated_at" field.
  11104. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  11105. m.updated_at = &t
  11106. }
  11107. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11108. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  11109. v := m.updated_at
  11110. if v == nil {
  11111. return
  11112. }
  11113. return *v, true
  11114. }
  11115. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  11116. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11118. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11119. if !m.op.Is(OpUpdateOne) {
  11120. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11121. }
  11122. if m.id == nil || m.oldValue == nil {
  11123. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11124. }
  11125. oldValue, err := m.oldValue(ctx)
  11126. if err != nil {
  11127. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11128. }
  11129. return oldValue.UpdatedAt, nil
  11130. }
  11131. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11132. func (m *LabelMutation) ResetUpdatedAt() {
  11133. m.updated_at = nil
  11134. }
  11135. // SetStatus sets the "status" field.
  11136. func (m *LabelMutation) SetStatus(u uint8) {
  11137. m.status = &u
  11138. m.addstatus = nil
  11139. }
  11140. // Status returns the value of the "status" field in the mutation.
  11141. func (m *LabelMutation) Status() (r uint8, exists bool) {
  11142. v := m.status
  11143. if v == nil {
  11144. return
  11145. }
  11146. return *v, true
  11147. }
  11148. // OldStatus returns the old "status" field's value of the Label entity.
  11149. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11151. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11152. if !m.op.Is(OpUpdateOne) {
  11153. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11154. }
  11155. if m.id == nil || m.oldValue == nil {
  11156. return v, errors.New("OldStatus requires an ID field in the mutation")
  11157. }
  11158. oldValue, err := m.oldValue(ctx)
  11159. if err != nil {
  11160. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11161. }
  11162. return oldValue.Status, nil
  11163. }
  11164. // AddStatus adds u to the "status" field.
  11165. func (m *LabelMutation) AddStatus(u int8) {
  11166. if m.addstatus != nil {
  11167. *m.addstatus += u
  11168. } else {
  11169. m.addstatus = &u
  11170. }
  11171. }
  11172. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11173. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  11174. v := m.addstatus
  11175. if v == nil {
  11176. return
  11177. }
  11178. return *v, true
  11179. }
  11180. // ClearStatus clears the value of the "status" field.
  11181. func (m *LabelMutation) ClearStatus() {
  11182. m.status = nil
  11183. m.addstatus = nil
  11184. m.clearedFields[label.FieldStatus] = struct{}{}
  11185. }
  11186. // StatusCleared returns if the "status" field was cleared in this mutation.
  11187. func (m *LabelMutation) StatusCleared() bool {
  11188. _, ok := m.clearedFields[label.FieldStatus]
  11189. return ok
  11190. }
  11191. // ResetStatus resets all changes to the "status" field.
  11192. func (m *LabelMutation) ResetStatus() {
  11193. m.status = nil
  11194. m.addstatus = nil
  11195. delete(m.clearedFields, label.FieldStatus)
  11196. }
  11197. // SetType sets the "type" field.
  11198. func (m *LabelMutation) SetType(i int) {
  11199. m._type = &i
  11200. m.add_type = nil
  11201. }
  11202. // GetType returns the value of the "type" field in the mutation.
  11203. func (m *LabelMutation) GetType() (r int, exists bool) {
  11204. v := m._type
  11205. if v == nil {
  11206. return
  11207. }
  11208. return *v, true
  11209. }
  11210. // OldType returns the old "type" field's value of the Label entity.
  11211. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11213. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  11214. if !m.op.Is(OpUpdateOne) {
  11215. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11216. }
  11217. if m.id == nil || m.oldValue == nil {
  11218. return v, errors.New("OldType requires an ID field in the mutation")
  11219. }
  11220. oldValue, err := m.oldValue(ctx)
  11221. if err != nil {
  11222. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11223. }
  11224. return oldValue.Type, nil
  11225. }
  11226. // AddType adds i to the "type" field.
  11227. func (m *LabelMutation) AddType(i int) {
  11228. if m.add_type != nil {
  11229. *m.add_type += i
  11230. } else {
  11231. m.add_type = &i
  11232. }
  11233. }
  11234. // AddedType returns the value that was added to the "type" field in this mutation.
  11235. func (m *LabelMutation) AddedType() (r int, exists bool) {
  11236. v := m.add_type
  11237. if v == nil {
  11238. return
  11239. }
  11240. return *v, true
  11241. }
  11242. // ResetType resets all changes to the "type" field.
  11243. func (m *LabelMutation) ResetType() {
  11244. m._type = nil
  11245. m.add_type = nil
  11246. }
  11247. // SetName sets the "name" field.
  11248. func (m *LabelMutation) SetName(s string) {
  11249. m.name = &s
  11250. }
  11251. // Name returns the value of the "name" field in the mutation.
  11252. func (m *LabelMutation) Name() (r string, exists bool) {
  11253. v := m.name
  11254. if v == nil {
  11255. return
  11256. }
  11257. return *v, true
  11258. }
  11259. // OldName returns the old "name" field's value of the Label entity.
  11260. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11262. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  11263. if !m.op.Is(OpUpdateOne) {
  11264. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11265. }
  11266. if m.id == nil || m.oldValue == nil {
  11267. return v, errors.New("OldName requires an ID field in the mutation")
  11268. }
  11269. oldValue, err := m.oldValue(ctx)
  11270. if err != nil {
  11271. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11272. }
  11273. return oldValue.Name, nil
  11274. }
  11275. // ResetName resets all changes to the "name" field.
  11276. func (m *LabelMutation) ResetName() {
  11277. m.name = nil
  11278. }
  11279. // SetFrom sets the "from" field.
  11280. func (m *LabelMutation) SetFrom(i int) {
  11281. m.from = &i
  11282. m.addfrom = nil
  11283. }
  11284. // From returns the value of the "from" field in the mutation.
  11285. func (m *LabelMutation) From() (r int, exists bool) {
  11286. v := m.from
  11287. if v == nil {
  11288. return
  11289. }
  11290. return *v, true
  11291. }
  11292. // OldFrom returns the old "from" field's value of the Label entity.
  11293. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11295. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  11296. if !m.op.Is(OpUpdateOne) {
  11297. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  11298. }
  11299. if m.id == nil || m.oldValue == nil {
  11300. return v, errors.New("OldFrom requires an ID field in the mutation")
  11301. }
  11302. oldValue, err := m.oldValue(ctx)
  11303. if err != nil {
  11304. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  11305. }
  11306. return oldValue.From, nil
  11307. }
  11308. // AddFrom adds i to the "from" field.
  11309. func (m *LabelMutation) AddFrom(i int) {
  11310. if m.addfrom != nil {
  11311. *m.addfrom += i
  11312. } else {
  11313. m.addfrom = &i
  11314. }
  11315. }
  11316. // AddedFrom returns the value that was added to the "from" field in this mutation.
  11317. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  11318. v := m.addfrom
  11319. if v == nil {
  11320. return
  11321. }
  11322. return *v, true
  11323. }
  11324. // ResetFrom resets all changes to the "from" field.
  11325. func (m *LabelMutation) ResetFrom() {
  11326. m.from = nil
  11327. m.addfrom = nil
  11328. }
  11329. // SetMode sets the "mode" field.
  11330. func (m *LabelMutation) SetMode(i int) {
  11331. m.mode = &i
  11332. m.addmode = nil
  11333. }
  11334. // Mode returns the value of the "mode" field in the mutation.
  11335. func (m *LabelMutation) Mode() (r int, exists bool) {
  11336. v := m.mode
  11337. if v == nil {
  11338. return
  11339. }
  11340. return *v, true
  11341. }
  11342. // OldMode returns the old "mode" field's value of the Label entity.
  11343. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11345. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  11346. if !m.op.Is(OpUpdateOne) {
  11347. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  11348. }
  11349. if m.id == nil || m.oldValue == nil {
  11350. return v, errors.New("OldMode requires an ID field in the mutation")
  11351. }
  11352. oldValue, err := m.oldValue(ctx)
  11353. if err != nil {
  11354. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  11355. }
  11356. return oldValue.Mode, nil
  11357. }
  11358. // AddMode adds i to the "mode" field.
  11359. func (m *LabelMutation) AddMode(i int) {
  11360. if m.addmode != nil {
  11361. *m.addmode += i
  11362. } else {
  11363. m.addmode = &i
  11364. }
  11365. }
  11366. // AddedMode returns the value that was added to the "mode" field in this mutation.
  11367. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  11368. v := m.addmode
  11369. if v == nil {
  11370. return
  11371. }
  11372. return *v, true
  11373. }
  11374. // ResetMode resets all changes to the "mode" field.
  11375. func (m *LabelMutation) ResetMode() {
  11376. m.mode = nil
  11377. m.addmode = nil
  11378. }
  11379. // SetConditions sets the "conditions" field.
  11380. func (m *LabelMutation) SetConditions(s string) {
  11381. m.conditions = &s
  11382. }
  11383. // Conditions returns the value of the "conditions" field in the mutation.
  11384. func (m *LabelMutation) Conditions() (r string, exists bool) {
  11385. v := m.conditions
  11386. if v == nil {
  11387. return
  11388. }
  11389. return *v, true
  11390. }
  11391. // OldConditions returns the old "conditions" field's value of the Label entity.
  11392. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11394. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  11395. if !m.op.Is(OpUpdateOne) {
  11396. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  11397. }
  11398. if m.id == nil || m.oldValue == nil {
  11399. return v, errors.New("OldConditions requires an ID field in the mutation")
  11400. }
  11401. oldValue, err := m.oldValue(ctx)
  11402. if err != nil {
  11403. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  11404. }
  11405. return oldValue.Conditions, nil
  11406. }
  11407. // ClearConditions clears the value of the "conditions" field.
  11408. func (m *LabelMutation) ClearConditions() {
  11409. m.conditions = nil
  11410. m.clearedFields[label.FieldConditions] = struct{}{}
  11411. }
  11412. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  11413. func (m *LabelMutation) ConditionsCleared() bool {
  11414. _, ok := m.clearedFields[label.FieldConditions]
  11415. return ok
  11416. }
  11417. // ResetConditions resets all changes to the "conditions" field.
  11418. func (m *LabelMutation) ResetConditions() {
  11419. m.conditions = nil
  11420. delete(m.clearedFields, label.FieldConditions)
  11421. }
  11422. // SetOrganizationID sets the "organization_id" field.
  11423. func (m *LabelMutation) SetOrganizationID(u uint64) {
  11424. m.organization_id = &u
  11425. m.addorganization_id = nil
  11426. }
  11427. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11428. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  11429. v := m.organization_id
  11430. if v == nil {
  11431. return
  11432. }
  11433. return *v, true
  11434. }
  11435. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  11436. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11438. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11439. if !m.op.Is(OpUpdateOne) {
  11440. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11441. }
  11442. if m.id == nil || m.oldValue == nil {
  11443. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11444. }
  11445. oldValue, err := m.oldValue(ctx)
  11446. if err != nil {
  11447. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11448. }
  11449. return oldValue.OrganizationID, nil
  11450. }
  11451. // AddOrganizationID adds u to the "organization_id" field.
  11452. func (m *LabelMutation) AddOrganizationID(u int64) {
  11453. if m.addorganization_id != nil {
  11454. *m.addorganization_id += u
  11455. } else {
  11456. m.addorganization_id = &u
  11457. }
  11458. }
  11459. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11460. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  11461. v := m.addorganization_id
  11462. if v == nil {
  11463. return
  11464. }
  11465. return *v, true
  11466. }
  11467. // ClearOrganizationID clears the value of the "organization_id" field.
  11468. func (m *LabelMutation) ClearOrganizationID() {
  11469. m.organization_id = nil
  11470. m.addorganization_id = nil
  11471. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  11472. }
  11473. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11474. func (m *LabelMutation) OrganizationIDCleared() bool {
  11475. _, ok := m.clearedFields[label.FieldOrganizationID]
  11476. return ok
  11477. }
  11478. // ResetOrganizationID resets all changes to the "organization_id" field.
  11479. func (m *LabelMutation) ResetOrganizationID() {
  11480. m.organization_id = nil
  11481. m.addorganization_id = nil
  11482. delete(m.clearedFields, label.FieldOrganizationID)
  11483. }
  11484. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  11485. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  11486. if m.label_relationships == nil {
  11487. m.label_relationships = make(map[uint64]struct{})
  11488. }
  11489. for i := range ids {
  11490. m.label_relationships[ids[i]] = struct{}{}
  11491. }
  11492. }
  11493. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  11494. func (m *LabelMutation) ClearLabelRelationships() {
  11495. m.clearedlabel_relationships = true
  11496. }
  11497. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  11498. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  11499. return m.clearedlabel_relationships
  11500. }
  11501. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  11502. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  11503. if m.removedlabel_relationships == nil {
  11504. m.removedlabel_relationships = make(map[uint64]struct{})
  11505. }
  11506. for i := range ids {
  11507. delete(m.label_relationships, ids[i])
  11508. m.removedlabel_relationships[ids[i]] = struct{}{}
  11509. }
  11510. }
  11511. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  11512. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  11513. for id := range m.removedlabel_relationships {
  11514. ids = append(ids, id)
  11515. }
  11516. return
  11517. }
  11518. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  11519. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  11520. for id := range m.label_relationships {
  11521. ids = append(ids, id)
  11522. }
  11523. return
  11524. }
  11525. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  11526. func (m *LabelMutation) ResetLabelRelationships() {
  11527. m.label_relationships = nil
  11528. m.clearedlabel_relationships = false
  11529. m.removedlabel_relationships = nil
  11530. }
  11531. // Where appends a list predicates to the LabelMutation builder.
  11532. func (m *LabelMutation) Where(ps ...predicate.Label) {
  11533. m.predicates = append(m.predicates, ps...)
  11534. }
  11535. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  11536. // users can use type-assertion to append predicates that do not depend on any generated package.
  11537. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  11538. p := make([]predicate.Label, len(ps))
  11539. for i := range ps {
  11540. p[i] = ps[i]
  11541. }
  11542. m.Where(p...)
  11543. }
  11544. // Op returns the operation name.
  11545. func (m *LabelMutation) Op() Op {
  11546. return m.op
  11547. }
  11548. // SetOp allows setting the mutation operation.
  11549. func (m *LabelMutation) SetOp(op Op) {
  11550. m.op = op
  11551. }
  11552. // Type returns the node type of this mutation (Label).
  11553. func (m *LabelMutation) Type() string {
  11554. return m.typ
  11555. }
  11556. // Fields returns all fields that were changed during this mutation. Note that in
  11557. // order to get all numeric fields that were incremented/decremented, call
  11558. // AddedFields().
  11559. func (m *LabelMutation) Fields() []string {
  11560. fields := make([]string, 0, 9)
  11561. if m.created_at != nil {
  11562. fields = append(fields, label.FieldCreatedAt)
  11563. }
  11564. if m.updated_at != nil {
  11565. fields = append(fields, label.FieldUpdatedAt)
  11566. }
  11567. if m.status != nil {
  11568. fields = append(fields, label.FieldStatus)
  11569. }
  11570. if m._type != nil {
  11571. fields = append(fields, label.FieldType)
  11572. }
  11573. if m.name != nil {
  11574. fields = append(fields, label.FieldName)
  11575. }
  11576. if m.from != nil {
  11577. fields = append(fields, label.FieldFrom)
  11578. }
  11579. if m.mode != nil {
  11580. fields = append(fields, label.FieldMode)
  11581. }
  11582. if m.conditions != nil {
  11583. fields = append(fields, label.FieldConditions)
  11584. }
  11585. if m.organization_id != nil {
  11586. fields = append(fields, label.FieldOrganizationID)
  11587. }
  11588. return fields
  11589. }
  11590. // Field returns the value of a field with the given name. The second boolean
  11591. // return value indicates that this field was not set, or was not defined in the
  11592. // schema.
  11593. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  11594. switch name {
  11595. case label.FieldCreatedAt:
  11596. return m.CreatedAt()
  11597. case label.FieldUpdatedAt:
  11598. return m.UpdatedAt()
  11599. case label.FieldStatus:
  11600. return m.Status()
  11601. case label.FieldType:
  11602. return m.GetType()
  11603. case label.FieldName:
  11604. return m.Name()
  11605. case label.FieldFrom:
  11606. return m.From()
  11607. case label.FieldMode:
  11608. return m.Mode()
  11609. case label.FieldConditions:
  11610. return m.Conditions()
  11611. case label.FieldOrganizationID:
  11612. return m.OrganizationID()
  11613. }
  11614. return nil, false
  11615. }
  11616. // OldField returns the old value of the field from the database. An error is
  11617. // returned if the mutation operation is not UpdateOne, or the query to the
  11618. // database failed.
  11619. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11620. switch name {
  11621. case label.FieldCreatedAt:
  11622. return m.OldCreatedAt(ctx)
  11623. case label.FieldUpdatedAt:
  11624. return m.OldUpdatedAt(ctx)
  11625. case label.FieldStatus:
  11626. return m.OldStatus(ctx)
  11627. case label.FieldType:
  11628. return m.OldType(ctx)
  11629. case label.FieldName:
  11630. return m.OldName(ctx)
  11631. case label.FieldFrom:
  11632. return m.OldFrom(ctx)
  11633. case label.FieldMode:
  11634. return m.OldMode(ctx)
  11635. case label.FieldConditions:
  11636. return m.OldConditions(ctx)
  11637. case label.FieldOrganizationID:
  11638. return m.OldOrganizationID(ctx)
  11639. }
  11640. return nil, fmt.Errorf("unknown Label field %s", name)
  11641. }
  11642. // SetField sets the value of a field with the given name. It returns an error if
  11643. // the field is not defined in the schema, or if the type mismatched the field
  11644. // type.
  11645. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  11646. switch name {
  11647. case label.FieldCreatedAt:
  11648. v, ok := value.(time.Time)
  11649. if !ok {
  11650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11651. }
  11652. m.SetCreatedAt(v)
  11653. return nil
  11654. case label.FieldUpdatedAt:
  11655. v, ok := value.(time.Time)
  11656. if !ok {
  11657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11658. }
  11659. m.SetUpdatedAt(v)
  11660. return nil
  11661. case label.FieldStatus:
  11662. v, ok := value.(uint8)
  11663. if !ok {
  11664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11665. }
  11666. m.SetStatus(v)
  11667. return nil
  11668. case label.FieldType:
  11669. v, ok := value.(int)
  11670. if !ok {
  11671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11672. }
  11673. m.SetType(v)
  11674. return nil
  11675. case label.FieldName:
  11676. v, ok := value.(string)
  11677. if !ok {
  11678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11679. }
  11680. m.SetName(v)
  11681. return nil
  11682. case label.FieldFrom:
  11683. v, ok := value.(int)
  11684. if !ok {
  11685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11686. }
  11687. m.SetFrom(v)
  11688. return nil
  11689. case label.FieldMode:
  11690. v, ok := value.(int)
  11691. if !ok {
  11692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11693. }
  11694. m.SetMode(v)
  11695. return nil
  11696. case label.FieldConditions:
  11697. v, ok := value.(string)
  11698. if !ok {
  11699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11700. }
  11701. m.SetConditions(v)
  11702. return nil
  11703. case label.FieldOrganizationID:
  11704. v, ok := value.(uint64)
  11705. if !ok {
  11706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11707. }
  11708. m.SetOrganizationID(v)
  11709. return nil
  11710. }
  11711. return fmt.Errorf("unknown Label field %s", name)
  11712. }
  11713. // AddedFields returns all numeric fields that were incremented/decremented during
  11714. // this mutation.
  11715. func (m *LabelMutation) AddedFields() []string {
  11716. var fields []string
  11717. if m.addstatus != nil {
  11718. fields = append(fields, label.FieldStatus)
  11719. }
  11720. if m.add_type != nil {
  11721. fields = append(fields, label.FieldType)
  11722. }
  11723. if m.addfrom != nil {
  11724. fields = append(fields, label.FieldFrom)
  11725. }
  11726. if m.addmode != nil {
  11727. fields = append(fields, label.FieldMode)
  11728. }
  11729. if m.addorganization_id != nil {
  11730. fields = append(fields, label.FieldOrganizationID)
  11731. }
  11732. return fields
  11733. }
  11734. // AddedField returns the numeric value that was incremented/decremented on a field
  11735. // with the given name. The second boolean return value indicates that this field
  11736. // was not set, or was not defined in the schema.
  11737. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  11738. switch name {
  11739. case label.FieldStatus:
  11740. return m.AddedStatus()
  11741. case label.FieldType:
  11742. return m.AddedType()
  11743. case label.FieldFrom:
  11744. return m.AddedFrom()
  11745. case label.FieldMode:
  11746. return m.AddedMode()
  11747. case label.FieldOrganizationID:
  11748. return m.AddedOrganizationID()
  11749. }
  11750. return nil, false
  11751. }
  11752. // AddField adds the value to the field with the given name. It returns an error if
  11753. // the field is not defined in the schema, or if the type mismatched the field
  11754. // type.
  11755. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  11756. switch name {
  11757. case label.FieldStatus:
  11758. v, ok := value.(int8)
  11759. if !ok {
  11760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11761. }
  11762. m.AddStatus(v)
  11763. return nil
  11764. case label.FieldType:
  11765. v, ok := value.(int)
  11766. if !ok {
  11767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11768. }
  11769. m.AddType(v)
  11770. return nil
  11771. case label.FieldFrom:
  11772. v, ok := value.(int)
  11773. if !ok {
  11774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11775. }
  11776. m.AddFrom(v)
  11777. return nil
  11778. case label.FieldMode:
  11779. v, ok := value.(int)
  11780. if !ok {
  11781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11782. }
  11783. m.AddMode(v)
  11784. return nil
  11785. case label.FieldOrganizationID:
  11786. v, ok := value.(int64)
  11787. if !ok {
  11788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11789. }
  11790. m.AddOrganizationID(v)
  11791. return nil
  11792. }
  11793. return fmt.Errorf("unknown Label numeric field %s", name)
  11794. }
  11795. // ClearedFields returns all nullable fields that were cleared during this
  11796. // mutation.
  11797. func (m *LabelMutation) ClearedFields() []string {
  11798. var fields []string
  11799. if m.FieldCleared(label.FieldStatus) {
  11800. fields = append(fields, label.FieldStatus)
  11801. }
  11802. if m.FieldCleared(label.FieldConditions) {
  11803. fields = append(fields, label.FieldConditions)
  11804. }
  11805. if m.FieldCleared(label.FieldOrganizationID) {
  11806. fields = append(fields, label.FieldOrganizationID)
  11807. }
  11808. return fields
  11809. }
  11810. // FieldCleared returns a boolean indicating if a field with the given name was
  11811. // cleared in this mutation.
  11812. func (m *LabelMutation) FieldCleared(name string) bool {
  11813. _, ok := m.clearedFields[name]
  11814. return ok
  11815. }
  11816. // ClearField clears the value of the field with the given name. It returns an
  11817. // error if the field is not defined in the schema.
  11818. func (m *LabelMutation) ClearField(name string) error {
  11819. switch name {
  11820. case label.FieldStatus:
  11821. m.ClearStatus()
  11822. return nil
  11823. case label.FieldConditions:
  11824. m.ClearConditions()
  11825. return nil
  11826. case label.FieldOrganizationID:
  11827. m.ClearOrganizationID()
  11828. return nil
  11829. }
  11830. return fmt.Errorf("unknown Label nullable field %s", name)
  11831. }
  11832. // ResetField resets all changes in the mutation for the field with the given name.
  11833. // It returns an error if the field is not defined in the schema.
  11834. func (m *LabelMutation) ResetField(name string) error {
  11835. switch name {
  11836. case label.FieldCreatedAt:
  11837. m.ResetCreatedAt()
  11838. return nil
  11839. case label.FieldUpdatedAt:
  11840. m.ResetUpdatedAt()
  11841. return nil
  11842. case label.FieldStatus:
  11843. m.ResetStatus()
  11844. return nil
  11845. case label.FieldType:
  11846. m.ResetType()
  11847. return nil
  11848. case label.FieldName:
  11849. m.ResetName()
  11850. return nil
  11851. case label.FieldFrom:
  11852. m.ResetFrom()
  11853. return nil
  11854. case label.FieldMode:
  11855. m.ResetMode()
  11856. return nil
  11857. case label.FieldConditions:
  11858. m.ResetConditions()
  11859. return nil
  11860. case label.FieldOrganizationID:
  11861. m.ResetOrganizationID()
  11862. return nil
  11863. }
  11864. return fmt.Errorf("unknown Label field %s", name)
  11865. }
  11866. // AddedEdges returns all edge names that were set/added in this mutation.
  11867. func (m *LabelMutation) AddedEdges() []string {
  11868. edges := make([]string, 0, 1)
  11869. if m.label_relationships != nil {
  11870. edges = append(edges, label.EdgeLabelRelationships)
  11871. }
  11872. return edges
  11873. }
  11874. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11875. // name in this mutation.
  11876. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  11877. switch name {
  11878. case label.EdgeLabelRelationships:
  11879. ids := make([]ent.Value, 0, len(m.label_relationships))
  11880. for id := range m.label_relationships {
  11881. ids = append(ids, id)
  11882. }
  11883. return ids
  11884. }
  11885. return nil
  11886. }
  11887. // RemovedEdges returns all edge names that were removed in this mutation.
  11888. func (m *LabelMutation) RemovedEdges() []string {
  11889. edges := make([]string, 0, 1)
  11890. if m.removedlabel_relationships != nil {
  11891. edges = append(edges, label.EdgeLabelRelationships)
  11892. }
  11893. return edges
  11894. }
  11895. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11896. // the given name in this mutation.
  11897. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  11898. switch name {
  11899. case label.EdgeLabelRelationships:
  11900. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  11901. for id := range m.removedlabel_relationships {
  11902. ids = append(ids, id)
  11903. }
  11904. return ids
  11905. }
  11906. return nil
  11907. }
  11908. // ClearedEdges returns all edge names that were cleared in this mutation.
  11909. func (m *LabelMutation) ClearedEdges() []string {
  11910. edges := make([]string, 0, 1)
  11911. if m.clearedlabel_relationships {
  11912. edges = append(edges, label.EdgeLabelRelationships)
  11913. }
  11914. return edges
  11915. }
  11916. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11917. // was cleared in this mutation.
  11918. func (m *LabelMutation) EdgeCleared(name string) bool {
  11919. switch name {
  11920. case label.EdgeLabelRelationships:
  11921. return m.clearedlabel_relationships
  11922. }
  11923. return false
  11924. }
  11925. // ClearEdge clears the value of the edge with the given name. It returns an error
  11926. // if that edge is not defined in the schema.
  11927. func (m *LabelMutation) ClearEdge(name string) error {
  11928. switch name {
  11929. }
  11930. return fmt.Errorf("unknown Label unique edge %s", name)
  11931. }
  11932. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11933. // It returns an error if the edge is not defined in the schema.
  11934. func (m *LabelMutation) ResetEdge(name string) error {
  11935. switch name {
  11936. case label.EdgeLabelRelationships:
  11937. m.ResetLabelRelationships()
  11938. return nil
  11939. }
  11940. return fmt.Errorf("unknown Label edge %s", name)
  11941. }
  11942. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  11943. type LabelRelationshipMutation struct {
  11944. config
  11945. op Op
  11946. typ string
  11947. id *uint64
  11948. created_at *time.Time
  11949. updated_at *time.Time
  11950. status *uint8
  11951. addstatus *int8
  11952. deleted_at *time.Time
  11953. organization_id *uint64
  11954. addorganization_id *int64
  11955. clearedFields map[string]struct{}
  11956. contacts *uint64
  11957. clearedcontacts bool
  11958. labels *uint64
  11959. clearedlabels bool
  11960. done bool
  11961. oldValue func(context.Context) (*LabelRelationship, error)
  11962. predicates []predicate.LabelRelationship
  11963. }
  11964. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  11965. // labelrelationshipOption allows management of the mutation configuration using functional options.
  11966. type labelrelationshipOption func(*LabelRelationshipMutation)
  11967. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  11968. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  11969. m := &LabelRelationshipMutation{
  11970. config: c,
  11971. op: op,
  11972. typ: TypeLabelRelationship,
  11973. clearedFields: make(map[string]struct{}),
  11974. }
  11975. for _, opt := range opts {
  11976. opt(m)
  11977. }
  11978. return m
  11979. }
  11980. // withLabelRelationshipID sets the ID field of the mutation.
  11981. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  11982. return func(m *LabelRelationshipMutation) {
  11983. var (
  11984. err error
  11985. once sync.Once
  11986. value *LabelRelationship
  11987. )
  11988. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  11989. once.Do(func() {
  11990. if m.done {
  11991. err = errors.New("querying old values post mutation is not allowed")
  11992. } else {
  11993. value, err = m.Client().LabelRelationship.Get(ctx, id)
  11994. }
  11995. })
  11996. return value, err
  11997. }
  11998. m.id = &id
  11999. }
  12000. }
  12001. // withLabelRelationship sets the old LabelRelationship of the mutation.
  12002. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  12003. return func(m *LabelRelationshipMutation) {
  12004. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  12005. return node, nil
  12006. }
  12007. m.id = &node.ID
  12008. }
  12009. }
  12010. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12011. // executed in a transaction (ent.Tx), a transactional client is returned.
  12012. func (m LabelRelationshipMutation) Client() *Client {
  12013. client := &Client{config: m.config}
  12014. client.init()
  12015. return client
  12016. }
  12017. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12018. // it returns an error otherwise.
  12019. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  12020. if _, ok := m.driver.(*txDriver); !ok {
  12021. return nil, errors.New("ent: mutation is not running in a transaction")
  12022. }
  12023. tx := &Tx{config: m.config}
  12024. tx.init()
  12025. return tx, nil
  12026. }
  12027. // SetID sets the value of the id field. Note that this
  12028. // operation is only accepted on creation of LabelRelationship entities.
  12029. func (m *LabelRelationshipMutation) SetID(id uint64) {
  12030. m.id = &id
  12031. }
  12032. // ID returns the ID value in the mutation. Note that the ID is only available
  12033. // if it was provided to the builder or after it was returned from the database.
  12034. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  12035. if m.id == nil {
  12036. return
  12037. }
  12038. return *m.id, true
  12039. }
  12040. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12041. // That means, if the mutation is applied within a transaction with an isolation level such
  12042. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12043. // or updated by the mutation.
  12044. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  12045. switch {
  12046. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12047. id, exists := m.ID()
  12048. if exists {
  12049. return []uint64{id}, nil
  12050. }
  12051. fallthrough
  12052. case m.op.Is(OpUpdate | OpDelete):
  12053. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  12054. default:
  12055. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12056. }
  12057. }
  12058. // SetCreatedAt sets the "created_at" field.
  12059. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  12060. m.created_at = &t
  12061. }
  12062. // CreatedAt returns the value of the "created_at" field in the mutation.
  12063. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  12064. v := m.created_at
  12065. if v == nil {
  12066. return
  12067. }
  12068. return *v, true
  12069. }
  12070. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  12071. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12073. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12074. if !m.op.Is(OpUpdateOne) {
  12075. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12076. }
  12077. if m.id == nil || m.oldValue == nil {
  12078. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12079. }
  12080. oldValue, err := m.oldValue(ctx)
  12081. if err != nil {
  12082. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12083. }
  12084. return oldValue.CreatedAt, nil
  12085. }
  12086. // ResetCreatedAt resets all changes to the "created_at" field.
  12087. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  12088. m.created_at = nil
  12089. }
  12090. // SetUpdatedAt sets the "updated_at" field.
  12091. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  12092. m.updated_at = &t
  12093. }
  12094. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12095. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  12096. v := m.updated_at
  12097. if v == nil {
  12098. return
  12099. }
  12100. return *v, true
  12101. }
  12102. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  12103. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12105. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12106. if !m.op.Is(OpUpdateOne) {
  12107. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12108. }
  12109. if m.id == nil || m.oldValue == nil {
  12110. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12111. }
  12112. oldValue, err := m.oldValue(ctx)
  12113. if err != nil {
  12114. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12115. }
  12116. return oldValue.UpdatedAt, nil
  12117. }
  12118. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12119. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  12120. m.updated_at = nil
  12121. }
  12122. // SetStatus sets the "status" field.
  12123. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  12124. m.status = &u
  12125. m.addstatus = nil
  12126. }
  12127. // Status returns the value of the "status" field in the mutation.
  12128. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  12129. v := m.status
  12130. if v == nil {
  12131. return
  12132. }
  12133. return *v, true
  12134. }
  12135. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  12136. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12138. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12139. if !m.op.Is(OpUpdateOne) {
  12140. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12141. }
  12142. if m.id == nil || m.oldValue == nil {
  12143. return v, errors.New("OldStatus requires an ID field in the mutation")
  12144. }
  12145. oldValue, err := m.oldValue(ctx)
  12146. if err != nil {
  12147. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12148. }
  12149. return oldValue.Status, nil
  12150. }
  12151. // AddStatus adds u to the "status" field.
  12152. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  12153. if m.addstatus != nil {
  12154. *m.addstatus += u
  12155. } else {
  12156. m.addstatus = &u
  12157. }
  12158. }
  12159. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12160. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  12161. v := m.addstatus
  12162. if v == nil {
  12163. return
  12164. }
  12165. return *v, true
  12166. }
  12167. // ClearStatus clears the value of the "status" field.
  12168. func (m *LabelRelationshipMutation) ClearStatus() {
  12169. m.status = nil
  12170. m.addstatus = nil
  12171. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  12172. }
  12173. // StatusCleared returns if the "status" field was cleared in this mutation.
  12174. func (m *LabelRelationshipMutation) StatusCleared() bool {
  12175. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  12176. return ok
  12177. }
  12178. // ResetStatus resets all changes to the "status" field.
  12179. func (m *LabelRelationshipMutation) ResetStatus() {
  12180. m.status = nil
  12181. m.addstatus = nil
  12182. delete(m.clearedFields, labelrelationship.FieldStatus)
  12183. }
  12184. // SetDeletedAt sets the "deleted_at" field.
  12185. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  12186. m.deleted_at = &t
  12187. }
  12188. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12189. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  12190. v := m.deleted_at
  12191. if v == nil {
  12192. return
  12193. }
  12194. return *v, true
  12195. }
  12196. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  12197. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12199. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12200. if !m.op.Is(OpUpdateOne) {
  12201. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12202. }
  12203. if m.id == nil || m.oldValue == nil {
  12204. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12205. }
  12206. oldValue, err := m.oldValue(ctx)
  12207. if err != nil {
  12208. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12209. }
  12210. return oldValue.DeletedAt, nil
  12211. }
  12212. // ClearDeletedAt clears the value of the "deleted_at" field.
  12213. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  12214. m.deleted_at = nil
  12215. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  12216. }
  12217. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12218. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  12219. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  12220. return ok
  12221. }
  12222. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12223. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  12224. m.deleted_at = nil
  12225. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  12226. }
  12227. // SetLabelID sets the "label_id" field.
  12228. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  12229. m.labels = &u
  12230. }
  12231. // LabelID returns the value of the "label_id" field in the mutation.
  12232. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  12233. v := m.labels
  12234. if v == nil {
  12235. return
  12236. }
  12237. return *v, true
  12238. }
  12239. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  12240. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12242. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  12243. if !m.op.Is(OpUpdateOne) {
  12244. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  12245. }
  12246. if m.id == nil || m.oldValue == nil {
  12247. return v, errors.New("OldLabelID requires an ID field in the mutation")
  12248. }
  12249. oldValue, err := m.oldValue(ctx)
  12250. if err != nil {
  12251. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  12252. }
  12253. return oldValue.LabelID, nil
  12254. }
  12255. // ResetLabelID resets all changes to the "label_id" field.
  12256. func (m *LabelRelationshipMutation) ResetLabelID() {
  12257. m.labels = nil
  12258. }
  12259. // SetContactID sets the "contact_id" field.
  12260. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  12261. m.contacts = &u
  12262. }
  12263. // ContactID returns the value of the "contact_id" field in the mutation.
  12264. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  12265. v := m.contacts
  12266. if v == nil {
  12267. return
  12268. }
  12269. return *v, true
  12270. }
  12271. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  12272. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12274. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12275. if !m.op.Is(OpUpdateOne) {
  12276. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12277. }
  12278. if m.id == nil || m.oldValue == nil {
  12279. return v, errors.New("OldContactID requires an ID field in the mutation")
  12280. }
  12281. oldValue, err := m.oldValue(ctx)
  12282. if err != nil {
  12283. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12284. }
  12285. return oldValue.ContactID, nil
  12286. }
  12287. // ResetContactID resets all changes to the "contact_id" field.
  12288. func (m *LabelRelationshipMutation) ResetContactID() {
  12289. m.contacts = nil
  12290. }
  12291. // SetOrganizationID sets the "organization_id" field.
  12292. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  12293. m.organization_id = &u
  12294. m.addorganization_id = nil
  12295. }
  12296. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12297. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  12298. v := m.organization_id
  12299. if v == nil {
  12300. return
  12301. }
  12302. return *v, true
  12303. }
  12304. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  12305. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12307. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12308. if !m.op.Is(OpUpdateOne) {
  12309. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12310. }
  12311. if m.id == nil || m.oldValue == nil {
  12312. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12313. }
  12314. oldValue, err := m.oldValue(ctx)
  12315. if err != nil {
  12316. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12317. }
  12318. return oldValue.OrganizationID, nil
  12319. }
  12320. // AddOrganizationID adds u to the "organization_id" field.
  12321. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  12322. if m.addorganization_id != nil {
  12323. *m.addorganization_id += u
  12324. } else {
  12325. m.addorganization_id = &u
  12326. }
  12327. }
  12328. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12329. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  12330. v := m.addorganization_id
  12331. if v == nil {
  12332. return
  12333. }
  12334. return *v, true
  12335. }
  12336. // ClearOrganizationID clears the value of the "organization_id" field.
  12337. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  12338. m.organization_id = nil
  12339. m.addorganization_id = nil
  12340. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  12341. }
  12342. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12343. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  12344. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  12345. return ok
  12346. }
  12347. // ResetOrganizationID resets all changes to the "organization_id" field.
  12348. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  12349. m.organization_id = nil
  12350. m.addorganization_id = nil
  12351. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  12352. }
  12353. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  12354. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  12355. m.contacts = &id
  12356. }
  12357. // ClearContacts clears the "contacts" edge to the Contact entity.
  12358. func (m *LabelRelationshipMutation) ClearContacts() {
  12359. m.clearedcontacts = true
  12360. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  12361. }
  12362. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  12363. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  12364. return m.clearedcontacts
  12365. }
  12366. // ContactsID returns the "contacts" edge ID in the mutation.
  12367. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  12368. if m.contacts != nil {
  12369. return *m.contacts, true
  12370. }
  12371. return
  12372. }
  12373. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  12374. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12375. // ContactsID instead. It exists only for internal usage by the builders.
  12376. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  12377. if id := m.contacts; id != nil {
  12378. ids = append(ids, *id)
  12379. }
  12380. return
  12381. }
  12382. // ResetContacts resets all changes to the "contacts" edge.
  12383. func (m *LabelRelationshipMutation) ResetContacts() {
  12384. m.contacts = nil
  12385. m.clearedcontacts = false
  12386. }
  12387. // SetLabelsID sets the "labels" edge to the Label entity by id.
  12388. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  12389. m.labels = &id
  12390. }
  12391. // ClearLabels clears the "labels" edge to the Label entity.
  12392. func (m *LabelRelationshipMutation) ClearLabels() {
  12393. m.clearedlabels = true
  12394. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  12395. }
  12396. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  12397. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  12398. return m.clearedlabels
  12399. }
  12400. // LabelsID returns the "labels" edge ID in the mutation.
  12401. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  12402. if m.labels != nil {
  12403. return *m.labels, true
  12404. }
  12405. return
  12406. }
  12407. // LabelsIDs returns the "labels" edge IDs in the mutation.
  12408. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12409. // LabelsID instead. It exists only for internal usage by the builders.
  12410. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  12411. if id := m.labels; id != nil {
  12412. ids = append(ids, *id)
  12413. }
  12414. return
  12415. }
  12416. // ResetLabels resets all changes to the "labels" edge.
  12417. func (m *LabelRelationshipMutation) ResetLabels() {
  12418. m.labels = nil
  12419. m.clearedlabels = false
  12420. }
  12421. // Where appends a list predicates to the LabelRelationshipMutation builder.
  12422. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  12423. m.predicates = append(m.predicates, ps...)
  12424. }
  12425. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  12426. // users can use type-assertion to append predicates that do not depend on any generated package.
  12427. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  12428. p := make([]predicate.LabelRelationship, len(ps))
  12429. for i := range ps {
  12430. p[i] = ps[i]
  12431. }
  12432. m.Where(p...)
  12433. }
  12434. // Op returns the operation name.
  12435. func (m *LabelRelationshipMutation) Op() Op {
  12436. return m.op
  12437. }
  12438. // SetOp allows setting the mutation operation.
  12439. func (m *LabelRelationshipMutation) SetOp(op Op) {
  12440. m.op = op
  12441. }
  12442. // Type returns the node type of this mutation (LabelRelationship).
  12443. func (m *LabelRelationshipMutation) Type() string {
  12444. return m.typ
  12445. }
  12446. // Fields returns all fields that were changed during this mutation. Note that in
  12447. // order to get all numeric fields that were incremented/decremented, call
  12448. // AddedFields().
  12449. func (m *LabelRelationshipMutation) Fields() []string {
  12450. fields := make([]string, 0, 7)
  12451. if m.created_at != nil {
  12452. fields = append(fields, labelrelationship.FieldCreatedAt)
  12453. }
  12454. if m.updated_at != nil {
  12455. fields = append(fields, labelrelationship.FieldUpdatedAt)
  12456. }
  12457. if m.status != nil {
  12458. fields = append(fields, labelrelationship.FieldStatus)
  12459. }
  12460. if m.deleted_at != nil {
  12461. fields = append(fields, labelrelationship.FieldDeletedAt)
  12462. }
  12463. if m.labels != nil {
  12464. fields = append(fields, labelrelationship.FieldLabelID)
  12465. }
  12466. if m.contacts != nil {
  12467. fields = append(fields, labelrelationship.FieldContactID)
  12468. }
  12469. if m.organization_id != nil {
  12470. fields = append(fields, labelrelationship.FieldOrganizationID)
  12471. }
  12472. return fields
  12473. }
  12474. // Field returns the value of a field with the given name. The second boolean
  12475. // return value indicates that this field was not set, or was not defined in the
  12476. // schema.
  12477. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  12478. switch name {
  12479. case labelrelationship.FieldCreatedAt:
  12480. return m.CreatedAt()
  12481. case labelrelationship.FieldUpdatedAt:
  12482. return m.UpdatedAt()
  12483. case labelrelationship.FieldStatus:
  12484. return m.Status()
  12485. case labelrelationship.FieldDeletedAt:
  12486. return m.DeletedAt()
  12487. case labelrelationship.FieldLabelID:
  12488. return m.LabelID()
  12489. case labelrelationship.FieldContactID:
  12490. return m.ContactID()
  12491. case labelrelationship.FieldOrganizationID:
  12492. return m.OrganizationID()
  12493. }
  12494. return nil, false
  12495. }
  12496. // OldField returns the old value of the field from the database. An error is
  12497. // returned if the mutation operation is not UpdateOne, or the query to the
  12498. // database failed.
  12499. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12500. switch name {
  12501. case labelrelationship.FieldCreatedAt:
  12502. return m.OldCreatedAt(ctx)
  12503. case labelrelationship.FieldUpdatedAt:
  12504. return m.OldUpdatedAt(ctx)
  12505. case labelrelationship.FieldStatus:
  12506. return m.OldStatus(ctx)
  12507. case labelrelationship.FieldDeletedAt:
  12508. return m.OldDeletedAt(ctx)
  12509. case labelrelationship.FieldLabelID:
  12510. return m.OldLabelID(ctx)
  12511. case labelrelationship.FieldContactID:
  12512. return m.OldContactID(ctx)
  12513. case labelrelationship.FieldOrganizationID:
  12514. return m.OldOrganizationID(ctx)
  12515. }
  12516. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  12517. }
  12518. // SetField sets the value of a field with the given name. It returns an error if
  12519. // the field is not defined in the schema, or if the type mismatched the field
  12520. // type.
  12521. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  12522. switch name {
  12523. case labelrelationship.FieldCreatedAt:
  12524. v, ok := value.(time.Time)
  12525. if !ok {
  12526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12527. }
  12528. m.SetCreatedAt(v)
  12529. return nil
  12530. case labelrelationship.FieldUpdatedAt:
  12531. v, ok := value.(time.Time)
  12532. if !ok {
  12533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12534. }
  12535. m.SetUpdatedAt(v)
  12536. return nil
  12537. case labelrelationship.FieldStatus:
  12538. v, ok := value.(uint8)
  12539. if !ok {
  12540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12541. }
  12542. m.SetStatus(v)
  12543. return nil
  12544. case labelrelationship.FieldDeletedAt:
  12545. v, ok := value.(time.Time)
  12546. if !ok {
  12547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12548. }
  12549. m.SetDeletedAt(v)
  12550. return nil
  12551. case labelrelationship.FieldLabelID:
  12552. v, ok := value.(uint64)
  12553. if !ok {
  12554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12555. }
  12556. m.SetLabelID(v)
  12557. return nil
  12558. case labelrelationship.FieldContactID:
  12559. v, ok := value.(uint64)
  12560. if !ok {
  12561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12562. }
  12563. m.SetContactID(v)
  12564. return nil
  12565. case labelrelationship.FieldOrganizationID:
  12566. v, ok := value.(uint64)
  12567. if !ok {
  12568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12569. }
  12570. m.SetOrganizationID(v)
  12571. return nil
  12572. }
  12573. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12574. }
  12575. // AddedFields returns all numeric fields that were incremented/decremented during
  12576. // this mutation.
  12577. func (m *LabelRelationshipMutation) AddedFields() []string {
  12578. var fields []string
  12579. if m.addstatus != nil {
  12580. fields = append(fields, labelrelationship.FieldStatus)
  12581. }
  12582. if m.addorganization_id != nil {
  12583. fields = append(fields, labelrelationship.FieldOrganizationID)
  12584. }
  12585. return fields
  12586. }
  12587. // AddedField returns the numeric value that was incremented/decremented on a field
  12588. // with the given name. The second boolean return value indicates that this field
  12589. // was not set, or was not defined in the schema.
  12590. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  12591. switch name {
  12592. case labelrelationship.FieldStatus:
  12593. return m.AddedStatus()
  12594. case labelrelationship.FieldOrganizationID:
  12595. return m.AddedOrganizationID()
  12596. }
  12597. return nil, false
  12598. }
  12599. // AddField adds the value to the field with the given name. It returns an error if
  12600. // the field is not defined in the schema, or if the type mismatched the field
  12601. // type.
  12602. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  12603. switch name {
  12604. case labelrelationship.FieldStatus:
  12605. v, ok := value.(int8)
  12606. if !ok {
  12607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12608. }
  12609. m.AddStatus(v)
  12610. return nil
  12611. case labelrelationship.FieldOrganizationID:
  12612. v, ok := value.(int64)
  12613. if !ok {
  12614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12615. }
  12616. m.AddOrganizationID(v)
  12617. return nil
  12618. }
  12619. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  12620. }
  12621. // ClearedFields returns all nullable fields that were cleared during this
  12622. // mutation.
  12623. func (m *LabelRelationshipMutation) ClearedFields() []string {
  12624. var fields []string
  12625. if m.FieldCleared(labelrelationship.FieldStatus) {
  12626. fields = append(fields, labelrelationship.FieldStatus)
  12627. }
  12628. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  12629. fields = append(fields, labelrelationship.FieldDeletedAt)
  12630. }
  12631. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  12632. fields = append(fields, labelrelationship.FieldOrganizationID)
  12633. }
  12634. return fields
  12635. }
  12636. // FieldCleared returns a boolean indicating if a field with the given name was
  12637. // cleared in this mutation.
  12638. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  12639. _, ok := m.clearedFields[name]
  12640. return ok
  12641. }
  12642. // ClearField clears the value of the field with the given name. It returns an
  12643. // error if the field is not defined in the schema.
  12644. func (m *LabelRelationshipMutation) ClearField(name string) error {
  12645. switch name {
  12646. case labelrelationship.FieldStatus:
  12647. m.ClearStatus()
  12648. return nil
  12649. case labelrelationship.FieldDeletedAt:
  12650. m.ClearDeletedAt()
  12651. return nil
  12652. case labelrelationship.FieldOrganizationID:
  12653. m.ClearOrganizationID()
  12654. return nil
  12655. }
  12656. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  12657. }
  12658. // ResetField resets all changes in the mutation for the field with the given name.
  12659. // It returns an error if the field is not defined in the schema.
  12660. func (m *LabelRelationshipMutation) ResetField(name string) error {
  12661. switch name {
  12662. case labelrelationship.FieldCreatedAt:
  12663. m.ResetCreatedAt()
  12664. return nil
  12665. case labelrelationship.FieldUpdatedAt:
  12666. m.ResetUpdatedAt()
  12667. return nil
  12668. case labelrelationship.FieldStatus:
  12669. m.ResetStatus()
  12670. return nil
  12671. case labelrelationship.FieldDeletedAt:
  12672. m.ResetDeletedAt()
  12673. return nil
  12674. case labelrelationship.FieldLabelID:
  12675. m.ResetLabelID()
  12676. return nil
  12677. case labelrelationship.FieldContactID:
  12678. m.ResetContactID()
  12679. return nil
  12680. case labelrelationship.FieldOrganizationID:
  12681. m.ResetOrganizationID()
  12682. return nil
  12683. }
  12684. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12685. }
  12686. // AddedEdges returns all edge names that were set/added in this mutation.
  12687. func (m *LabelRelationshipMutation) AddedEdges() []string {
  12688. edges := make([]string, 0, 2)
  12689. if m.contacts != nil {
  12690. edges = append(edges, labelrelationship.EdgeContacts)
  12691. }
  12692. if m.labels != nil {
  12693. edges = append(edges, labelrelationship.EdgeLabels)
  12694. }
  12695. return edges
  12696. }
  12697. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12698. // name in this mutation.
  12699. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  12700. switch name {
  12701. case labelrelationship.EdgeContacts:
  12702. if id := m.contacts; id != nil {
  12703. return []ent.Value{*id}
  12704. }
  12705. case labelrelationship.EdgeLabels:
  12706. if id := m.labels; id != nil {
  12707. return []ent.Value{*id}
  12708. }
  12709. }
  12710. return nil
  12711. }
  12712. // RemovedEdges returns all edge names that were removed in this mutation.
  12713. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  12714. edges := make([]string, 0, 2)
  12715. return edges
  12716. }
  12717. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12718. // the given name in this mutation.
  12719. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  12720. return nil
  12721. }
  12722. // ClearedEdges returns all edge names that were cleared in this mutation.
  12723. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  12724. edges := make([]string, 0, 2)
  12725. if m.clearedcontacts {
  12726. edges = append(edges, labelrelationship.EdgeContacts)
  12727. }
  12728. if m.clearedlabels {
  12729. edges = append(edges, labelrelationship.EdgeLabels)
  12730. }
  12731. return edges
  12732. }
  12733. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12734. // was cleared in this mutation.
  12735. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  12736. switch name {
  12737. case labelrelationship.EdgeContacts:
  12738. return m.clearedcontacts
  12739. case labelrelationship.EdgeLabels:
  12740. return m.clearedlabels
  12741. }
  12742. return false
  12743. }
  12744. // ClearEdge clears the value of the edge with the given name. It returns an error
  12745. // if that edge is not defined in the schema.
  12746. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  12747. switch name {
  12748. case labelrelationship.EdgeContacts:
  12749. m.ClearContacts()
  12750. return nil
  12751. case labelrelationship.EdgeLabels:
  12752. m.ClearLabels()
  12753. return nil
  12754. }
  12755. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  12756. }
  12757. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12758. // It returns an error if the edge is not defined in the schema.
  12759. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  12760. switch name {
  12761. case labelrelationship.EdgeContacts:
  12762. m.ResetContacts()
  12763. return nil
  12764. case labelrelationship.EdgeLabels:
  12765. m.ResetLabels()
  12766. return nil
  12767. }
  12768. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  12769. }
  12770. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  12771. type MessageMutation struct {
  12772. config
  12773. op Op
  12774. typ string
  12775. id *int
  12776. wx_wxid *string
  12777. wxid *string
  12778. content *string
  12779. clearedFields map[string]struct{}
  12780. done bool
  12781. oldValue func(context.Context) (*Message, error)
  12782. predicates []predicate.Message
  12783. }
  12784. var _ ent.Mutation = (*MessageMutation)(nil)
  12785. // messageOption allows management of the mutation configuration using functional options.
  12786. type messageOption func(*MessageMutation)
  12787. // newMessageMutation creates new mutation for the Message entity.
  12788. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  12789. m := &MessageMutation{
  12790. config: c,
  12791. op: op,
  12792. typ: TypeMessage,
  12793. clearedFields: make(map[string]struct{}),
  12794. }
  12795. for _, opt := range opts {
  12796. opt(m)
  12797. }
  12798. return m
  12799. }
  12800. // withMessageID sets the ID field of the mutation.
  12801. func withMessageID(id int) messageOption {
  12802. return func(m *MessageMutation) {
  12803. var (
  12804. err error
  12805. once sync.Once
  12806. value *Message
  12807. )
  12808. m.oldValue = func(ctx context.Context) (*Message, error) {
  12809. once.Do(func() {
  12810. if m.done {
  12811. err = errors.New("querying old values post mutation is not allowed")
  12812. } else {
  12813. value, err = m.Client().Message.Get(ctx, id)
  12814. }
  12815. })
  12816. return value, err
  12817. }
  12818. m.id = &id
  12819. }
  12820. }
  12821. // withMessage sets the old Message of the mutation.
  12822. func withMessage(node *Message) messageOption {
  12823. return func(m *MessageMutation) {
  12824. m.oldValue = func(context.Context) (*Message, error) {
  12825. return node, nil
  12826. }
  12827. m.id = &node.ID
  12828. }
  12829. }
  12830. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12831. // executed in a transaction (ent.Tx), a transactional client is returned.
  12832. func (m MessageMutation) Client() *Client {
  12833. client := &Client{config: m.config}
  12834. client.init()
  12835. return client
  12836. }
  12837. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12838. // it returns an error otherwise.
  12839. func (m MessageMutation) Tx() (*Tx, error) {
  12840. if _, ok := m.driver.(*txDriver); !ok {
  12841. return nil, errors.New("ent: mutation is not running in a transaction")
  12842. }
  12843. tx := &Tx{config: m.config}
  12844. tx.init()
  12845. return tx, nil
  12846. }
  12847. // ID returns the ID value in the mutation. Note that the ID is only available
  12848. // if it was provided to the builder or after it was returned from the database.
  12849. func (m *MessageMutation) ID() (id int, exists bool) {
  12850. if m.id == nil {
  12851. return
  12852. }
  12853. return *m.id, true
  12854. }
  12855. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12856. // That means, if the mutation is applied within a transaction with an isolation level such
  12857. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12858. // or updated by the mutation.
  12859. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  12860. switch {
  12861. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12862. id, exists := m.ID()
  12863. if exists {
  12864. return []int{id}, nil
  12865. }
  12866. fallthrough
  12867. case m.op.Is(OpUpdate | OpDelete):
  12868. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  12869. default:
  12870. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12871. }
  12872. }
  12873. // SetWxWxid sets the "wx_wxid" field.
  12874. func (m *MessageMutation) SetWxWxid(s string) {
  12875. m.wx_wxid = &s
  12876. }
  12877. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  12878. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  12879. v := m.wx_wxid
  12880. if v == nil {
  12881. return
  12882. }
  12883. return *v, true
  12884. }
  12885. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  12886. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12888. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  12889. if !m.op.Is(OpUpdateOne) {
  12890. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  12891. }
  12892. if m.id == nil || m.oldValue == nil {
  12893. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  12894. }
  12895. oldValue, err := m.oldValue(ctx)
  12896. if err != nil {
  12897. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  12898. }
  12899. return oldValue.WxWxid, nil
  12900. }
  12901. // ClearWxWxid clears the value of the "wx_wxid" field.
  12902. func (m *MessageMutation) ClearWxWxid() {
  12903. m.wx_wxid = nil
  12904. m.clearedFields[message.FieldWxWxid] = struct{}{}
  12905. }
  12906. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  12907. func (m *MessageMutation) WxWxidCleared() bool {
  12908. _, ok := m.clearedFields[message.FieldWxWxid]
  12909. return ok
  12910. }
  12911. // ResetWxWxid resets all changes to the "wx_wxid" field.
  12912. func (m *MessageMutation) ResetWxWxid() {
  12913. m.wx_wxid = nil
  12914. delete(m.clearedFields, message.FieldWxWxid)
  12915. }
  12916. // SetWxid sets the "wxid" field.
  12917. func (m *MessageMutation) SetWxid(s string) {
  12918. m.wxid = &s
  12919. }
  12920. // Wxid returns the value of the "wxid" field in the mutation.
  12921. func (m *MessageMutation) Wxid() (r string, exists bool) {
  12922. v := m.wxid
  12923. if v == nil {
  12924. return
  12925. }
  12926. return *v, true
  12927. }
  12928. // OldWxid returns the old "wxid" field's value of the Message entity.
  12929. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12931. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  12932. if !m.op.Is(OpUpdateOne) {
  12933. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  12934. }
  12935. if m.id == nil || m.oldValue == nil {
  12936. return v, errors.New("OldWxid requires an ID field in the mutation")
  12937. }
  12938. oldValue, err := m.oldValue(ctx)
  12939. if err != nil {
  12940. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  12941. }
  12942. return oldValue.Wxid, nil
  12943. }
  12944. // ResetWxid resets all changes to the "wxid" field.
  12945. func (m *MessageMutation) ResetWxid() {
  12946. m.wxid = nil
  12947. }
  12948. // SetContent sets the "content" field.
  12949. func (m *MessageMutation) SetContent(s string) {
  12950. m.content = &s
  12951. }
  12952. // Content returns the value of the "content" field in the mutation.
  12953. func (m *MessageMutation) Content() (r string, exists bool) {
  12954. v := m.content
  12955. if v == nil {
  12956. return
  12957. }
  12958. return *v, true
  12959. }
  12960. // OldContent returns the old "content" field's value of the Message entity.
  12961. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12963. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  12964. if !m.op.Is(OpUpdateOne) {
  12965. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  12966. }
  12967. if m.id == nil || m.oldValue == nil {
  12968. return v, errors.New("OldContent requires an ID field in the mutation")
  12969. }
  12970. oldValue, err := m.oldValue(ctx)
  12971. if err != nil {
  12972. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  12973. }
  12974. return oldValue.Content, nil
  12975. }
  12976. // ResetContent resets all changes to the "content" field.
  12977. func (m *MessageMutation) ResetContent() {
  12978. m.content = nil
  12979. }
  12980. // Where appends a list predicates to the MessageMutation builder.
  12981. func (m *MessageMutation) Where(ps ...predicate.Message) {
  12982. m.predicates = append(m.predicates, ps...)
  12983. }
  12984. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  12985. // users can use type-assertion to append predicates that do not depend on any generated package.
  12986. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  12987. p := make([]predicate.Message, len(ps))
  12988. for i := range ps {
  12989. p[i] = ps[i]
  12990. }
  12991. m.Where(p...)
  12992. }
  12993. // Op returns the operation name.
  12994. func (m *MessageMutation) Op() Op {
  12995. return m.op
  12996. }
  12997. // SetOp allows setting the mutation operation.
  12998. func (m *MessageMutation) SetOp(op Op) {
  12999. m.op = op
  13000. }
  13001. // Type returns the node type of this mutation (Message).
  13002. func (m *MessageMutation) Type() string {
  13003. return m.typ
  13004. }
  13005. // Fields returns all fields that were changed during this mutation. Note that in
  13006. // order to get all numeric fields that were incremented/decremented, call
  13007. // AddedFields().
  13008. func (m *MessageMutation) Fields() []string {
  13009. fields := make([]string, 0, 3)
  13010. if m.wx_wxid != nil {
  13011. fields = append(fields, message.FieldWxWxid)
  13012. }
  13013. if m.wxid != nil {
  13014. fields = append(fields, message.FieldWxid)
  13015. }
  13016. if m.content != nil {
  13017. fields = append(fields, message.FieldContent)
  13018. }
  13019. return fields
  13020. }
  13021. // Field returns the value of a field with the given name. The second boolean
  13022. // return value indicates that this field was not set, or was not defined in the
  13023. // schema.
  13024. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  13025. switch name {
  13026. case message.FieldWxWxid:
  13027. return m.WxWxid()
  13028. case message.FieldWxid:
  13029. return m.Wxid()
  13030. case message.FieldContent:
  13031. return m.Content()
  13032. }
  13033. return nil, false
  13034. }
  13035. // OldField returns the old value of the field from the database. An error is
  13036. // returned if the mutation operation is not UpdateOne, or the query to the
  13037. // database failed.
  13038. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13039. switch name {
  13040. case message.FieldWxWxid:
  13041. return m.OldWxWxid(ctx)
  13042. case message.FieldWxid:
  13043. return m.OldWxid(ctx)
  13044. case message.FieldContent:
  13045. return m.OldContent(ctx)
  13046. }
  13047. return nil, fmt.Errorf("unknown Message field %s", name)
  13048. }
  13049. // SetField sets the value of a field with the given name. It returns an error if
  13050. // the field is not defined in the schema, or if the type mismatched the field
  13051. // type.
  13052. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  13053. switch name {
  13054. case message.FieldWxWxid:
  13055. v, ok := value.(string)
  13056. if !ok {
  13057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13058. }
  13059. m.SetWxWxid(v)
  13060. return nil
  13061. case message.FieldWxid:
  13062. v, ok := value.(string)
  13063. if !ok {
  13064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13065. }
  13066. m.SetWxid(v)
  13067. return nil
  13068. case message.FieldContent:
  13069. v, ok := value.(string)
  13070. if !ok {
  13071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13072. }
  13073. m.SetContent(v)
  13074. return nil
  13075. }
  13076. return fmt.Errorf("unknown Message field %s", name)
  13077. }
  13078. // AddedFields returns all numeric fields that were incremented/decremented during
  13079. // this mutation.
  13080. func (m *MessageMutation) AddedFields() []string {
  13081. return nil
  13082. }
  13083. // AddedField returns the numeric value that was incremented/decremented on a field
  13084. // with the given name. The second boolean return value indicates that this field
  13085. // was not set, or was not defined in the schema.
  13086. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  13087. return nil, false
  13088. }
  13089. // AddField adds the value to the field with the given name. It returns an error if
  13090. // the field is not defined in the schema, or if the type mismatched the field
  13091. // type.
  13092. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  13093. switch name {
  13094. }
  13095. return fmt.Errorf("unknown Message numeric field %s", name)
  13096. }
  13097. // ClearedFields returns all nullable fields that were cleared during this
  13098. // mutation.
  13099. func (m *MessageMutation) ClearedFields() []string {
  13100. var fields []string
  13101. if m.FieldCleared(message.FieldWxWxid) {
  13102. fields = append(fields, message.FieldWxWxid)
  13103. }
  13104. return fields
  13105. }
  13106. // FieldCleared returns a boolean indicating if a field with the given name was
  13107. // cleared in this mutation.
  13108. func (m *MessageMutation) FieldCleared(name string) bool {
  13109. _, ok := m.clearedFields[name]
  13110. return ok
  13111. }
  13112. // ClearField clears the value of the field with the given name. It returns an
  13113. // error if the field is not defined in the schema.
  13114. func (m *MessageMutation) ClearField(name string) error {
  13115. switch name {
  13116. case message.FieldWxWxid:
  13117. m.ClearWxWxid()
  13118. return nil
  13119. }
  13120. return fmt.Errorf("unknown Message nullable field %s", name)
  13121. }
  13122. // ResetField resets all changes in the mutation for the field with the given name.
  13123. // It returns an error if the field is not defined in the schema.
  13124. func (m *MessageMutation) ResetField(name string) error {
  13125. switch name {
  13126. case message.FieldWxWxid:
  13127. m.ResetWxWxid()
  13128. return nil
  13129. case message.FieldWxid:
  13130. m.ResetWxid()
  13131. return nil
  13132. case message.FieldContent:
  13133. m.ResetContent()
  13134. return nil
  13135. }
  13136. return fmt.Errorf("unknown Message field %s", name)
  13137. }
  13138. // AddedEdges returns all edge names that were set/added in this mutation.
  13139. func (m *MessageMutation) AddedEdges() []string {
  13140. edges := make([]string, 0, 0)
  13141. return edges
  13142. }
  13143. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13144. // name in this mutation.
  13145. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  13146. return nil
  13147. }
  13148. // RemovedEdges returns all edge names that were removed in this mutation.
  13149. func (m *MessageMutation) RemovedEdges() []string {
  13150. edges := make([]string, 0, 0)
  13151. return edges
  13152. }
  13153. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13154. // the given name in this mutation.
  13155. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  13156. return nil
  13157. }
  13158. // ClearedEdges returns all edge names that were cleared in this mutation.
  13159. func (m *MessageMutation) ClearedEdges() []string {
  13160. edges := make([]string, 0, 0)
  13161. return edges
  13162. }
  13163. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13164. // was cleared in this mutation.
  13165. func (m *MessageMutation) EdgeCleared(name string) bool {
  13166. return false
  13167. }
  13168. // ClearEdge clears the value of the edge with the given name. It returns an error
  13169. // if that edge is not defined in the schema.
  13170. func (m *MessageMutation) ClearEdge(name string) error {
  13171. return fmt.Errorf("unknown Message unique edge %s", name)
  13172. }
  13173. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13174. // It returns an error if the edge is not defined in the schema.
  13175. func (m *MessageMutation) ResetEdge(name string) error {
  13176. return fmt.Errorf("unknown Message edge %s", name)
  13177. }
  13178. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  13179. type MessageRecordsMutation struct {
  13180. config
  13181. op Op
  13182. typ string
  13183. id *uint64
  13184. created_at *time.Time
  13185. updated_at *time.Time
  13186. status *uint8
  13187. addstatus *int8
  13188. bot_wxid *string
  13189. contact_type *int
  13190. addcontact_type *int
  13191. contact_wxid *string
  13192. content_type *int
  13193. addcontent_type *int
  13194. content *string
  13195. meta *custom_types.Meta
  13196. error_detail *string
  13197. send_time *time.Time
  13198. source_type *int
  13199. addsource_type *int
  13200. organization_id *uint64
  13201. addorganization_id *int64
  13202. clearedFields map[string]struct{}
  13203. sop_stage *uint64
  13204. clearedsop_stage bool
  13205. sop_node *uint64
  13206. clearedsop_node bool
  13207. message_contact *uint64
  13208. clearedmessage_contact bool
  13209. done bool
  13210. oldValue func(context.Context) (*MessageRecords, error)
  13211. predicates []predicate.MessageRecords
  13212. }
  13213. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  13214. // messagerecordsOption allows management of the mutation configuration using functional options.
  13215. type messagerecordsOption func(*MessageRecordsMutation)
  13216. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  13217. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  13218. m := &MessageRecordsMutation{
  13219. config: c,
  13220. op: op,
  13221. typ: TypeMessageRecords,
  13222. clearedFields: make(map[string]struct{}),
  13223. }
  13224. for _, opt := range opts {
  13225. opt(m)
  13226. }
  13227. return m
  13228. }
  13229. // withMessageRecordsID sets the ID field of the mutation.
  13230. func withMessageRecordsID(id uint64) messagerecordsOption {
  13231. return func(m *MessageRecordsMutation) {
  13232. var (
  13233. err error
  13234. once sync.Once
  13235. value *MessageRecords
  13236. )
  13237. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  13238. once.Do(func() {
  13239. if m.done {
  13240. err = errors.New("querying old values post mutation is not allowed")
  13241. } else {
  13242. value, err = m.Client().MessageRecords.Get(ctx, id)
  13243. }
  13244. })
  13245. return value, err
  13246. }
  13247. m.id = &id
  13248. }
  13249. }
  13250. // withMessageRecords sets the old MessageRecords of the mutation.
  13251. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  13252. return func(m *MessageRecordsMutation) {
  13253. m.oldValue = func(context.Context) (*MessageRecords, error) {
  13254. return node, nil
  13255. }
  13256. m.id = &node.ID
  13257. }
  13258. }
  13259. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13260. // executed in a transaction (ent.Tx), a transactional client is returned.
  13261. func (m MessageRecordsMutation) Client() *Client {
  13262. client := &Client{config: m.config}
  13263. client.init()
  13264. return client
  13265. }
  13266. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13267. // it returns an error otherwise.
  13268. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  13269. if _, ok := m.driver.(*txDriver); !ok {
  13270. return nil, errors.New("ent: mutation is not running in a transaction")
  13271. }
  13272. tx := &Tx{config: m.config}
  13273. tx.init()
  13274. return tx, nil
  13275. }
  13276. // SetID sets the value of the id field. Note that this
  13277. // operation is only accepted on creation of MessageRecords entities.
  13278. func (m *MessageRecordsMutation) SetID(id uint64) {
  13279. m.id = &id
  13280. }
  13281. // ID returns the ID value in the mutation. Note that the ID is only available
  13282. // if it was provided to the builder or after it was returned from the database.
  13283. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  13284. if m.id == nil {
  13285. return
  13286. }
  13287. return *m.id, true
  13288. }
  13289. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13290. // That means, if the mutation is applied within a transaction with an isolation level such
  13291. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13292. // or updated by the mutation.
  13293. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  13294. switch {
  13295. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13296. id, exists := m.ID()
  13297. if exists {
  13298. return []uint64{id}, nil
  13299. }
  13300. fallthrough
  13301. case m.op.Is(OpUpdate | OpDelete):
  13302. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  13303. default:
  13304. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13305. }
  13306. }
  13307. // SetCreatedAt sets the "created_at" field.
  13308. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  13309. m.created_at = &t
  13310. }
  13311. // CreatedAt returns the value of the "created_at" field in the mutation.
  13312. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  13313. v := m.created_at
  13314. if v == nil {
  13315. return
  13316. }
  13317. return *v, true
  13318. }
  13319. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  13320. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13322. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13323. if !m.op.Is(OpUpdateOne) {
  13324. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13325. }
  13326. if m.id == nil || m.oldValue == nil {
  13327. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13328. }
  13329. oldValue, err := m.oldValue(ctx)
  13330. if err != nil {
  13331. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13332. }
  13333. return oldValue.CreatedAt, nil
  13334. }
  13335. // ResetCreatedAt resets all changes to the "created_at" field.
  13336. func (m *MessageRecordsMutation) ResetCreatedAt() {
  13337. m.created_at = nil
  13338. }
  13339. // SetUpdatedAt sets the "updated_at" field.
  13340. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  13341. m.updated_at = &t
  13342. }
  13343. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13344. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  13345. v := m.updated_at
  13346. if v == nil {
  13347. return
  13348. }
  13349. return *v, true
  13350. }
  13351. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  13352. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13354. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13355. if !m.op.Is(OpUpdateOne) {
  13356. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13357. }
  13358. if m.id == nil || m.oldValue == nil {
  13359. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13360. }
  13361. oldValue, err := m.oldValue(ctx)
  13362. if err != nil {
  13363. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13364. }
  13365. return oldValue.UpdatedAt, nil
  13366. }
  13367. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13368. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  13369. m.updated_at = nil
  13370. }
  13371. // SetStatus sets the "status" field.
  13372. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  13373. m.status = &u
  13374. m.addstatus = nil
  13375. }
  13376. // Status returns the value of the "status" field in the mutation.
  13377. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  13378. v := m.status
  13379. if v == nil {
  13380. return
  13381. }
  13382. return *v, true
  13383. }
  13384. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  13385. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13387. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13388. if !m.op.Is(OpUpdateOne) {
  13389. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13390. }
  13391. if m.id == nil || m.oldValue == nil {
  13392. return v, errors.New("OldStatus requires an ID field in the mutation")
  13393. }
  13394. oldValue, err := m.oldValue(ctx)
  13395. if err != nil {
  13396. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13397. }
  13398. return oldValue.Status, nil
  13399. }
  13400. // AddStatus adds u to the "status" field.
  13401. func (m *MessageRecordsMutation) AddStatus(u int8) {
  13402. if m.addstatus != nil {
  13403. *m.addstatus += u
  13404. } else {
  13405. m.addstatus = &u
  13406. }
  13407. }
  13408. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13409. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  13410. v := m.addstatus
  13411. if v == nil {
  13412. return
  13413. }
  13414. return *v, true
  13415. }
  13416. // ClearStatus clears the value of the "status" field.
  13417. func (m *MessageRecordsMutation) ClearStatus() {
  13418. m.status = nil
  13419. m.addstatus = nil
  13420. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  13421. }
  13422. // StatusCleared returns if the "status" field was cleared in this mutation.
  13423. func (m *MessageRecordsMutation) StatusCleared() bool {
  13424. _, ok := m.clearedFields[messagerecords.FieldStatus]
  13425. return ok
  13426. }
  13427. // ResetStatus resets all changes to the "status" field.
  13428. func (m *MessageRecordsMutation) ResetStatus() {
  13429. m.status = nil
  13430. m.addstatus = nil
  13431. delete(m.clearedFields, messagerecords.FieldStatus)
  13432. }
  13433. // SetBotWxid sets the "bot_wxid" field.
  13434. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  13435. m.bot_wxid = &s
  13436. }
  13437. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  13438. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  13439. v := m.bot_wxid
  13440. if v == nil {
  13441. return
  13442. }
  13443. return *v, true
  13444. }
  13445. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  13446. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13448. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  13449. if !m.op.Is(OpUpdateOne) {
  13450. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  13451. }
  13452. if m.id == nil || m.oldValue == nil {
  13453. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  13454. }
  13455. oldValue, err := m.oldValue(ctx)
  13456. if err != nil {
  13457. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  13458. }
  13459. return oldValue.BotWxid, nil
  13460. }
  13461. // ResetBotWxid resets all changes to the "bot_wxid" field.
  13462. func (m *MessageRecordsMutation) ResetBotWxid() {
  13463. m.bot_wxid = nil
  13464. }
  13465. // SetContactID sets the "contact_id" field.
  13466. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  13467. m.message_contact = &u
  13468. }
  13469. // ContactID returns the value of the "contact_id" field in the mutation.
  13470. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  13471. v := m.message_contact
  13472. if v == nil {
  13473. return
  13474. }
  13475. return *v, true
  13476. }
  13477. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  13478. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13480. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13481. if !m.op.Is(OpUpdateOne) {
  13482. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13483. }
  13484. if m.id == nil || m.oldValue == nil {
  13485. return v, errors.New("OldContactID requires an ID field in the mutation")
  13486. }
  13487. oldValue, err := m.oldValue(ctx)
  13488. if err != nil {
  13489. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13490. }
  13491. return oldValue.ContactID, nil
  13492. }
  13493. // ClearContactID clears the value of the "contact_id" field.
  13494. func (m *MessageRecordsMutation) ClearContactID() {
  13495. m.message_contact = nil
  13496. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  13497. }
  13498. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  13499. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  13500. _, ok := m.clearedFields[messagerecords.FieldContactID]
  13501. return ok
  13502. }
  13503. // ResetContactID resets all changes to the "contact_id" field.
  13504. func (m *MessageRecordsMutation) ResetContactID() {
  13505. m.message_contact = nil
  13506. delete(m.clearedFields, messagerecords.FieldContactID)
  13507. }
  13508. // SetContactType sets the "contact_type" field.
  13509. func (m *MessageRecordsMutation) SetContactType(i int) {
  13510. m.contact_type = &i
  13511. m.addcontact_type = nil
  13512. }
  13513. // ContactType returns the value of the "contact_type" field in the mutation.
  13514. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  13515. v := m.contact_type
  13516. if v == nil {
  13517. return
  13518. }
  13519. return *v, true
  13520. }
  13521. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  13522. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13524. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  13525. if !m.op.Is(OpUpdateOne) {
  13526. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  13527. }
  13528. if m.id == nil || m.oldValue == nil {
  13529. return v, errors.New("OldContactType requires an ID field in the mutation")
  13530. }
  13531. oldValue, err := m.oldValue(ctx)
  13532. if err != nil {
  13533. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  13534. }
  13535. return oldValue.ContactType, nil
  13536. }
  13537. // AddContactType adds i to the "contact_type" field.
  13538. func (m *MessageRecordsMutation) AddContactType(i int) {
  13539. if m.addcontact_type != nil {
  13540. *m.addcontact_type += i
  13541. } else {
  13542. m.addcontact_type = &i
  13543. }
  13544. }
  13545. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  13546. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  13547. v := m.addcontact_type
  13548. if v == nil {
  13549. return
  13550. }
  13551. return *v, true
  13552. }
  13553. // ResetContactType resets all changes to the "contact_type" field.
  13554. func (m *MessageRecordsMutation) ResetContactType() {
  13555. m.contact_type = nil
  13556. m.addcontact_type = nil
  13557. }
  13558. // SetContactWxid sets the "contact_wxid" field.
  13559. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  13560. m.contact_wxid = &s
  13561. }
  13562. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  13563. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  13564. v := m.contact_wxid
  13565. if v == nil {
  13566. return
  13567. }
  13568. return *v, true
  13569. }
  13570. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  13571. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13573. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  13574. if !m.op.Is(OpUpdateOne) {
  13575. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  13576. }
  13577. if m.id == nil || m.oldValue == nil {
  13578. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  13579. }
  13580. oldValue, err := m.oldValue(ctx)
  13581. if err != nil {
  13582. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  13583. }
  13584. return oldValue.ContactWxid, nil
  13585. }
  13586. // ResetContactWxid resets all changes to the "contact_wxid" field.
  13587. func (m *MessageRecordsMutation) ResetContactWxid() {
  13588. m.contact_wxid = nil
  13589. }
  13590. // SetContentType sets the "content_type" field.
  13591. func (m *MessageRecordsMutation) SetContentType(i int) {
  13592. m.content_type = &i
  13593. m.addcontent_type = nil
  13594. }
  13595. // ContentType returns the value of the "content_type" field in the mutation.
  13596. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  13597. v := m.content_type
  13598. if v == nil {
  13599. return
  13600. }
  13601. return *v, true
  13602. }
  13603. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  13604. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13606. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  13607. if !m.op.Is(OpUpdateOne) {
  13608. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  13609. }
  13610. if m.id == nil || m.oldValue == nil {
  13611. return v, errors.New("OldContentType requires an ID field in the mutation")
  13612. }
  13613. oldValue, err := m.oldValue(ctx)
  13614. if err != nil {
  13615. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  13616. }
  13617. return oldValue.ContentType, nil
  13618. }
  13619. // AddContentType adds i to the "content_type" field.
  13620. func (m *MessageRecordsMutation) AddContentType(i int) {
  13621. if m.addcontent_type != nil {
  13622. *m.addcontent_type += i
  13623. } else {
  13624. m.addcontent_type = &i
  13625. }
  13626. }
  13627. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  13628. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  13629. v := m.addcontent_type
  13630. if v == nil {
  13631. return
  13632. }
  13633. return *v, true
  13634. }
  13635. // ResetContentType resets all changes to the "content_type" field.
  13636. func (m *MessageRecordsMutation) ResetContentType() {
  13637. m.content_type = nil
  13638. m.addcontent_type = nil
  13639. }
  13640. // SetContent sets the "content" field.
  13641. func (m *MessageRecordsMutation) SetContent(s string) {
  13642. m.content = &s
  13643. }
  13644. // Content returns the value of the "content" field in the mutation.
  13645. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  13646. v := m.content
  13647. if v == nil {
  13648. return
  13649. }
  13650. return *v, true
  13651. }
  13652. // OldContent returns the old "content" field's value of the MessageRecords entity.
  13653. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13655. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  13656. if !m.op.Is(OpUpdateOne) {
  13657. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  13658. }
  13659. if m.id == nil || m.oldValue == nil {
  13660. return v, errors.New("OldContent requires an ID field in the mutation")
  13661. }
  13662. oldValue, err := m.oldValue(ctx)
  13663. if err != nil {
  13664. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  13665. }
  13666. return oldValue.Content, nil
  13667. }
  13668. // ResetContent resets all changes to the "content" field.
  13669. func (m *MessageRecordsMutation) ResetContent() {
  13670. m.content = nil
  13671. }
  13672. // SetMeta sets the "meta" field.
  13673. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  13674. m.meta = &ct
  13675. }
  13676. // Meta returns the value of the "meta" field in the mutation.
  13677. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  13678. v := m.meta
  13679. if v == nil {
  13680. return
  13681. }
  13682. return *v, true
  13683. }
  13684. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  13685. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13687. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  13688. if !m.op.Is(OpUpdateOne) {
  13689. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  13690. }
  13691. if m.id == nil || m.oldValue == nil {
  13692. return v, errors.New("OldMeta requires an ID field in the mutation")
  13693. }
  13694. oldValue, err := m.oldValue(ctx)
  13695. if err != nil {
  13696. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  13697. }
  13698. return oldValue.Meta, nil
  13699. }
  13700. // ClearMeta clears the value of the "meta" field.
  13701. func (m *MessageRecordsMutation) ClearMeta() {
  13702. m.meta = nil
  13703. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  13704. }
  13705. // MetaCleared returns if the "meta" field was cleared in this mutation.
  13706. func (m *MessageRecordsMutation) MetaCleared() bool {
  13707. _, ok := m.clearedFields[messagerecords.FieldMeta]
  13708. return ok
  13709. }
  13710. // ResetMeta resets all changes to the "meta" field.
  13711. func (m *MessageRecordsMutation) ResetMeta() {
  13712. m.meta = nil
  13713. delete(m.clearedFields, messagerecords.FieldMeta)
  13714. }
  13715. // SetErrorDetail sets the "error_detail" field.
  13716. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  13717. m.error_detail = &s
  13718. }
  13719. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  13720. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  13721. v := m.error_detail
  13722. if v == nil {
  13723. return
  13724. }
  13725. return *v, true
  13726. }
  13727. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  13728. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13730. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  13731. if !m.op.Is(OpUpdateOne) {
  13732. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  13733. }
  13734. if m.id == nil || m.oldValue == nil {
  13735. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  13736. }
  13737. oldValue, err := m.oldValue(ctx)
  13738. if err != nil {
  13739. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  13740. }
  13741. return oldValue.ErrorDetail, nil
  13742. }
  13743. // ResetErrorDetail resets all changes to the "error_detail" field.
  13744. func (m *MessageRecordsMutation) ResetErrorDetail() {
  13745. m.error_detail = nil
  13746. }
  13747. // SetSendTime sets the "send_time" field.
  13748. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  13749. m.send_time = &t
  13750. }
  13751. // SendTime returns the value of the "send_time" field in the mutation.
  13752. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  13753. v := m.send_time
  13754. if v == nil {
  13755. return
  13756. }
  13757. return *v, true
  13758. }
  13759. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  13760. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13762. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  13763. if !m.op.Is(OpUpdateOne) {
  13764. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  13765. }
  13766. if m.id == nil || m.oldValue == nil {
  13767. return v, errors.New("OldSendTime requires an ID field in the mutation")
  13768. }
  13769. oldValue, err := m.oldValue(ctx)
  13770. if err != nil {
  13771. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  13772. }
  13773. return oldValue.SendTime, nil
  13774. }
  13775. // ClearSendTime clears the value of the "send_time" field.
  13776. func (m *MessageRecordsMutation) ClearSendTime() {
  13777. m.send_time = nil
  13778. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  13779. }
  13780. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  13781. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  13782. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  13783. return ok
  13784. }
  13785. // ResetSendTime resets all changes to the "send_time" field.
  13786. func (m *MessageRecordsMutation) ResetSendTime() {
  13787. m.send_time = nil
  13788. delete(m.clearedFields, messagerecords.FieldSendTime)
  13789. }
  13790. // SetSourceType sets the "source_type" field.
  13791. func (m *MessageRecordsMutation) SetSourceType(i int) {
  13792. m.source_type = &i
  13793. m.addsource_type = nil
  13794. }
  13795. // SourceType returns the value of the "source_type" field in the mutation.
  13796. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  13797. v := m.source_type
  13798. if v == nil {
  13799. return
  13800. }
  13801. return *v, true
  13802. }
  13803. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  13804. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13806. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  13807. if !m.op.Is(OpUpdateOne) {
  13808. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  13809. }
  13810. if m.id == nil || m.oldValue == nil {
  13811. return v, errors.New("OldSourceType requires an ID field in the mutation")
  13812. }
  13813. oldValue, err := m.oldValue(ctx)
  13814. if err != nil {
  13815. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  13816. }
  13817. return oldValue.SourceType, nil
  13818. }
  13819. // AddSourceType adds i to the "source_type" field.
  13820. func (m *MessageRecordsMutation) AddSourceType(i int) {
  13821. if m.addsource_type != nil {
  13822. *m.addsource_type += i
  13823. } else {
  13824. m.addsource_type = &i
  13825. }
  13826. }
  13827. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  13828. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  13829. v := m.addsource_type
  13830. if v == nil {
  13831. return
  13832. }
  13833. return *v, true
  13834. }
  13835. // ResetSourceType resets all changes to the "source_type" field.
  13836. func (m *MessageRecordsMutation) ResetSourceType() {
  13837. m.source_type = nil
  13838. m.addsource_type = nil
  13839. }
  13840. // SetSourceID sets the "source_id" field.
  13841. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  13842. m.sop_stage = &u
  13843. }
  13844. // SourceID returns the value of the "source_id" field in the mutation.
  13845. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  13846. v := m.sop_stage
  13847. if v == nil {
  13848. return
  13849. }
  13850. return *v, true
  13851. }
  13852. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  13853. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13855. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  13856. if !m.op.Is(OpUpdateOne) {
  13857. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  13858. }
  13859. if m.id == nil || m.oldValue == nil {
  13860. return v, errors.New("OldSourceID requires an ID field in the mutation")
  13861. }
  13862. oldValue, err := m.oldValue(ctx)
  13863. if err != nil {
  13864. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  13865. }
  13866. return oldValue.SourceID, nil
  13867. }
  13868. // ClearSourceID clears the value of the "source_id" field.
  13869. func (m *MessageRecordsMutation) ClearSourceID() {
  13870. m.sop_stage = nil
  13871. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  13872. }
  13873. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  13874. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  13875. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  13876. return ok
  13877. }
  13878. // ResetSourceID resets all changes to the "source_id" field.
  13879. func (m *MessageRecordsMutation) ResetSourceID() {
  13880. m.sop_stage = nil
  13881. delete(m.clearedFields, messagerecords.FieldSourceID)
  13882. }
  13883. // SetSubSourceID sets the "sub_source_id" field.
  13884. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  13885. m.sop_node = &u
  13886. }
  13887. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  13888. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  13889. v := m.sop_node
  13890. if v == nil {
  13891. return
  13892. }
  13893. return *v, true
  13894. }
  13895. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  13896. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13898. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  13899. if !m.op.Is(OpUpdateOne) {
  13900. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  13901. }
  13902. if m.id == nil || m.oldValue == nil {
  13903. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  13904. }
  13905. oldValue, err := m.oldValue(ctx)
  13906. if err != nil {
  13907. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  13908. }
  13909. return oldValue.SubSourceID, nil
  13910. }
  13911. // ClearSubSourceID clears the value of the "sub_source_id" field.
  13912. func (m *MessageRecordsMutation) ClearSubSourceID() {
  13913. m.sop_node = nil
  13914. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  13915. }
  13916. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  13917. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  13918. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  13919. return ok
  13920. }
  13921. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  13922. func (m *MessageRecordsMutation) ResetSubSourceID() {
  13923. m.sop_node = nil
  13924. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  13925. }
  13926. // SetOrganizationID sets the "organization_id" field.
  13927. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  13928. m.organization_id = &u
  13929. m.addorganization_id = nil
  13930. }
  13931. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13932. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  13933. v := m.organization_id
  13934. if v == nil {
  13935. return
  13936. }
  13937. return *v, true
  13938. }
  13939. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  13940. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13942. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13943. if !m.op.Is(OpUpdateOne) {
  13944. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13945. }
  13946. if m.id == nil || m.oldValue == nil {
  13947. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13948. }
  13949. oldValue, err := m.oldValue(ctx)
  13950. if err != nil {
  13951. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13952. }
  13953. return oldValue.OrganizationID, nil
  13954. }
  13955. // AddOrganizationID adds u to the "organization_id" field.
  13956. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  13957. if m.addorganization_id != nil {
  13958. *m.addorganization_id += u
  13959. } else {
  13960. m.addorganization_id = &u
  13961. }
  13962. }
  13963. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13964. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  13965. v := m.addorganization_id
  13966. if v == nil {
  13967. return
  13968. }
  13969. return *v, true
  13970. }
  13971. // ClearOrganizationID clears the value of the "organization_id" field.
  13972. func (m *MessageRecordsMutation) ClearOrganizationID() {
  13973. m.organization_id = nil
  13974. m.addorganization_id = nil
  13975. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  13976. }
  13977. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13978. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  13979. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  13980. return ok
  13981. }
  13982. // ResetOrganizationID resets all changes to the "organization_id" field.
  13983. func (m *MessageRecordsMutation) ResetOrganizationID() {
  13984. m.organization_id = nil
  13985. m.addorganization_id = nil
  13986. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  13987. }
  13988. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  13989. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  13990. m.sop_stage = &id
  13991. }
  13992. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  13993. func (m *MessageRecordsMutation) ClearSopStage() {
  13994. m.clearedsop_stage = true
  13995. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  13996. }
  13997. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  13998. func (m *MessageRecordsMutation) SopStageCleared() bool {
  13999. return m.SourceIDCleared() || m.clearedsop_stage
  14000. }
  14001. // SopStageID returns the "sop_stage" edge ID in the mutation.
  14002. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  14003. if m.sop_stage != nil {
  14004. return *m.sop_stage, true
  14005. }
  14006. return
  14007. }
  14008. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  14009. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14010. // SopStageID instead. It exists only for internal usage by the builders.
  14011. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  14012. if id := m.sop_stage; id != nil {
  14013. ids = append(ids, *id)
  14014. }
  14015. return
  14016. }
  14017. // ResetSopStage resets all changes to the "sop_stage" edge.
  14018. func (m *MessageRecordsMutation) ResetSopStage() {
  14019. m.sop_stage = nil
  14020. m.clearedsop_stage = false
  14021. }
  14022. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  14023. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  14024. m.sop_node = &id
  14025. }
  14026. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  14027. func (m *MessageRecordsMutation) ClearSopNode() {
  14028. m.clearedsop_node = true
  14029. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14030. }
  14031. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  14032. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  14033. return m.SubSourceIDCleared() || m.clearedsop_node
  14034. }
  14035. // SopNodeID returns the "sop_node" edge ID in the mutation.
  14036. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  14037. if m.sop_node != nil {
  14038. return *m.sop_node, true
  14039. }
  14040. return
  14041. }
  14042. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  14043. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14044. // SopNodeID instead. It exists only for internal usage by the builders.
  14045. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  14046. if id := m.sop_node; id != nil {
  14047. ids = append(ids, *id)
  14048. }
  14049. return
  14050. }
  14051. // ResetSopNode resets all changes to the "sop_node" edge.
  14052. func (m *MessageRecordsMutation) ResetSopNode() {
  14053. m.sop_node = nil
  14054. m.clearedsop_node = false
  14055. }
  14056. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  14057. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  14058. m.message_contact = &id
  14059. }
  14060. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  14061. func (m *MessageRecordsMutation) ClearMessageContact() {
  14062. m.clearedmessage_contact = true
  14063. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14064. }
  14065. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  14066. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  14067. return m.ContactIDCleared() || m.clearedmessage_contact
  14068. }
  14069. // MessageContactID returns the "message_contact" edge ID in the mutation.
  14070. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  14071. if m.message_contact != nil {
  14072. return *m.message_contact, true
  14073. }
  14074. return
  14075. }
  14076. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  14077. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14078. // MessageContactID instead. It exists only for internal usage by the builders.
  14079. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  14080. if id := m.message_contact; id != nil {
  14081. ids = append(ids, *id)
  14082. }
  14083. return
  14084. }
  14085. // ResetMessageContact resets all changes to the "message_contact" edge.
  14086. func (m *MessageRecordsMutation) ResetMessageContact() {
  14087. m.message_contact = nil
  14088. m.clearedmessage_contact = false
  14089. }
  14090. // Where appends a list predicates to the MessageRecordsMutation builder.
  14091. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  14092. m.predicates = append(m.predicates, ps...)
  14093. }
  14094. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  14095. // users can use type-assertion to append predicates that do not depend on any generated package.
  14096. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  14097. p := make([]predicate.MessageRecords, len(ps))
  14098. for i := range ps {
  14099. p[i] = ps[i]
  14100. }
  14101. m.Where(p...)
  14102. }
  14103. // Op returns the operation name.
  14104. func (m *MessageRecordsMutation) Op() Op {
  14105. return m.op
  14106. }
  14107. // SetOp allows setting the mutation operation.
  14108. func (m *MessageRecordsMutation) SetOp(op Op) {
  14109. m.op = op
  14110. }
  14111. // Type returns the node type of this mutation (MessageRecords).
  14112. func (m *MessageRecordsMutation) Type() string {
  14113. return m.typ
  14114. }
  14115. // Fields returns all fields that were changed during this mutation. Note that in
  14116. // order to get all numeric fields that were incremented/decremented, call
  14117. // AddedFields().
  14118. func (m *MessageRecordsMutation) Fields() []string {
  14119. fields := make([]string, 0, 16)
  14120. if m.created_at != nil {
  14121. fields = append(fields, messagerecords.FieldCreatedAt)
  14122. }
  14123. if m.updated_at != nil {
  14124. fields = append(fields, messagerecords.FieldUpdatedAt)
  14125. }
  14126. if m.status != nil {
  14127. fields = append(fields, messagerecords.FieldStatus)
  14128. }
  14129. if m.bot_wxid != nil {
  14130. fields = append(fields, messagerecords.FieldBotWxid)
  14131. }
  14132. if m.message_contact != nil {
  14133. fields = append(fields, messagerecords.FieldContactID)
  14134. }
  14135. if m.contact_type != nil {
  14136. fields = append(fields, messagerecords.FieldContactType)
  14137. }
  14138. if m.contact_wxid != nil {
  14139. fields = append(fields, messagerecords.FieldContactWxid)
  14140. }
  14141. if m.content_type != nil {
  14142. fields = append(fields, messagerecords.FieldContentType)
  14143. }
  14144. if m.content != nil {
  14145. fields = append(fields, messagerecords.FieldContent)
  14146. }
  14147. if m.meta != nil {
  14148. fields = append(fields, messagerecords.FieldMeta)
  14149. }
  14150. if m.error_detail != nil {
  14151. fields = append(fields, messagerecords.FieldErrorDetail)
  14152. }
  14153. if m.send_time != nil {
  14154. fields = append(fields, messagerecords.FieldSendTime)
  14155. }
  14156. if m.source_type != nil {
  14157. fields = append(fields, messagerecords.FieldSourceType)
  14158. }
  14159. if m.sop_stage != nil {
  14160. fields = append(fields, messagerecords.FieldSourceID)
  14161. }
  14162. if m.sop_node != nil {
  14163. fields = append(fields, messagerecords.FieldSubSourceID)
  14164. }
  14165. if m.organization_id != nil {
  14166. fields = append(fields, messagerecords.FieldOrganizationID)
  14167. }
  14168. return fields
  14169. }
  14170. // Field returns the value of a field with the given name. The second boolean
  14171. // return value indicates that this field was not set, or was not defined in the
  14172. // schema.
  14173. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  14174. switch name {
  14175. case messagerecords.FieldCreatedAt:
  14176. return m.CreatedAt()
  14177. case messagerecords.FieldUpdatedAt:
  14178. return m.UpdatedAt()
  14179. case messagerecords.FieldStatus:
  14180. return m.Status()
  14181. case messagerecords.FieldBotWxid:
  14182. return m.BotWxid()
  14183. case messagerecords.FieldContactID:
  14184. return m.ContactID()
  14185. case messagerecords.FieldContactType:
  14186. return m.ContactType()
  14187. case messagerecords.FieldContactWxid:
  14188. return m.ContactWxid()
  14189. case messagerecords.FieldContentType:
  14190. return m.ContentType()
  14191. case messagerecords.FieldContent:
  14192. return m.Content()
  14193. case messagerecords.FieldMeta:
  14194. return m.Meta()
  14195. case messagerecords.FieldErrorDetail:
  14196. return m.ErrorDetail()
  14197. case messagerecords.FieldSendTime:
  14198. return m.SendTime()
  14199. case messagerecords.FieldSourceType:
  14200. return m.SourceType()
  14201. case messagerecords.FieldSourceID:
  14202. return m.SourceID()
  14203. case messagerecords.FieldSubSourceID:
  14204. return m.SubSourceID()
  14205. case messagerecords.FieldOrganizationID:
  14206. return m.OrganizationID()
  14207. }
  14208. return nil, false
  14209. }
  14210. // OldField returns the old value of the field from the database. An error is
  14211. // returned if the mutation operation is not UpdateOne, or the query to the
  14212. // database failed.
  14213. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14214. switch name {
  14215. case messagerecords.FieldCreatedAt:
  14216. return m.OldCreatedAt(ctx)
  14217. case messagerecords.FieldUpdatedAt:
  14218. return m.OldUpdatedAt(ctx)
  14219. case messagerecords.FieldStatus:
  14220. return m.OldStatus(ctx)
  14221. case messagerecords.FieldBotWxid:
  14222. return m.OldBotWxid(ctx)
  14223. case messagerecords.FieldContactID:
  14224. return m.OldContactID(ctx)
  14225. case messagerecords.FieldContactType:
  14226. return m.OldContactType(ctx)
  14227. case messagerecords.FieldContactWxid:
  14228. return m.OldContactWxid(ctx)
  14229. case messagerecords.FieldContentType:
  14230. return m.OldContentType(ctx)
  14231. case messagerecords.FieldContent:
  14232. return m.OldContent(ctx)
  14233. case messagerecords.FieldMeta:
  14234. return m.OldMeta(ctx)
  14235. case messagerecords.FieldErrorDetail:
  14236. return m.OldErrorDetail(ctx)
  14237. case messagerecords.FieldSendTime:
  14238. return m.OldSendTime(ctx)
  14239. case messagerecords.FieldSourceType:
  14240. return m.OldSourceType(ctx)
  14241. case messagerecords.FieldSourceID:
  14242. return m.OldSourceID(ctx)
  14243. case messagerecords.FieldSubSourceID:
  14244. return m.OldSubSourceID(ctx)
  14245. case messagerecords.FieldOrganizationID:
  14246. return m.OldOrganizationID(ctx)
  14247. }
  14248. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  14249. }
  14250. // SetField sets the value of a field with the given name. It returns an error if
  14251. // the field is not defined in the schema, or if the type mismatched the field
  14252. // type.
  14253. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  14254. switch name {
  14255. case messagerecords.FieldCreatedAt:
  14256. v, ok := value.(time.Time)
  14257. if !ok {
  14258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14259. }
  14260. m.SetCreatedAt(v)
  14261. return nil
  14262. case messagerecords.FieldUpdatedAt:
  14263. v, ok := value.(time.Time)
  14264. if !ok {
  14265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14266. }
  14267. m.SetUpdatedAt(v)
  14268. return nil
  14269. case messagerecords.FieldStatus:
  14270. v, ok := value.(uint8)
  14271. if !ok {
  14272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14273. }
  14274. m.SetStatus(v)
  14275. return nil
  14276. case messagerecords.FieldBotWxid:
  14277. v, ok := value.(string)
  14278. if !ok {
  14279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14280. }
  14281. m.SetBotWxid(v)
  14282. return nil
  14283. case messagerecords.FieldContactID:
  14284. v, ok := value.(uint64)
  14285. if !ok {
  14286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14287. }
  14288. m.SetContactID(v)
  14289. return nil
  14290. case messagerecords.FieldContactType:
  14291. v, ok := value.(int)
  14292. if !ok {
  14293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14294. }
  14295. m.SetContactType(v)
  14296. return nil
  14297. case messagerecords.FieldContactWxid:
  14298. v, ok := value.(string)
  14299. if !ok {
  14300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14301. }
  14302. m.SetContactWxid(v)
  14303. return nil
  14304. case messagerecords.FieldContentType:
  14305. v, ok := value.(int)
  14306. if !ok {
  14307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14308. }
  14309. m.SetContentType(v)
  14310. return nil
  14311. case messagerecords.FieldContent:
  14312. v, ok := value.(string)
  14313. if !ok {
  14314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14315. }
  14316. m.SetContent(v)
  14317. return nil
  14318. case messagerecords.FieldMeta:
  14319. v, ok := value.(custom_types.Meta)
  14320. if !ok {
  14321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14322. }
  14323. m.SetMeta(v)
  14324. return nil
  14325. case messagerecords.FieldErrorDetail:
  14326. v, ok := value.(string)
  14327. if !ok {
  14328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14329. }
  14330. m.SetErrorDetail(v)
  14331. return nil
  14332. case messagerecords.FieldSendTime:
  14333. v, ok := value.(time.Time)
  14334. if !ok {
  14335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14336. }
  14337. m.SetSendTime(v)
  14338. return nil
  14339. case messagerecords.FieldSourceType:
  14340. v, ok := value.(int)
  14341. if !ok {
  14342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14343. }
  14344. m.SetSourceType(v)
  14345. return nil
  14346. case messagerecords.FieldSourceID:
  14347. v, ok := value.(uint64)
  14348. if !ok {
  14349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14350. }
  14351. m.SetSourceID(v)
  14352. return nil
  14353. case messagerecords.FieldSubSourceID:
  14354. v, ok := value.(uint64)
  14355. if !ok {
  14356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14357. }
  14358. m.SetSubSourceID(v)
  14359. return nil
  14360. case messagerecords.FieldOrganizationID:
  14361. v, ok := value.(uint64)
  14362. if !ok {
  14363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14364. }
  14365. m.SetOrganizationID(v)
  14366. return nil
  14367. }
  14368. return fmt.Errorf("unknown MessageRecords field %s", name)
  14369. }
  14370. // AddedFields returns all numeric fields that were incremented/decremented during
  14371. // this mutation.
  14372. func (m *MessageRecordsMutation) AddedFields() []string {
  14373. var fields []string
  14374. if m.addstatus != nil {
  14375. fields = append(fields, messagerecords.FieldStatus)
  14376. }
  14377. if m.addcontact_type != nil {
  14378. fields = append(fields, messagerecords.FieldContactType)
  14379. }
  14380. if m.addcontent_type != nil {
  14381. fields = append(fields, messagerecords.FieldContentType)
  14382. }
  14383. if m.addsource_type != nil {
  14384. fields = append(fields, messagerecords.FieldSourceType)
  14385. }
  14386. if m.addorganization_id != nil {
  14387. fields = append(fields, messagerecords.FieldOrganizationID)
  14388. }
  14389. return fields
  14390. }
  14391. // AddedField returns the numeric value that was incremented/decremented on a field
  14392. // with the given name. The second boolean return value indicates that this field
  14393. // was not set, or was not defined in the schema.
  14394. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  14395. switch name {
  14396. case messagerecords.FieldStatus:
  14397. return m.AddedStatus()
  14398. case messagerecords.FieldContactType:
  14399. return m.AddedContactType()
  14400. case messagerecords.FieldContentType:
  14401. return m.AddedContentType()
  14402. case messagerecords.FieldSourceType:
  14403. return m.AddedSourceType()
  14404. case messagerecords.FieldOrganizationID:
  14405. return m.AddedOrganizationID()
  14406. }
  14407. return nil, false
  14408. }
  14409. // AddField adds the value to the field with the given name. It returns an error if
  14410. // the field is not defined in the schema, or if the type mismatched the field
  14411. // type.
  14412. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  14413. switch name {
  14414. case messagerecords.FieldStatus:
  14415. v, ok := value.(int8)
  14416. if !ok {
  14417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14418. }
  14419. m.AddStatus(v)
  14420. return nil
  14421. case messagerecords.FieldContactType:
  14422. v, ok := value.(int)
  14423. if !ok {
  14424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14425. }
  14426. m.AddContactType(v)
  14427. return nil
  14428. case messagerecords.FieldContentType:
  14429. v, ok := value.(int)
  14430. if !ok {
  14431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14432. }
  14433. m.AddContentType(v)
  14434. return nil
  14435. case messagerecords.FieldSourceType:
  14436. v, ok := value.(int)
  14437. if !ok {
  14438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14439. }
  14440. m.AddSourceType(v)
  14441. return nil
  14442. case messagerecords.FieldOrganizationID:
  14443. v, ok := value.(int64)
  14444. if !ok {
  14445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14446. }
  14447. m.AddOrganizationID(v)
  14448. return nil
  14449. }
  14450. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  14451. }
  14452. // ClearedFields returns all nullable fields that were cleared during this
  14453. // mutation.
  14454. func (m *MessageRecordsMutation) ClearedFields() []string {
  14455. var fields []string
  14456. if m.FieldCleared(messagerecords.FieldStatus) {
  14457. fields = append(fields, messagerecords.FieldStatus)
  14458. }
  14459. if m.FieldCleared(messagerecords.FieldContactID) {
  14460. fields = append(fields, messagerecords.FieldContactID)
  14461. }
  14462. if m.FieldCleared(messagerecords.FieldMeta) {
  14463. fields = append(fields, messagerecords.FieldMeta)
  14464. }
  14465. if m.FieldCleared(messagerecords.FieldSendTime) {
  14466. fields = append(fields, messagerecords.FieldSendTime)
  14467. }
  14468. if m.FieldCleared(messagerecords.FieldSourceID) {
  14469. fields = append(fields, messagerecords.FieldSourceID)
  14470. }
  14471. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  14472. fields = append(fields, messagerecords.FieldSubSourceID)
  14473. }
  14474. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  14475. fields = append(fields, messagerecords.FieldOrganizationID)
  14476. }
  14477. return fields
  14478. }
  14479. // FieldCleared returns a boolean indicating if a field with the given name was
  14480. // cleared in this mutation.
  14481. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  14482. _, ok := m.clearedFields[name]
  14483. return ok
  14484. }
  14485. // ClearField clears the value of the field with the given name. It returns an
  14486. // error if the field is not defined in the schema.
  14487. func (m *MessageRecordsMutation) ClearField(name string) error {
  14488. switch name {
  14489. case messagerecords.FieldStatus:
  14490. m.ClearStatus()
  14491. return nil
  14492. case messagerecords.FieldContactID:
  14493. m.ClearContactID()
  14494. return nil
  14495. case messagerecords.FieldMeta:
  14496. m.ClearMeta()
  14497. return nil
  14498. case messagerecords.FieldSendTime:
  14499. m.ClearSendTime()
  14500. return nil
  14501. case messagerecords.FieldSourceID:
  14502. m.ClearSourceID()
  14503. return nil
  14504. case messagerecords.FieldSubSourceID:
  14505. m.ClearSubSourceID()
  14506. return nil
  14507. case messagerecords.FieldOrganizationID:
  14508. m.ClearOrganizationID()
  14509. return nil
  14510. }
  14511. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  14512. }
  14513. // ResetField resets all changes in the mutation for the field with the given name.
  14514. // It returns an error if the field is not defined in the schema.
  14515. func (m *MessageRecordsMutation) ResetField(name string) error {
  14516. switch name {
  14517. case messagerecords.FieldCreatedAt:
  14518. m.ResetCreatedAt()
  14519. return nil
  14520. case messagerecords.FieldUpdatedAt:
  14521. m.ResetUpdatedAt()
  14522. return nil
  14523. case messagerecords.FieldStatus:
  14524. m.ResetStatus()
  14525. return nil
  14526. case messagerecords.FieldBotWxid:
  14527. m.ResetBotWxid()
  14528. return nil
  14529. case messagerecords.FieldContactID:
  14530. m.ResetContactID()
  14531. return nil
  14532. case messagerecords.FieldContactType:
  14533. m.ResetContactType()
  14534. return nil
  14535. case messagerecords.FieldContactWxid:
  14536. m.ResetContactWxid()
  14537. return nil
  14538. case messagerecords.FieldContentType:
  14539. m.ResetContentType()
  14540. return nil
  14541. case messagerecords.FieldContent:
  14542. m.ResetContent()
  14543. return nil
  14544. case messagerecords.FieldMeta:
  14545. m.ResetMeta()
  14546. return nil
  14547. case messagerecords.FieldErrorDetail:
  14548. m.ResetErrorDetail()
  14549. return nil
  14550. case messagerecords.FieldSendTime:
  14551. m.ResetSendTime()
  14552. return nil
  14553. case messagerecords.FieldSourceType:
  14554. m.ResetSourceType()
  14555. return nil
  14556. case messagerecords.FieldSourceID:
  14557. m.ResetSourceID()
  14558. return nil
  14559. case messagerecords.FieldSubSourceID:
  14560. m.ResetSubSourceID()
  14561. return nil
  14562. case messagerecords.FieldOrganizationID:
  14563. m.ResetOrganizationID()
  14564. return nil
  14565. }
  14566. return fmt.Errorf("unknown MessageRecords field %s", name)
  14567. }
  14568. // AddedEdges returns all edge names that were set/added in this mutation.
  14569. func (m *MessageRecordsMutation) AddedEdges() []string {
  14570. edges := make([]string, 0, 3)
  14571. if m.sop_stage != nil {
  14572. edges = append(edges, messagerecords.EdgeSopStage)
  14573. }
  14574. if m.sop_node != nil {
  14575. edges = append(edges, messagerecords.EdgeSopNode)
  14576. }
  14577. if m.message_contact != nil {
  14578. edges = append(edges, messagerecords.EdgeMessageContact)
  14579. }
  14580. return edges
  14581. }
  14582. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14583. // name in this mutation.
  14584. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  14585. switch name {
  14586. case messagerecords.EdgeSopStage:
  14587. if id := m.sop_stage; id != nil {
  14588. return []ent.Value{*id}
  14589. }
  14590. case messagerecords.EdgeSopNode:
  14591. if id := m.sop_node; id != nil {
  14592. return []ent.Value{*id}
  14593. }
  14594. case messagerecords.EdgeMessageContact:
  14595. if id := m.message_contact; id != nil {
  14596. return []ent.Value{*id}
  14597. }
  14598. }
  14599. return nil
  14600. }
  14601. // RemovedEdges returns all edge names that were removed in this mutation.
  14602. func (m *MessageRecordsMutation) RemovedEdges() []string {
  14603. edges := make([]string, 0, 3)
  14604. return edges
  14605. }
  14606. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14607. // the given name in this mutation.
  14608. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  14609. return nil
  14610. }
  14611. // ClearedEdges returns all edge names that were cleared in this mutation.
  14612. func (m *MessageRecordsMutation) ClearedEdges() []string {
  14613. edges := make([]string, 0, 3)
  14614. if m.clearedsop_stage {
  14615. edges = append(edges, messagerecords.EdgeSopStage)
  14616. }
  14617. if m.clearedsop_node {
  14618. edges = append(edges, messagerecords.EdgeSopNode)
  14619. }
  14620. if m.clearedmessage_contact {
  14621. edges = append(edges, messagerecords.EdgeMessageContact)
  14622. }
  14623. return edges
  14624. }
  14625. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14626. // was cleared in this mutation.
  14627. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  14628. switch name {
  14629. case messagerecords.EdgeSopStage:
  14630. return m.clearedsop_stage
  14631. case messagerecords.EdgeSopNode:
  14632. return m.clearedsop_node
  14633. case messagerecords.EdgeMessageContact:
  14634. return m.clearedmessage_contact
  14635. }
  14636. return false
  14637. }
  14638. // ClearEdge clears the value of the edge with the given name. It returns an error
  14639. // if that edge is not defined in the schema.
  14640. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  14641. switch name {
  14642. case messagerecords.EdgeSopStage:
  14643. m.ClearSopStage()
  14644. return nil
  14645. case messagerecords.EdgeSopNode:
  14646. m.ClearSopNode()
  14647. return nil
  14648. case messagerecords.EdgeMessageContact:
  14649. m.ClearMessageContact()
  14650. return nil
  14651. }
  14652. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  14653. }
  14654. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14655. // It returns an error if the edge is not defined in the schema.
  14656. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  14657. switch name {
  14658. case messagerecords.EdgeSopStage:
  14659. m.ResetSopStage()
  14660. return nil
  14661. case messagerecords.EdgeSopNode:
  14662. m.ResetSopNode()
  14663. return nil
  14664. case messagerecords.EdgeMessageContact:
  14665. m.ResetMessageContact()
  14666. return nil
  14667. }
  14668. return fmt.Errorf("unknown MessageRecords edge %s", name)
  14669. }
  14670. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  14671. type MsgMutation struct {
  14672. config
  14673. op Op
  14674. typ string
  14675. id *uint64
  14676. created_at *time.Time
  14677. updated_at *time.Time
  14678. deleted_at *time.Time
  14679. status *uint8
  14680. addstatus *int8
  14681. fromwxid *string
  14682. toid *string
  14683. msgtype *int32
  14684. addmsgtype *int32
  14685. msg *string
  14686. batch_no *string
  14687. clearedFields map[string]struct{}
  14688. done bool
  14689. oldValue func(context.Context) (*Msg, error)
  14690. predicates []predicate.Msg
  14691. }
  14692. var _ ent.Mutation = (*MsgMutation)(nil)
  14693. // msgOption allows management of the mutation configuration using functional options.
  14694. type msgOption func(*MsgMutation)
  14695. // newMsgMutation creates new mutation for the Msg entity.
  14696. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  14697. m := &MsgMutation{
  14698. config: c,
  14699. op: op,
  14700. typ: TypeMsg,
  14701. clearedFields: make(map[string]struct{}),
  14702. }
  14703. for _, opt := range opts {
  14704. opt(m)
  14705. }
  14706. return m
  14707. }
  14708. // withMsgID sets the ID field of the mutation.
  14709. func withMsgID(id uint64) msgOption {
  14710. return func(m *MsgMutation) {
  14711. var (
  14712. err error
  14713. once sync.Once
  14714. value *Msg
  14715. )
  14716. m.oldValue = func(ctx context.Context) (*Msg, error) {
  14717. once.Do(func() {
  14718. if m.done {
  14719. err = errors.New("querying old values post mutation is not allowed")
  14720. } else {
  14721. value, err = m.Client().Msg.Get(ctx, id)
  14722. }
  14723. })
  14724. return value, err
  14725. }
  14726. m.id = &id
  14727. }
  14728. }
  14729. // withMsg sets the old Msg of the mutation.
  14730. func withMsg(node *Msg) msgOption {
  14731. return func(m *MsgMutation) {
  14732. m.oldValue = func(context.Context) (*Msg, error) {
  14733. return node, nil
  14734. }
  14735. m.id = &node.ID
  14736. }
  14737. }
  14738. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14739. // executed in a transaction (ent.Tx), a transactional client is returned.
  14740. func (m MsgMutation) Client() *Client {
  14741. client := &Client{config: m.config}
  14742. client.init()
  14743. return client
  14744. }
  14745. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14746. // it returns an error otherwise.
  14747. func (m MsgMutation) Tx() (*Tx, error) {
  14748. if _, ok := m.driver.(*txDriver); !ok {
  14749. return nil, errors.New("ent: mutation is not running in a transaction")
  14750. }
  14751. tx := &Tx{config: m.config}
  14752. tx.init()
  14753. return tx, nil
  14754. }
  14755. // SetID sets the value of the id field. Note that this
  14756. // operation is only accepted on creation of Msg entities.
  14757. func (m *MsgMutation) SetID(id uint64) {
  14758. m.id = &id
  14759. }
  14760. // ID returns the ID value in the mutation. Note that the ID is only available
  14761. // if it was provided to the builder or after it was returned from the database.
  14762. func (m *MsgMutation) ID() (id uint64, exists bool) {
  14763. if m.id == nil {
  14764. return
  14765. }
  14766. return *m.id, true
  14767. }
  14768. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14769. // That means, if the mutation is applied within a transaction with an isolation level such
  14770. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14771. // or updated by the mutation.
  14772. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  14773. switch {
  14774. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14775. id, exists := m.ID()
  14776. if exists {
  14777. return []uint64{id}, nil
  14778. }
  14779. fallthrough
  14780. case m.op.Is(OpUpdate | OpDelete):
  14781. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  14782. default:
  14783. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14784. }
  14785. }
  14786. // SetCreatedAt sets the "created_at" field.
  14787. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  14788. m.created_at = &t
  14789. }
  14790. // CreatedAt returns the value of the "created_at" field in the mutation.
  14791. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  14792. v := m.created_at
  14793. if v == nil {
  14794. return
  14795. }
  14796. return *v, true
  14797. }
  14798. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  14799. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14801. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14802. if !m.op.Is(OpUpdateOne) {
  14803. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14804. }
  14805. if m.id == nil || m.oldValue == nil {
  14806. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14807. }
  14808. oldValue, err := m.oldValue(ctx)
  14809. if err != nil {
  14810. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14811. }
  14812. return oldValue.CreatedAt, nil
  14813. }
  14814. // ResetCreatedAt resets all changes to the "created_at" field.
  14815. func (m *MsgMutation) ResetCreatedAt() {
  14816. m.created_at = nil
  14817. }
  14818. // SetUpdatedAt sets the "updated_at" field.
  14819. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  14820. m.updated_at = &t
  14821. }
  14822. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14823. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  14824. v := m.updated_at
  14825. if v == nil {
  14826. return
  14827. }
  14828. return *v, true
  14829. }
  14830. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  14831. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14833. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14834. if !m.op.Is(OpUpdateOne) {
  14835. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14836. }
  14837. if m.id == nil || m.oldValue == nil {
  14838. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14839. }
  14840. oldValue, err := m.oldValue(ctx)
  14841. if err != nil {
  14842. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14843. }
  14844. return oldValue.UpdatedAt, nil
  14845. }
  14846. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14847. func (m *MsgMutation) ResetUpdatedAt() {
  14848. m.updated_at = nil
  14849. }
  14850. // SetDeletedAt sets the "deleted_at" field.
  14851. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  14852. m.deleted_at = &t
  14853. }
  14854. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14855. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  14856. v := m.deleted_at
  14857. if v == nil {
  14858. return
  14859. }
  14860. return *v, true
  14861. }
  14862. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  14863. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14865. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14866. if !m.op.Is(OpUpdateOne) {
  14867. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14868. }
  14869. if m.id == nil || m.oldValue == nil {
  14870. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14871. }
  14872. oldValue, err := m.oldValue(ctx)
  14873. if err != nil {
  14874. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14875. }
  14876. return oldValue.DeletedAt, nil
  14877. }
  14878. // ClearDeletedAt clears the value of the "deleted_at" field.
  14879. func (m *MsgMutation) ClearDeletedAt() {
  14880. m.deleted_at = nil
  14881. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  14882. }
  14883. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14884. func (m *MsgMutation) DeletedAtCleared() bool {
  14885. _, ok := m.clearedFields[msg.FieldDeletedAt]
  14886. return ok
  14887. }
  14888. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14889. func (m *MsgMutation) ResetDeletedAt() {
  14890. m.deleted_at = nil
  14891. delete(m.clearedFields, msg.FieldDeletedAt)
  14892. }
  14893. // SetStatus sets the "status" field.
  14894. func (m *MsgMutation) SetStatus(u uint8) {
  14895. m.status = &u
  14896. m.addstatus = nil
  14897. }
  14898. // Status returns the value of the "status" field in the mutation.
  14899. func (m *MsgMutation) Status() (r uint8, exists bool) {
  14900. v := m.status
  14901. if v == nil {
  14902. return
  14903. }
  14904. return *v, true
  14905. }
  14906. // OldStatus returns the old "status" field's value of the Msg entity.
  14907. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14909. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14910. if !m.op.Is(OpUpdateOne) {
  14911. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14912. }
  14913. if m.id == nil || m.oldValue == nil {
  14914. return v, errors.New("OldStatus requires an ID field in the mutation")
  14915. }
  14916. oldValue, err := m.oldValue(ctx)
  14917. if err != nil {
  14918. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14919. }
  14920. return oldValue.Status, nil
  14921. }
  14922. // AddStatus adds u to the "status" field.
  14923. func (m *MsgMutation) AddStatus(u int8) {
  14924. if m.addstatus != nil {
  14925. *m.addstatus += u
  14926. } else {
  14927. m.addstatus = &u
  14928. }
  14929. }
  14930. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14931. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  14932. v := m.addstatus
  14933. if v == nil {
  14934. return
  14935. }
  14936. return *v, true
  14937. }
  14938. // ClearStatus clears the value of the "status" field.
  14939. func (m *MsgMutation) ClearStatus() {
  14940. m.status = nil
  14941. m.addstatus = nil
  14942. m.clearedFields[msg.FieldStatus] = struct{}{}
  14943. }
  14944. // StatusCleared returns if the "status" field was cleared in this mutation.
  14945. func (m *MsgMutation) StatusCleared() bool {
  14946. _, ok := m.clearedFields[msg.FieldStatus]
  14947. return ok
  14948. }
  14949. // ResetStatus resets all changes to the "status" field.
  14950. func (m *MsgMutation) ResetStatus() {
  14951. m.status = nil
  14952. m.addstatus = nil
  14953. delete(m.clearedFields, msg.FieldStatus)
  14954. }
  14955. // SetFromwxid sets the "fromwxid" field.
  14956. func (m *MsgMutation) SetFromwxid(s string) {
  14957. m.fromwxid = &s
  14958. }
  14959. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  14960. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  14961. v := m.fromwxid
  14962. if v == nil {
  14963. return
  14964. }
  14965. return *v, true
  14966. }
  14967. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  14968. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14970. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  14971. if !m.op.Is(OpUpdateOne) {
  14972. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  14973. }
  14974. if m.id == nil || m.oldValue == nil {
  14975. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  14976. }
  14977. oldValue, err := m.oldValue(ctx)
  14978. if err != nil {
  14979. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  14980. }
  14981. return oldValue.Fromwxid, nil
  14982. }
  14983. // ClearFromwxid clears the value of the "fromwxid" field.
  14984. func (m *MsgMutation) ClearFromwxid() {
  14985. m.fromwxid = nil
  14986. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  14987. }
  14988. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  14989. func (m *MsgMutation) FromwxidCleared() bool {
  14990. _, ok := m.clearedFields[msg.FieldFromwxid]
  14991. return ok
  14992. }
  14993. // ResetFromwxid resets all changes to the "fromwxid" field.
  14994. func (m *MsgMutation) ResetFromwxid() {
  14995. m.fromwxid = nil
  14996. delete(m.clearedFields, msg.FieldFromwxid)
  14997. }
  14998. // SetToid sets the "toid" field.
  14999. func (m *MsgMutation) SetToid(s string) {
  15000. m.toid = &s
  15001. }
  15002. // Toid returns the value of the "toid" field in the mutation.
  15003. func (m *MsgMutation) Toid() (r string, exists bool) {
  15004. v := m.toid
  15005. if v == nil {
  15006. return
  15007. }
  15008. return *v, true
  15009. }
  15010. // OldToid returns the old "toid" field's value of the Msg entity.
  15011. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15013. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  15014. if !m.op.Is(OpUpdateOne) {
  15015. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  15016. }
  15017. if m.id == nil || m.oldValue == nil {
  15018. return v, errors.New("OldToid requires an ID field in the mutation")
  15019. }
  15020. oldValue, err := m.oldValue(ctx)
  15021. if err != nil {
  15022. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  15023. }
  15024. return oldValue.Toid, nil
  15025. }
  15026. // ClearToid clears the value of the "toid" field.
  15027. func (m *MsgMutation) ClearToid() {
  15028. m.toid = nil
  15029. m.clearedFields[msg.FieldToid] = struct{}{}
  15030. }
  15031. // ToidCleared returns if the "toid" field was cleared in this mutation.
  15032. func (m *MsgMutation) ToidCleared() bool {
  15033. _, ok := m.clearedFields[msg.FieldToid]
  15034. return ok
  15035. }
  15036. // ResetToid resets all changes to the "toid" field.
  15037. func (m *MsgMutation) ResetToid() {
  15038. m.toid = nil
  15039. delete(m.clearedFields, msg.FieldToid)
  15040. }
  15041. // SetMsgtype sets the "msgtype" field.
  15042. func (m *MsgMutation) SetMsgtype(i int32) {
  15043. m.msgtype = &i
  15044. m.addmsgtype = nil
  15045. }
  15046. // Msgtype returns the value of the "msgtype" field in the mutation.
  15047. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  15048. v := m.msgtype
  15049. if v == nil {
  15050. return
  15051. }
  15052. return *v, true
  15053. }
  15054. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  15055. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15057. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  15058. if !m.op.Is(OpUpdateOne) {
  15059. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  15060. }
  15061. if m.id == nil || m.oldValue == nil {
  15062. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  15063. }
  15064. oldValue, err := m.oldValue(ctx)
  15065. if err != nil {
  15066. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  15067. }
  15068. return oldValue.Msgtype, nil
  15069. }
  15070. // AddMsgtype adds i to the "msgtype" field.
  15071. func (m *MsgMutation) AddMsgtype(i int32) {
  15072. if m.addmsgtype != nil {
  15073. *m.addmsgtype += i
  15074. } else {
  15075. m.addmsgtype = &i
  15076. }
  15077. }
  15078. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  15079. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  15080. v := m.addmsgtype
  15081. if v == nil {
  15082. return
  15083. }
  15084. return *v, true
  15085. }
  15086. // ClearMsgtype clears the value of the "msgtype" field.
  15087. func (m *MsgMutation) ClearMsgtype() {
  15088. m.msgtype = nil
  15089. m.addmsgtype = nil
  15090. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  15091. }
  15092. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  15093. func (m *MsgMutation) MsgtypeCleared() bool {
  15094. _, ok := m.clearedFields[msg.FieldMsgtype]
  15095. return ok
  15096. }
  15097. // ResetMsgtype resets all changes to the "msgtype" field.
  15098. func (m *MsgMutation) ResetMsgtype() {
  15099. m.msgtype = nil
  15100. m.addmsgtype = nil
  15101. delete(m.clearedFields, msg.FieldMsgtype)
  15102. }
  15103. // SetMsg sets the "msg" field.
  15104. func (m *MsgMutation) SetMsg(s string) {
  15105. m.msg = &s
  15106. }
  15107. // Msg returns the value of the "msg" field in the mutation.
  15108. func (m *MsgMutation) Msg() (r string, exists bool) {
  15109. v := m.msg
  15110. if v == nil {
  15111. return
  15112. }
  15113. return *v, true
  15114. }
  15115. // OldMsg returns the old "msg" field's value of the Msg entity.
  15116. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15118. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  15119. if !m.op.Is(OpUpdateOne) {
  15120. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  15121. }
  15122. if m.id == nil || m.oldValue == nil {
  15123. return v, errors.New("OldMsg requires an ID field in the mutation")
  15124. }
  15125. oldValue, err := m.oldValue(ctx)
  15126. if err != nil {
  15127. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  15128. }
  15129. return oldValue.Msg, nil
  15130. }
  15131. // ClearMsg clears the value of the "msg" field.
  15132. func (m *MsgMutation) ClearMsg() {
  15133. m.msg = nil
  15134. m.clearedFields[msg.FieldMsg] = struct{}{}
  15135. }
  15136. // MsgCleared returns if the "msg" field was cleared in this mutation.
  15137. func (m *MsgMutation) MsgCleared() bool {
  15138. _, ok := m.clearedFields[msg.FieldMsg]
  15139. return ok
  15140. }
  15141. // ResetMsg resets all changes to the "msg" field.
  15142. func (m *MsgMutation) ResetMsg() {
  15143. m.msg = nil
  15144. delete(m.clearedFields, msg.FieldMsg)
  15145. }
  15146. // SetBatchNo sets the "batch_no" field.
  15147. func (m *MsgMutation) SetBatchNo(s string) {
  15148. m.batch_no = &s
  15149. }
  15150. // BatchNo returns the value of the "batch_no" field in the mutation.
  15151. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  15152. v := m.batch_no
  15153. if v == nil {
  15154. return
  15155. }
  15156. return *v, true
  15157. }
  15158. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  15159. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15161. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  15162. if !m.op.Is(OpUpdateOne) {
  15163. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  15164. }
  15165. if m.id == nil || m.oldValue == nil {
  15166. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  15167. }
  15168. oldValue, err := m.oldValue(ctx)
  15169. if err != nil {
  15170. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  15171. }
  15172. return oldValue.BatchNo, nil
  15173. }
  15174. // ClearBatchNo clears the value of the "batch_no" field.
  15175. func (m *MsgMutation) ClearBatchNo() {
  15176. m.batch_no = nil
  15177. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  15178. }
  15179. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  15180. func (m *MsgMutation) BatchNoCleared() bool {
  15181. _, ok := m.clearedFields[msg.FieldBatchNo]
  15182. return ok
  15183. }
  15184. // ResetBatchNo resets all changes to the "batch_no" field.
  15185. func (m *MsgMutation) ResetBatchNo() {
  15186. m.batch_no = nil
  15187. delete(m.clearedFields, msg.FieldBatchNo)
  15188. }
  15189. // Where appends a list predicates to the MsgMutation builder.
  15190. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  15191. m.predicates = append(m.predicates, ps...)
  15192. }
  15193. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  15194. // users can use type-assertion to append predicates that do not depend on any generated package.
  15195. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  15196. p := make([]predicate.Msg, len(ps))
  15197. for i := range ps {
  15198. p[i] = ps[i]
  15199. }
  15200. m.Where(p...)
  15201. }
  15202. // Op returns the operation name.
  15203. func (m *MsgMutation) Op() Op {
  15204. return m.op
  15205. }
  15206. // SetOp allows setting the mutation operation.
  15207. func (m *MsgMutation) SetOp(op Op) {
  15208. m.op = op
  15209. }
  15210. // Type returns the node type of this mutation (Msg).
  15211. func (m *MsgMutation) Type() string {
  15212. return m.typ
  15213. }
  15214. // Fields returns all fields that were changed during this mutation. Note that in
  15215. // order to get all numeric fields that were incremented/decremented, call
  15216. // AddedFields().
  15217. func (m *MsgMutation) Fields() []string {
  15218. fields := make([]string, 0, 9)
  15219. if m.created_at != nil {
  15220. fields = append(fields, msg.FieldCreatedAt)
  15221. }
  15222. if m.updated_at != nil {
  15223. fields = append(fields, msg.FieldUpdatedAt)
  15224. }
  15225. if m.deleted_at != nil {
  15226. fields = append(fields, msg.FieldDeletedAt)
  15227. }
  15228. if m.status != nil {
  15229. fields = append(fields, msg.FieldStatus)
  15230. }
  15231. if m.fromwxid != nil {
  15232. fields = append(fields, msg.FieldFromwxid)
  15233. }
  15234. if m.toid != nil {
  15235. fields = append(fields, msg.FieldToid)
  15236. }
  15237. if m.msgtype != nil {
  15238. fields = append(fields, msg.FieldMsgtype)
  15239. }
  15240. if m.msg != nil {
  15241. fields = append(fields, msg.FieldMsg)
  15242. }
  15243. if m.batch_no != nil {
  15244. fields = append(fields, msg.FieldBatchNo)
  15245. }
  15246. return fields
  15247. }
  15248. // Field returns the value of a field with the given name. The second boolean
  15249. // return value indicates that this field was not set, or was not defined in the
  15250. // schema.
  15251. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  15252. switch name {
  15253. case msg.FieldCreatedAt:
  15254. return m.CreatedAt()
  15255. case msg.FieldUpdatedAt:
  15256. return m.UpdatedAt()
  15257. case msg.FieldDeletedAt:
  15258. return m.DeletedAt()
  15259. case msg.FieldStatus:
  15260. return m.Status()
  15261. case msg.FieldFromwxid:
  15262. return m.Fromwxid()
  15263. case msg.FieldToid:
  15264. return m.Toid()
  15265. case msg.FieldMsgtype:
  15266. return m.Msgtype()
  15267. case msg.FieldMsg:
  15268. return m.Msg()
  15269. case msg.FieldBatchNo:
  15270. return m.BatchNo()
  15271. }
  15272. return nil, false
  15273. }
  15274. // OldField returns the old value of the field from the database. An error is
  15275. // returned if the mutation operation is not UpdateOne, or the query to the
  15276. // database failed.
  15277. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15278. switch name {
  15279. case msg.FieldCreatedAt:
  15280. return m.OldCreatedAt(ctx)
  15281. case msg.FieldUpdatedAt:
  15282. return m.OldUpdatedAt(ctx)
  15283. case msg.FieldDeletedAt:
  15284. return m.OldDeletedAt(ctx)
  15285. case msg.FieldStatus:
  15286. return m.OldStatus(ctx)
  15287. case msg.FieldFromwxid:
  15288. return m.OldFromwxid(ctx)
  15289. case msg.FieldToid:
  15290. return m.OldToid(ctx)
  15291. case msg.FieldMsgtype:
  15292. return m.OldMsgtype(ctx)
  15293. case msg.FieldMsg:
  15294. return m.OldMsg(ctx)
  15295. case msg.FieldBatchNo:
  15296. return m.OldBatchNo(ctx)
  15297. }
  15298. return nil, fmt.Errorf("unknown Msg field %s", name)
  15299. }
  15300. // SetField sets the value of a field with the given name. It returns an error if
  15301. // the field is not defined in the schema, or if the type mismatched the field
  15302. // type.
  15303. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  15304. switch name {
  15305. case msg.FieldCreatedAt:
  15306. v, ok := value.(time.Time)
  15307. if !ok {
  15308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15309. }
  15310. m.SetCreatedAt(v)
  15311. return nil
  15312. case msg.FieldUpdatedAt:
  15313. v, ok := value.(time.Time)
  15314. if !ok {
  15315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15316. }
  15317. m.SetUpdatedAt(v)
  15318. return nil
  15319. case msg.FieldDeletedAt:
  15320. v, ok := value.(time.Time)
  15321. if !ok {
  15322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15323. }
  15324. m.SetDeletedAt(v)
  15325. return nil
  15326. case msg.FieldStatus:
  15327. v, ok := value.(uint8)
  15328. if !ok {
  15329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15330. }
  15331. m.SetStatus(v)
  15332. return nil
  15333. case msg.FieldFromwxid:
  15334. v, ok := value.(string)
  15335. if !ok {
  15336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15337. }
  15338. m.SetFromwxid(v)
  15339. return nil
  15340. case msg.FieldToid:
  15341. v, ok := value.(string)
  15342. if !ok {
  15343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15344. }
  15345. m.SetToid(v)
  15346. return nil
  15347. case msg.FieldMsgtype:
  15348. v, ok := value.(int32)
  15349. if !ok {
  15350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15351. }
  15352. m.SetMsgtype(v)
  15353. return nil
  15354. case msg.FieldMsg:
  15355. v, ok := value.(string)
  15356. if !ok {
  15357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15358. }
  15359. m.SetMsg(v)
  15360. return nil
  15361. case msg.FieldBatchNo:
  15362. v, ok := value.(string)
  15363. if !ok {
  15364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15365. }
  15366. m.SetBatchNo(v)
  15367. return nil
  15368. }
  15369. return fmt.Errorf("unknown Msg field %s", name)
  15370. }
  15371. // AddedFields returns all numeric fields that were incremented/decremented during
  15372. // this mutation.
  15373. func (m *MsgMutation) AddedFields() []string {
  15374. var fields []string
  15375. if m.addstatus != nil {
  15376. fields = append(fields, msg.FieldStatus)
  15377. }
  15378. if m.addmsgtype != nil {
  15379. fields = append(fields, msg.FieldMsgtype)
  15380. }
  15381. return fields
  15382. }
  15383. // AddedField returns the numeric value that was incremented/decremented on a field
  15384. // with the given name. The second boolean return value indicates that this field
  15385. // was not set, or was not defined in the schema.
  15386. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  15387. switch name {
  15388. case msg.FieldStatus:
  15389. return m.AddedStatus()
  15390. case msg.FieldMsgtype:
  15391. return m.AddedMsgtype()
  15392. }
  15393. return nil, false
  15394. }
  15395. // AddField adds the value to the field with the given name. It returns an error if
  15396. // the field is not defined in the schema, or if the type mismatched the field
  15397. // type.
  15398. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  15399. switch name {
  15400. case msg.FieldStatus:
  15401. v, ok := value.(int8)
  15402. if !ok {
  15403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15404. }
  15405. m.AddStatus(v)
  15406. return nil
  15407. case msg.FieldMsgtype:
  15408. v, ok := value.(int32)
  15409. if !ok {
  15410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15411. }
  15412. m.AddMsgtype(v)
  15413. return nil
  15414. }
  15415. return fmt.Errorf("unknown Msg numeric field %s", name)
  15416. }
  15417. // ClearedFields returns all nullable fields that were cleared during this
  15418. // mutation.
  15419. func (m *MsgMutation) ClearedFields() []string {
  15420. var fields []string
  15421. if m.FieldCleared(msg.FieldDeletedAt) {
  15422. fields = append(fields, msg.FieldDeletedAt)
  15423. }
  15424. if m.FieldCleared(msg.FieldStatus) {
  15425. fields = append(fields, msg.FieldStatus)
  15426. }
  15427. if m.FieldCleared(msg.FieldFromwxid) {
  15428. fields = append(fields, msg.FieldFromwxid)
  15429. }
  15430. if m.FieldCleared(msg.FieldToid) {
  15431. fields = append(fields, msg.FieldToid)
  15432. }
  15433. if m.FieldCleared(msg.FieldMsgtype) {
  15434. fields = append(fields, msg.FieldMsgtype)
  15435. }
  15436. if m.FieldCleared(msg.FieldMsg) {
  15437. fields = append(fields, msg.FieldMsg)
  15438. }
  15439. if m.FieldCleared(msg.FieldBatchNo) {
  15440. fields = append(fields, msg.FieldBatchNo)
  15441. }
  15442. return fields
  15443. }
  15444. // FieldCleared returns a boolean indicating if a field with the given name was
  15445. // cleared in this mutation.
  15446. func (m *MsgMutation) FieldCleared(name string) bool {
  15447. _, ok := m.clearedFields[name]
  15448. return ok
  15449. }
  15450. // ClearField clears the value of the field with the given name. It returns an
  15451. // error if the field is not defined in the schema.
  15452. func (m *MsgMutation) ClearField(name string) error {
  15453. switch name {
  15454. case msg.FieldDeletedAt:
  15455. m.ClearDeletedAt()
  15456. return nil
  15457. case msg.FieldStatus:
  15458. m.ClearStatus()
  15459. return nil
  15460. case msg.FieldFromwxid:
  15461. m.ClearFromwxid()
  15462. return nil
  15463. case msg.FieldToid:
  15464. m.ClearToid()
  15465. return nil
  15466. case msg.FieldMsgtype:
  15467. m.ClearMsgtype()
  15468. return nil
  15469. case msg.FieldMsg:
  15470. m.ClearMsg()
  15471. return nil
  15472. case msg.FieldBatchNo:
  15473. m.ClearBatchNo()
  15474. return nil
  15475. }
  15476. return fmt.Errorf("unknown Msg nullable field %s", name)
  15477. }
  15478. // ResetField resets all changes in the mutation for the field with the given name.
  15479. // It returns an error if the field is not defined in the schema.
  15480. func (m *MsgMutation) ResetField(name string) error {
  15481. switch name {
  15482. case msg.FieldCreatedAt:
  15483. m.ResetCreatedAt()
  15484. return nil
  15485. case msg.FieldUpdatedAt:
  15486. m.ResetUpdatedAt()
  15487. return nil
  15488. case msg.FieldDeletedAt:
  15489. m.ResetDeletedAt()
  15490. return nil
  15491. case msg.FieldStatus:
  15492. m.ResetStatus()
  15493. return nil
  15494. case msg.FieldFromwxid:
  15495. m.ResetFromwxid()
  15496. return nil
  15497. case msg.FieldToid:
  15498. m.ResetToid()
  15499. return nil
  15500. case msg.FieldMsgtype:
  15501. m.ResetMsgtype()
  15502. return nil
  15503. case msg.FieldMsg:
  15504. m.ResetMsg()
  15505. return nil
  15506. case msg.FieldBatchNo:
  15507. m.ResetBatchNo()
  15508. return nil
  15509. }
  15510. return fmt.Errorf("unknown Msg field %s", name)
  15511. }
  15512. // AddedEdges returns all edge names that were set/added in this mutation.
  15513. func (m *MsgMutation) AddedEdges() []string {
  15514. edges := make([]string, 0, 0)
  15515. return edges
  15516. }
  15517. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15518. // name in this mutation.
  15519. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  15520. return nil
  15521. }
  15522. // RemovedEdges returns all edge names that were removed in this mutation.
  15523. func (m *MsgMutation) RemovedEdges() []string {
  15524. edges := make([]string, 0, 0)
  15525. return edges
  15526. }
  15527. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15528. // the given name in this mutation.
  15529. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  15530. return nil
  15531. }
  15532. // ClearedEdges returns all edge names that were cleared in this mutation.
  15533. func (m *MsgMutation) ClearedEdges() []string {
  15534. edges := make([]string, 0, 0)
  15535. return edges
  15536. }
  15537. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15538. // was cleared in this mutation.
  15539. func (m *MsgMutation) EdgeCleared(name string) bool {
  15540. return false
  15541. }
  15542. // ClearEdge clears the value of the edge with the given name. It returns an error
  15543. // if that edge is not defined in the schema.
  15544. func (m *MsgMutation) ClearEdge(name string) error {
  15545. return fmt.Errorf("unknown Msg unique edge %s", name)
  15546. }
  15547. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15548. // It returns an error if the edge is not defined in the schema.
  15549. func (m *MsgMutation) ResetEdge(name string) error {
  15550. return fmt.Errorf("unknown Msg edge %s", name)
  15551. }
  15552. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  15553. type ServerMutation struct {
  15554. config
  15555. op Op
  15556. typ string
  15557. id *uint64
  15558. created_at *time.Time
  15559. updated_at *time.Time
  15560. status *uint8
  15561. addstatus *int8
  15562. deleted_at *time.Time
  15563. name *string
  15564. public_ip *string
  15565. private_ip *string
  15566. admin_port *string
  15567. clearedFields map[string]struct{}
  15568. wxs map[uint64]struct{}
  15569. removedwxs map[uint64]struct{}
  15570. clearedwxs bool
  15571. done bool
  15572. oldValue func(context.Context) (*Server, error)
  15573. predicates []predicate.Server
  15574. }
  15575. var _ ent.Mutation = (*ServerMutation)(nil)
  15576. // serverOption allows management of the mutation configuration using functional options.
  15577. type serverOption func(*ServerMutation)
  15578. // newServerMutation creates new mutation for the Server entity.
  15579. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  15580. m := &ServerMutation{
  15581. config: c,
  15582. op: op,
  15583. typ: TypeServer,
  15584. clearedFields: make(map[string]struct{}),
  15585. }
  15586. for _, opt := range opts {
  15587. opt(m)
  15588. }
  15589. return m
  15590. }
  15591. // withServerID sets the ID field of the mutation.
  15592. func withServerID(id uint64) serverOption {
  15593. return func(m *ServerMutation) {
  15594. var (
  15595. err error
  15596. once sync.Once
  15597. value *Server
  15598. )
  15599. m.oldValue = func(ctx context.Context) (*Server, error) {
  15600. once.Do(func() {
  15601. if m.done {
  15602. err = errors.New("querying old values post mutation is not allowed")
  15603. } else {
  15604. value, err = m.Client().Server.Get(ctx, id)
  15605. }
  15606. })
  15607. return value, err
  15608. }
  15609. m.id = &id
  15610. }
  15611. }
  15612. // withServer sets the old Server of the mutation.
  15613. func withServer(node *Server) serverOption {
  15614. return func(m *ServerMutation) {
  15615. m.oldValue = func(context.Context) (*Server, error) {
  15616. return node, nil
  15617. }
  15618. m.id = &node.ID
  15619. }
  15620. }
  15621. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15622. // executed in a transaction (ent.Tx), a transactional client is returned.
  15623. func (m ServerMutation) Client() *Client {
  15624. client := &Client{config: m.config}
  15625. client.init()
  15626. return client
  15627. }
  15628. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15629. // it returns an error otherwise.
  15630. func (m ServerMutation) Tx() (*Tx, error) {
  15631. if _, ok := m.driver.(*txDriver); !ok {
  15632. return nil, errors.New("ent: mutation is not running in a transaction")
  15633. }
  15634. tx := &Tx{config: m.config}
  15635. tx.init()
  15636. return tx, nil
  15637. }
  15638. // SetID sets the value of the id field. Note that this
  15639. // operation is only accepted on creation of Server entities.
  15640. func (m *ServerMutation) SetID(id uint64) {
  15641. m.id = &id
  15642. }
  15643. // ID returns the ID value in the mutation. Note that the ID is only available
  15644. // if it was provided to the builder or after it was returned from the database.
  15645. func (m *ServerMutation) ID() (id uint64, exists bool) {
  15646. if m.id == nil {
  15647. return
  15648. }
  15649. return *m.id, true
  15650. }
  15651. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15652. // That means, if the mutation is applied within a transaction with an isolation level such
  15653. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15654. // or updated by the mutation.
  15655. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  15656. switch {
  15657. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15658. id, exists := m.ID()
  15659. if exists {
  15660. return []uint64{id}, nil
  15661. }
  15662. fallthrough
  15663. case m.op.Is(OpUpdate | OpDelete):
  15664. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  15665. default:
  15666. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15667. }
  15668. }
  15669. // SetCreatedAt sets the "created_at" field.
  15670. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  15671. m.created_at = &t
  15672. }
  15673. // CreatedAt returns the value of the "created_at" field in the mutation.
  15674. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  15675. v := m.created_at
  15676. if v == nil {
  15677. return
  15678. }
  15679. return *v, true
  15680. }
  15681. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  15682. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15684. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15685. if !m.op.Is(OpUpdateOne) {
  15686. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15687. }
  15688. if m.id == nil || m.oldValue == nil {
  15689. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15690. }
  15691. oldValue, err := m.oldValue(ctx)
  15692. if err != nil {
  15693. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15694. }
  15695. return oldValue.CreatedAt, nil
  15696. }
  15697. // ResetCreatedAt resets all changes to the "created_at" field.
  15698. func (m *ServerMutation) ResetCreatedAt() {
  15699. m.created_at = nil
  15700. }
  15701. // SetUpdatedAt sets the "updated_at" field.
  15702. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  15703. m.updated_at = &t
  15704. }
  15705. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15706. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  15707. v := m.updated_at
  15708. if v == nil {
  15709. return
  15710. }
  15711. return *v, true
  15712. }
  15713. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  15714. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15716. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15717. if !m.op.Is(OpUpdateOne) {
  15718. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15719. }
  15720. if m.id == nil || m.oldValue == nil {
  15721. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15722. }
  15723. oldValue, err := m.oldValue(ctx)
  15724. if err != nil {
  15725. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15726. }
  15727. return oldValue.UpdatedAt, nil
  15728. }
  15729. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15730. func (m *ServerMutation) ResetUpdatedAt() {
  15731. m.updated_at = nil
  15732. }
  15733. // SetStatus sets the "status" field.
  15734. func (m *ServerMutation) SetStatus(u uint8) {
  15735. m.status = &u
  15736. m.addstatus = nil
  15737. }
  15738. // Status returns the value of the "status" field in the mutation.
  15739. func (m *ServerMutation) Status() (r uint8, exists bool) {
  15740. v := m.status
  15741. if v == nil {
  15742. return
  15743. }
  15744. return *v, true
  15745. }
  15746. // OldStatus returns the old "status" field's value of the Server entity.
  15747. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15749. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15750. if !m.op.Is(OpUpdateOne) {
  15751. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15752. }
  15753. if m.id == nil || m.oldValue == nil {
  15754. return v, errors.New("OldStatus requires an ID field in the mutation")
  15755. }
  15756. oldValue, err := m.oldValue(ctx)
  15757. if err != nil {
  15758. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15759. }
  15760. return oldValue.Status, nil
  15761. }
  15762. // AddStatus adds u to the "status" field.
  15763. func (m *ServerMutation) AddStatus(u int8) {
  15764. if m.addstatus != nil {
  15765. *m.addstatus += u
  15766. } else {
  15767. m.addstatus = &u
  15768. }
  15769. }
  15770. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15771. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  15772. v := m.addstatus
  15773. if v == nil {
  15774. return
  15775. }
  15776. return *v, true
  15777. }
  15778. // ClearStatus clears the value of the "status" field.
  15779. func (m *ServerMutation) ClearStatus() {
  15780. m.status = nil
  15781. m.addstatus = nil
  15782. m.clearedFields[server.FieldStatus] = struct{}{}
  15783. }
  15784. // StatusCleared returns if the "status" field was cleared in this mutation.
  15785. func (m *ServerMutation) StatusCleared() bool {
  15786. _, ok := m.clearedFields[server.FieldStatus]
  15787. return ok
  15788. }
  15789. // ResetStatus resets all changes to the "status" field.
  15790. func (m *ServerMutation) ResetStatus() {
  15791. m.status = nil
  15792. m.addstatus = nil
  15793. delete(m.clearedFields, server.FieldStatus)
  15794. }
  15795. // SetDeletedAt sets the "deleted_at" field.
  15796. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  15797. m.deleted_at = &t
  15798. }
  15799. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15800. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  15801. v := m.deleted_at
  15802. if v == nil {
  15803. return
  15804. }
  15805. return *v, true
  15806. }
  15807. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  15808. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15810. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15811. if !m.op.Is(OpUpdateOne) {
  15812. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15813. }
  15814. if m.id == nil || m.oldValue == nil {
  15815. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15816. }
  15817. oldValue, err := m.oldValue(ctx)
  15818. if err != nil {
  15819. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15820. }
  15821. return oldValue.DeletedAt, nil
  15822. }
  15823. // ClearDeletedAt clears the value of the "deleted_at" field.
  15824. func (m *ServerMutation) ClearDeletedAt() {
  15825. m.deleted_at = nil
  15826. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  15827. }
  15828. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15829. func (m *ServerMutation) DeletedAtCleared() bool {
  15830. _, ok := m.clearedFields[server.FieldDeletedAt]
  15831. return ok
  15832. }
  15833. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15834. func (m *ServerMutation) ResetDeletedAt() {
  15835. m.deleted_at = nil
  15836. delete(m.clearedFields, server.FieldDeletedAt)
  15837. }
  15838. // SetName sets the "name" field.
  15839. func (m *ServerMutation) SetName(s string) {
  15840. m.name = &s
  15841. }
  15842. // Name returns the value of the "name" field in the mutation.
  15843. func (m *ServerMutation) Name() (r string, exists bool) {
  15844. v := m.name
  15845. if v == nil {
  15846. return
  15847. }
  15848. return *v, true
  15849. }
  15850. // OldName returns the old "name" field's value of the Server entity.
  15851. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15853. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  15854. if !m.op.Is(OpUpdateOne) {
  15855. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15856. }
  15857. if m.id == nil || m.oldValue == nil {
  15858. return v, errors.New("OldName requires an ID field in the mutation")
  15859. }
  15860. oldValue, err := m.oldValue(ctx)
  15861. if err != nil {
  15862. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15863. }
  15864. return oldValue.Name, nil
  15865. }
  15866. // ResetName resets all changes to the "name" field.
  15867. func (m *ServerMutation) ResetName() {
  15868. m.name = nil
  15869. }
  15870. // SetPublicIP sets the "public_ip" field.
  15871. func (m *ServerMutation) SetPublicIP(s string) {
  15872. m.public_ip = &s
  15873. }
  15874. // PublicIP returns the value of the "public_ip" field in the mutation.
  15875. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  15876. v := m.public_ip
  15877. if v == nil {
  15878. return
  15879. }
  15880. return *v, true
  15881. }
  15882. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  15883. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15885. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  15886. if !m.op.Is(OpUpdateOne) {
  15887. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  15888. }
  15889. if m.id == nil || m.oldValue == nil {
  15890. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  15891. }
  15892. oldValue, err := m.oldValue(ctx)
  15893. if err != nil {
  15894. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  15895. }
  15896. return oldValue.PublicIP, nil
  15897. }
  15898. // ResetPublicIP resets all changes to the "public_ip" field.
  15899. func (m *ServerMutation) ResetPublicIP() {
  15900. m.public_ip = nil
  15901. }
  15902. // SetPrivateIP sets the "private_ip" field.
  15903. func (m *ServerMutation) SetPrivateIP(s string) {
  15904. m.private_ip = &s
  15905. }
  15906. // PrivateIP returns the value of the "private_ip" field in the mutation.
  15907. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  15908. v := m.private_ip
  15909. if v == nil {
  15910. return
  15911. }
  15912. return *v, true
  15913. }
  15914. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  15915. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15917. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  15918. if !m.op.Is(OpUpdateOne) {
  15919. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  15920. }
  15921. if m.id == nil || m.oldValue == nil {
  15922. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  15923. }
  15924. oldValue, err := m.oldValue(ctx)
  15925. if err != nil {
  15926. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  15927. }
  15928. return oldValue.PrivateIP, nil
  15929. }
  15930. // ResetPrivateIP resets all changes to the "private_ip" field.
  15931. func (m *ServerMutation) ResetPrivateIP() {
  15932. m.private_ip = nil
  15933. }
  15934. // SetAdminPort sets the "admin_port" field.
  15935. func (m *ServerMutation) SetAdminPort(s string) {
  15936. m.admin_port = &s
  15937. }
  15938. // AdminPort returns the value of the "admin_port" field in the mutation.
  15939. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  15940. v := m.admin_port
  15941. if v == nil {
  15942. return
  15943. }
  15944. return *v, true
  15945. }
  15946. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  15947. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15949. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  15950. if !m.op.Is(OpUpdateOne) {
  15951. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  15952. }
  15953. if m.id == nil || m.oldValue == nil {
  15954. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  15955. }
  15956. oldValue, err := m.oldValue(ctx)
  15957. if err != nil {
  15958. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  15959. }
  15960. return oldValue.AdminPort, nil
  15961. }
  15962. // ResetAdminPort resets all changes to the "admin_port" field.
  15963. func (m *ServerMutation) ResetAdminPort() {
  15964. m.admin_port = nil
  15965. }
  15966. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  15967. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  15968. if m.wxs == nil {
  15969. m.wxs = make(map[uint64]struct{})
  15970. }
  15971. for i := range ids {
  15972. m.wxs[ids[i]] = struct{}{}
  15973. }
  15974. }
  15975. // ClearWxs clears the "wxs" edge to the Wx entity.
  15976. func (m *ServerMutation) ClearWxs() {
  15977. m.clearedwxs = true
  15978. }
  15979. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  15980. func (m *ServerMutation) WxsCleared() bool {
  15981. return m.clearedwxs
  15982. }
  15983. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  15984. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  15985. if m.removedwxs == nil {
  15986. m.removedwxs = make(map[uint64]struct{})
  15987. }
  15988. for i := range ids {
  15989. delete(m.wxs, ids[i])
  15990. m.removedwxs[ids[i]] = struct{}{}
  15991. }
  15992. }
  15993. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  15994. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  15995. for id := range m.removedwxs {
  15996. ids = append(ids, id)
  15997. }
  15998. return
  15999. }
  16000. // WxsIDs returns the "wxs" edge IDs in the mutation.
  16001. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  16002. for id := range m.wxs {
  16003. ids = append(ids, id)
  16004. }
  16005. return
  16006. }
  16007. // ResetWxs resets all changes to the "wxs" edge.
  16008. func (m *ServerMutation) ResetWxs() {
  16009. m.wxs = nil
  16010. m.clearedwxs = false
  16011. m.removedwxs = nil
  16012. }
  16013. // Where appends a list predicates to the ServerMutation builder.
  16014. func (m *ServerMutation) Where(ps ...predicate.Server) {
  16015. m.predicates = append(m.predicates, ps...)
  16016. }
  16017. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  16018. // users can use type-assertion to append predicates that do not depend on any generated package.
  16019. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  16020. p := make([]predicate.Server, len(ps))
  16021. for i := range ps {
  16022. p[i] = ps[i]
  16023. }
  16024. m.Where(p...)
  16025. }
  16026. // Op returns the operation name.
  16027. func (m *ServerMutation) Op() Op {
  16028. return m.op
  16029. }
  16030. // SetOp allows setting the mutation operation.
  16031. func (m *ServerMutation) SetOp(op Op) {
  16032. m.op = op
  16033. }
  16034. // Type returns the node type of this mutation (Server).
  16035. func (m *ServerMutation) Type() string {
  16036. return m.typ
  16037. }
  16038. // Fields returns all fields that were changed during this mutation. Note that in
  16039. // order to get all numeric fields that were incremented/decremented, call
  16040. // AddedFields().
  16041. func (m *ServerMutation) Fields() []string {
  16042. fields := make([]string, 0, 8)
  16043. if m.created_at != nil {
  16044. fields = append(fields, server.FieldCreatedAt)
  16045. }
  16046. if m.updated_at != nil {
  16047. fields = append(fields, server.FieldUpdatedAt)
  16048. }
  16049. if m.status != nil {
  16050. fields = append(fields, server.FieldStatus)
  16051. }
  16052. if m.deleted_at != nil {
  16053. fields = append(fields, server.FieldDeletedAt)
  16054. }
  16055. if m.name != nil {
  16056. fields = append(fields, server.FieldName)
  16057. }
  16058. if m.public_ip != nil {
  16059. fields = append(fields, server.FieldPublicIP)
  16060. }
  16061. if m.private_ip != nil {
  16062. fields = append(fields, server.FieldPrivateIP)
  16063. }
  16064. if m.admin_port != nil {
  16065. fields = append(fields, server.FieldAdminPort)
  16066. }
  16067. return fields
  16068. }
  16069. // Field returns the value of a field with the given name. The second boolean
  16070. // return value indicates that this field was not set, or was not defined in the
  16071. // schema.
  16072. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  16073. switch name {
  16074. case server.FieldCreatedAt:
  16075. return m.CreatedAt()
  16076. case server.FieldUpdatedAt:
  16077. return m.UpdatedAt()
  16078. case server.FieldStatus:
  16079. return m.Status()
  16080. case server.FieldDeletedAt:
  16081. return m.DeletedAt()
  16082. case server.FieldName:
  16083. return m.Name()
  16084. case server.FieldPublicIP:
  16085. return m.PublicIP()
  16086. case server.FieldPrivateIP:
  16087. return m.PrivateIP()
  16088. case server.FieldAdminPort:
  16089. return m.AdminPort()
  16090. }
  16091. return nil, false
  16092. }
  16093. // OldField returns the old value of the field from the database. An error is
  16094. // returned if the mutation operation is not UpdateOne, or the query to the
  16095. // database failed.
  16096. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16097. switch name {
  16098. case server.FieldCreatedAt:
  16099. return m.OldCreatedAt(ctx)
  16100. case server.FieldUpdatedAt:
  16101. return m.OldUpdatedAt(ctx)
  16102. case server.FieldStatus:
  16103. return m.OldStatus(ctx)
  16104. case server.FieldDeletedAt:
  16105. return m.OldDeletedAt(ctx)
  16106. case server.FieldName:
  16107. return m.OldName(ctx)
  16108. case server.FieldPublicIP:
  16109. return m.OldPublicIP(ctx)
  16110. case server.FieldPrivateIP:
  16111. return m.OldPrivateIP(ctx)
  16112. case server.FieldAdminPort:
  16113. return m.OldAdminPort(ctx)
  16114. }
  16115. return nil, fmt.Errorf("unknown Server field %s", name)
  16116. }
  16117. // SetField sets the value of a field with the given name. It returns an error if
  16118. // the field is not defined in the schema, or if the type mismatched the field
  16119. // type.
  16120. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  16121. switch name {
  16122. case server.FieldCreatedAt:
  16123. v, ok := value.(time.Time)
  16124. if !ok {
  16125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16126. }
  16127. m.SetCreatedAt(v)
  16128. return nil
  16129. case server.FieldUpdatedAt:
  16130. v, ok := value.(time.Time)
  16131. if !ok {
  16132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16133. }
  16134. m.SetUpdatedAt(v)
  16135. return nil
  16136. case server.FieldStatus:
  16137. v, ok := value.(uint8)
  16138. if !ok {
  16139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16140. }
  16141. m.SetStatus(v)
  16142. return nil
  16143. case server.FieldDeletedAt:
  16144. v, ok := value.(time.Time)
  16145. if !ok {
  16146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16147. }
  16148. m.SetDeletedAt(v)
  16149. return nil
  16150. case server.FieldName:
  16151. v, ok := value.(string)
  16152. if !ok {
  16153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16154. }
  16155. m.SetName(v)
  16156. return nil
  16157. case server.FieldPublicIP:
  16158. v, ok := value.(string)
  16159. if !ok {
  16160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16161. }
  16162. m.SetPublicIP(v)
  16163. return nil
  16164. case server.FieldPrivateIP:
  16165. v, ok := value.(string)
  16166. if !ok {
  16167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16168. }
  16169. m.SetPrivateIP(v)
  16170. return nil
  16171. case server.FieldAdminPort:
  16172. v, ok := value.(string)
  16173. if !ok {
  16174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16175. }
  16176. m.SetAdminPort(v)
  16177. return nil
  16178. }
  16179. return fmt.Errorf("unknown Server field %s", name)
  16180. }
  16181. // AddedFields returns all numeric fields that were incremented/decremented during
  16182. // this mutation.
  16183. func (m *ServerMutation) AddedFields() []string {
  16184. var fields []string
  16185. if m.addstatus != nil {
  16186. fields = append(fields, server.FieldStatus)
  16187. }
  16188. return fields
  16189. }
  16190. // AddedField returns the numeric value that was incremented/decremented on a field
  16191. // with the given name. The second boolean return value indicates that this field
  16192. // was not set, or was not defined in the schema.
  16193. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  16194. switch name {
  16195. case server.FieldStatus:
  16196. return m.AddedStatus()
  16197. }
  16198. return nil, false
  16199. }
  16200. // AddField adds the value to the field with the given name. It returns an error if
  16201. // the field is not defined in the schema, or if the type mismatched the field
  16202. // type.
  16203. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  16204. switch name {
  16205. case server.FieldStatus:
  16206. v, ok := value.(int8)
  16207. if !ok {
  16208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16209. }
  16210. m.AddStatus(v)
  16211. return nil
  16212. }
  16213. return fmt.Errorf("unknown Server numeric field %s", name)
  16214. }
  16215. // ClearedFields returns all nullable fields that were cleared during this
  16216. // mutation.
  16217. func (m *ServerMutation) ClearedFields() []string {
  16218. var fields []string
  16219. if m.FieldCleared(server.FieldStatus) {
  16220. fields = append(fields, server.FieldStatus)
  16221. }
  16222. if m.FieldCleared(server.FieldDeletedAt) {
  16223. fields = append(fields, server.FieldDeletedAt)
  16224. }
  16225. return fields
  16226. }
  16227. // FieldCleared returns a boolean indicating if a field with the given name was
  16228. // cleared in this mutation.
  16229. func (m *ServerMutation) FieldCleared(name string) bool {
  16230. _, ok := m.clearedFields[name]
  16231. return ok
  16232. }
  16233. // ClearField clears the value of the field with the given name. It returns an
  16234. // error if the field is not defined in the schema.
  16235. func (m *ServerMutation) ClearField(name string) error {
  16236. switch name {
  16237. case server.FieldStatus:
  16238. m.ClearStatus()
  16239. return nil
  16240. case server.FieldDeletedAt:
  16241. m.ClearDeletedAt()
  16242. return nil
  16243. }
  16244. return fmt.Errorf("unknown Server nullable field %s", name)
  16245. }
  16246. // ResetField resets all changes in the mutation for the field with the given name.
  16247. // It returns an error if the field is not defined in the schema.
  16248. func (m *ServerMutation) ResetField(name string) error {
  16249. switch name {
  16250. case server.FieldCreatedAt:
  16251. m.ResetCreatedAt()
  16252. return nil
  16253. case server.FieldUpdatedAt:
  16254. m.ResetUpdatedAt()
  16255. return nil
  16256. case server.FieldStatus:
  16257. m.ResetStatus()
  16258. return nil
  16259. case server.FieldDeletedAt:
  16260. m.ResetDeletedAt()
  16261. return nil
  16262. case server.FieldName:
  16263. m.ResetName()
  16264. return nil
  16265. case server.FieldPublicIP:
  16266. m.ResetPublicIP()
  16267. return nil
  16268. case server.FieldPrivateIP:
  16269. m.ResetPrivateIP()
  16270. return nil
  16271. case server.FieldAdminPort:
  16272. m.ResetAdminPort()
  16273. return nil
  16274. }
  16275. return fmt.Errorf("unknown Server field %s", name)
  16276. }
  16277. // AddedEdges returns all edge names that were set/added in this mutation.
  16278. func (m *ServerMutation) AddedEdges() []string {
  16279. edges := make([]string, 0, 1)
  16280. if m.wxs != nil {
  16281. edges = append(edges, server.EdgeWxs)
  16282. }
  16283. return edges
  16284. }
  16285. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16286. // name in this mutation.
  16287. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  16288. switch name {
  16289. case server.EdgeWxs:
  16290. ids := make([]ent.Value, 0, len(m.wxs))
  16291. for id := range m.wxs {
  16292. ids = append(ids, id)
  16293. }
  16294. return ids
  16295. }
  16296. return nil
  16297. }
  16298. // RemovedEdges returns all edge names that were removed in this mutation.
  16299. func (m *ServerMutation) RemovedEdges() []string {
  16300. edges := make([]string, 0, 1)
  16301. if m.removedwxs != nil {
  16302. edges = append(edges, server.EdgeWxs)
  16303. }
  16304. return edges
  16305. }
  16306. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16307. // the given name in this mutation.
  16308. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  16309. switch name {
  16310. case server.EdgeWxs:
  16311. ids := make([]ent.Value, 0, len(m.removedwxs))
  16312. for id := range m.removedwxs {
  16313. ids = append(ids, id)
  16314. }
  16315. return ids
  16316. }
  16317. return nil
  16318. }
  16319. // ClearedEdges returns all edge names that were cleared in this mutation.
  16320. func (m *ServerMutation) ClearedEdges() []string {
  16321. edges := make([]string, 0, 1)
  16322. if m.clearedwxs {
  16323. edges = append(edges, server.EdgeWxs)
  16324. }
  16325. return edges
  16326. }
  16327. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16328. // was cleared in this mutation.
  16329. func (m *ServerMutation) EdgeCleared(name string) bool {
  16330. switch name {
  16331. case server.EdgeWxs:
  16332. return m.clearedwxs
  16333. }
  16334. return false
  16335. }
  16336. // ClearEdge clears the value of the edge with the given name. It returns an error
  16337. // if that edge is not defined in the schema.
  16338. func (m *ServerMutation) ClearEdge(name string) error {
  16339. switch name {
  16340. }
  16341. return fmt.Errorf("unknown Server unique edge %s", name)
  16342. }
  16343. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16344. // It returns an error if the edge is not defined in the schema.
  16345. func (m *ServerMutation) ResetEdge(name string) error {
  16346. switch name {
  16347. case server.EdgeWxs:
  16348. m.ResetWxs()
  16349. return nil
  16350. }
  16351. return fmt.Errorf("unknown Server edge %s", name)
  16352. }
  16353. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  16354. type SopNodeMutation struct {
  16355. config
  16356. op Op
  16357. typ string
  16358. id *uint64
  16359. created_at *time.Time
  16360. updated_at *time.Time
  16361. status *uint8
  16362. addstatus *int8
  16363. deleted_at *time.Time
  16364. parent_id *uint64
  16365. addparent_id *int64
  16366. name *string
  16367. condition_type *int
  16368. addcondition_type *int
  16369. condition_list *[]string
  16370. appendcondition_list []string
  16371. no_reply_condition *uint64
  16372. addno_reply_condition *int64
  16373. no_reply_unit *string
  16374. action_message *[]custom_types.Action
  16375. appendaction_message []custom_types.Action
  16376. action_label_add *[]uint64
  16377. appendaction_label_add []uint64
  16378. action_label_del *[]uint64
  16379. appendaction_label_del []uint64
  16380. action_forward **custom_types.ActionForward
  16381. clearedFields map[string]struct{}
  16382. sop_stage *uint64
  16383. clearedsop_stage bool
  16384. node_messages map[uint64]struct{}
  16385. removednode_messages map[uint64]struct{}
  16386. clearednode_messages bool
  16387. done bool
  16388. oldValue func(context.Context) (*SopNode, error)
  16389. predicates []predicate.SopNode
  16390. }
  16391. var _ ent.Mutation = (*SopNodeMutation)(nil)
  16392. // sopnodeOption allows management of the mutation configuration using functional options.
  16393. type sopnodeOption func(*SopNodeMutation)
  16394. // newSopNodeMutation creates new mutation for the SopNode entity.
  16395. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  16396. m := &SopNodeMutation{
  16397. config: c,
  16398. op: op,
  16399. typ: TypeSopNode,
  16400. clearedFields: make(map[string]struct{}),
  16401. }
  16402. for _, opt := range opts {
  16403. opt(m)
  16404. }
  16405. return m
  16406. }
  16407. // withSopNodeID sets the ID field of the mutation.
  16408. func withSopNodeID(id uint64) sopnodeOption {
  16409. return func(m *SopNodeMutation) {
  16410. var (
  16411. err error
  16412. once sync.Once
  16413. value *SopNode
  16414. )
  16415. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  16416. once.Do(func() {
  16417. if m.done {
  16418. err = errors.New("querying old values post mutation is not allowed")
  16419. } else {
  16420. value, err = m.Client().SopNode.Get(ctx, id)
  16421. }
  16422. })
  16423. return value, err
  16424. }
  16425. m.id = &id
  16426. }
  16427. }
  16428. // withSopNode sets the old SopNode of the mutation.
  16429. func withSopNode(node *SopNode) sopnodeOption {
  16430. return func(m *SopNodeMutation) {
  16431. m.oldValue = func(context.Context) (*SopNode, error) {
  16432. return node, nil
  16433. }
  16434. m.id = &node.ID
  16435. }
  16436. }
  16437. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16438. // executed in a transaction (ent.Tx), a transactional client is returned.
  16439. func (m SopNodeMutation) Client() *Client {
  16440. client := &Client{config: m.config}
  16441. client.init()
  16442. return client
  16443. }
  16444. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16445. // it returns an error otherwise.
  16446. func (m SopNodeMutation) Tx() (*Tx, error) {
  16447. if _, ok := m.driver.(*txDriver); !ok {
  16448. return nil, errors.New("ent: mutation is not running in a transaction")
  16449. }
  16450. tx := &Tx{config: m.config}
  16451. tx.init()
  16452. return tx, nil
  16453. }
  16454. // SetID sets the value of the id field. Note that this
  16455. // operation is only accepted on creation of SopNode entities.
  16456. func (m *SopNodeMutation) SetID(id uint64) {
  16457. m.id = &id
  16458. }
  16459. // ID returns the ID value in the mutation. Note that the ID is only available
  16460. // if it was provided to the builder or after it was returned from the database.
  16461. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  16462. if m.id == nil {
  16463. return
  16464. }
  16465. return *m.id, true
  16466. }
  16467. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16468. // That means, if the mutation is applied within a transaction with an isolation level such
  16469. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16470. // or updated by the mutation.
  16471. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  16472. switch {
  16473. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16474. id, exists := m.ID()
  16475. if exists {
  16476. return []uint64{id}, nil
  16477. }
  16478. fallthrough
  16479. case m.op.Is(OpUpdate | OpDelete):
  16480. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  16481. default:
  16482. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16483. }
  16484. }
  16485. // SetCreatedAt sets the "created_at" field.
  16486. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  16487. m.created_at = &t
  16488. }
  16489. // CreatedAt returns the value of the "created_at" field in the mutation.
  16490. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  16491. v := m.created_at
  16492. if v == nil {
  16493. return
  16494. }
  16495. return *v, true
  16496. }
  16497. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  16498. // If the SopNode 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 *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16501. if !m.op.Is(OpUpdateOne) {
  16502. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16503. }
  16504. if m.id == nil || m.oldValue == nil {
  16505. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  16510. }
  16511. return oldValue.CreatedAt, nil
  16512. }
  16513. // ResetCreatedAt resets all changes to the "created_at" field.
  16514. func (m *SopNodeMutation) ResetCreatedAt() {
  16515. m.created_at = nil
  16516. }
  16517. // SetUpdatedAt sets the "updated_at" field.
  16518. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  16519. m.updated_at = &t
  16520. }
  16521. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16522. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  16523. v := m.updated_at
  16524. if v == nil {
  16525. return
  16526. }
  16527. return *v, true
  16528. }
  16529. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  16530. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16532. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16533. if !m.op.Is(OpUpdateOne) {
  16534. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16535. }
  16536. if m.id == nil || m.oldValue == nil {
  16537. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16538. }
  16539. oldValue, err := m.oldValue(ctx)
  16540. if err != nil {
  16541. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16542. }
  16543. return oldValue.UpdatedAt, nil
  16544. }
  16545. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16546. func (m *SopNodeMutation) ResetUpdatedAt() {
  16547. m.updated_at = nil
  16548. }
  16549. // SetStatus sets the "status" field.
  16550. func (m *SopNodeMutation) SetStatus(u uint8) {
  16551. m.status = &u
  16552. m.addstatus = nil
  16553. }
  16554. // Status returns the value of the "status" field in the mutation.
  16555. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  16556. v := m.status
  16557. if v == nil {
  16558. return
  16559. }
  16560. return *v, true
  16561. }
  16562. // OldStatus returns the old "status" field's value of the SopNode entity.
  16563. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16565. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16566. if !m.op.Is(OpUpdateOne) {
  16567. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16568. }
  16569. if m.id == nil || m.oldValue == nil {
  16570. return v, errors.New("OldStatus requires an ID field in the mutation")
  16571. }
  16572. oldValue, err := m.oldValue(ctx)
  16573. if err != nil {
  16574. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16575. }
  16576. return oldValue.Status, nil
  16577. }
  16578. // AddStatus adds u to the "status" field.
  16579. func (m *SopNodeMutation) AddStatus(u int8) {
  16580. if m.addstatus != nil {
  16581. *m.addstatus += u
  16582. } else {
  16583. m.addstatus = &u
  16584. }
  16585. }
  16586. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16587. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  16588. v := m.addstatus
  16589. if v == nil {
  16590. return
  16591. }
  16592. return *v, true
  16593. }
  16594. // ClearStatus clears the value of the "status" field.
  16595. func (m *SopNodeMutation) ClearStatus() {
  16596. m.status = nil
  16597. m.addstatus = nil
  16598. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  16599. }
  16600. // StatusCleared returns if the "status" field was cleared in this mutation.
  16601. func (m *SopNodeMutation) StatusCleared() bool {
  16602. _, ok := m.clearedFields[sopnode.FieldStatus]
  16603. return ok
  16604. }
  16605. // ResetStatus resets all changes to the "status" field.
  16606. func (m *SopNodeMutation) ResetStatus() {
  16607. m.status = nil
  16608. m.addstatus = nil
  16609. delete(m.clearedFields, sopnode.FieldStatus)
  16610. }
  16611. // SetDeletedAt sets the "deleted_at" field.
  16612. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  16613. m.deleted_at = &t
  16614. }
  16615. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16616. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  16617. v := m.deleted_at
  16618. if v == nil {
  16619. return
  16620. }
  16621. return *v, true
  16622. }
  16623. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  16624. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16626. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16627. if !m.op.Is(OpUpdateOne) {
  16628. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16629. }
  16630. if m.id == nil || m.oldValue == nil {
  16631. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16632. }
  16633. oldValue, err := m.oldValue(ctx)
  16634. if err != nil {
  16635. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16636. }
  16637. return oldValue.DeletedAt, nil
  16638. }
  16639. // ClearDeletedAt clears the value of the "deleted_at" field.
  16640. func (m *SopNodeMutation) ClearDeletedAt() {
  16641. m.deleted_at = nil
  16642. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  16643. }
  16644. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16645. func (m *SopNodeMutation) DeletedAtCleared() bool {
  16646. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  16647. return ok
  16648. }
  16649. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16650. func (m *SopNodeMutation) ResetDeletedAt() {
  16651. m.deleted_at = nil
  16652. delete(m.clearedFields, sopnode.FieldDeletedAt)
  16653. }
  16654. // SetStageID sets the "stage_id" field.
  16655. func (m *SopNodeMutation) SetStageID(u uint64) {
  16656. m.sop_stage = &u
  16657. }
  16658. // StageID returns the value of the "stage_id" field in the mutation.
  16659. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  16660. v := m.sop_stage
  16661. if v == nil {
  16662. return
  16663. }
  16664. return *v, true
  16665. }
  16666. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  16667. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16669. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  16670. if !m.op.Is(OpUpdateOne) {
  16671. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  16672. }
  16673. if m.id == nil || m.oldValue == nil {
  16674. return v, errors.New("OldStageID requires an ID field in the mutation")
  16675. }
  16676. oldValue, err := m.oldValue(ctx)
  16677. if err != nil {
  16678. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  16679. }
  16680. return oldValue.StageID, nil
  16681. }
  16682. // ResetStageID resets all changes to the "stage_id" field.
  16683. func (m *SopNodeMutation) ResetStageID() {
  16684. m.sop_stage = nil
  16685. }
  16686. // SetParentID sets the "parent_id" field.
  16687. func (m *SopNodeMutation) SetParentID(u uint64) {
  16688. m.parent_id = &u
  16689. m.addparent_id = nil
  16690. }
  16691. // ParentID returns the value of the "parent_id" field in the mutation.
  16692. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  16693. v := m.parent_id
  16694. if v == nil {
  16695. return
  16696. }
  16697. return *v, true
  16698. }
  16699. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  16700. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16702. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  16703. if !m.op.Is(OpUpdateOne) {
  16704. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  16705. }
  16706. if m.id == nil || m.oldValue == nil {
  16707. return v, errors.New("OldParentID requires an ID field in the mutation")
  16708. }
  16709. oldValue, err := m.oldValue(ctx)
  16710. if err != nil {
  16711. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  16712. }
  16713. return oldValue.ParentID, nil
  16714. }
  16715. // AddParentID adds u to the "parent_id" field.
  16716. func (m *SopNodeMutation) AddParentID(u int64) {
  16717. if m.addparent_id != nil {
  16718. *m.addparent_id += u
  16719. } else {
  16720. m.addparent_id = &u
  16721. }
  16722. }
  16723. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  16724. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  16725. v := m.addparent_id
  16726. if v == nil {
  16727. return
  16728. }
  16729. return *v, true
  16730. }
  16731. // ResetParentID resets all changes to the "parent_id" field.
  16732. func (m *SopNodeMutation) ResetParentID() {
  16733. m.parent_id = nil
  16734. m.addparent_id = nil
  16735. }
  16736. // SetName sets the "name" field.
  16737. func (m *SopNodeMutation) SetName(s string) {
  16738. m.name = &s
  16739. }
  16740. // Name returns the value of the "name" field in the mutation.
  16741. func (m *SopNodeMutation) Name() (r string, exists bool) {
  16742. v := m.name
  16743. if v == nil {
  16744. return
  16745. }
  16746. return *v, true
  16747. }
  16748. // OldName returns the old "name" field's value of the SopNode entity.
  16749. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16751. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  16752. if !m.op.Is(OpUpdateOne) {
  16753. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16754. }
  16755. if m.id == nil || m.oldValue == nil {
  16756. return v, errors.New("OldName requires an ID field in the mutation")
  16757. }
  16758. oldValue, err := m.oldValue(ctx)
  16759. if err != nil {
  16760. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16761. }
  16762. return oldValue.Name, nil
  16763. }
  16764. // ResetName resets all changes to the "name" field.
  16765. func (m *SopNodeMutation) ResetName() {
  16766. m.name = nil
  16767. }
  16768. // SetConditionType sets the "condition_type" field.
  16769. func (m *SopNodeMutation) SetConditionType(i int) {
  16770. m.condition_type = &i
  16771. m.addcondition_type = nil
  16772. }
  16773. // ConditionType returns the value of the "condition_type" field in the mutation.
  16774. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  16775. v := m.condition_type
  16776. if v == nil {
  16777. return
  16778. }
  16779. return *v, true
  16780. }
  16781. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  16782. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16784. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  16785. if !m.op.Is(OpUpdateOne) {
  16786. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  16787. }
  16788. if m.id == nil || m.oldValue == nil {
  16789. return v, errors.New("OldConditionType requires an ID field in the mutation")
  16790. }
  16791. oldValue, err := m.oldValue(ctx)
  16792. if err != nil {
  16793. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  16794. }
  16795. return oldValue.ConditionType, nil
  16796. }
  16797. // AddConditionType adds i to the "condition_type" field.
  16798. func (m *SopNodeMutation) AddConditionType(i int) {
  16799. if m.addcondition_type != nil {
  16800. *m.addcondition_type += i
  16801. } else {
  16802. m.addcondition_type = &i
  16803. }
  16804. }
  16805. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  16806. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  16807. v := m.addcondition_type
  16808. if v == nil {
  16809. return
  16810. }
  16811. return *v, true
  16812. }
  16813. // ResetConditionType resets all changes to the "condition_type" field.
  16814. func (m *SopNodeMutation) ResetConditionType() {
  16815. m.condition_type = nil
  16816. m.addcondition_type = nil
  16817. }
  16818. // SetConditionList sets the "condition_list" field.
  16819. func (m *SopNodeMutation) SetConditionList(s []string) {
  16820. m.condition_list = &s
  16821. m.appendcondition_list = nil
  16822. }
  16823. // ConditionList returns the value of the "condition_list" field in the mutation.
  16824. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  16825. v := m.condition_list
  16826. if v == nil {
  16827. return
  16828. }
  16829. return *v, true
  16830. }
  16831. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  16832. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16834. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  16835. if !m.op.Is(OpUpdateOne) {
  16836. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  16837. }
  16838. if m.id == nil || m.oldValue == nil {
  16839. return v, errors.New("OldConditionList requires an ID field in the mutation")
  16840. }
  16841. oldValue, err := m.oldValue(ctx)
  16842. if err != nil {
  16843. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  16844. }
  16845. return oldValue.ConditionList, nil
  16846. }
  16847. // AppendConditionList adds s to the "condition_list" field.
  16848. func (m *SopNodeMutation) AppendConditionList(s []string) {
  16849. m.appendcondition_list = append(m.appendcondition_list, s...)
  16850. }
  16851. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  16852. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  16853. if len(m.appendcondition_list) == 0 {
  16854. return nil, false
  16855. }
  16856. return m.appendcondition_list, true
  16857. }
  16858. // ClearConditionList clears the value of the "condition_list" field.
  16859. func (m *SopNodeMutation) ClearConditionList() {
  16860. m.condition_list = nil
  16861. m.appendcondition_list = nil
  16862. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  16863. }
  16864. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  16865. func (m *SopNodeMutation) ConditionListCleared() bool {
  16866. _, ok := m.clearedFields[sopnode.FieldConditionList]
  16867. return ok
  16868. }
  16869. // ResetConditionList resets all changes to the "condition_list" field.
  16870. func (m *SopNodeMutation) ResetConditionList() {
  16871. m.condition_list = nil
  16872. m.appendcondition_list = nil
  16873. delete(m.clearedFields, sopnode.FieldConditionList)
  16874. }
  16875. // SetNoReplyCondition sets the "no_reply_condition" field.
  16876. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  16877. m.no_reply_condition = &u
  16878. m.addno_reply_condition = nil
  16879. }
  16880. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  16881. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  16882. v := m.no_reply_condition
  16883. if v == nil {
  16884. return
  16885. }
  16886. return *v, true
  16887. }
  16888. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  16889. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16891. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  16892. if !m.op.Is(OpUpdateOne) {
  16893. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  16894. }
  16895. if m.id == nil || m.oldValue == nil {
  16896. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  16897. }
  16898. oldValue, err := m.oldValue(ctx)
  16899. if err != nil {
  16900. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  16901. }
  16902. return oldValue.NoReplyCondition, nil
  16903. }
  16904. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  16905. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  16906. if m.addno_reply_condition != nil {
  16907. *m.addno_reply_condition += u
  16908. } else {
  16909. m.addno_reply_condition = &u
  16910. }
  16911. }
  16912. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  16913. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  16914. v := m.addno_reply_condition
  16915. if v == nil {
  16916. return
  16917. }
  16918. return *v, true
  16919. }
  16920. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  16921. func (m *SopNodeMutation) ResetNoReplyCondition() {
  16922. m.no_reply_condition = nil
  16923. m.addno_reply_condition = nil
  16924. }
  16925. // SetNoReplyUnit sets the "no_reply_unit" field.
  16926. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  16927. m.no_reply_unit = &s
  16928. }
  16929. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  16930. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  16931. v := m.no_reply_unit
  16932. if v == nil {
  16933. return
  16934. }
  16935. return *v, true
  16936. }
  16937. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  16938. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16940. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  16941. if !m.op.Is(OpUpdateOne) {
  16942. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  16943. }
  16944. if m.id == nil || m.oldValue == nil {
  16945. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  16946. }
  16947. oldValue, err := m.oldValue(ctx)
  16948. if err != nil {
  16949. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  16950. }
  16951. return oldValue.NoReplyUnit, nil
  16952. }
  16953. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  16954. func (m *SopNodeMutation) ResetNoReplyUnit() {
  16955. m.no_reply_unit = nil
  16956. }
  16957. // SetActionMessage sets the "action_message" field.
  16958. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  16959. m.action_message = &ct
  16960. m.appendaction_message = nil
  16961. }
  16962. // ActionMessage returns the value of the "action_message" field in the mutation.
  16963. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  16964. v := m.action_message
  16965. if v == nil {
  16966. return
  16967. }
  16968. return *v, true
  16969. }
  16970. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  16971. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16973. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  16974. if !m.op.Is(OpUpdateOne) {
  16975. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  16976. }
  16977. if m.id == nil || m.oldValue == nil {
  16978. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  16979. }
  16980. oldValue, err := m.oldValue(ctx)
  16981. if err != nil {
  16982. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  16983. }
  16984. return oldValue.ActionMessage, nil
  16985. }
  16986. // AppendActionMessage adds ct to the "action_message" field.
  16987. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  16988. m.appendaction_message = append(m.appendaction_message, ct...)
  16989. }
  16990. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  16991. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  16992. if len(m.appendaction_message) == 0 {
  16993. return nil, false
  16994. }
  16995. return m.appendaction_message, true
  16996. }
  16997. // ClearActionMessage clears the value of the "action_message" field.
  16998. func (m *SopNodeMutation) ClearActionMessage() {
  16999. m.action_message = nil
  17000. m.appendaction_message = nil
  17001. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  17002. }
  17003. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  17004. func (m *SopNodeMutation) ActionMessageCleared() bool {
  17005. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  17006. return ok
  17007. }
  17008. // ResetActionMessage resets all changes to the "action_message" field.
  17009. func (m *SopNodeMutation) ResetActionMessage() {
  17010. m.action_message = nil
  17011. m.appendaction_message = nil
  17012. delete(m.clearedFields, sopnode.FieldActionMessage)
  17013. }
  17014. // SetActionLabelAdd sets the "action_label_add" field.
  17015. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  17016. m.action_label_add = &u
  17017. m.appendaction_label_add = nil
  17018. }
  17019. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17020. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17021. v := m.action_label_add
  17022. if v == nil {
  17023. return
  17024. }
  17025. return *v, true
  17026. }
  17027. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  17028. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17030. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17031. if !m.op.Is(OpUpdateOne) {
  17032. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17033. }
  17034. if m.id == nil || m.oldValue == nil {
  17035. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17036. }
  17037. oldValue, err := m.oldValue(ctx)
  17038. if err != nil {
  17039. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17040. }
  17041. return oldValue.ActionLabelAdd, nil
  17042. }
  17043. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17044. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  17045. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17046. }
  17047. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17048. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17049. if len(m.appendaction_label_add) == 0 {
  17050. return nil, false
  17051. }
  17052. return m.appendaction_label_add, true
  17053. }
  17054. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17055. func (m *SopNodeMutation) ClearActionLabelAdd() {
  17056. m.action_label_add = nil
  17057. m.appendaction_label_add = nil
  17058. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  17059. }
  17060. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17061. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  17062. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  17063. return ok
  17064. }
  17065. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17066. func (m *SopNodeMutation) ResetActionLabelAdd() {
  17067. m.action_label_add = nil
  17068. m.appendaction_label_add = nil
  17069. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  17070. }
  17071. // SetActionLabelDel sets the "action_label_del" field.
  17072. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  17073. m.action_label_del = &u
  17074. m.appendaction_label_del = nil
  17075. }
  17076. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17077. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  17078. v := m.action_label_del
  17079. if v == nil {
  17080. return
  17081. }
  17082. return *v, true
  17083. }
  17084. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  17085. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17087. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17088. if !m.op.Is(OpUpdateOne) {
  17089. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17090. }
  17091. if m.id == nil || m.oldValue == nil {
  17092. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17093. }
  17094. oldValue, err := m.oldValue(ctx)
  17095. if err != nil {
  17096. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  17097. }
  17098. return oldValue.ActionLabelDel, nil
  17099. }
  17100. // AppendActionLabelDel adds u to the "action_label_del" field.
  17101. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  17102. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  17103. }
  17104. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  17105. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  17106. if len(m.appendaction_label_del) == 0 {
  17107. return nil, false
  17108. }
  17109. return m.appendaction_label_del, true
  17110. }
  17111. // ClearActionLabelDel clears the value of the "action_label_del" field.
  17112. func (m *SopNodeMutation) ClearActionLabelDel() {
  17113. m.action_label_del = nil
  17114. m.appendaction_label_del = nil
  17115. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  17116. }
  17117. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  17118. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  17119. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  17120. return ok
  17121. }
  17122. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  17123. func (m *SopNodeMutation) ResetActionLabelDel() {
  17124. m.action_label_del = nil
  17125. m.appendaction_label_del = nil
  17126. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  17127. }
  17128. // SetActionForward sets the "action_forward" field.
  17129. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  17130. m.action_forward = &ctf
  17131. }
  17132. // ActionForward returns the value of the "action_forward" field in the mutation.
  17133. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  17134. v := m.action_forward
  17135. if v == nil {
  17136. return
  17137. }
  17138. return *v, true
  17139. }
  17140. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  17141. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17143. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  17144. if !m.op.Is(OpUpdateOne) {
  17145. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  17146. }
  17147. if m.id == nil || m.oldValue == nil {
  17148. return v, errors.New("OldActionForward requires an ID field in the mutation")
  17149. }
  17150. oldValue, err := m.oldValue(ctx)
  17151. if err != nil {
  17152. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  17153. }
  17154. return oldValue.ActionForward, nil
  17155. }
  17156. // ClearActionForward clears the value of the "action_forward" field.
  17157. func (m *SopNodeMutation) ClearActionForward() {
  17158. m.action_forward = nil
  17159. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  17160. }
  17161. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  17162. func (m *SopNodeMutation) ActionForwardCleared() bool {
  17163. _, ok := m.clearedFields[sopnode.FieldActionForward]
  17164. return ok
  17165. }
  17166. // ResetActionForward resets all changes to the "action_forward" field.
  17167. func (m *SopNodeMutation) ResetActionForward() {
  17168. m.action_forward = nil
  17169. delete(m.clearedFields, sopnode.FieldActionForward)
  17170. }
  17171. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17172. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  17173. m.sop_stage = &id
  17174. }
  17175. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17176. func (m *SopNodeMutation) ClearSopStage() {
  17177. m.clearedsop_stage = true
  17178. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  17179. }
  17180. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17181. func (m *SopNodeMutation) SopStageCleared() bool {
  17182. return m.clearedsop_stage
  17183. }
  17184. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17185. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  17186. if m.sop_stage != nil {
  17187. return *m.sop_stage, true
  17188. }
  17189. return
  17190. }
  17191. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17192. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17193. // SopStageID instead. It exists only for internal usage by the builders.
  17194. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  17195. if id := m.sop_stage; id != nil {
  17196. ids = append(ids, *id)
  17197. }
  17198. return
  17199. }
  17200. // ResetSopStage resets all changes to the "sop_stage" edge.
  17201. func (m *SopNodeMutation) ResetSopStage() {
  17202. m.sop_stage = nil
  17203. m.clearedsop_stage = false
  17204. }
  17205. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  17206. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  17207. if m.node_messages == nil {
  17208. m.node_messages = make(map[uint64]struct{})
  17209. }
  17210. for i := range ids {
  17211. m.node_messages[ids[i]] = struct{}{}
  17212. }
  17213. }
  17214. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  17215. func (m *SopNodeMutation) ClearNodeMessages() {
  17216. m.clearednode_messages = true
  17217. }
  17218. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  17219. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  17220. return m.clearednode_messages
  17221. }
  17222. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  17223. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  17224. if m.removednode_messages == nil {
  17225. m.removednode_messages = make(map[uint64]struct{})
  17226. }
  17227. for i := range ids {
  17228. delete(m.node_messages, ids[i])
  17229. m.removednode_messages[ids[i]] = struct{}{}
  17230. }
  17231. }
  17232. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  17233. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  17234. for id := range m.removednode_messages {
  17235. ids = append(ids, id)
  17236. }
  17237. return
  17238. }
  17239. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  17240. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  17241. for id := range m.node_messages {
  17242. ids = append(ids, id)
  17243. }
  17244. return
  17245. }
  17246. // ResetNodeMessages resets all changes to the "node_messages" edge.
  17247. func (m *SopNodeMutation) ResetNodeMessages() {
  17248. m.node_messages = nil
  17249. m.clearednode_messages = false
  17250. m.removednode_messages = nil
  17251. }
  17252. // Where appends a list predicates to the SopNodeMutation builder.
  17253. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  17254. m.predicates = append(m.predicates, ps...)
  17255. }
  17256. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  17257. // users can use type-assertion to append predicates that do not depend on any generated package.
  17258. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  17259. p := make([]predicate.SopNode, len(ps))
  17260. for i := range ps {
  17261. p[i] = ps[i]
  17262. }
  17263. m.Where(p...)
  17264. }
  17265. // Op returns the operation name.
  17266. func (m *SopNodeMutation) Op() Op {
  17267. return m.op
  17268. }
  17269. // SetOp allows setting the mutation operation.
  17270. func (m *SopNodeMutation) SetOp(op Op) {
  17271. m.op = op
  17272. }
  17273. // Type returns the node type of this mutation (SopNode).
  17274. func (m *SopNodeMutation) Type() string {
  17275. return m.typ
  17276. }
  17277. // Fields returns all fields that were changed during this mutation. Note that in
  17278. // order to get all numeric fields that were incremented/decremented, call
  17279. // AddedFields().
  17280. func (m *SopNodeMutation) Fields() []string {
  17281. fields := make([]string, 0, 15)
  17282. if m.created_at != nil {
  17283. fields = append(fields, sopnode.FieldCreatedAt)
  17284. }
  17285. if m.updated_at != nil {
  17286. fields = append(fields, sopnode.FieldUpdatedAt)
  17287. }
  17288. if m.status != nil {
  17289. fields = append(fields, sopnode.FieldStatus)
  17290. }
  17291. if m.deleted_at != nil {
  17292. fields = append(fields, sopnode.FieldDeletedAt)
  17293. }
  17294. if m.sop_stage != nil {
  17295. fields = append(fields, sopnode.FieldStageID)
  17296. }
  17297. if m.parent_id != nil {
  17298. fields = append(fields, sopnode.FieldParentID)
  17299. }
  17300. if m.name != nil {
  17301. fields = append(fields, sopnode.FieldName)
  17302. }
  17303. if m.condition_type != nil {
  17304. fields = append(fields, sopnode.FieldConditionType)
  17305. }
  17306. if m.condition_list != nil {
  17307. fields = append(fields, sopnode.FieldConditionList)
  17308. }
  17309. if m.no_reply_condition != nil {
  17310. fields = append(fields, sopnode.FieldNoReplyCondition)
  17311. }
  17312. if m.no_reply_unit != nil {
  17313. fields = append(fields, sopnode.FieldNoReplyUnit)
  17314. }
  17315. if m.action_message != nil {
  17316. fields = append(fields, sopnode.FieldActionMessage)
  17317. }
  17318. if m.action_label_add != nil {
  17319. fields = append(fields, sopnode.FieldActionLabelAdd)
  17320. }
  17321. if m.action_label_del != nil {
  17322. fields = append(fields, sopnode.FieldActionLabelDel)
  17323. }
  17324. if m.action_forward != nil {
  17325. fields = append(fields, sopnode.FieldActionForward)
  17326. }
  17327. return fields
  17328. }
  17329. // Field returns the value of a field with the given name. The second boolean
  17330. // return value indicates that this field was not set, or was not defined in the
  17331. // schema.
  17332. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  17333. switch name {
  17334. case sopnode.FieldCreatedAt:
  17335. return m.CreatedAt()
  17336. case sopnode.FieldUpdatedAt:
  17337. return m.UpdatedAt()
  17338. case sopnode.FieldStatus:
  17339. return m.Status()
  17340. case sopnode.FieldDeletedAt:
  17341. return m.DeletedAt()
  17342. case sopnode.FieldStageID:
  17343. return m.StageID()
  17344. case sopnode.FieldParentID:
  17345. return m.ParentID()
  17346. case sopnode.FieldName:
  17347. return m.Name()
  17348. case sopnode.FieldConditionType:
  17349. return m.ConditionType()
  17350. case sopnode.FieldConditionList:
  17351. return m.ConditionList()
  17352. case sopnode.FieldNoReplyCondition:
  17353. return m.NoReplyCondition()
  17354. case sopnode.FieldNoReplyUnit:
  17355. return m.NoReplyUnit()
  17356. case sopnode.FieldActionMessage:
  17357. return m.ActionMessage()
  17358. case sopnode.FieldActionLabelAdd:
  17359. return m.ActionLabelAdd()
  17360. case sopnode.FieldActionLabelDel:
  17361. return m.ActionLabelDel()
  17362. case sopnode.FieldActionForward:
  17363. return m.ActionForward()
  17364. }
  17365. return nil, false
  17366. }
  17367. // OldField returns the old value of the field from the database. An error is
  17368. // returned if the mutation operation is not UpdateOne, or the query to the
  17369. // database failed.
  17370. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17371. switch name {
  17372. case sopnode.FieldCreatedAt:
  17373. return m.OldCreatedAt(ctx)
  17374. case sopnode.FieldUpdatedAt:
  17375. return m.OldUpdatedAt(ctx)
  17376. case sopnode.FieldStatus:
  17377. return m.OldStatus(ctx)
  17378. case sopnode.FieldDeletedAt:
  17379. return m.OldDeletedAt(ctx)
  17380. case sopnode.FieldStageID:
  17381. return m.OldStageID(ctx)
  17382. case sopnode.FieldParentID:
  17383. return m.OldParentID(ctx)
  17384. case sopnode.FieldName:
  17385. return m.OldName(ctx)
  17386. case sopnode.FieldConditionType:
  17387. return m.OldConditionType(ctx)
  17388. case sopnode.FieldConditionList:
  17389. return m.OldConditionList(ctx)
  17390. case sopnode.FieldNoReplyCondition:
  17391. return m.OldNoReplyCondition(ctx)
  17392. case sopnode.FieldNoReplyUnit:
  17393. return m.OldNoReplyUnit(ctx)
  17394. case sopnode.FieldActionMessage:
  17395. return m.OldActionMessage(ctx)
  17396. case sopnode.FieldActionLabelAdd:
  17397. return m.OldActionLabelAdd(ctx)
  17398. case sopnode.FieldActionLabelDel:
  17399. return m.OldActionLabelDel(ctx)
  17400. case sopnode.FieldActionForward:
  17401. return m.OldActionForward(ctx)
  17402. }
  17403. return nil, fmt.Errorf("unknown SopNode field %s", name)
  17404. }
  17405. // SetField sets the value of a field with the given name. It returns an error if
  17406. // the field is not defined in the schema, or if the type mismatched the field
  17407. // type.
  17408. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  17409. switch name {
  17410. case sopnode.FieldCreatedAt:
  17411. v, ok := value.(time.Time)
  17412. if !ok {
  17413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17414. }
  17415. m.SetCreatedAt(v)
  17416. return nil
  17417. case sopnode.FieldUpdatedAt:
  17418. v, ok := value.(time.Time)
  17419. if !ok {
  17420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17421. }
  17422. m.SetUpdatedAt(v)
  17423. return nil
  17424. case sopnode.FieldStatus:
  17425. v, ok := value.(uint8)
  17426. if !ok {
  17427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17428. }
  17429. m.SetStatus(v)
  17430. return nil
  17431. case sopnode.FieldDeletedAt:
  17432. v, ok := value.(time.Time)
  17433. if !ok {
  17434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17435. }
  17436. m.SetDeletedAt(v)
  17437. return nil
  17438. case sopnode.FieldStageID:
  17439. v, ok := value.(uint64)
  17440. if !ok {
  17441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17442. }
  17443. m.SetStageID(v)
  17444. return nil
  17445. case sopnode.FieldParentID:
  17446. v, ok := value.(uint64)
  17447. if !ok {
  17448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17449. }
  17450. m.SetParentID(v)
  17451. return nil
  17452. case sopnode.FieldName:
  17453. v, ok := value.(string)
  17454. if !ok {
  17455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17456. }
  17457. m.SetName(v)
  17458. return nil
  17459. case sopnode.FieldConditionType:
  17460. v, ok := value.(int)
  17461. if !ok {
  17462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17463. }
  17464. m.SetConditionType(v)
  17465. return nil
  17466. case sopnode.FieldConditionList:
  17467. v, ok := value.([]string)
  17468. if !ok {
  17469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17470. }
  17471. m.SetConditionList(v)
  17472. return nil
  17473. case sopnode.FieldNoReplyCondition:
  17474. v, ok := value.(uint64)
  17475. if !ok {
  17476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17477. }
  17478. m.SetNoReplyCondition(v)
  17479. return nil
  17480. case sopnode.FieldNoReplyUnit:
  17481. v, ok := value.(string)
  17482. if !ok {
  17483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17484. }
  17485. m.SetNoReplyUnit(v)
  17486. return nil
  17487. case sopnode.FieldActionMessage:
  17488. v, ok := value.([]custom_types.Action)
  17489. if !ok {
  17490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17491. }
  17492. m.SetActionMessage(v)
  17493. return nil
  17494. case sopnode.FieldActionLabelAdd:
  17495. v, ok := value.([]uint64)
  17496. if !ok {
  17497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17498. }
  17499. m.SetActionLabelAdd(v)
  17500. return nil
  17501. case sopnode.FieldActionLabelDel:
  17502. v, ok := value.([]uint64)
  17503. if !ok {
  17504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17505. }
  17506. m.SetActionLabelDel(v)
  17507. return nil
  17508. case sopnode.FieldActionForward:
  17509. v, ok := value.(*custom_types.ActionForward)
  17510. if !ok {
  17511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17512. }
  17513. m.SetActionForward(v)
  17514. return nil
  17515. }
  17516. return fmt.Errorf("unknown SopNode field %s", name)
  17517. }
  17518. // AddedFields returns all numeric fields that were incremented/decremented during
  17519. // this mutation.
  17520. func (m *SopNodeMutation) AddedFields() []string {
  17521. var fields []string
  17522. if m.addstatus != nil {
  17523. fields = append(fields, sopnode.FieldStatus)
  17524. }
  17525. if m.addparent_id != nil {
  17526. fields = append(fields, sopnode.FieldParentID)
  17527. }
  17528. if m.addcondition_type != nil {
  17529. fields = append(fields, sopnode.FieldConditionType)
  17530. }
  17531. if m.addno_reply_condition != nil {
  17532. fields = append(fields, sopnode.FieldNoReplyCondition)
  17533. }
  17534. return fields
  17535. }
  17536. // AddedField returns the numeric value that was incremented/decremented on a field
  17537. // with the given name. The second boolean return value indicates that this field
  17538. // was not set, or was not defined in the schema.
  17539. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  17540. switch name {
  17541. case sopnode.FieldStatus:
  17542. return m.AddedStatus()
  17543. case sopnode.FieldParentID:
  17544. return m.AddedParentID()
  17545. case sopnode.FieldConditionType:
  17546. return m.AddedConditionType()
  17547. case sopnode.FieldNoReplyCondition:
  17548. return m.AddedNoReplyCondition()
  17549. }
  17550. return nil, false
  17551. }
  17552. // AddField adds the value to the field with the given name. It returns an error if
  17553. // the field is not defined in the schema, or if the type mismatched the field
  17554. // type.
  17555. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  17556. switch name {
  17557. case sopnode.FieldStatus:
  17558. v, ok := value.(int8)
  17559. if !ok {
  17560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17561. }
  17562. m.AddStatus(v)
  17563. return nil
  17564. case sopnode.FieldParentID:
  17565. v, ok := value.(int64)
  17566. if !ok {
  17567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17568. }
  17569. m.AddParentID(v)
  17570. return nil
  17571. case sopnode.FieldConditionType:
  17572. v, ok := value.(int)
  17573. if !ok {
  17574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17575. }
  17576. m.AddConditionType(v)
  17577. return nil
  17578. case sopnode.FieldNoReplyCondition:
  17579. v, ok := value.(int64)
  17580. if !ok {
  17581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17582. }
  17583. m.AddNoReplyCondition(v)
  17584. return nil
  17585. }
  17586. return fmt.Errorf("unknown SopNode numeric field %s", name)
  17587. }
  17588. // ClearedFields returns all nullable fields that were cleared during this
  17589. // mutation.
  17590. func (m *SopNodeMutation) ClearedFields() []string {
  17591. var fields []string
  17592. if m.FieldCleared(sopnode.FieldStatus) {
  17593. fields = append(fields, sopnode.FieldStatus)
  17594. }
  17595. if m.FieldCleared(sopnode.FieldDeletedAt) {
  17596. fields = append(fields, sopnode.FieldDeletedAt)
  17597. }
  17598. if m.FieldCleared(sopnode.FieldConditionList) {
  17599. fields = append(fields, sopnode.FieldConditionList)
  17600. }
  17601. if m.FieldCleared(sopnode.FieldActionMessage) {
  17602. fields = append(fields, sopnode.FieldActionMessage)
  17603. }
  17604. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  17605. fields = append(fields, sopnode.FieldActionLabelAdd)
  17606. }
  17607. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  17608. fields = append(fields, sopnode.FieldActionLabelDel)
  17609. }
  17610. if m.FieldCleared(sopnode.FieldActionForward) {
  17611. fields = append(fields, sopnode.FieldActionForward)
  17612. }
  17613. return fields
  17614. }
  17615. // FieldCleared returns a boolean indicating if a field with the given name was
  17616. // cleared in this mutation.
  17617. func (m *SopNodeMutation) FieldCleared(name string) bool {
  17618. _, ok := m.clearedFields[name]
  17619. return ok
  17620. }
  17621. // ClearField clears the value of the field with the given name. It returns an
  17622. // error if the field is not defined in the schema.
  17623. func (m *SopNodeMutation) ClearField(name string) error {
  17624. switch name {
  17625. case sopnode.FieldStatus:
  17626. m.ClearStatus()
  17627. return nil
  17628. case sopnode.FieldDeletedAt:
  17629. m.ClearDeletedAt()
  17630. return nil
  17631. case sopnode.FieldConditionList:
  17632. m.ClearConditionList()
  17633. return nil
  17634. case sopnode.FieldActionMessage:
  17635. m.ClearActionMessage()
  17636. return nil
  17637. case sopnode.FieldActionLabelAdd:
  17638. m.ClearActionLabelAdd()
  17639. return nil
  17640. case sopnode.FieldActionLabelDel:
  17641. m.ClearActionLabelDel()
  17642. return nil
  17643. case sopnode.FieldActionForward:
  17644. m.ClearActionForward()
  17645. return nil
  17646. }
  17647. return fmt.Errorf("unknown SopNode nullable field %s", name)
  17648. }
  17649. // ResetField resets all changes in the mutation for the field with the given name.
  17650. // It returns an error if the field is not defined in the schema.
  17651. func (m *SopNodeMutation) ResetField(name string) error {
  17652. switch name {
  17653. case sopnode.FieldCreatedAt:
  17654. m.ResetCreatedAt()
  17655. return nil
  17656. case sopnode.FieldUpdatedAt:
  17657. m.ResetUpdatedAt()
  17658. return nil
  17659. case sopnode.FieldStatus:
  17660. m.ResetStatus()
  17661. return nil
  17662. case sopnode.FieldDeletedAt:
  17663. m.ResetDeletedAt()
  17664. return nil
  17665. case sopnode.FieldStageID:
  17666. m.ResetStageID()
  17667. return nil
  17668. case sopnode.FieldParentID:
  17669. m.ResetParentID()
  17670. return nil
  17671. case sopnode.FieldName:
  17672. m.ResetName()
  17673. return nil
  17674. case sopnode.FieldConditionType:
  17675. m.ResetConditionType()
  17676. return nil
  17677. case sopnode.FieldConditionList:
  17678. m.ResetConditionList()
  17679. return nil
  17680. case sopnode.FieldNoReplyCondition:
  17681. m.ResetNoReplyCondition()
  17682. return nil
  17683. case sopnode.FieldNoReplyUnit:
  17684. m.ResetNoReplyUnit()
  17685. return nil
  17686. case sopnode.FieldActionMessage:
  17687. m.ResetActionMessage()
  17688. return nil
  17689. case sopnode.FieldActionLabelAdd:
  17690. m.ResetActionLabelAdd()
  17691. return nil
  17692. case sopnode.FieldActionLabelDel:
  17693. m.ResetActionLabelDel()
  17694. return nil
  17695. case sopnode.FieldActionForward:
  17696. m.ResetActionForward()
  17697. return nil
  17698. }
  17699. return fmt.Errorf("unknown SopNode field %s", name)
  17700. }
  17701. // AddedEdges returns all edge names that were set/added in this mutation.
  17702. func (m *SopNodeMutation) AddedEdges() []string {
  17703. edges := make([]string, 0, 2)
  17704. if m.sop_stage != nil {
  17705. edges = append(edges, sopnode.EdgeSopStage)
  17706. }
  17707. if m.node_messages != nil {
  17708. edges = append(edges, sopnode.EdgeNodeMessages)
  17709. }
  17710. return edges
  17711. }
  17712. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17713. // name in this mutation.
  17714. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  17715. switch name {
  17716. case sopnode.EdgeSopStage:
  17717. if id := m.sop_stage; id != nil {
  17718. return []ent.Value{*id}
  17719. }
  17720. case sopnode.EdgeNodeMessages:
  17721. ids := make([]ent.Value, 0, len(m.node_messages))
  17722. for id := range m.node_messages {
  17723. ids = append(ids, id)
  17724. }
  17725. return ids
  17726. }
  17727. return nil
  17728. }
  17729. // RemovedEdges returns all edge names that were removed in this mutation.
  17730. func (m *SopNodeMutation) RemovedEdges() []string {
  17731. edges := make([]string, 0, 2)
  17732. if m.removednode_messages != nil {
  17733. edges = append(edges, sopnode.EdgeNodeMessages)
  17734. }
  17735. return edges
  17736. }
  17737. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17738. // the given name in this mutation.
  17739. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  17740. switch name {
  17741. case sopnode.EdgeNodeMessages:
  17742. ids := make([]ent.Value, 0, len(m.removednode_messages))
  17743. for id := range m.removednode_messages {
  17744. ids = append(ids, id)
  17745. }
  17746. return ids
  17747. }
  17748. return nil
  17749. }
  17750. // ClearedEdges returns all edge names that were cleared in this mutation.
  17751. func (m *SopNodeMutation) ClearedEdges() []string {
  17752. edges := make([]string, 0, 2)
  17753. if m.clearedsop_stage {
  17754. edges = append(edges, sopnode.EdgeSopStage)
  17755. }
  17756. if m.clearednode_messages {
  17757. edges = append(edges, sopnode.EdgeNodeMessages)
  17758. }
  17759. return edges
  17760. }
  17761. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17762. // was cleared in this mutation.
  17763. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  17764. switch name {
  17765. case sopnode.EdgeSopStage:
  17766. return m.clearedsop_stage
  17767. case sopnode.EdgeNodeMessages:
  17768. return m.clearednode_messages
  17769. }
  17770. return false
  17771. }
  17772. // ClearEdge clears the value of the edge with the given name. It returns an error
  17773. // if that edge is not defined in the schema.
  17774. func (m *SopNodeMutation) ClearEdge(name string) error {
  17775. switch name {
  17776. case sopnode.EdgeSopStage:
  17777. m.ClearSopStage()
  17778. return nil
  17779. }
  17780. return fmt.Errorf("unknown SopNode unique edge %s", name)
  17781. }
  17782. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17783. // It returns an error if the edge is not defined in the schema.
  17784. func (m *SopNodeMutation) ResetEdge(name string) error {
  17785. switch name {
  17786. case sopnode.EdgeSopStage:
  17787. m.ResetSopStage()
  17788. return nil
  17789. case sopnode.EdgeNodeMessages:
  17790. m.ResetNodeMessages()
  17791. return nil
  17792. }
  17793. return fmt.Errorf("unknown SopNode edge %s", name)
  17794. }
  17795. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  17796. type SopStageMutation struct {
  17797. config
  17798. op Op
  17799. typ string
  17800. id *uint64
  17801. created_at *time.Time
  17802. updated_at *time.Time
  17803. status *uint8
  17804. addstatus *int8
  17805. deleted_at *time.Time
  17806. name *string
  17807. condition_type *int
  17808. addcondition_type *int
  17809. condition_operator *int
  17810. addcondition_operator *int
  17811. condition_list *[]custom_types.Condition
  17812. appendcondition_list []custom_types.Condition
  17813. action_message *[]custom_types.Action
  17814. appendaction_message []custom_types.Action
  17815. action_label_add *[]uint64
  17816. appendaction_label_add []uint64
  17817. action_label_del *[]uint64
  17818. appendaction_label_del []uint64
  17819. action_forward **custom_types.ActionForward
  17820. index_sort *int
  17821. addindex_sort *int
  17822. clearedFields map[string]struct{}
  17823. sop_task *uint64
  17824. clearedsop_task bool
  17825. stage_nodes map[uint64]struct{}
  17826. removedstage_nodes map[uint64]struct{}
  17827. clearedstage_nodes bool
  17828. stage_messages map[uint64]struct{}
  17829. removedstage_messages map[uint64]struct{}
  17830. clearedstage_messages bool
  17831. done bool
  17832. oldValue func(context.Context) (*SopStage, error)
  17833. predicates []predicate.SopStage
  17834. }
  17835. var _ ent.Mutation = (*SopStageMutation)(nil)
  17836. // sopstageOption allows management of the mutation configuration using functional options.
  17837. type sopstageOption func(*SopStageMutation)
  17838. // newSopStageMutation creates new mutation for the SopStage entity.
  17839. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  17840. m := &SopStageMutation{
  17841. config: c,
  17842. op: op,
  17843. typ: TypeSopStage,
  17844. clearedFields: make(map[string]struct{}),
  17845. }
  17846. for _, opt := range opts {
  17847. opt(m)
  17848. }
  17849. return m
  17850. }
  17851. // withSopStageID sets the ID field of the mutation.
  17852. func withSopStageID(id uint64) sopstageOption {
  17853. return func(m *SopStageMutation) {
  17854. var (
  17855. err error
  17856. once sync.Once
  17857. value *SopStage
  17858. )
  17859. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  17860. once.Do(func() {
  17861. if m.done {
  17862. err = errors.New("querying old values post mutation is not allowed")
  17863. } else {
  17864. value, err = m.Client().SopStage.Get(ctx, id)
  17865. }
  17866. })
  17867. return value, err
  17868. }
  17869. m.id = &id
  17870. }
  17871. }
  17872. // withSopStage sets the old SopStage of the mutation.
  17873. func withSopStage(node *SopStage) sopstageOption {
  17874. return func(m *SopStageMutation) {
  17875. m.oldValue = func(context.Context) (*SopStage, error) {
  17876. return node, nil
  17877. }
  17878. m.id = &node.ID
  17879. }
  17880. }
  17881. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17882. // executed in a transaction (ent.Tx), a transactional client is returned.
  17883. func (m SopStageMutation) Client() *Client {
  17884. client := &Client{config: m.config}
  17885. client.init()
  17886. return client
  17887. }
  17888. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17889. // it returns an error otherwise.
  17890. func (m SopStageMutation) Tx() (*Tx, error) {
  17891. if _, ok := m.driver.(*txDriver); !ok {
  17892. return nil, errors.New("ent: mutation is not running in a transaction")
  17893. }
  17894. tx := &Tx{config: m.config}
  17895. tx.init()
  17896. return tx, nil
  17897. }
  17898. // SetID sets the value of the id field. Note that this
  17899. // operation is only accepted on creation of SopStage entities.
  17900. func (m *SopStageMutation) SetID(id uint64) {
  17901. m.id = &id
  17902. }
  17903. // ID returns the ID value in the mutation. Note that the ID is only available
  17904. // if it was provided to the builder or after it was returned from the database.
  17905. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  17906. if m.id == nil {
  17907. return
  17908. }
  17909. return *m.id, true
  17910. }
  17911. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17912. // That means, if the mutation is applied within a transaction with an isolation level such
  17913. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17914. // or updated by the mutation.
  17915. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  17916. switch {
  17917. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17918. id, exists := m.ID()
  17919. if exists {
  17920. return []uint64{id}, nil
  17921. }
  17922. fallthrough
  17923. case m.op.Is(OpUpdate | OpDelete):
  17924. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  17925. default:
  17926. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17927. }
  17928. }
  17929. // SetCreatedAt sets the "created_at" field.
  17930. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  17931. m.created_at = &t
  17932. }
  17933. // CreatedAt returns the value of the "created_at" field in the mutation.
  17934. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  17935. v := m.created_at
  17936. if v == nil {
  17937. return
  17938. }
  17939. return *v, true
  17940. }
  17941. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  17942. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17944. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17945. if !m.op.Is(OpUpdateOne) {
  17946. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17947. }
  17948. if m.id == nil || m.oldValue == nil {
  17949. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17950. }
  17951. oldValue, err := m.oldValue(ctx)
  17952. if err != nil {
  17953. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17954. }
  17955. return oldValue.CreatedAt, nil
  17956. }
  17957. // ResetCreatedAt resets all changes to the "created_at" field.
  17958. func (m *SopStageMutation) ResetCreatedAt() {
  17959. m.created_at = nil
  17960. }
  17961. // SetUpdatedAt sets the "updated_at" field.
  17962. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  17963. m.updated_at = &t
  17964. }
  17965. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17966. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  17967. v := m.updated_at
  17968. if v == nil {
  17969. return
  17970. }
  17971. return *v, true
  17972. }
  17973. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  17974. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17976. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17977. if !m.op.Is(OpUpdateOne) {
  17978. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17979. }
  17980. if m.id == nil || m.oldValue == nil {
  17981. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17982. }
  17983. oldValue, err := m.oldValue(ctx)
  17984. if err != nil {
  17985. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17986. }
  17987. return oldValue.UpdatedAt, nil
  17988. }
  17989. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17990. func (m *SopStageMutation) ResetUpdatedAt() {
  17991. m.updated_at = nil
  17992. }
  17993. // SetStatus sets the "status" field.
  17994. func (m *SopStageMutation) SetStatus(u uint8) {
  17995. m.status = &u
  17996. m.addstatus = nil
  17997. }
  17998. // Status returns the value of the "status" field in the mutation.
  17999. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  18000. v := m.status
  18001. if v == nil {
  18002. return
  18003. }
  18004. return *v, true
  18005. }
  18006. // OldStatus returns the old "status" field's value of the SopStage entity.
  18007. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18009. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18010. if !m.op.Is(OpUpdateOne) {
  18011. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18012. }
  18013. if m.id == nil || m.oldValue == nil {
  18014. return v, errors.New("OldStatus requires an ID field in the mutation")
  18015. }
  18016. oldValue, err := m.oldValue(ctx)
  18017. if err != nil {
  18018. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18019. }
  18020. return oldValue.Status, nil
  18021. }
  18022. // AddStatus adds u to the "status" field.
  18023. func (m *SopStageMutation) AddStatus(u int8) {
  18024. if m.addstatus != nil {
  18025. *m.addstatus += u
  18026. } else {
  18027. m.addstatus = &u
  18028. }
  18029. }
  18030. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18031. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  18032. v := m.addstatus
  18033. if v == nil {
  18034. return
  18035. }
  18036. return *v, true
  18037. }
  18038. // ClearStatus clears the value of the "status" field.
  18039. func (m *SopStageMutation) ClearStatus() {
  18040. m.status = nil
  18041. m.addstatus = nil
  18042. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  18043. }
  18044. // StatusCleared returns if the "status" field was cleared in this mutation.
  18045. func (m *SopStageMutation) StatusCleared() bool {
  18046. _, ok := m.clearedFields[sopstage.FieldStatus]
  18047. return ok
  18048. }
  18049. // ResetStatus resets all changes to the "status" field.
  18050. func (m *SopStageMutation) ResetStatus() {
  18051. m.status = nil
  18052. m.addstatus = nil
  18053. delete(m.clearedFields, sopstage.FieldStatus)
  18054. }
  18055. // SetDeletedAt sets the "deleted_at" field.
  18056. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  18057. m.deleted_at = &t
  18058. }
  18059. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18060. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  18061. v := m.deleted_at
  18062. if v == nil {
  18063. return
  18064. }
  18065. return *v, true
  18066. }
  18067. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  18068. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18070. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18071. if !m.op.Is(OpUpdateOne) {
  18072. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18073. }
  18074. if m.id == nil || m.oldValue == nil {
  18075. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18076. }
  18077. oldValue, err := m.oldValue(ctx)
  18078. if err != nil {
  18079. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18080. }
  18081. return oldValue.DeletedAt, nil
  18082. }
  18083. // ClearDeletedAt clears the value of the "deleted_at" field.
  18084. func (m *SopStageMutation) ClearDeletedAt() {
  18085. m.deleted_at = nil
  18086. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  18087. }
  18088. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18089. func (m *SopStageMutation) DeletedAtCleared() bool {
  18090. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  18091. return ok
  18092. }
  18093. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18094. func (m *SopStageMutation) ResetDeletedAt() {
  18095. m.deleted_at = nil
  18096. delete(m.clearedFields, sopstage.FieldDeletedAt)
  18097. }
  18098. // SetTaskID sets the "task_id" field.
  18099. func (m *SopStageMutation) SetTaskID(u uint64) {
  18100. m.sop_task = &u
  18101. }
  18102. // TaskID returns the value of the "task_id" field in the mutation.
  18103. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  18104. v := m.sop_task
  18105. if v == nil {
  18106. return
  18107. }
  18108. return *v, true
  18109. }
  18110. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  18111. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18113. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  18114. if !m.op.Is(OpUpdateOne) {
  18115. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  18116. }
  18117. if m.id == nil || m.oldValue == nil {
  18118. return v, errors.New("OldTaskID requires an ID field in the mutation")
  18119. }
  18120. oldValue, err := m.oldValue(ctx)
  18121. if err != nil {
  18122. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  18123. }
  18124. return oldValue.TaskID, nil
  18125. }
  18126. // ResetTaskID resets all changes to the "task_id" field.
  18127. func (m *SopStageMutation) ResetTaskID() {
  18128. m.sop_task = nil
  18129. }
  18130. // SetName sets the "name" field.
  18131. func (m *SopStageMutation) SetName(s string) {
  18132. m.name = &s
  18133. }
  18134. // Name returns the value of the "name" field in the mutation.
  18135. func (m *SopStageMutation) Name() (r string, exists bool) {
  18136. v := m.name
  18137. if v == nil {
  18138. return
  18139. }
  18140. return *v, true
  18141. }
  18142. // OldName returns the old "name" field's value of the SopStage entity.
  18143. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18145. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  18146. if !m.op.Is(OpUpdateOne) {
  18147. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18148. }
  18149. if m.id == nil || m.oldValue == nil {
  18150. return v, errors.New("OldName requires an ID field in the mutation")
  18151. }
  18152. oldValue, err := m.oldValue(ctx)
  18153. if err != nil {
  18154. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18155. }
  18156. return oldValue.Name, nil
  18157. }
  18158. // ResetName resets all changes to the "name" field.
  18159. func (m *SopStageMutation) ResetName() {
  18160. m.name = nil
  18161. }
  18162. // SetConditionType sets the "condition_type" field.
  18163. func (m *SopStageMutation) SetConditionType(i int) {
  18164. m.condition_type = &i
  18165. m.addcondition_type = nil
  18166. }
  18167. // ConditionType returns the value of the "condition_type" field in the mutation.
  18168. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  18169. v := m.condition_type
  18170. if v == nil {
  18171. return
  18172. }
  18173. return *v, true
  18174. }
  18175. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  18176. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18178. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  18179. if !m.op.Is(OpUpdateOne) {
  18180. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  18181. }
  18182. if m.id == nil || m.oldValue == nil {
  18183. return v, errors.New("OldConditionType requires an ID field in the mutation")
  18184. }
  18185. oldValue, err := m.oldValue(ctx)
  18186. if err != nil {
  18187. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  18188. }
  18189. return oldValue.ConditionType, nil
  18190. }
  18191. // AddConditionType adds i to the "condition_type" field.
  18192. func (m *SopStageMutation) AddConditionType(i int) {
  18193. if m.addcondition_type != nil {
  18194. *m.addcondition_type += i
  18195. } else {
  18196. m.addcondition_type = &i
  18197. }
  18198. }
  18199. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  18200. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  18201. v := m.addcondition_type
  18202. if v == nil {
  18203. return
  18204. }
  18205. return *v, true
  18206. }
  18207. // ResetConditionType resets all changes to the "condition_type" field.
  18208. func (m *SopStageMutation) ResetConditionType() {
  18209. m.condition_type = nil
  18210. m.addcondition_type = nil
  18211. }
  18212. // SetConditionOperator sets the "condition_operator" field.
  18213. func (m *SopStageMutation) SetConditionOperator(i int) {
  18214. m.condition_operator = &i
  18215. m.addcondition_operator = nil
  18216. }
  18217. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  18218. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  18219. v := m.condition_operator
  18220. if v == nil {
  18221. return
  18222. }
  18223. return *v, true
  18224. }
  18225. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  18226. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18228. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  18229. if !m.op.Is(OpUpdateOne) {
  18230. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  18231. }
  18232. if m.id == nil || m.oldValue == nil {
  18233. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  18234. }
  18235. oldValue, err := m.oldValue(ctx)
  18236. if err != nil {
  18237. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  18238. }
  18239. return oldValue.ConditionOperator, nil
  18240. }
  18241. // AddConditionOperator adds i to the "condition_operator" field.
  18242. func (m *SopStageMutation) AddConditionOperator(i int) {
  18243. if m.addcondition_operator != nil {
  18244. *m.addcondition_operator += i
  18245. } else {
  18246. m.addcondition_operator = &i
  18247. }
  18248. }
  18249. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  18250. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  18251. v := m.addcondition_operator
  18252. if v == nil {
  18253. return
  18254. }
  18255. return *v, true
  18256. }
  18257. // ResetConditionOperator resets all changes to the "condition_operator" field.
  18258. func (m *SopStageMutation) ResetConditionOperator() {
  18259. m.condition_operator = nil
  18260. m.addcondition_operator = nil
  18261. }
  18262. // SetConditionList sets the "condition_list" field.
  18263. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  18264. m.condition_list = &ct
  18265. m.appendcondition_list = nil
  18266. }
  18267. // ConditionList returns the value of the "condition_list" field in the mutation.
  18268. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  18269. v := m.condition_list
  18270. if v == nil {
  18271. return
  18272. }
  18273. return *v, true
  18274. }
  18275. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  18276. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18278. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  18279. if !m.op.Is(OpUpdateOne) {
  18280. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  18281. }
  18282. if m.id == nil || m.oldValue == nil {
  18283. return v, errors.New("OldConditionList requires an ID field in the mutation")
  18284. }
  18285. oldValue, err := m.oldValue(ctx)
  18286. if err != nil {
  18287. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  18288. }
  18289. return oldValue.ConditionList, nil
  18290. }
  18291. // AppendConditionList adds ct to the "condition_list" field.
  18292. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  18293. m.appendcondition_list = append(m.appendcondition_list, ct...)
  18294. }
  18295. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  18296. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  18297. if len(m.appendcondition_list) == 0 {
  18298. return nil, false
  18299. }
  18300. return m.appendcondition_list, true
  18301. }
  18302. // ResetConditionList resets all changes to the "condition_list" field.
  18303. func (m *SopStageMutation) ResetConditionList() {
  18304. m.condition_list = nil
  18305. m.appendcondition_list = nil
  18306. }
  18307. // SetActionMessage sets the "action_message" field.
  18308. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  18309. m.action_message = &ct
  18310. m.appendaction_message = nil
  18311. }
  18312. // ActionMessage returns the value of the "action_message" field in the mutation.
  18313. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  18314. v := m.action_message
  18315. if v == nil {
  18316. return
  18317. }
  18318. return *v, true
  18319. }
  18320. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  18321. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18323. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  18324. if !m.op.Is(OpUpdateOne) {
  18325. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  18326. }
  18327. if m.id == nil || m.oldValue == nil {
  18328. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  18329. }
  18330. oldValue, err := m.oldValue(ctx)
  18331. if err != nil {
  18332. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  18333. }
  18334. return oldValue.ActionMessage, nil
  18335. }
  18336. // AppendActionMessage adds ct to the "action_message" field.
  18337. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  18338. m.appendaction_message = append(m.appendaction_message, ct...)
  18339. }
  18340. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  18341. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  18342. if len(m.appendaction_message) == 0 {
  18343. return nil, false
  18344. }
  18345. return m.appendaction_message, true
  18346. }
  18347. // ClearActionMessage clears the value of the "action_message" field.
  18348. func (m *SopStageMutation) ClearActionMessage() {
  18349. m.action_message = nil
  18350. m.appendaction_message = nil
  18351. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  18352. }
  18353. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  18354. func (m *SopStageMutation) ActionMessageCleared() bool {
  18355. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  18356. return ok
  18357. }
  18358. // ResetActionMessage resets all changes to the "action_message" field.
  18359. func (m *SopStageMutation) ResetActionMessage() {
  18360. m.action_message = nil
  18361. m.appendaction_message = nil
  18362. delete(m.clearedFields, sopstage.FieldActionMessage)
  18363. }
  18364. // SetActionLabelAdd sets the "action_label_add" field.
  18365. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  18366. m.action_label_add = &u
  18367. m.appendaction_label_add = nil
  18368. }
  18369. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  18370. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  18371. v := m.action_label_add
  18372. if v == nil {
  18373. return
  18374. }
  18375. return *v, true
  18376. }
  18377. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  18378. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18380. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  18381. if !m.op.Is(OpUpdateOne) {
  18382. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  18383. }
  18384. if m.id == nil || m.oldValue == nil {
  18385. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  18386. }
  18387. oldValue, err := m.oldValue(ctx)
  18388. if err != nil {
  18389. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  18390. }
  18391. return oldValue.ActionLabelAdd, nil
  18392. }
  18393. // AppendActionLabelAdd adds u to the "action_label_add" field.
  18394. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  18395. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  18396. }
  18397. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  18398. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  18399. if len(m.appendaction_label_add) == 0 {
  18400. return nil, false
  18401. }
  18402. return m.appendaction_label_add, true
  18403. }
  18404. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18405. func (m *SopStageMutation) ClearActionLabelAdd() {
  18406. m.action_label_add = nil
  18407. m.appendaction_label_add = nil
  18408. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  18409. }
  18410. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18411. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  18412. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  18413. return ok
  18414. }
  18415. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18416. func (m *SopStageMutation) ResetActionLabelAdd() {
  18417. m.action_label_add = nil
  18418. m.appendaction_label_add = nil
  18419. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  18420. }
  18421. // SetActionLabelDel sets the "action_label_del" field.
  18422. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  18423. m.action_label_del = &u
  18424. m.appendaction_label_del = nil
  18425. }
  18426. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18427. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  18428. v := m.action_label_del
  18429. if v == nil {
  18430. return
  18431. }
  18432. return *v, true
  18433. }
  18434. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  18435. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18437. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18438. if !m.op.Is(OpUpdateOne) {
  18439. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18440. }
  18441. if m.id == nil || m.oldValue == nil {
  18442. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18443. }
  18444. oldValue, err := m.oldValue(ctx)
  18445. if err != nil {
  18446. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18447. }
  18448. return oldValue.ActionLabelDel, nil
  18449. }
  18450. // AppendActionLabelDel adds u to the "action_label_del" field.
  18451. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  18452. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18453. }
  18454. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18455. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18456. if len(m.appendaction_label_del) == 0 {
  18457. return nil, false
  18458. }
  18459. return m.appendaction_label_del, true
  18460. }
  18461. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18462. func (m *SopStageMutation) ClearActionLabelDel() {
  18463. m.action_label_del = nil
  18464. m.appendaction_label_del = nil
  18465. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  18466. }
  18467. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18468. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  18469. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  18470. return ok
  18471. }
  18472. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18473. func (m *SopStageMutation) ResetActionLabelDel() {
  18474. m.action_label_del = nil
  18475. m.appendaction_label_del = nil
  18476. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  18477. }
  18478. // SetActionForward sets the "action_forward" field.
  18479. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  18480. m.action_forward = &ctf
  18481. }
  18482. // ActionForward returns the value of the "action_forward" field in the mutation.
  18483. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  18484. v := m.action_forward
  18485. if v == nil {
  18486. return
  18487. }
  18488. return *v, true
  18489. }
  18490. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  18491. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18493. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  18494. if !m.op.Is(OpUpdateOne) {
  18495. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  18496. }
  18497. if m.id == nil || m.oldValue == nil {
  18498. return v, errors.New("OldActionForward requires an ID field in the mutation")
  18499. }
  18500. oldValue, err := m.oldValue(ctx)
  18501. if err != nil {
  18502. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  18503. }
  18504. return oldValue.ActionForward, nil
  18505. }
  18506. // ClearActionForward clears the value of the "action_forward" field.
  18507. func (m *SopStageMutation) ClearActionForward() {
  18508. m.action_forward = nil
  18509. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  18510. }
  18511. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  18512. func (m *SopStageMutation) ActionForwardCleared() bool {
  18513. _, ok := m.clearedFields[sopstage.FieldActionForward]
  18514. return ok
  18515. }
  18516. // ResetActionForward resets all changes to the "action_forward" field.
  18517. func (m *SopStageMutation) ResetActionForward() {
  18518. m.action_forward = nil
  18519. delete(m.clearedFields, sopstage.FieldActionForward)
  18520. }
  18521. // SetIndexSort sets the "index_sort" field.
  18522. func (m *SopStageMutation) SetIndexSort(i int) {
  18523. m.index_sort = &i
  18524. m.addindex_sort = nil
  18525. }
  18526. // IndexSort returns the value of the "index_sort" field in the mutation.
  18527. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  18528. v := m.index_sort
  18529. if v == nil {
  18530. return
  18531. }
  18532. return *v, true
  18533. }
  18534. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  18535. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18537. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  18538. if !m.op.Is(OpUpdateOne) {
  18539. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  18540. }
  18541. if m.id == nil || m.oldValue == nil {
  18542. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  18543. }
  18544. oldValue, err := m.oldValue(ctx)
  18545. if err != nil {
  18546. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  18547. }
  18548. return oldValue.IndexSort, nil
  18549. }
  18550. // AddIndexSort adds i to the "index_sort" field.
  18551. func (m *SopStageMutation) AddIndexSort(i int) {
  18552. if m.addindex_sort != nil {
  18553. *m.addindex_sort += i
  18554. } else {
  18555. m.addindex_sort = &i
  18556. }
  18557. }
  18558. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  18559. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  18560. v := m.addindex_sort
  18561. if v == nil {
  18562. return
  18563. }
  18564. return *v, true
  18565. }
  18566. // ClearIndexSort clears the value of the "index_sort" field.
  18567. func (m *SopStageMutation) ClearIndexSort() {
  18568. m.index_sort = nil
  18569. m.addindex_sort = nil
  18570. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  18571. }
  18572. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  18573. func (m *SopStageMutation) IndexSortCleared() bool {
  18574. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  18575. return ok
  18576. }
  18577. // ResetIndexSort resets all changes to the "index_sort" field.
  18578. func (m *SopStageMutation) ResetIndexSort() {
  18579. m.index_sort = nil
  18580. m.addindex_sort = nil
  18581. delete(m.clearedFields, sopstage.FieldIndexSort)
  18582. }
  18583. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  18584. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  18585. m.sop_task = &id
  18586. }
  18587. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  18588. func (m *SopStageMutation) ClearSopTask() {
  18589. m.clearedsop_task = true
  18590. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  18591. }
  18592. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  18593. func (m *SopStageMutation) SopTaskCleared() bool {
  18594. return m.clearedsop_task
  18595. }
  18596. // SopTaskID returns the "sop_task" edge ID in the mutation.
  18597. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  18598. if m.sop_task != nil {
  18599. return *m.sop_task, true
  18600. }
  18601. return
  18602. }
  18603. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  18604. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18605. // SopTaskID instead. It exists only for internal usage by the builders.
  18606. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  18607. if id := m.sop_task; id != nil {
  18608. ids = append(ids, *id)
  18609. }
  18610. return
  18611. }
  18612. // ResetSopTask resets all changes to the "sop_task" edge.
  18613. func (m *SopStageMutation) ResetSopTask() {
  18614. m.sop_task = nil
  18615. m.clearedsop_task = false
  18616. }
  18617. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  18618. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  18619. if m.stage_nodes == nil {
  18620. m.stage_nodes = make(map[uint64]struct{})
  18621. }
  18622. for i := range ids {
  18623. m.stage_nodes[ids[i]] = struct{}{}
  18624. }
  18625. }
  18626. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  18627. func (m *SopStageMutation) ClearStageNodes() {
  18628. m.clearedstage_nodes = true
  18629. }
  18630. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  18631. func (m *SopStageMutation) StageNodesCleared() bool {
  18632. return m.clearedstage_nodes
  18633. }
  18634. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  18635. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  18636. if m.removedstage_nodes == nil {
  18637. m.removedstage_nodes = make(map[uint64]struct{})
  18638. }
  18639. for i := range ids {
  18640. delete(m.stage_nodes, ids[i])
  18641. m.removedstage_nodes[ids[i]] = struct{}{}
  18642. }
  18643. }
  18644. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  18645. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  18646. for id := range m.removedstage_nodes {
  18647. ids = append(ids, id)
  18648. }
  18649. return
  18650. }
  18651. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  18652. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  18653. for id := range m.stage_nodes {
  18654. ids = append(ids, id)
  18655. }
  18656. return
  18657. }
  18658. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  18659. func (m *SopStageMutation) ResetStageNodes() {
  18660. m.stage_nodes = nil
  18661. m.clearedstage_nodes = false
  18662. m.removedstage_nodes = nil
  18663. }
  18664. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  18665. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  18666. if m.stage_messages == nil {
  18667. m.stage_messages = make(map[uint64]struct{})
  18668. }
  18669. for i := range ids {
  18670. m.stage_messages[ids[i]] = struct{}{}
  18671. }
  18672. }
  18673. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  18674. func (m *SopStageMutation) ClearStageMessages() {
  18675. m.clearedstage_messages = true
  18676. }
  18677. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  18678. func (m *SopStageMutation) StageMessagesCleared() bool {
  18679. return m.clearedstage_messages
  18680. }
  18681. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  18682. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  18683. if m.removedstage_messages == nil {
  18684. m.removedstage_messages = make(map[uint64]struct{})
  18685. }
  18686. for i := range ids {
  18687. delete(m.stage_messages, ids[i])
  18688. m.removedstage_messages[ids[i]] = struct{}{}
  18689. }
  18690. }
  18691. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  18692. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  18693. for id := range m.removedstage_messages {
  18694. ids = append(ids, id)
  18695. }
  18696. return
  18697. }
  18698. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  18699. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  18700. for id := range m.stage_messages {
  18701. ids = append(ids, id)
  18702. }
  18703. return
  18704. }
  18705. // ResetStageMessages resets all changes to the "stage_messages" edge.
  18706. func (m *SopStageMutation) ResetStageMessages() {
  18707. m.stage_messages = nil
  18708. m.clearedstage_messages = false
  18709. m.removedstage_messages = nil
  18710. }
  18711. // Where appends a list predicates to the SopStageMutation builder.
  18712. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  18713. m.predicates = append(m.predicates, ps...)
  18714. }
  18715. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  18716. // users can use type-assertion to append predicates that do not depend on any generated package.
  18717. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  18718. p := make([]predicate.SopStage, len(ps))
  18719. for i := range ps {
  18720. p[i] = ps[i]
  18721. }
  18722. m.Where(p...)
  18723. }
  18724. // Op returns the operation name.
  18725. func (m *SopStageMutation) Op() Op {
  18726. return m.op
  18727. }
  18728. // SetOp allows setting the mutation operation.
  18729. func (m *SopStageMutation) SetOp(op Op) {
  18730. m.op = op
  18731. }
  18732. // Type returns the node type of this mutation (SopStage).
  18733. func (m *SopStageMutation) Type() string {
  18734. return m.typ
  18735. }
  18736. // Fields returns all fields that were changed during this mutation. Note that in
  18737. // order to get all numeric fields that were incremented/decremented, call
  18738. // AddedFields().
  18739. func (m *SopStageMutation) Fields() []string {
  18740. fields := make([]string, 0, 14)
  18741. if m.created_at != nil {
  18742. fields = append(fields, sopstage.FieldCreatedAt)
  18743. }
  18744. if m.updated_at != nil {
  18745. fields = append(fields, sopstage.FieldUpdatedAt)
  18746. }
  18747. if m.status != nil {
  18748. fields = append(fields, sopstage.FieldStatus)
  18749. }
  18750. if m.deleted_at != nil {
  18751. fields = append(fields, sopstage.FieldDeletedAt)
  18752. }
  18753. if m.sop_task != nil {
  18754. fields = append(fields, sopstage.FieldTaskID)
  18755. }
  18756. if m.name != nil {
  18757. fields = append(fields, sopstage.FieldName)
  18758. }
  18759. if m.condition_type != nil {
  18760. fields = append(fields, sopstage.FieldConditionType)
  18761. }
  18762. if m.condition_operator != nil {
  18763. fields = append(fields, sopstage.FieldConditionOperator)
  18764. }
  18765. if m.condition_list != nil {
  18766. fields = append(fields, sopstage.FieldConditionList)
  18767. }
  18768. if m.action_message != nil {
  18769. fields = append(fields, sopstage.FieldActionMessage)
  18770. }
  18771. if m.action_label_add != nil {
  18772. fields = append(fields, sopstage.FieldActionLabelAdd)
  18773. }
  18774. if m.action_label_del != nil {
  18775. fields = append(fields, sopstage.FieldActionLabelDel)
  18776. }
  18777. if m.action_forward != nil {
  18778. fields = append(fields, sopstage.FieldActionForward)
  18779. }
  18780. if m.index_sort != nil {
  18781. fields = append(fields, sopstage.FieldIndexSort)
  18782. }
  18783. return fields
  18784. }
  18785. // Field returns the value of a field with the given name. The second boolean
  18786. // return value indicates that this field was not set, or was not defined in the
  18787. // schema.
  18788. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  18789. switch name {
  18790. case sopstage.FieldCreatedAt:
  18791. return m.CreatedAt()
  18792. case sopstage.FieldUpdatedAt:
  18793. return m.UpdatedAt()
  18794. case sopstage.FieldStatus:
  18795. return m.Status()
  18796. case sopstage.FieldDeletedAt:
  18797. return m.DeletedAt()
  18798. case sopstage.FieldTaskID:
  18799. return m.TaskID()
  18800. case sopstage.FieldName:
  18801. return m.Name()
  18802. case sopstage.FieldConditionType:
  18803. return m.ConditionType()
  18804. case sopstage.FieldConditionOperator:
  18805. return m.ConditionOperator()
  18806. case sopstage.FieldConditionList:
  18807. return m.ConditionList()
  18808. case sopstage.FieldActionMessage:
  18809. return m.ActionMessage()
  18810. case sopstage.FieldActionLabelAdd:
  18811. return m.ActionLabelAdd()
  18812. case sopstage.FieldActionLabelDel:
  18813. return m.ActionLabelDel()
  18814. case sopstage.FieldActionForward:
  18815. return m.ActionForward()
  18816. case sopstage.FieldIndexSort:
  18817. return m.IndexSort()
  18818. }
  18819. return nil, false
  18820. }
  18821. // OldField returns the old value of the field from the database. An error is
  18822. // returned if the mutation operation is not UpdateOne, or the query to the
  18823. // database failed.
  18824. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18825. switch name {
  18826. case sopstage.FieldCreatedAt:
  18827. return m.OldCreatedAt(ctx)
  18828. case sopstage.FieldUpdatedAt:
  18829. return m.OldUpdatedAt(ctx)
  18830. case sopstage.FieldStatus:
  18831. return m.OldStatus(ctx)
  18832. case sopstage.FieldDeletedAt:
  18833. return m.OldDeletedAt(ctx)
  18834. case sopstage.FieldTaskID:
  18835. return m.OldTaskID(ctx)
  18836. case sopstage.FieldName:
  18837. return m.OldName(ctx)
  18838. case sopstage.FieldConditionType:
  18839. return m.OldConditionType(ctx)
  18840. case sopstage.FieldConditionOperator:
  18841. return m.OldConditionOperator(ctx)
  18842. case sopstage.FieldConditionList:
  18843. return m.OldConditionList(ctx)
  18844. case sopstage.FieldActionMessage:
  18845. return m.OldActionMessage(ctx)
  18846. case sopstage.FieldActionLabelAdd:
  18847. return m.OldActionLabelAdd(ctx)
  18848. case sopstage.FieldActionLabelDel:
  18849. return m.OldActionLabelDel(ctx)
  18850. case sopstage.FieldActionForward:
  18851. return m.OldActionForward(ctx)
  18852. case sopstage.FieldIndexSort:
  18853. return m.OldIndexSort(ctx)
  18854. }
  18855. return nil, fmt.Errorf("unknown SopStage field %s", name)
  18856. }
  18857. // SetField sets the value of a field with the given name. It returns an error if
  18858. // the field is not defined in the schema, or if the type mismatched the field
  18859. // type.
  18860. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  18861. switch name {
  18862. case sopstage.FieldCreatedAt:
  18863. v, ok := value.(time.Time)
  18864. if !ok {
  18865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18866. }
  18867. m.SetCreatedAt(v)
  18868. return nil
  18869. case sopstage.FieldUpdatedAt:
  18870. v, ok := value.(time.Time)
  18871. if !ok {
  18872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18873. }
  18874. m.SetUpdatedAt(v)
  18875. return nil
  18876. case sopstage.FieldStatus:
  18877. v, ok := value.(uint8)
  18878. if !ok {
  18879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18880. }
  18881. m.SetStatus(v)
  18882. return nil
  18883. case sopstage.FieldDeletedAt:
  18884. v, ok := value.(time.Time)
  18885. if !ok {
  18886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18887. }
  18888. m.SetDeletedAt(v)
  18889. return nil
  18890. case sopstage.FieldTaskID:
  18891. v, ok := value.(uint64)
  18892. if !ok {
  18893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18894. }
  18895. m.SetTaskID(v)
  18896. return nil
  18897. case sopstage.FieldName:
  18898. v, ok := value.(string)
  18899. if !ok {
  18900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18901. }
  18902. m.SetName(v)
  18903. return nil
  18904. case sopstage.FieldConditionType:
  18905. v, ok := value.(int)
  18906. if !ok {
  18907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18908. }
  18909. m.SetConditionType(v)
  18910. return nil
  18911. case sopstage.FieldConditionOperator:
  18912. v, ok := value.(int)
  18913. if !ok {
  18914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18915. }
  18916. m.SetConditionOperator(v)
  18917. return nil
  18918. case sopstage.FieldConditionList:
  18919. v, ok := value.([]custom_types.Condition)
  18920. if !ok {
  18921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18922. }
  18923. m.SetConditionList(v)
  18924. return nil
  18925. case sopstage.FieldActionMessage:
  18926. v, ok := value.([]custom_types.Action)
  18927. if !ok {
  18928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18929. }
  18930. m.SetActionMessage(v)
  18931. return nil
  18932. case sopstage.FieldActionLabelAdd:
  18933. v, ok := value.([]uint64)
  18934. if !ok {
  18935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18936. }
  18937. m.SetActionLabelAdd(v)
  18938. return nil
  18939. case sopstage.FieldActionLabelDel:
  18940. v, ok := value.([]uint64)
  18941. if !ok {
  18942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18943. }
  18944. m.SetActionLabelDel(v)
  18945. return nil
  18946. case sopstage.FieldActionForward:
  18947. v, ok := value.(*custom_types.ActionForward)
  18948. if !ok {
  18949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18950. }
  18951. m.SetActionForward(v)
  18952. return nil
  18953. case sopstage.FieldIndexSort:
  18954. v, ok := value.(int)
  18955. if !ok {
  18956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18957. }
  18958. m.SetIndexSort(v)
  18959. return nil
  18960. }
  18961. return fmt.Errorf("unknown SopStage field %s", name)
  18962. }
  18963. // AddedFields returns all numeric fields that were incremented/decremented during
  18964. // this mutation.
  18965. func (m *SopStageMutation) AddedFields() []string {
  18966. var fields []string
  18967. if m.addstatus != nil {
  18968. fields = append(fields, sopstage.FieldStatus)
  18969. }
  18970. if m.addcondition_type != nil {
  18971. fields = append(fields, sopstage.FieldConditionType)
  18972. }
  18973. if m.addcondition_operator != nil {
  18974. fields = append(fields, sopstage.FieldConditionOperator)
  18975. }
  18976. if m.addindex_sort != nil {
  18977. fields = append(fields, sopstage.FieldIndexSort)
  18978. }
  18979. return fields
  18980. }
  18981. // AddedField returns the numeric value that was incremented/decremented on a field
  18982. // with the given name. The second boolean return value indicates that this field
  18983. // was not set, or was not defined in the schema.
  18984. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  18985. switch name {
  18986. case sopstage.FieldStatus:
  18987. return m.AddedStatus()
  18988. case sopstage.FieldConditionType:
  18989. return m.AddedConditionType()
  18990. case sopstage.FieldConditionOperator:
  18991. return m.AddedConditionOperator()
  18992. case sopstage.FieldIndexSort:
  18993. return m.AddedIndexSort()
  18994. }
  18995. return nil, false
  18996. }
  18997. // AddField adds the value to the field with the given name. It returns an error if
  18998. // the field is not defined in the schema, or if the type mismatched the field
  18999. // type.
  19000. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  19001. switch name {
  19002. case sopstage.FieldStatus:
  19003. v, ok := value.(int8)
  19004. if !ok {
  19005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19006. }
  19007. m.AddStatus(v)
  19008. return nil
  19009. case sopstage.FieldConditionType:
  19010. v, ok := value.(int)
  19011. if !ok {
  19012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19013. }
  19014. m.AddConditionType(v)
  19015. return nil
  19016. case sopstage.FieldConditionOperator:
  19017. v, ok := value.(int)
  19018. if !ok {
  19019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19020. }
  19021. m.AddConditionOperator(v)
  19022. return nil
  19023. case sopstage.FieldIndexSort:
  19024. v, ok := value.(int)
  19025. if !ok {
  19026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19027. }
  19028. m.AddIndexSort(v)
  19029. return nil
  19030. }
  19031. return fmt.Errorf("unknown SopStage numeric field %s", name)
  19032. }
  19033. // ClearedFields returns all nullable fields that were cleared during this
  19034. // mutation.
  19035. func (m *SopStageMutation) ClearedFields() []string {
  19036. var fields []string
  19037. if m.FieldCleared(sopstage.FieldStatus) {
  19038. fields = append(fields, sopstage.FieldStatus)
  19039. }
  19040. if m.FieldCleared(sopstage.FieldDeletedAt) {
  19041. fields = append(fields, sopstage.FieldDeletedAt)
  19042. }
  19043. if m.FieldCleared(sopstage.FieldActionMessage) {
  19044. fields = append(fields, sopstage.FieldActionMessage)
  19045. }
  19046. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  19047. fields = append(fields, sopstage.FieldActionLabelAdd)
  19048. }
  19049. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  19050. fields = append(fields, sopstage.FieldActionLabelDel)
  19051. }
  19052. if m.FieldCleared(sopstage.FieldActionForward) {
  19053. fields = append(fields, sopstage.FieldActionForward)
  19054. }
  19055. if m.FieldCleared(sopstage.FieldIndexSort) {
  19056. fields = append(fields, sopstage.FieldIndexSort)
  19057. }
  19058. return fields
  19059. }
  19060. // FieldCleared returns a boolean indicating if a field with the given name was
  19061. // cleared in this mutation.
  19062. func (m *SopStageMutation) FieldCleared(name string) bool {
  19063. _, ok := m.clearedFields[name]
  19064. return ok
  19065. }
  19066. // ClearField clears the value of the field with the given name. It returns an
  19067. // error if the field is not defined in the schema.
  19068. func (m *SopStageMutation) ClearField(name string) error {
  19069. switch name {
  19070. case sopstage.FieldStatus:
  19071. m.ClearStatus()
  19072. return nil
  19073. case sopstage.FieldDeletedAt:
  19074. m.ClearDeletedAt()
  19075. return nil
  19076. case sopstage.FieldActionMessage:
  19077. m.ClearActionMessage()
  19078. return nil
  19079. case sopstage.FieldActionLabelAdd:
  19080. m.ClearActionLabelAdd()
  19081. return nil
  19082. case sopstage.FieldActionLabelDel:
  19083. m.ClearActionLabelDel()
  19084. return nil
  19085. case sopstage.FieldActionForward:
  19086. m.ClearActionForward()
  19087. return nil
  19088. case sopstage.FieldIndexSort:
  19089. m.ClearIndexSort()
  19090. return nil
  19091. }
  19092. return fmt.Errorf("unknown SopStage nullable field %s", name)
  19093. }
  19094. // ResetField resets all changes in the mutation for the field with the given name.
  19095. // It returns an error if the field is not defined in the schema.
  19096. func (m *SopStageMutation) ResetField(name string) error {
  19097. switch name {
  19098. case sopstage.FieldCreatedAt:
  19099. m.ResetCreatedAt()
  19100. return nil
  19101. case sopstage.FieldUpdatedAt:
  19102. m.ResetUpdatedAt()
  19103. return nil
  19104. case sopstage.FieldStatus:
  19105. m.ResetStatus()
  19106. return nil
  19107. case sopstage.FieldDeletedAt:
  19108. m.ResetDeletedAt()
  19109. return nil
  19110. case sopstage.FieldTaskID:
  19111. m.ResetTaskID()
  19112. return nil
  19113. case sopstage.FieldName:
  19114. m.ResetName()
  19115. return nil
  19116. case sopstage.FieldConditionType:
  19117. m.ResetConditionType()
  19118. return nil
  19119. case sopstage.FieldConditionOperator:
  19120. m.ResetConditionOperator()
  19121. return nil
  19122. case sopstage.FieldConditionList:
  19123. m.ResetConditionList()
  19124. return nil
  19125. case sopstage.FieldActionMessage:
  19126. m.ResetActionMessage()
  19127. return nil
  19128. case sopstage.FieldActionLabelAdd:
  19129. m.ResetActionLabelAdd()
  19130. return nil
  19131. case sopstage.FieldActionLabelDel:
  19132. m.ResetActionLabelDel()
  19133. return nil
  19134. case sopstage.FieldActionForward:
  19135. m.ResetActionForward()
  19136. return nil
  19137. case sopstage.FieldIndexSort:
  19138. m.ResetIndexSort()
  19139. return nil
  19140. }
  19141. return fmt.Errorf("unknown SopStage field %s", name)
  19142. }
  19143. // AddedEdges returns all edge names that were set/added in this mutation.
  19144. func (m *SopStageMutation) AddedEdges() []string {
  19145. edges := make([]string, 0, 3)
  19146. if m.sop_task != nil {
  19147. edges = append(edges, sopstage.EdgeSopTask)
  19148. }
  19149. if m.stage_nodes != nil {
  19150. edges = append(edges, sopstage.EdgeStageNodes)
  19151. }
  19152. if m.stage_messages != nil {
  19153. edges = append(edges, sopstage.EdgeStageMessages)
  19154. }
  19155. return edges
  19156. }
  19157. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19158. // name in this mutation.
  19159. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  19160. switch name {
  19161. case sopstage.EdgeSopTask:
  19162. if id := m.sop_task; id != nil {
  19163. return []ent.Value{*id}
  19164. }
  19165. case sopstage.EdgeStageNodes:
  19166. ids := make([]ent.Value, 0, len(m.stage_nodes))
  19167. for id := range m.stage_nodes {
  19168. ids = append(ids, id)
  19169. }
  19170. return ids
  19171. case sopstage.EdgeStageMessages:
  19172. ids := make([]ent.Value, 0, len(m.stage_messages))
  19173. for id := range m.stage_messages {
  19174. ids = append(ids, id)
  19175. }
  19176. return ids
  19177. }
  19178. return nil
  19179. }
  19180. // RemovedEdges returns all edge names that were removed in this mutation.
  19181. func (m *SopStageMutation) RemovedEdges() []string {
  19182. edges := make([]string, 0, 3)
  19183. if m.removedstage_nodes != nil {
  19184. edges = append(edges, sopstage.EdgeStageNodes)
  19185. }
  19186. if m.removedstage_messages != nil {
  19187. edges = append(edges, sopstage.EdgeStageMessages)
  19188. }
  19189. return edges
  19190. }
  19191. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19192. // the given name in this mutation.
  19193. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  19194. switch name {
  19195. case sopstage.EdgeStageNodes:
  19196. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  19197. for id := range m.removedstage_nodes {
  19198. ids = append(ids, id)
  19199. }
  19200. return ids
  19201. case sopstage.EdgeStageMessages:
  19202. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  19203. for id := range m.removedstage_messages {
  19204. ids = append(ids, id)
  19205. }
  19206. return ids
  19207. }
  19208. return nil
  19209. }
  19210. // ClearedEdges returns all edge names that were cleared in this mutation.
  19211. func (m *SopStageMutation) ClearedEdges() []string {
  19212. edges := make([]string, 0, 3)
  19213. if m.clearedsop_task {
  19214. edges = append(edges, sopstage.EdgeSopTask)
  19215. }
  19216. if m.clearedstage_nodes {
  19217. edges = append(edges, sopstage.EdgeStageNodes)
  19218. }
  19219. if m.clearedstage_messages {
  19220. edges = append(edges, sopstage.EdgeStageMessages)
  19221. }
  19222. return edges
  19223. }
  19224. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19225. // was cleared in this mutation.
  19226. func (m *SopStageMutation) EdgeCleared(name string) bool {
  19227. switch name {
  19228. case sopstage.EdgeSopTask:
  19229. return m.clearedsop_task
  19230. case sopstage.EdgeStageNodes:
  19231. return m.clearedstage_nodes
  19232. case sopstage.EdgeStageMessages:
  19233. return m.clearedstage_messages
  19234. }
  19235. return false
  19236. }
  19237. // ClearEdge clears the value of the edge with the given name. It returns an error
  19238. // if that edge is not defined in the schema.
  19239. func (m *SopStageMutation) ClearEdge(name string) error {
  19240. switch name {
  19241. case sopstage.EdgeSopTask:
  19242. m.ClearSopTask()
  19243. return nil
  19244. }
  19245. return fmt.Errorf("unknown SopStage unique edge %s", name)
  19246. }
  19247. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19248. // It returns an error if the edge is not defined in the schema.
  19249. func (m *SopStageMutation) ResetEdge(name string) error {
  19250. switch name {
  19251. case sopstage.EdgeSopTask:
  19252. m.ResetSopTask()
  19253. return nil
  19254. case sopstage.EdgeStageNodes:
  19255. m.ResetStageNodes()
  19256. return nil
  19257. case sopstage.EdgeStageMessages:
  19258. m.ResetStageMessages()
  19259. return nil
  19260. }
  19261. return fmt.Errorf("unknown SopStage edge %s", name)
  19262. }
  19263. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  19264. type SopTaskMutation struct {
  19265. config
  19266. op Op
  19267. typ string
  19268. id *uint64
  19269. created_at *time.Time
  19270. updated_at *time.Time
  19271. status *uint8
  19272. addstatus *int8
  19273. deleted_at *time.Time
  19274. name *string
  19275. bot_wxid_list *[]string
  19276. appendbot_wxid_list []string
  19277. _type *int
  19278. add_type *int
  19279. plan_start_time *time.Time
  19280. plan_end_time *time.Time
  19281. creator_id *string
  19282. organization_id *uint64
  19283. addorganization_id *int64
  19284. token *[]string
  19285. appendtoken []string
  19286. clearedFields map[string]struct{}
  19287. task_stages map[uint64]struct{}
  19288. removedtask_stages map[uint64]struct{}
  19289. clearedtask_stages bool
  19290. done bool
  19291. oldValue func(context.Context) (*SopTask, error)
  19292. predicates []predicate.SopTask
  19293. }
  19294. var _ ent.Mutation = (*SopTaskMutation)(nil)
  19295. // soptaskOption allows management of the mutation configuration using functional options.
  19296. type soptaskOption func(*SopTaskMutation)
  19297. // newSopTaskMutation creates new mutation for the SopTask entity.
  19298. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  19299. m := &SopTaskMutation{
  19300. config: c,
  19301. op: op,
  19302. typ: TypeSopTask,
  19303. clearedFields: make(map[string]struct{}),
  19304. }
  19305. for _, opt := range opts {
  19306. opt(m)
  19307. }
  19308. return m
  19309. }
  19310. // withSopTaskID sets the ID field of the mutation.
  19311. func withSopTaskID(id uint64) soptaskOption {
  19312. return func(m *SopTaskMutation) {
  19313. var (
  19314. err error
  19315. once sync.Once
  19316. value *SopTask
  19317. )
  19318. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  19319. once.Do(func() {
  19320. if m.done {
  19321. err = errors.New("querying old values post mutation is not allowed")
  19322. } else {
  19323. value, err = m.Client().SopTask.Get(ctx, id)
  19324. }
  19325. })
  19326. return value, err
  19327. }
  19328. m.id = &id
  19329. }
  19330. }
  19331. // withSopTask sets the old SopTask of the mutation.
  19332. func withSopTask(node *SopTask) soptaskOption {
  19333. return func(m *SopTaskMutation) {
  19334. m.oldValue = func(context.Context) (*SopTask, error) {
  19335. return node, nil
  19336. }
  19337. m.id = &node.ID
  19338. }
  19339. }
  19340. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19341. // executed in a transaction (ent.Tx), a transactional client is returned.
  19342. func (m SopTaskMutation) Client() *Client {
  19343. client := &Client{config: m.config}
  19344. client.init()
  19345. return client
  19346. }
  19347. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19348. // it returns an error otherwise.
  19349. func (m SopTaskMutation) Tx() (*Tx, error) {
  19350. if _, ok := m.driver.(*txDriver); !ok {
  19351. return nil, errors.New("ent: mutation is not running in a transaction")
  19352. }
  19353. tx := &Tx{config: m.config}
  19354. tx.init()
  19355. return tx, nil
  19356. }
  19357. // SetID sets the value of the id field. Note that this
  19358. // operation is only accepted on creation of SopTask entities.
  19359. func (m *SopTaskMutation) SetID(id uint64) {
  19360. m.id = &id
  19361. }
  19362. // ID returns the ID value in the mutation. Note that the ID is only available
  19363. // if it was provided to the builder or after it was returned from the database.
  19364. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  19365. if m.id == nil {
  19366. return
  19367. }
  19368. return *m.id, true
  19369. }
  19370. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19371. // That means, if the mutation is applied within a transaction with an isolation level such
  19372. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19373. // or updated by the mutation.
  19374. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  19375. switch {
  19376. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19377. id, exists := m.ID()
  19378. if exists {
  19379. return []uint64{id}, nil
  19380. }
  19381. fallthrough
  19382. case m.op.Is(OpUpdate | OpDelete):
  19383. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  19384. default:
  19385. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19386. }
  19387. }
  19388. // SetCreatedAt sets the "created_at" field.
  19389. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  19390. m.created_at = &t
  19391. }
  19392. // CreatedAt returns the value of the "created_at" field in the mutation.
  19393. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  19394. v := m.created_at
  19395. if v == nil {
  19396. return
  19397. }
  19398. return *v, true
  19399. }
  19400. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  19401. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19403. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19404. if !m.op.Is(OpUpdateOne) {
  19405. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19406. }
  19407. if m.id == nil || m.oldValue == nil {
  19408. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19409. }
  19410. oldValue, err := m.oldValue(ctx)
  19411. if err != nil {
  19412. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19413. }
  19414. return oldValue.CreatedAt, nil
  19415. }
  19416. // ResetCreatedAt resets all changes to the "created_at" field.
  19417. func (m *SopTaskMutation) ResetCreatedAt() {
  19418. m.created_at = nil
  19419. }
  19420. // SetUpdatedAt sets the "updated_at" field.
  19421. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  19422. m.updated_at = &t
  19423. }
  19424. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19425. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  19426. v := m.updated_at
  19427. if v == nil {
  19428. return
  19429. }
  19430. return *v, true
  19431. }
  19432. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  19433. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19435. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19436. if !m.op.Is(OpUpdateOne) {
  19437. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19438. }
  19439. if m.id == nil || m.oldValue == nil {
  19440. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19441. }
  19442. oldValue, err := m.oldValue(ctx)
  19443. if err != nil {
  19444. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19445. }
  19446. return oldValue.UpdatedAt, nil
  19447. }
  19448. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19449. func (m *SopTaskMutation) ResetUpdatedAt() {
  19450. m.updated_at = nil
  19451. }
  19452. // SetStatus sets the "status" field.
  19453. func (m *SopTaskMutation) SetStatus(u uint8) {
  19454. m.status = &u
  19455. m.addstatus = nil
  19456. }
  19457. // Status returns the value of the "status" field in the mutation.
  19458. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  19459. v := m.status
  19460. if v == nil {
  19461. return
  19462. }
  19463. return *v, true
  19464. }
  19465. // OldStatus returns the old "status" field's value of the SopTask entity.
  19466. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19468. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19469. if !m.op.Is(OpUpdateOne) {
  19470. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19471. }
  19472. if m.id == nil || m.oldValue == nil {
  19473. return v, errors.New("OldStatus requires an ID field in the mutation")
  19474. }
  19475. oldValue, err := m.oldValue(ctx)
  19476. if err != nil {
  19477. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19478. }
  19479. return oldValue.Status, nil
  19480. }
  19481. // AddStatus adds u to the "status" field.
  19482. func (m *SopTaskMutation) AddStatus(u int8) {
  19483. if m.addstatus != nil {
  19484. *m.addstatus += u
  19485. } else {
  19486. m.addstatus = &u
  19487. }
  19488. }
  19489. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19490. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  19491. v := m.addstatus
  19492. if v == nil {
  19493. return
  19494. }
  19495. return *v, true
  19496. }
  19497. // ClearStatus clears the value of the "status" field.
  19498. func (m *SopTaskMutation) ClearStatus() {
  19499. m.status = nil
  19500. m.addstatus = nil
  19501. m.clearedFields[soptask.FieldStatus] = struct{}{}
  19502. }
  19503. // StatusCleared returns if the "status" field was cleared in this mutation.
  19504. func (m *SopTaskMutation) StatusCleared() bool {
  19505. _, ok := m.clearedFields[soptask.FieldStatus]
  19506. return ok
  19507. }
  19508. // ResetStatus resets all changes to the "status" field.
  19509. func (m *SopTaskMutation) ResetStatus() {
  19510. m.status = nil
  19511. m.addstatus = nil
  19512. delete(m.clearedFields, soptask.FieldStatus)
  19513. }
  19514. // SetDeletedAt sets the "deleted_at" field.
  19515. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  19516. m.deleted_at = &t
  19517. }
  19518. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19519. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  19520. v := m.deleted_at
  19521. if v == nil {
  19522. return
  19523. }
  19524. return *v, true
  19525. }
  19526. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  19527. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19529. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19530. if !m.op.Is(OpUpdateOne) {
  19531. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19532. }
  19533. if m.id == nil || m.oldValue == nil {
  19534. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19535. }
  19536. oldValue, err := m.oldValue(ctx)
  19537. if err != nil {
  19538. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19539. }
  19540. return oldValue.DeletedAt, nil
  19541. }
  19542. // ClearDeletedAt clears the value of the "deleted_at" field.
  19543. func (m *SopTaskMutation) ClearDeletedAt() {
  19544. m.deleted_at = nil
  19545. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  19546. }
  19547. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19548. func (m *SopTaskMutation) DeletedAtCleared() bool {
  19549. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  19550. return ok
  19551. }
  19552. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19553. func (m *SopTaskMutation) ResetDeletedAt() {
  19554. m.deleted_at = nil
  19555. delete(m.clearedFields, soptask.FieldDeletedAt)
  19556. }
  19557. // SetName sets the "name" field.
  19558. func (m *SopTaskMutation) SetName(s string) {
  19559. m.name = &s
  19560. }
  19561. // Name returns the value of the "name" field in the mutation.
  19562. func (m *SopTaskMutation) Name() (r string, exists bool) {
  19563. v := m.name
  19564. if v == nil {
  19565. return
  19566. }
  19567. return *v, true
  19568. }
  19569. // OldName returns the old "name" field's value of the SopTask entity.
  19570. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19572. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  19573. if !m.op.Is(OpUpdateOne) {
  19574. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19575. }
  19576. if m.id == nil || m.oldValue == nil {
  19577. return v, errors.New("OldName requires an ID field in the mutation")
  19578. }
  19579. oldValue, err := m.oldValue(ctx)
  19580. if err != nil {
  19581. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19582. }
  19583. return oldValue.Name, nil
  19584. }
  19585. // ResetName resets all changes to the "name" field.
  19586. func (m *SopTaskMutation) ResetName() {
  19587. m.name = nil
  19588. }
  19589. // SetBotWxidList sets the "bot_wxid_list" field.
  19590. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  19591. m.bot_wxid_list = &s
  19592. m.appendbot_wxid_list = nil
  19593. }
  19594. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  19595. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  19596. v := m.bot_wxid_list
  19597. if v == nil {
  19598. return
  19599. }
  19600. return *v, true
  19601. }
  19602. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  19603. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19605. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  19606. if !m.op.Is(OpUpdateOne) {
  19607. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  19608. }
  19609. if m.id == nil || m.oldValue == nil {
  19610. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  19611. }
  19612. oldValue, err := m.oldValue(ctx)
  19613. if err != nil {
  19614. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  19615. }
  19616. return oldValue.BotWxidList, nil
  19617. }
  19618. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  19619. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  19620. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  19621. }
  19622. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  19623. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  19624. if len(m.appendbot_wxid_list) == 0 {
  19625. return nil, false
  19626. }
  19627. return m.appendbot_wxid_list, true
  19628. }
  19629. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  19630. func (m *SopTaskMutation) ClearBotWxidList() {
  19631. m.bot_wxid_list = nil
  19632. m.appendbot_wxid_list = nil
  19633. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  19634. }
  19635. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  19636. func (m *SopTaskMutation) BotWxidListCleared() bool {
  19637. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  19638. return ok
  19639. }
  19640. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  19641. func (m *SopTaskMutation) ResetBotWxidList() {
  19642. m.bot_wxid_list = nil
  19643. m.appendbot_wxid_list = nil
  19644. delete(m.clearedFields, soptask.FieldBotWxidList)
  19645. }
  19646. // SetType sets the "type" field.
  19647. func (m *SopTaskMutation) SetType(i int) {
  19648. m._type = &i
  19649. m.add_type = nil
  19650. }
  19651. // GetType returns the value of the "type" field in the mutation.
  19652. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  19653. v := m._type
  19654. if v == nil {
  19655. return
  19656. }
  19657. return *v, true
  19658. }
  19659. // OldType returns the old "type" field's value of the SopTask entity.
  19660. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19662. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  19663. if !m.op.Is(OpUpdateOne) {
  19664. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19665. }
  19666. if m.id == nil || m.oldValue == nil {
  19667. return v, errors.New("OldType requires an ID field in the mutation")
  19668. }
  19669. oldValue, err := m.oldValue(ctx)
  19670. if err != nil {
  19671. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19672. }
  19673. return oldValue.Type, nil
  19674. }
  19675. // AddType adds i to the "type" field.
  19676. func (m *SopTaskMutation) AddType(i int) {
  19677. if m.add_type != nil {
  19678. *m.add_type += i
  19679. } else {
  19680. m.add_type = &i
  19681. }
  19682. }
  19683. // AddedType returns the value that was added to the "type" field in this mutation.
  19684. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  19685. v := m.add_type
  19686. if v == nil {
  19687. return
  19688. }
  19689. return *v, true
  19690. }
  19691. // ResetType resets all changes to the "type" field.
  19692. func (m *SopTaskMutation) ResetType() {
  19693. m._type = nil
  19694. m.add_type = nil
  19695. }
  19696. // SetPlanStartTime sets the "plan_start_time" field.
  19697. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  19698. m.plan_start_time = &t
  19699. }
  19700. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  19701. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  19702. v := m.plan_start_time
  19703. if v == nil {
  19704. return
  19705. }
  19706. return *v, true
  19707. }
  19708. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  19709. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19711. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  19712. if !m.op.Is(OpUpdateOne) {
  19713. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  19714. }
  19715. if m.id == nil || m.oldValue == nil {
  19716. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  19717. }
  19718. oldValue, err := m.oldValue(ctx)
  19719. if err != nil {
  19720. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  19721. }
  19722. return oldValue.PlanStartTime, nil
  19723. }
  19724. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  19725. func (m *SopTaskMutation) ClearPlanStartTime() {
  19726. m.plan_start_time = nil
  19727. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  19728. }
  19729. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  19730. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  19731. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  19732. return ok
  19733. }
  19734. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  19735. func (m *SopTaskMutation) ResetPlanStartTime() {
  19736. m.plan_start_time = nil
  19737. delete(m.clearedFields, soptask.FieldPlanStartTime)
  19738. }
  19739. // SetPlanEndTime sets the "plan_end_time" field.
  19740. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  19741. m.plan_end_time = &t
  19742. }
  19743. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  19744. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  19745. v := m.plan_end_time
  19746. if v == nil {
  19747. return
  19748. }
  19749. return *v, true
  19750. }
  19751. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  19752. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19754. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  19755. if !m.op.Is(OpUpdateOne) {
  19756. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  19757. }
  19758. if m.id == nil || m.oldValue == nil {
  19759. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  19760. }
  19761. oldValue, err := m.oldValue(ctx)
  19762. if err != nil {
  19763. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  19764. }
  19765. return oldValue.PlanEndTime, nil
  19766. }
  19767. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  19768. func (m *SopTaskMutation) ClearPlanEndTime() {
  19769. m.plan_end_time = nil
  19770. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  19771. }
  19772. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  19773. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  19774. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  19775. return ok
  19776. }
  19777. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  19778. func (m *SopTaskMutation) ResetPlanEndTime() {
  19779. m.plan_end_time = nil
  19780. delete(m.clearedFields, soptask.FieldPlanEndTime)
  19781. }
  19782. // SetCreatorID sets the "creator_id" field.
  19783. func (m *SopTaskMutation) SetCreatorID(s string) {
  19784. m.creator_id = &s
  19785. }
  19786. // CreatorID returns the value of the "creator_id" field in the mutation.
  19787. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  19788. v := m.creator_id
  19789. if v == nil {
  19790. return
  19791. }
  19792. return *v, true
  19793. }
  19794. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  19795. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19797. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  19798. if !m.op.Is(OpUpdateOne) {
  19799. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  19800. }
  19801. if m.id == nil || m.oldValue == nil {
  19802. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  19803. }
  19804. oldValue, err := m.oldValue(ctx)
  19805. if err != nil {
  19806. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  19807. }
  19808. return oldValue.CreatorID, nil
  19809. }
  19810. // ClearCreatorID clears the value of the "creator_id" field.
  19811. func (m *SopTaskMutation) ClearCreatorID() {
  19812. m.creator_id = nil
  19813. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  19814. }
  19815. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  19816. func (m *SopTaskMutation) CreatorIDCleared() bool {
  19817. _, ok := m.clearedFields[soptask.FieldCreatorID]
  19818. return ok
  19819. }
  19820. // ResetCreatorID resets all changes to the "creator_id" field.
  19821. func (m *SopTaskMutation) ResetCreatorID() {
  19822. m.creator_id = nil
  19823. delete(m.clearedFields, soptask.FieldCreatorID)
  19824. }
  19825. // SetOrganizationID sets the "organization_id" field.
  19826. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  19827. m.organization_id = &u
  19828. m.addorganization_id = nil
  19829. }
  19830. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19831. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  19832. v := m.organization_id
  19833. if v == nil {
  19834. return
  19835. }
  19836. return *v, true
  19837. }
  19838. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  19839. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19841. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19842. if !m.op.Is(OpUpdateOne) {
  19843. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19844. }
  19845. if m.id == nil || m.oldValue == nil {
  19846. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19847. }
  19848. oldValue, err := m.oldValue(ctx)
  19849. if err != nil {
  19850. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19851. }
  19852. return oldValue.OrganizationID, nil
  19853. }
  19854. // AddOrganizationID adds u to the "organization_id" field.
  19855. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  19856. if m.addorganization_id != nil {
  19857. *m.addorganization_id += u
  19858. } else {
  19859. m.addorganization_id = &u
  19860. }
  19861. }
  19862. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19863. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  19864. v := m.addorganization_id
  19865. if v == nil {
  19866. return
  19867. }
  19868. return *v, true
  19869. }
  19870. // ClearOrganizationID clears the value of the "organization_id" field.
  19871. func (m *SopTaskMutation) ClearOrganizationID() {
  19872. m.organization_id = nil
  19873. m.addorganization_id = nil
  19874. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  19875. }
  19876. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19877. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  19878. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  19879. return ok
  19880. }
  19881. // ResetOrganizationID resets all changes to the "organization_id" field.
  19882. func (m *SopTaskMutation) ResetOrganizationID() {
  19883. m.organization_id = nil
  19884. m.addorganization_id = nil
  19885. delete(m.clearedFields, soptask.FieldOrganizationID)
  19886. }
  19887. // SetToken sets the "token" field.
  19888. func (m *SopTaskMutation) SetToken(s []string) {
  19889. m.token = &s
  19890. m.appendtoken = nil
  19891. }
  19892. // Token returns the value of the "token" field in the mutation.
  19893. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  19894. v := m.token
  19895. if v == nil {
  19896. return
  19897. }
  19898. return *v, true
  19899. }
  19900. // OldToken returns the old "token" field's value of the SopTask entity.
  19901. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19903. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  19904. if !m.op.Is(OpUpdateOne) {
  19905. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  19906. }
  19907. if m.id == nil || m.oldValue == nil {
  19908. return v, errors.New("OldToken requires an ID field in the mutation")
  19909. }
  19910. oldValue, err := m.oldValue(ctx)
  19911. if err != nil {
  19912. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  19913. }
  19914. return oldValue.Token, nil
  19915. }
  19916. // AppendToken adds s to the "token" field.
  19917. func (m *SopTaskMutation) AppendToken(s []string) {
  19918. m.appendtoken = append(m.appendtoken, s...)
  19919. }
  19920. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  19921. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  19922. if len(m.appendtoken) == 0 {
  19923. return nil, false
  19924. }
  19925. return m.appendtoken, true
  19926. }
  19927. // ClearToken clears the value of the "token" field.
  19928. func (m *SopTaskMutation) ClearToken() {
  19929. m.token = nil
  19930. m.appendtoken = nil
  19931. m.clearedFields[soptask.FieldToken] = struct{}{}
  19932. }
  19933. // TokenCleared returns if the "token" field was cleared in this mutation.
  19934. func (m *SopTaskMutation) TokenCleared() bool {
  19935. _, ok := m.clearedFields[soptask.FieldToken]
  19936. return ok
  19937. }
  19938. // ResetToken resets all changes to the "token" field.
  19939. func (m *SopTaskMutation) ResetToken() {
  19940. m.token = nil
  19941. m.appendtoken = nil
  19942. delete(m.clearedFields, soptask.FieldToken)
  19943. }
  19944. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  19945. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  19946. if m.task_stages == nil {
  19947. m.task_stages = make(map[uint64]struct{})
  19948. }
  19949. for i := range ids {
  19950. m.task_stages[ids[i]] = struct{}{}
  19951. }
  19952. }
  19953. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  19954. func (m *SopTaskMutation) ClearTaskStages() {
  19955. m.clearedtask_stages = true
  19956. }
  19957. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  19958. func (m *SopTaskMutation) TaskStagesCleared() bool {
  19959. return m.clearedtask_stages
  19960. }
  19961. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  19962. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  19963. if m.removedtask_stages == nil {
  19964. m.removedtask_stages = make(map[uint64]struct{})
  19965. }
  19966. for i := range ids {
  19967. delete(m.task_stages, ids[i])
  19968. m.removedtask_stages[ids[i]] = struct{}{}
  19969. }
  19970. }
  19971. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  19972. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  19973. for id := range m.removedtask_stages {
  19974. ids = append(ids, id)
  19975. }
  19976. return
  19977. }
  19978. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  19979. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  19980. for id := range m.task_stages {
  19981. ids = append(ids, id)
  19982. }
  19983. return
  19984. }
  19985. // ResetTaskStages resets all changes to the "task_stages" edge.
  19986. func (m *SopTaskMutation) ResetTaskStages() {
  19987. m.task_stages = nil
  19988. m.clearedtask_stages = false
  19989. m.removedtask_stages = nil
  19990. }
  19991. // Where appends a list predicates to the SopTaskMutation builder.
  19992. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  19993. m.predicates = append(m.predicates, ps...)
  19994. }
  19995. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  19996. // users can use type-assertion to append predicates that do not depend on any generated package.
  19997. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  19998. p := make([]predicate.SopTask, len(ps))
  19999. for i := range ps {
  20000. p[i] = ps[i]
  20001. }
  20002. m.Where(p...)
  20003. }
  20004. // Op returns the operation name.
  20005. func (m *SopTaskMutation) Op() Op {
  20006. return m.op
  20007. }
  20008. // SetOp allows setting the mutation operation.
  20009. func (m *SopTaskMutation) SetOp(op Op) {
  20010. m.op = op
  20011. }
  20012. // Type returns the node type of this mutation (SopTask).
  20013. func (m *SopTaskMutation) Type() string {
  20014. return m.typ
  20015. }
  20016. // Fields returns all fields that were changed during this mutation. Note that in
  20017. // order to get all numeric fields that were incremented/decremented, call
  20018. // AddedFields().
  20019. func (m *SopTaskMutation) Fields() []string {
  20020. fields := make([]string, 0, 12)
  20021. if m.created_at != nil {
  20022. fields = append(fields, soptask.FieldCreatedAt)
  20023. }
  20024. if m.updated_at != nil {
  20025. fields = append(fields, soptask.FieldUpdatedAt)
  20026. }
  20027. if m.status != nil {
  20028. fields = append(fields, soptask.FieldStatus)
  20029. }
  20030. if m.deleted_at != nil {
  20031. fields = append(fields, soptask.FieldDeletedAt)
  20032. }
  20033. if m.name != nil {
  20034. fields = append(fields, soptask.FieldName)
  20035. }
  20036. if m.bot_wxid_list != nil {
  20037. fields = append(fields, soptask.FieldBotWxidList)
  20038. }
  20039. if m._type != nil {
  20040. fields = append(fields, soptask.FieldType)
  20041. }
  20042. if m.plan_start_time != nil {
  20043. fields = append(fields, soptask.FieldPlanStartTime)
  20044. }
  20045. if m.plan_end_time != nil {
  20046. fields = append(fields, soptask.FieldPlanEndTime)
  20047. }
  20048. if m.creator_id != nil {
  20049. fields = append(fields, soptask.FieldCreatorID)
  20050. }
  20051. if m.organization_id != nil {
  20052. fields = append(fields, soptask.FieldOrganizationID)
  20053. }
  20054. if m.token != nil {
  20055. fields = append(fields, soptask.FieldToken)
  20056. }
  20057. return fields
  20058. }
  20059. // Field returns the value of a field with the given name. The second boolean
  20060. // return value indicates that this field was not set, or was not defined in the
  20061. // schema.
  20062. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  20063. switch name {
  20064. case soptask.FieldCreatedAt:
  20065. return m.CreatedAt()
  20066. case soptask.FieldUpdatedAt:
  20067. return m.UpdatedAt()
  20068. case soptask.FieldStatus:
  20069. return m.Status()
  20070. case soptask.FieldDeletedAt:
  20071. return m.DeletedAt()
  20072. case soptask.FieldName:
  20073. return m.Name()
  20074. case soptask.FieldBotWxidList:
  20075. return m.BotWxidList()
  20076. case soptask.FieldType:
  20077. return m.GetType()
  20078. case soptask.FieldPlanStartTime:
  20079. return m.PlanStartTime()
  20080. case soptask.FieldPlanEndTime:
  20081. return m.PlanEndTime()
  20082. case soptask.FieldCreatorID:
  20083. return m.CreatorID()
  20084. case soptask.FieldOrganizationID:
  20085. return m.OrganizationID()
  20086. case soptask.FieldToken:
  20087. return m.Token()
  20088. }
  20089. return nil, false
  20090. }
  20091. // OldField returns the old value of the field from the database. An error is
  20092. // returned if the mutation operation is not UpdateOne, or the query to the
  20093. // database failed.
  20094. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20095. switch name {
  20096. case soptask.FieldCreatedAt:
  20097. return m.OldCreatedAt(ctx)
  20098. case soptask.FieldUpdatedAt:
  20099. return m.OldUpdatedAt(ctx)
  20100. case soptask.FieldStatus:
  20101. return m.OldStatus(ctx)
  20102. case soptask.FieldDeletedAt:
  20103. return m.OldDeletedAt(ctx)
  20104. case soptask.FieldName:
  20105. return m.OldName(ctx)
  20106. case soptask.FieldBotWxidList:
  20107. return m.OldBotWxidList(ctx)
  20108. case soptask.FieldType:
  20109. return m.OldType(ctx)
  20110. case soptask.FieldPlanStartTime:
  20111. return m.OldPlanStartTime(ctx)
  20112. case soptask.FieldPlanEndTime:
  20113. return m.OldPlanEndTime(ctx)
  20114. case soptask.FieldCreatorID:
  20115. return m.OldCreatorID(ctx)
  20116. case soptask.FieldOrganizationID:
  20117. return m.OldOrganizationID(ctx)
  20118. case soptask.FieldToken:
  20119. return m.OldToken(ctx)
  20120. }
  20121. return nil, fmt.Errorf("unknown SopTask field %s", name)
  20122. }
  20123. // SetField sets the value of a field with the given name. It returns an error if
  20124. // the field is not defined in the schema, or if the type mismatched the field
  20125. // type.
  20126. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  20127. switch name {
  20128. case soptask.FieldCreatedAt:
  20129. v, ok := value.(time.Time)
  20130. if !ok {
  20131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20132. }
  20133. m.SetCreatedAt(v)
  20134. return nil
  20135. case soptask.FieldUpdatedAt:
  20136. v, ok := value.(time.Time)
  20137. if !ok {
  20138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20139. }
  20140. m.SetUpdatedAt(v)
  20141. return nil
  20142. case soptask.FieldStatus:
  20143. v, ok := value.(uint8)
  20144. if !ok {
  20145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20146. }
  20147. m.SetStatus(v)
  20148. return nil
  20149. case soptask.FieldDeletedAt:
  20150. v, ok := value.(time.Time)
  20151. if !ok {
  20152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20153. }
  20154. m.SetDeletedAt(v)
  20155. return nil
  20156. case soptask.FieldName:
  20157. v, ok := value.(string)
  20158. if !ok {
  20159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20160. }
  20161. m.SetName(v)
  20162. return nil
  20163. case soptask.FieldBotWxidList:
  20164. v, ok := value.([]string)
  20165. if !ok {
  20166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20167. }
  20168. m.SetBotWxidList(v)
  20169. return nil
  20170. case soptask.FieldType:
  20171. v, ok := value.(int)
  20172. if !ok {
  20173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20174. }
  20175. m.SetType(v)
  20176. return nil
  20177. case soptask.FieldPlanStartTime:
  20178. v, ok := value.(time.Time)
  20179. if !ok {
  20180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20181. }
  20182. m.SetPlanStartTime(v)
  20183. return nil
  20184. case soptask.FieldPlanEndTime:
  20185. v, ok := value.(time.Time)
  20186. if !ok {
  20187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20188. }
  20189. m.SetPlanEndTime(v)
  20190. return nil
  20191. case soptask.FieldCreatorID:
  20192. v, ok := value.(string)
  20193. if !ok {
  20194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20195. }
  20196. m.SetCreatorID(v)
  20197. return nil
  20198. case soptask.FieldOrganizationID:
  20199. v, ok := value.(uint64)
  20200. if !ok {
  20201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20202. }
  20203. m.SetOrganizationID(v)
  20204. return nil
  20205. case soptask.FieldToken:
  20206. v, ok := value.([]string)
  20207. if !ok {
  20208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20209. }
  20210. m.SetToken(v)
  20211. return nil
  20212. }
  20213. return fmt.Errorf("unknown SopTask field %s", name)
  20214. }
  20215. // AddedFields returns all numeric fields that were incremented/decremented during
  20216. // this mutation.
  20217. func (m *SopTaskMutation) AddedFields() []string {
  20218. var fields []string
  20219. if m.addstatus != nil {
  20220. fields = append(fields, soptask.FieldStatus)
  20221. }
  20222. if m.add_type != nil {
  20223. fields = append(fields, soptask.FieldType)
  20224. }
  20225. if m.addorganization_id != nil {
  20226. fields = append(fields, soptask.FieldOrganizationID)
  20227. }
  20228. return fields
  20229. }
  20230. // AddedField returns the numeric value that was incremented/decremented on a field
  20231. // with the given name. The second boolean return value indicates that this field
  20232. // was not set, or was not defined in the schema.
  20233. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  20234. switch name {
  20235. case soptask.FieldStatus:
  20236. return m.AddedStatus()
  20237. case soptask.FieldType:
  20238. return m.AddedType()
  20239. case soptask.FieldOrganizationID:
  20240. return m.AddedOrganizationID()
  20241. }
  20242. return nil, false
  20243. }
  20244. // AddField adds the value to the field with the given name. It returns an error if
  20245. // the field is not defined in the schema, or if the type mismatched the field
  20246. // type.
  20247. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  20248. switch name {
  20249. case soptask.FieldStatus:
  20250. v, ok := value.(int8)
  20251. if !ok {
  20252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20253. }
  20254. m.AddStatus(v)
  20255. return nil
  20256. case soptask.FieldType:
  20257. v, ok := value.(int)
  20258. if !ok {
  20259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20260. }
  20261. m.AddType(v)
  20262. return nil
  20263. case soptask.FieldOrganizationID:
  20264. v, ok := value.(int64)
  20265. if !ok {
  20266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20267. }
  20268. m.AddOrganizationID(v)
  20269. return nil
  20270. }
  20271. return fmt.Errorf("unknown SopTask numeric field %s", name)
  20272. }
  20273. // ClearedFields returns all nullable fields that were cleared during this
  20274. // mutation.
  20275. func (m *SopTaskMutation) ClearedFields() []string {
  20276. var fields []string
  20277. if m.FieldCleared(soptask.FieldStatus) {
  20278. fields = append(fields, soptask.FieldStatus)
  20279. }
  20280. if m.FieldCleared(soptask.FieldDeletedAt) {
  20281. fields = append(fields, soptask.FieldDeletedAt)
  20282. }
  20283. if m.FieldCleared(soptask.FieldBotWxidList) {
  20284. fields = append(fields, soptask.FieldBotWxidList)
  20285. }
  20286. if m.FieldCleared(soptask.FieldPlanStartTime) {
  20287. fields = append(fields, soptask.FieldPlanStartTime)
  20288. }
  20289. if m.FieldCleared(soptask.FieldPlanEndTime) {
  20290. fields = append(fields, soptask.FieldPlanEndTime)
  20291. }
  20292. if m.FieldCleared(soptask.FieldCreatorID) {
  20293. fields = append(fields, soptask.FieldCreatorID)
  20294. }
  20295. if m.FieldCleared(soptask.FieldOrganizationID) {
  20296. fields = append(fields, soptask.FieldOrganizationID)
  20297. }
  20298. if m.FieldCleared(soptask.FieldToken) {
  20299. fields = append(fields, soptask.FieldToken)
  20300. }
  20301. return fields
  20302. }
  20303. // FieldCleared returns a boolean indicating if a field with the given name was
  20304. // cleared in this mutation.
  20305. func (m *SopTaskMutation) FieldCleared(name string) bool {
  20306. _, ok := m.clearedFields[name]
  20307. return ok
  20308. }
  20309. // ClearField clears the value of the field with the given name. It returns an
  20310. // error if the field is not defined in the schema.
  20311. func (m *SopTaskMutation) ClearField(name string) error {
  20312. switch name {
  20313. case soptask.FieldStatus:
  20314. m.ClearStatus()
  20315. return nil
  20316. case soptask.FieldDeletedAt:
  20317. m.ClearDeletedAt()
  20318. return nil
  20319. case soptask.FieldBotWxidList:
  20320. m.ClearBotWxidList()
  20321. return nil
  20322. case soptask.FieldPlanStartTime:
  20323. m.ClearPlanStartTime()
  20324. return nil
  20325. case soptask.FieldPlanEndTime:
  20326. m.ClearPlanEndTime()
  20327. return nil
  20328. case soptask.FieldCreatorID:
  20329. m.ClearCreatorID()
  20330. return nil
  20331. case soptask.FieldOrganizationID:
  20332. m.ClearOrganizationID()
  20333. return nil
  20334. case soptask.FieldToken:
  20335. m.ClearToken()
  20336. return nil
  20337. }
  20338. return fmt.Errorf("unknown SopTask nullable field %s", name)
  20339. }
  20340. // ResetField resets all changes in the mutation for the field with the given name.
  20341. // It returns an error if the field is not defined in the schema.
  20342. func (m *SopTaskMutation) ResetField(name string) error {
  20343. switch name {
  20344. case soptask.FieldCreatedAt:
  20345. m.ResetCreatedAt()
  20346. return nil
  20347. case soptask.FieldUpdatedAt:
  20348. m.ResetUpdatedAt()
  20349. return nil
  20350. case soptask.FieldStatus:
  20351. m.ResetStatus()
  20352. return nil
  20353. case soptask.FieldDeletedAt:
  20354. m.ResetDeletedAt()
  20355. return nil
  20356. case soptask.FieldName:
  20357. m.ResetName()
  20358. return nil
  20359. case soptask.FieldBotWxidList:
  20360. m.ResetBotWxidList()
  20361. return nil
  20362. case soptask.FieldType:
  20363. m.ResetType()
  20364. return nil
  20365. case soptask.FieldPlanStartTime:
  20366. m.ResetPlanStartTime()
  20367. return nil
  20368. case soptask.FieldPlanEndTime:
  20369. m.ResetPlanEndTime()
  20370. return nil
  20371. case soptask.FieldCreatorID:
  20372. m.ResetCreatorID()
  20373. return nil
  20374. case soptask.FieldOrganizationID:
  20375. m.ResetOrganizationID()
  20376. return nil
  20377. case soptask.FieldToken:
  20378. m.ResetToken()
  20379. return nil
  20380. }
  20381. return fmt.Errorf("unknown SopTask field %s", name)
  20382. }
  20383. // AddedEdges returns all edge names that were set/added in this mutation.
  20384. func (m *SopTaskMutation) AddedEdges() []string {
  20385. edges := make([]string, 0, 1)
  20386. if m.task_stages != nil {
  20387. edges = append(edges, soptask.EdgeTaskStages)
  20388. }
  20389. return edges
  20390. }
  20391. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20392. // name in this mutation.
  20393. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  20394. switch name {
  20395. case soptask.EdgeTaskStages:
  20396. ids := make([]ent.Value, 0, len(m.task_stages))
  20397. for id := range m.task_stages {
  20398. ids = append(ids, id)
  20399. }
  20400. return ids
  20401. }
  20402. return nil
  20403. }
  20404. // RemovedEdges returns all edge names that were removed in this mutation.
  20405. func (m *SopTaskMutation) RemovedEdges() []string {
  20406. edges := make([]string, 0, 1)
  20407. if m.removedtask_stages != nil {
  20408. edges = append(edges, soptask.EdgeTaskStages)
  20409. }
  20410. return edges
  20411. }
  20412. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20413. // the given name in this mutation.
  20414. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  20415. switch name {
  20416. case soptask.EdgeTaskStages:
  20417. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  20418. for id := range m.removedtask_stages {
  20419. ids = append(ids, id)
  20420. }
  20421. return ids
  20422. }
  20423. return nil
  20424. }
  20425. // ClearedEdges returns all edge names that were cleared in this mutation.
  20426. func (m *SopTaskMutation) ClearedEdges() []string {
  20427. edges := make([]string, 0, 1)
  20428. if m.clearedtask_stages {
  20429. edges = append(edges, soptask.EdgeTaskStages)
  20430. }
  20431. return edges
  20432. }
  20433. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20434. // was cleared in this mutation.
  20435. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  20436. switch name {
  20437. case soptask.EdgeTaskStages:
  20438. return m.clearedtask_stages
  20439. }
  20440. return false
  20441. }
  20442. // ClearEdge clears the value of the edge with the given name. It returns an error
  20443. // if that edge is not defined in the schema.
  20444. func (m *SopTaskMutation) ClearEdge(name string) error {
  20445. switch name {
  20446. }
  20447. return fmt.Errorf("unknown SopTask unique edge %s", name)
  20448. }
  20449. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20450. // It returns an error if the edge is not defined in the schema.
  20451. func (m *SopTaskMutation) ResetEdge(name string) error {
  20452. switch name {
  20453. case soptask.EdgeTaskStages:
  20454. m.ResetTaskStages()
  20455. return nil
  20456. }
  20457. return fmt.Errorf("unknown SopTask edge %s", name)
  20458. }
  20459. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  20460. type TokenMutation struct {
  20461. config
  20462. op Op
  20463. typ string
  20464. id *uint64
  20465. created_at *time.Time
  20466. updated_at *time.Time
  20467. deleted_at *time.Time
  20468. expire_at *time.Time
  20469. token *string
  20470. mac *string
  20471. organization_id *uint64
  20472. addorganization_id *int64
  20473. custom_agent_base *string
  20474. custom_agent_key *string
  20475. openai_base *string
  20476. openai_key *string
  20477. clearedFields map[string]struct{}
  20478. agent *uint64
  20479. clearedagent bool
  20480. done bool
  20481. oldValue func(context.Context) (*Token, error)
  20482. predicates []predicate.Token
  20483. }
  20484. var _ ent.Mutation = (*TokenMutation)(nil)
  20485. // tokenOption allows management of the mutation configuration using functional options.
  20486. type tokenOption func(*TokenMutation)
  20487. // newTokenMutation creates new mutation for the Token entity.
  20488. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  20489. m := &TokenMutation{
  20490. config: c,
  20491. op: op,
  20492. typ: TypeToken,
  20493. clearedFields: make(map[string]struct{}),
  20494. }
  20495. for _, opt := range opts {
  20496. opt(m)
  20497. }
  20498. return m
  20499. }
  20500. // withTokenID sets the ID field of the mutation.
  20501. func withTokenID(id uint64) tokenOption {
  20502. return func(m *TokenMutation) {
  20503. var (
  20504. err error
  20505. once sync.Once
  20506. value *Token
  20507. )
  20508. m.oldValue = func(ctx context.Context) (*Token, error) {
  20509. once.Do(func() {
  20510. if m.done {
  20511. err = errors.New("querying old values post mutation is not allowed")
  20512. } else {
  20513. value, err = m.Client().Token.Get(ctx, id)
  20514. }
  20515. })
  20516. return value, err
  20517. }
  20518. m.id = &id
  20519. }
  20520. }
  20521. // withToken sets the old Token of the mutation.
  20522. func withToken(node *Token) tokenOption {
  20523. return func(m *TokenMutation) {
  20524. m.oldValue = func(context.Context) (*Token, error) {
  20525. return node, nil
  20526. }
  20527. m.id = &node.ID
  20528. }
  20529. }
  20530. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20531. // executed in a transaction (ent.Tx), a transactional client is returned.
  20532. func (m TokenMutation) Client() *Client {
  20533. client := &Client{config: m.config}
  20534. client.init()
  20535. return client
  20536. }
  20537. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20538. // it returns an error otherwise.
  20539. func (m TokenMutation) Tx() (*Tx, error) {
  20540. if _, ok := m.driver.(*txDriver); !ok {
  20541. return nil, errors.New("ent: mutation is not running in a transaction")
  20542. }
  20543. tx := &Tx{config: m.config}
  20544. tx.init()
  20545. return tx, nil
  20546. }
  20547. // SetID sets the value of the id field. Note that this
  20548. // operation is only accepted on creation of Token entities.
  20549. func (m *TokenMutation) SetID(id uint64) {
  20550. m.id = &id
  20551. }
  20552. // ID returns the ID value in the mutation. Note that the ID is only available
  20553. // if it was provided to the builder or after it was returned from the database.
  20554. func (m *TokenMutation) ID() (id uint64, exists bool) {
  20555. if m.id == nil {
  20556. return
  20557. }
  20558. return *m.id, true
  20559. }
  20560. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20561. // That means, if the mutation is applied within a transaction with an isolation level such
  20562. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20563. // or updated by the mutation.
  20564. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  20565. switch {
  20566. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20567. id, exists := m.ID()
  20568. if exists {
  20569. return []uint64{id}, nil
  20570. }
  20571. fallthrough
  20572. case m.op.Is(OpUpdate | OpDelete):
  20573. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  20574. default:
  20575. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20576. }
  20577. }
  20578. // SetCreatedAt sets the "created_at" field.
  20579. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  20580. m.created_at = &t
  20581. }
  20582. // CreatedAt returns the value of the "created_at" field in the mutation.
  20583. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  20584. v := m.created_at
  20585. if v == nil {
  20586. return
  20587. }
  20588. return *v, true
  20589. }
  20590. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  20591. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20593. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20594. if !m.op.Is(OpUpdateOne) {
  20595. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20596. }
  20597. if m.id == nil || m.oldValue == nil {
  20598. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20599. }
  20600. oldValue, err := m.oldValue(ctx)
  20601. if err != nil {
  20602. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20603. }
  20604. return oldValue.CreatedAt, nil
  20605. }
  20606. // ResetCreatedAt resets all changes to the "created_at" field.
  20607. func (m *TokenMutation) ResetCreatedAt() {
  20608. m.created_at = nil
  20609. }
  20610. // SetUpdatedAt sets the "updated_at" field.
  20611. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  20612. m.updated_at = &t
  20613. }
  20614. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20615. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  20616. v := m.updated_at
  20617. if v == nil {
  20618. return
  20619. }
  20620. return *v, true
  20621. }
  20622. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  20623. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20625. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20626. if !m.op.Is(OpUpdateOne) {
  20627. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20628. }
  20629. if m.id == nil || m.oldValue == nil {
  20630. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20631. }
  20632. oldValue, err := m.oldValue(ctx)
  20633. if err != nil {
  20634. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20635. }
  20636. return oldValue.UpdatedAt, nil
  20637. }
  20638. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20639. func (m *TokenMutation) ResetUpdatedAt() {
  20640. m.updated_at = nil
  20641. }
  20642. // SetDeletedAt sets the "deleted_at" field.
  20643. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  20644. m.deleted_at = &t
  20645. }
  20646. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20647. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  20648. v := m.deleted_at
  20649. if v == nil {
  20650. return
  20651. }
  20652. return *v, true
  20653. }
  20654. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  20655. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20657. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20658. if !m.op.Is(OpUpdateOne) {
  20659. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20660. }
  20661. if m.id == nil || m.oldValue == nil {
  20662. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20663. }
  20664. oldValue, err := m.oldValue(ctx)
  20665. if err != nil {
  20666. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20667. }
  20668. return oldValue.DeletedAt, nil
  20669. }
  20670. // ClearDeletedAt clears the value of the "deleted_at" field.
  20671. func (m *TokenMutation) ClearDeletedAt() {
  20672. m.deleted_at = nil
  20673. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  20674. }
  20675. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20676. func (m *TokenMutation) DeletedAtCleared() bool {
  20677. _, ok := m.clearedFields[token.FieldDeletedAt]
  20678. return ok
  20679. }
  20680. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20681. func (m *TokenMutation) ResetDeletedAt() {
  20682. m.deleted_at = nil
  20683. delete(m.clearedFields, token.FieldDeletedAt)
  20684. }
  20685. // SetExpireAt sets the "expire_at" field.
  20686. func (m *TokenMutation) SetExpireAt(t time.Time) {
  20687. m.expire_at = &t
  20688. }
  20689. // ExpireAt returns the value of the "expire_at" field in the mutation.
  20690. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  20691. v := m.expire_at
  20692. if v == nil {
  20693. return
  20694. }
  20695. return *v, true
  20696. }
  20697. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  20698. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20700. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  20701. if !m.op.Is(OpUpdateOne) {
  20702. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  20703. }
  20704. if m.id == nil || m.oldValue == nil {
  20705. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  20706. }
  20707. oldValue, err := m.oldValue(ctx)
  20708. if err != nil {
  20709. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  20710. }
  20711. return oldValue.ExpireAt, nil
  20712. }
  20713. // ClearExpireAt clears the value of the "expire_at" field.
  20714. func (m *TokenMutation) ClearExpireAt() {
  20715. m.expire_at = nil
  20716. m.clearedFields[token.FieldExpireAt] = struct{}{}
  20717. }
  20718. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  20719. func (m *TokenMutation) ExpireAtCleared() bool {
  20720. _, ok := m.clearedFields[token.FieldExpireAt]
  20721. return ok
  20722. }
  20723. // ResetExpireAt resets all changes to the "expire_at" field.
  20724. func (m *TokenMutation) ResetExpireAt() {
  20725. m.expire_at = nil
  20726. delete(m.clearedFields, token.FieldExpireAt)
  20727. }
  20728. // SetToken sets the "token" field.
  20729. func (m *TokenMutation) SetToken(s string) {
  20730. m.token = &s
  20731. }
  20732. // Token returns the value of the "token" field in the mutation.
  20733. func (m *TokenMutation) Token() (r string, exists bool) {
  20734. v := m.token
  20735. if v == nil {
  20736. return
  20737. }
  20738. return *v, true
  20739. }
  20740. // OldToken returns the old "token" field's value of the Token entity.
  20741. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20743. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  20744. if !m.op.Is(OpUpdateOne) {
  20745. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  20746. }
  20747. if m.id == nil || m.oldValue == nil {
  20748. return v, errors.New("OldToken requires an ID field in the mutation")
  20749. }
  20750. oldValue, err := m.oldValue(ctx)
  20751. if err != nil {
  20752. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  20753. }
  20754. return oldValue.Token, nil
  20755. }
  20756. // ClearToken clears the value of the "token" field.
  20757. func (m *TokenMutation) ClearToken() {
  20758. m.token = nil
  20759. m.clearedFields[token.FieldToken] = struct{}{}
  20760. }
  20761. // TokenCleared returns if the "token" field was cleared in this mutation.
  20762. func (m *TokenMutation) TokenCleared() bool {
  20763. _, ok := m.clearedFields[token.FieldToken]
  20764. return ok
  20765. }
  20766. // ResetToken resets all changes to the "token" field.
  20767. func (m *TokenMutation) ResetToken() {
  20768. m.token = nil
  20769. delete(m.clearedFields, token.FieldToken)
  20770. }
  20771. // SetMAC sets the "mac" field.
  20772. func (m *TokenMutation) SetMAC(s string) {
  20773. m.mac = &s
  20774. }
  20775. // MAC returns the value of the "mac" field in the mutation.
  20776. func (m *TokenMutation) MAC() (r string, exists bool) {
  20777. v := m.mac
  20778. if v == nil {
  20779. return
  20780. }
  20781. return *v, true
  20782. }
  20783. // OldMAC returns the old "mac" field's value of the Token entity.
  20784. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20786. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  20787. if !m.op.Is(OpUpdateOne) {
  20788. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  20789. }
  20790. if m.id == nil || m.oldValue == nil {
  20791. return v, errors.New("OldMAC requires an ID field in the mutation")
  20792. }
  20793. oldValue, err := m.oldValue(ctx)
  20794. if err != nil {
  20795. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  20796. }
  20797. return oldValue.MAC, nil
  20798. }
  20799. // ClearMAC clears the value of the "mac" field.
  20800. func (m *TokenMutation) ClearMAC() {
  20801. m.mac = nil
  20802. m.clearedFields[token.FieldMAC] = struct{}{}
  20803. }
  20804. // MACCleared returns if the "mac" field was cleared in this mutation.
  20805. func (m *TokenMutation) MACCleared() bool {
  20806. _, ok := m.clearedFields[token.FieldMAC]
  20807. return ok
  20808. }
  20809. // ResetMAC resets all changes to the "mac" field.
  20810. func (m *TokenMutation) ResetMAC() {
  20811. m.mac = nil
  20812. delete(m.clearedFields, token.FieldMAC)
  20813. }
  20814. // SetOrganizationID sets the "organization_id" field.
  20815. func (m *TokenMutation) SetOrganizationID(u uint64) {
  20816. m.organization_id = &u
  20817. m.addorganization_id = nil
  20818. }
  20819. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20820. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  20821. v := m.organization_id
  20822. if v == nil {
  20823. return
  20824. }
  20825. return *v, true
  20826. }
  20827. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  20828. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20830. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20831. if !m.op.Is(OpUpdateOne) {
  20832. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20833. }
  20834. if m.id == nil || m.oldValue == nil {
  20835. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20836. }
  20837. oldValue, err := m.oldValue(ctx)
  20838. if err != nil {
  20839. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20840. }
  20841. return oldValue.OrganizationID, nil
  20842. }
  20843. // AddOrganizationID adds u to the "organization_id" field.
  20844. func (m *TokenMutation) AddOrganizationID(u int64) {
  20845. if m.addorganization_id != nil {
  20846. *m.addorganization_id += u
  20847. } else {
  20848. m.addorganization_id = &u
  20849. }
  20850. }
  20851. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20852. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  20853. v := m.addorganization_id
  20854. if v == nil {
  20855. return
  20856. }
  20857. return *v, true
  20858. }
  20859. // ResetOrganizationID resets all changes to the "organization_id" field.
  20860. func (m *TokenMutation) ResetOrganizationID() {
  20861. m.organization_id = nil
  20862. m.addorganization_id = nil
  20863. }
  20864. // SetAgentID sets the "agent_id" field.
  20865. func (m *TokenMutation) SetAgentID(u uint64) {
  20866. m.agent = &u
  20867. }
  20868. // AgentID returns the value of the "agent_id" field in the mutation.
  20869. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  20870. v := m.agent
  20871. if v == nil {
  20872. return
  20873. }
  20874. return *v, true
  20875. }
  20876. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  20877. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20879. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  20880. if !m.op.Is(OpUpdateOne) {
  20881. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  20882. }
  20883. if m.id == nil || m.oldValue == nil {
  20884. return v, errors.New("OldAgentID requires an ID field in the mutation")
  20885. }
  20886. oldValue, err := m.oldValue(ctx)
  20887. if err != nil {
  20888. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  20889. }
  20890. return oldValue.AgentID, nil
  20891. }
  20892. // ResetAgentID resets all changes to the "agent_id" field.
  20893. func (m *TokenMutation) ResetAgentID() {
  20894. m.agent = nil
  20895. }
  20896. // SetCustomAgentBase sets the "custom_agent_base" field.
  20897. func (m *TokenMutation) SetCustomAgentBase(s string) {
  20898. m.custom_agent_base = &s
  20899. }
  20900. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  20901. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  20902. v := m.custom_agent_base
  20903. if v == nil {
  20904. return
  20905. }
  20906. return *v, true
  20907. }
  20908. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  20909. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20911. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  20912. if !m.op.Is(OpUpdateOne) {
  20913. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  20914. }
  20915. if m.id == nil || m.oldValue == nil {
  20916. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  20917. }
  20918. oldValue, err := m.oldValue(ctx)
  20919. if err != nil {
  20920. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  20921. }
  20922. return oldValue.CustomAgentBase, nil
  20923. }
  20924. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  20925. func (m *TokenMutation) ClearCustomAgentBase() {
  20926. m.custom_agent_base = nil
  20927. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  20928. }
  20929. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  20930. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  20931. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  20932. return ok
  20933. }
  20934. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  20935. func (m *TokenMutation) ResetCustomAgentBase() {
  20936. m.custom_agent_base = nil
  20937. delete(m.clearedFields, token.FieldCustomAgentBase)
  20938. }
  20939. // SetCustomAgentKey sets the "custom_agent_key" field.
  20940. func (m *TokenMutation) SetCustomAgentKey(s string) {
  20941. m.custom_agent_key = &s
  20942. }
  20943. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  20944. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  20945. v := m.custom_agent_key
  20946. if v == nil {
  20947. return
  20948. }
  20949. return *v, true
  20950. }
  20951. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  20952. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20954. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  20955. if !m.op.Is(OpUpdateOne) {
  20956. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  20957. }
  20958. if m.id == nil || m.oldValue == nil {
  20959. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  20960. }
  20961. oldValue, err := m.oldValue(ctx)
  20962. if err != nil {
  20963. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  20964. }
  20965. return oldValue.CustomAgentKey, nil
  20966. }
  20967. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  20968. func (m *TokenMutation) ClearCustomAgentKey() {
  20969. m.custom_agent_key = nil
  20970. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  20971. }
  20972. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  20973. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  20974. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  20975. return ok
  20976. }
  20977. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  20978. func (m *TokenMutation) ResetCustomAgentKey() {
  20979. m.custom_agent_key = nil
  20980. delete(m.clearedFields, token.FieldCustomAgentKey)
  20981. }
  20982. // SetOpenaiBase sets the "openai_base" field.
  20983. func (m *TokenMutation) SetOpenaiBase(s string) {
  20984. m.openai_base = &s
  20985. }
  20986. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  20987. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  20988. v := m.openai_base
  20989. if v == nil {
  20990. return
  20991. }
  20992. return *v, true
  20993. }
  20994. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  20995. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20997. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  20998. if !m.op.Is(OpUpdateOne) {
  20999. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  21000. }
  21001. if m.id == nil || m.oldValue == nil {
  21002. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  21003. }
  21004. oldValue, err := m.oldValue(ctx)
  21005. if err != nil {
  21006. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  21007. }
  21008. return oldValue.OpenaiBase, nil
  21009. }
  21010. // ClearOpenaiBase clears the value of the "openai_base" field.
  21011. func (m *TokenMutation) ClearOpenaiBase() {
  21012. m.openai_base = nil
  21013. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  21014. }
  21015. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  21016. func (m *TokenMutation) OpenaiBaseCleared() bool {
  21017. _, ok := m.clearedFields[token.FieldOpenaiBase]
  21018. return ok
  21019. }
  21020. // ResetOpenaiBase resets all changes to the "openai_base" field.
  21021. func (m *TokenMutation) ResetOpenaiBase() {
  21022. m.openai_base = nil
  21023. delete(m.clearedFields, token.FieldOpenaiBase)
  21024. }
  21025. // SetOpenaiKey sets the "openai_key" field.
  21026. func (m *TokenMutation) SetOpenaiKey(s string) {
  21027. m.openai_key = &s
  21028. }
  21029. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  21030. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  21031. v := m.openai_key
  21032. if v == nil {
  21033. return
  21034. }
  21035. return *v, true
  21036. }
  21037. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  21038. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21040. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  21041. if !m.op.Is(OpUpdateOne) {
  21042. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  21043. }
  21044. if m.id == nil || m.oldValue == nil {
  21045. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  21046. }
  21047. oldValue, err := m.oldValue(ctx)
  21048. if err != nil {
  21049. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  21050. }
  21051. return oldValue.OpenaiKey, nil
  21052. }
  21053. // ClearOpenaiKey clears the value of the "openai_key" field.
  21054. func (m *TokenMutation) ClearOpenaiKey() {
  21055. m.openai_key = nil
  21056. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  21057. }
  21058. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  21059. func (m *TokenMutation) OpenaiKeyCleared() bool {
  21060. _, ok := m.clearedFields[token.FieldOpenaiKey]
  21061. return ok
  21062. }
  21063. // ResetOpenaiKey resets all changes to the "openai_key" field.
  21064. func (m *TokenMutation) ResetOpenaiKey() {
  21065. m.openai_key = nil
  21066. delete(m.clearedFields, token.FieldOpenaiKey)
  21067. }
  21068. // ClearAgent clears the "agent" edge to the Agent entity.
  21069. func (m *TokenMutation) ClearAgent() {
  21070. m.clearedagent = true
  21071. m.clearedFields[token.FieldAgentID] = struct{}{}
  21072. }
  21073. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  21074. func (m *TokenMutation) AgentCleared() bool {
  21075. return m.clearedagent
  21076. }
  21077. // AgentIDs returns the "agent" edge IDs in the mutation.
  21078. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21079. // AgentID instead. It exists only for internal usage by the builders.
  21080. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  21081. if id := m.agent; id != nil {
  21082. ids = append(ids, *id)
  21083. }
  21084. return
  21085. }
  21086. // ResetAgent resets all changes to the "agent" edge.
  21087. func (m *TokenMutation) ResetAgent() {
  21088. m.agent = nil
  21089. m.clearedagent = false
  21090. }
  21091. // Where appends a list predicates to the TokenMutation builder.
  21092. func (m *TokenMutation) Where(ps ...predicate.Token) {
  21093. m.predicates = append(m.predicates, ps...)
  21094. }
  21095. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  21096. // users can use type-assertion to append predicates that do not depend on any generated package.
  21097. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  21098. p := make([]predicate.Token, len(ps))
  21099. for i := range ps {
  21100. p[i] = ps[i]
  21101. }
  21102. m.Where(p...)
  21103. }
  21104. // Op returns the operation name.
  21105. func (m *TokenMutation) Op() Op {
  21106. return m.op
  21107. }
  21108. // SetOp allows setting the mutation operation.
  21109. func (m *TokenMutation) SetOp(op Op) {
  21110. m.op = op
  21111. }
  21112. // Type returns the node type of this mutation (Token).
  21113. func (m *TokenMutation) Type() string {
  21114. return m.typ
  21115. }
  21116. // Fields returns all fields that were changed during this mutation. Note that in
  21117. // order to get all numeric fields that were incremented/decremented, call
  21118. // AddedFields().
  21119. func (m *TokenMutation) Fields() []string {
  21120. fields := make([]string, 0, 12)
  21121. if m.created_at != nil {
  21122. fields = append(fields, token.FieldCreatedAt)
  21123. }
  21124. if m.updated_at != nil {
  21125. fields = append(fields, token.FieldUpdatedAt)
  21126. }
  21127. if m.deleted_at != nil {
  21128. fields = append(fields, token.FieldDeletedAt)
  21129. }
  21130. if m.expire_at != nil {
  21131. fields = append(fields, token.FieldExpireAt)
  21132. }
  21133. if m.token != nil {
  21134. fields = append(fields, token.FieldToken)
  21135. }
  21136. if m.mac != nil {
  21137. fields = append(fields, token.FieldMAC)
  21138. }
  21139. if m.organization_id != nil {
  21140. fields = append(fields, token.FieldOrganizationID)
  21141. }
  21142. if m.agent != nil {
  21143. fields = append(fields, token.FieldAgentID)
  21144. }
  21145. if m.custom_agent_base != nil {
  21146. fields = append(fields, token.FieldCustomAgentBase)
  21147. }
  21148. if m.custom_agent_key != nil {
  21149. fields = append(fields, token.FieldCustomAgentKey)
  21150. }
  21151. if m.openai_base != nil {
  21152. fields = append(fields, token.FieldOpenaiBase)
  21153. }
  21154. if m.openai_key != nil {
  21155. fields = append(fields, token.FieldOpenaiKey)
  21156. }
  21157. return fields
  21158. }
  21159. // Field returns the value of a field with the given name. The second boolean
  21160. // return value indicates that this field was not set, or was not defined in the
  21161. // schema.
  21162. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  21163. switch name {
  21164. case token.FieldCreatedAt:
  21165. return m.CreatedAt()
  21166. case token.FieldUpdatedAt:
  21167. return m.UpdatedAt()
  21168. case token.FieldDeletedAt:
  21169. return m.DeletedAt()
  21170. case token.FieldExpireAt:
  21171. return m.ExpireAt()
  21172. case token.FieldToken:
  21173. return m.Token()
  21174. case token.FieldMAC:
  21175. return m.MAC()
  21176. case token.FieldOrganizationID:
  21177. return m.OrganizationID()
  21178. case token.FieldAgentID:
  21179. return m.AgentID()
  21180. case token.FieldCustomAgentBase:
  21181. return m.CustomAgentBase()
  21182. case token.FieldCustomAgentKey:
  21183. return m.CustomAgentKey()
  21184. case token.FieldOpenaiBase:
  21185. return m.OpenaiBase()
  21186. case token.FieldOpenaiKey:
  21187. return m.OpenaiKey()
  21188. }
  21189. return nil, false
  21190. }
  21191. // OldField returns the old value of the field from the database. An error is
  21192. // returned if the mutation operation is not UpdateOne, or the query to the
  21193. // database failed.
  21194. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21195. switch name {
  21196. case token.FieldCreatedAt:
  21197. return m.OldCreatedAt(ctx)
  21198. case token.FieldUpdatedAt:
  21199. return m.OldUpdatedAt(ctx)
  21200. case token.FieldDeletedAt:
  21201. return m.OldDeletedAt(ctx)
  21202. case token.FieldExpireAt:
  21203. return m.OldExpireAt(ctx)
  21204. case token.FieldToken:
  21205. return m.OldToken(ctx)
  21206. case token.FieldMAC:
  21207. return m.OldMAC(ctx)
  21208. case token.FieldOrganizationID:
  21209. return m.OldOrganizationID(ctx)
  21210. case token.FieldAgentID:
  21211. return m.OldAgentID(ctx)
  21212. case token.FieldCustomAgentBase:
  21213. return m.OldCustomAgentBase(ctx)
  21214. case token.FieldCustomAgentKey:
  21215. return m.OldCustomAgentKey(ctx)
  21216. case token.FieldOpenaiBase:
  21217. return m.OldOpenaiBase(ctx)
  21218. case token.FieldOpenaiKey:
  21219. return m.OldOpenaiKey(ctx)
  21220. }
  21221. return nil, fmt.Errorf("unknown Token field %s", name)
  21222. }
  21223. // SetField sets the value of a field with the given name. It returns an error if
  21224. // the field is not defined in the schema, or if the type mismatched the field
  21225. // type.
  21226. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  21227. switch name {
  21228. case token.FieldCreatedAt:
  21229. v, ok := value.(time.Time)
  21230. if !ok {
  21231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21232. }
  21233. m.SetCreatedAt(v)
  21234. return nil
  21235. case token.FieldUpdatedAt:
  21236. v, ok := value.(time.Time)
  21237. if !ok {
  21238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21239. }
  21240. m.SetUpdatedAt(v)
  21241. return nil
  21242. case token.FieldDeletedAt:
  21243. v, ok := value.(time.Time)
  21244. if !ok {
  21245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21246. }
  21247. m.SetDeletedAt(v)
  21248. return nil
  21249. case token.FieldExpireAt:
  21250. v, ok := value.(time.Time)
  21251. if !ok {
  21252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21253. }
  21254. m.SetExpireAt(v)
  21255. return nil
  21256. case token.FieldToken:
  21257. v, ok := value.(string)
  21258. if !ok {
  21259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21260. }
  21261. m.SetToken(v)
  21262. return nil
  21263. case token.FieldMAC:
  21264. v, ok := value.(string)
  21265. if !ok {
  21266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21267. }
  21268. m.SetMAC(v)
  21269. return nil
  21270. case token.FieldOrganizationID:
  21271. v, ok := value.(uint64)
  21272. if !ok {
  21273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21274. }
  21275. m.SetOrganizationID(v)
  21276. return nil
  21277. case token.FieldAgentID:
  21278. v, ok := value.(uint64)
  21279. if !ok {
  21280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21281. }
  21282. m.SetAgentID(v)
  21283. return nil
  21284. case token.FieldCustomAgentBase:
  21285. v, ok := value.(string)
  21286. if !ok {
  21287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21288. }
  21289. m.SetCustomAgentBase(v)
  21290. return nil
  21291. case token.FieldCustomAgentKey:
  21292. v, ok := value.(string)
  21293. if !ok {
  21294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21295. }
  21296. m.SetCustomAgentKey(v)
  21297. return nil
  21298. case token.FieldOpenaiBase:
  21299. v, ok := value.(string)
  21300. if !ok {
  21301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21302. }
  21303. m.SetOpenaiBase(v)
  21304. return nil
  21305. case token.FieldOpenaiKey:
  21306. v, ok := value.(string)
  21307. if !ok {
  21308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21309. }
  21310. m.SetOpenaiKey(v)
  21311. return nil
  21312. }
  21313. return fmt.Errorf("unknown Token field %s", name)
  21314. }
  21315. // AddedFields returns all numeric fields that were incremented/decremented during
  21316. // this mutation.
  21317. func (m *TokenMutation) AddedFields() []string {
  21318. var fields []string
  21319. if m.addorganization_id != nil {
  21320. fields = append(fields, token.FieldOrganizationID)
  21321. }
  21322. return fields
  21323. }
  21324. // AddedField returns the numeric value that was incremented/decremented on a field
  21325. // with the given name. The second boolean return value indicates that this field
  21326. // was not set, or was not defined in the schema.
  21327. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  21328. switch name {
  21329. case token.FieldOrganizationID:
  21330. return m.AddedOrganizationID()
  21331. }
  21332. return nil, false
  21333. }
  21334. // AddField adds the value to the field with the given name. It returns an error if
  21335. // the field is not defined in the schema, or if the type mismatched the field
  21336. // type.
  21337. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  21338. switch name {
  21339. case token.FieldOrganizationID:
  21340. v, ok := value.(int64)
  21341. if !ok {
  21342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21343. }
  21344. m.AddOrganizationID(v)
  21345. return nil
  21346. }
  21347. return fmt.Errorf("unknown Token numeric field %s", name)
  21348. }
  21349. // ClearedFields returns all nullable fields that were cleared during this
  21350. // mutation.
  21351. func (m *TokenMutation) ClearedFields() []string {
  21352. var fields []string
  21353. if m.FieldCleared(token.FieldDeletedAt) {
  21354. fields = append(fields, token.FieldDeletedAt)
  21355. }
  21356. if m.FieldCleared(token.FieldExpireAt) {
  21357. fields = append(fields, token.FieldExpireAt)
  21358. }
  21359. if m.FieldCleared(token.FieldToken) {
  21360. fields = append(fields, token.FieldToken)
  21361. }
  21362. if m.FieldCleared(token.FieldMAC) {
  21363. fields = append(fields, token.FieldMAC)
  21364. }
  21365. if m.FieldCleared(token.FieldCustomAgentBase) {
  21366. fields = append(fields, token.FieldCustomAgentBase)
  21367. }
  21368. if m.FieldCleared(token.FieldCustomAgentKey) {
  21369. fields = append(fields, token.FieldCustomAgentKey)
  21370. }
  21371. if m.FieldCleared(token.FieldOpenaiBase) {
  21372. fields = append(fields, token.FieldOpenaiBase)
  21373. }
  21374. if m.FieldCleared(token.FieldOpenaiKey) {
  21375. fields = append(fields, token.FieldOpenaiKey)
  21376. }
  21377. return fields
  21378. }
  21379. // FieldCleared returns a boolean indicating if a field with the given name was
  21380. // cleared in this mutation.
  21381. func (m *TokenMutation) FieldCleared(name string) bool {
  21382. _, ok := m.clearedFields[name]
  21383. return ok
  21384. }
  21385. // ClearField clears the value of the field with the given name. It returns an
  21386. // error if the field is not defined in the schema.
  21387. func (m *TokenMutation) ClearField(name string) error {
  21388. switch name {
  21389. case token.FieldDeletedAt:
  21390. m.ClearDeletedAt()
  21391. return nil
  21392. case token.FieldExpireAt:
  21393. m.ClearExpireAt()
  21394. return nil
  21395. case token.FieldToken:
  21396. m.ClearToken()
  21397. return nil
  21398. case token.FieldMAC:
  21399. m.ClearMAC()
  21400. return nil
  21401. case token.FieldCustomAgentBase:
  21402. m.ClearCustomAgentBase()
  21403. return nil
  21404. case token.FieldCustomAgentKey:
  21405. m.ClearCustomAgentKey()
  21406. return nil
  21407. case token.FieldOpenaiBase:
  21408. m.ClearOpenaiBase()
  21409. return nil
  21410. case token.FieldOpenaiKey:
  21411. m.ClearOpenaiKey()
  21412. return nil
  21413. }
  21414. return fmt.Errorf("unknown Token nullable field %s", name)
  21415. }
  21416. // ResetField resets all changes in the mutation for the field with the given name.
  21417. // It returns an error if the field is not defined in the schema.
  21418. func (m *TokenMutation) ResetField(name string) error {
  21419. switch name {
  21420. case token.FieldCreatedAt:
  21421. m.ResetCreatedAt()
  21422. return nil
  21423. case token.FieldUpdatedAt:
  21424. m.ResetUpdatedAt()
  21425. return nil
  21426. case token.FieldDeletedAt:
  21427. m.ResetDeletedAt()
  21428. return nil
  21429. case token.FieldExpireAt:
  21430. m.ResetExpireAt()
  21431. return nil
  21432. case token.FieldToken:
  21433. m.ResetToken()
  21434. return nil
  21435. case token.FieldMAC:
  21436. m.ResetMAC()
  21437. return nil
  21438. case token.FieldOrganizationID:
  21439. m.ResetOrganizationID()
  21440. return nil
  21441. case token.FieldAgentID:
  21442. m.ResetAgentID()
  21443. return nil
  21444. case token.FieldCustomAgentBase:
  21445. m.ResetCustomAgentBase()
  21446. return nil
  21447. case token.FieldCustomAgentKey:
  21448. m.ResetCustomAgentKey()
  21449. return nil
  21450. case token.FieldOpenaiBase:
  21451. m.ResetOpenaiBase()
  21452. return nil
  21453. case token.FieldOpenaiKey:
  21454. m.ResetOpenaiKey()
  21455. return nil
  21456. }
  21457. return fmt.Errorf("unknown Token field %s", name)
  21458. }
  21459. // AddedEdges returns all edge names that were set/added in this mutation.
  21460. func (m *TokenMutation) AddedEdges() []string {
  21461. edges := make([]string, 0, 1)
  21462. if m.agent != nil {
  21463. edges = append(edges, token.EdgeAgent)
  21464. }
  21465. return edges
  21466. }
  21467. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21468. // name in this mutation.
  21469. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  21470. switch name {
  21471. case token.EdgeAgent:
  21472. if id := m.agent; id != nil {
  21473. return []ent.Value{*id}
  21474. }
  21475. }
  21476. return nil
  21477. }
  21478. // RemovedEdges returns all edge names that were removed in this mutation.
  21479. func (m *TokenMutation) RemovedEdges() []string {
  21480. edges := make([]string, 0, 1)
  21481. return edges
  21482. }
  21483. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21484. // the given name in this mutation.
  21485. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  21486. return nil
  21487. }
  21488. // ClearedEdges returns all edge names that were cleared in this mutation.
  21489. func (m *TokenMutation) ClearedEdges() []string {
  21490. edges := make([]string, 0, 1)
  21491. if m.clearedagent {
  21492. edges = append(edges, token.EdgeAgent)
  21493. }
  21494. return edges
  21495. }
  21496. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21497. // was cleared in this mutation.
  21498. func (m *TokenMutation) EdgeCleared(name string) bool {
  21499. switch name {
  21500. case token.EdgeAgent:
  21501. return m.clearedagent
  21502. }
  21503. return false
  21504. }
  21505. // ClearEdge clears the value of the edge with the given name. It returns an error
  21506. // if that edge is not defined in the schema.
  21507. func (m *TokenMutation) ClearEdge(name string) error {
  21508. switch name {
  21509. case token.EdgeAgent:
  21510. m.ClearAgent()
  21511. return nil
  21512. }
  21513. return fmt.Errorf("unknown Token unique edge %s", name)
  21514. }
  21515. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21516. // It returns an error if the edge is not defined in the schema.
  21517. func (m *TokenMutation) ResetEdge(name string) error {
  21518. switch name {
  21519. case token.EdgeAgent:
  21520. m.ResetAgent()
  21521. return nil
  21522. }
  21523. return fmt.Errorf("unknown Token edge %s", name)
  21524. }
  21525. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  21526. type TutorialMutation struct {
  21527. config
  21528. op Op
  21529. typ string
  21530. id *uint64
  21531. created_at *time.Time
  21532. updated_at *time.Time
  21533. deleted_at *time.Time
  21534. index *int
  21535. addindex *int
  21536. title *string
  21537. content *string
  21538. organization_id *uint64
  21539. addorganization_id *int64
  21540. clearedFields map[string]struct{}
  21541. employee *uint64
  21542. clearedemployee bool
  21543. done bool
  21544. oldValue func(context.Context) (*Tutorial, error)
  21545. predicates []predicate.Tutorial
  21546. }
  21547. var _ ent.Mutation = (*TutorialMutation)(nil)
  21548. // tutorialOption allows management of the mutation configuration using functional options.
  21549. type tutorialOption func(*TutorialMutation)
  21550. // newTutorialMutation creates new mutation for the Tutorial entity.
  21551. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  21552. m := &TutorialMutation{
  21553. config: c,
  21554. op: op,
  21555. typ: TypeTutorial,
  21556. clearedFields: make(map[string]struct{}),
  21557. }
  21558. for _, opt := range opts {
  21559. opt(m)
  21560. }
  21561. return m
  21562. }
  21563. // withTutorialID sets the ID field of the mutation.
  21564. func withTutorialID(id uint64) tutorialOption {
  21565. return func(m *TutorialMutation) {
  21566. var (
  21567. err error
  21568. once sync.Once
  21569. value *Tutorial
  21570. )
  21571. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  21572. once.Do(func() {
  21573. if m.done {
  21574. err = errors.New("querying old values post mutation is not allowed")
  21575. } else {
  21576. value, err = m.Client().Tutorial.Get(ctx, id)
  21577. }
  21578. })
  21579. return value, err
  21580. }
  21581. m.id = &id
  21582. }
  21583. }
  21584. // withTutorial sets the old Tutorial of the mutation.
  21585. func withTutorial(node *Tutorial) tutorialOption {
  21586. return func(m *TutorialMutation) {
  21587. m.oldValue = func(context.Context) (*Tutorial, error) {
  21588. return node, nil
  21589. }
  21590. m.id = &node.ID
  21591. }
  21592. }
  21593. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21594. // executed in a transaction (ent.Tx), a transactional client is returned.
  21595. func (m TutorialMutation) Client() *Client {
  21596. client := &Client{config: m.config}
  21597. client.init()
  21598. return client
  21599. }
  21600. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21601. // it returns an error otherwise.
  21602. func (m TutorialMutation) Tx() (*Tx, error) {
  21603. if _, ok := m.driver.(*txDriver); !ok {
  21604. return nil, errors.New("ent: mutation is not running in a transaction")
  21605. }
  21606. tx := &Tx{config: m.config}
  21607. tx.init()
  21608. return tx, nil
  21609. }
  21610. // SetID sets the value of the id field. Note that this
  21611. // operation is only accepted on creation of Tutorial entities.
  21612. func (m *TutorialMutation) SetID(id uint64) {
  21613. m.id = &id
  21614. }
  21615. // ID returns the ID value in the mutation. Note that the ID is only available
  21616. // if it was provided to the builder or after it was returned from the database.
  21617. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  21618. if m.id == nil {
  21619. return
  21620. }
  21621. return *m.id, true
  21622. }
  21623. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21624. // That means, if the mutation is applied within a transaction with an isolation level such
  21625. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21626. // or updated by the mutation.
  21627. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  21628. switch {
  21629. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21630. id, exists := m.ID()
  21631. if exists {
  21632. return []uint64{id}, nil
  21633. }
  21634. fallthrough
  21635. case m.op.Is(OpUpdate | OpDelete):
  21636. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  21637. default:
  21638. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21639. }
  21640. }
  21641. // SetCreatedAt sets the "created_at" field.
  21642. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  21643. m.created_at = &t
  21644. }
  21645. // CreatedAt returns the value of the "created_at" field in the mutation.
  21646. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  21647. v := m.created_at
  21648. if v == nil {
  21649. return
  21650. }
  21651. return *v, true
  21652. }
  21653. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  21654. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21656. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21657. if !m.op.Is(OpUpdateOne) {
  21658. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21659. }
  21660. if m.id == nil || m.oldValue == nil {
  21661. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21662. }
  21663. oldValue, err := m.oldValue(ctx)
  21664. if err != nil {
  21665. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21666. }
  21667. return oldValue.CreatedAt, nil
  21668. }
  21669. // ResetCreatedAt resets all changes to the "created_at" field.
  21670. func (m *TutorialMutation) ResetCreatedAt() {
  21671. m.created_at = nil
  21672. }
  21673. // SetUpdatedAt sets the "updated_at" field.
  21674. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  21675. m.updated_at = &t
  21676. }
  21677. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21678. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  21679. v := m.updated_at
  21680. if v == nil {
  21681. return
  21682. }
  21683. return *v, true
  21684. }
  21685. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  21686. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21688. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21689. if !m.op.Is(OpUpdateOne) {
  21690. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21691. }
  21692. if m.id == nil || m.oldValue == nil {
  21693. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21694. }
  21695. oldValue, err := m.oldValue(ctx)
  21696. if err != nil {
  21697. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21698. }
  21699. return oldValue.UpdatedAt, nil
  21700. }
  21701. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21702. func (m *TutorialMutation) ResetUpdatedAt() {
  21703. m.updated_at = nil
  21704. }
  21705. // SetDeletedAt sets the "deleted_at" field.
  21706. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  21707. m.deleted_at = &t
  21708. }
  21709. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21710. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  21711. v := m.deleted_at
  21712. if v == nil {
  21713. return
  21714. }
  21715. return *v, true
  21716. }
  21717. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  21718. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21720. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21721. if !m.op.Is(OpUpdateOne) {
  21722. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21723. }
  21724. if m.id == nil || m.oldValue == nil {
  21725. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21726. }
  21727. oldValue, err := m.oldValue(ctx)
  21728. if err != nil {
  21729. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21730. }
  21731. return oldValue.DeletedAt, nil
  21732. }
  21733. // ClearDeletedAt clears the value of the "deleted_at" field.
  21734. func (m *TutorialMutation) ClearDeletedAt() {
  21735. m.deleted_at = nil
  21736. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  21737. }
  21738. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21739. func (m *TutorialMutation) DeletedAtCleared() bool {
  21740. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  21741. return ok
  21742. }
  21743. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21744. func (m *TutorialMutation) ResetDeletedAt() {
  21745. m.deleted_at = nil
  21746. delete(m.clearedFields, tutorial.FieldDeletedAt)
  21747. }
  21748. // SetEmployeeID sets the "employee_id" field.
  21749. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  21750. m.employee = &u
  21751. }
  21752. // EmployeeID returns the value of the "employee_id" field in the mutation.
  21753. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  21754. v := m.employee
  21755. if v == nil {
  21756. return
  21757. }
  21758. return *v, true
  21759. }
  21760. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  21761. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21763. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  21764. if !m.op.Is(OpUpdateOne) {
  21765. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  21766. }
  21767. if m.id == nil || m.oldValue == nil {
  21768. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  21769. }
  21770. oldValue, err := m.oldValue(ctx)
  21771. if err != nil {
  21772. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  21773. }
  21774. return oldValue.EmployeeID, nil
  21775. }
  21776. // ResetEmployeeID resets all changes to the "employee_id" field.
  21777. func (m *TutorialMutation) ResetEmployeeID() {
  21778. m.employee = nil
  21779. }
  21780. // SetIndex sets the "index" field.
  21781. func (m *TutorialMutation) SetIndex(i int) {
  21782. m.index = &i
  21783. m.addindex = nil
  21784. }
  21785. // Index returns the value of the "index" field in the mutation.
  21786. func (m *TutorialMutation) Index() (r int, exists bool) {
  21787. v := m.index
  21788. if v == nil {
  21789. return
  21790. }
  21791. return *v, true
  21792. }
  21793. // OldIndex returns the old "index" field's value of the Tutorial entity.
  21794. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21796. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  21797. if !m.op.Is(OpUpdateOne) {
  21798. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  21799. }
  21800. if m.id == nil || m.oldValue == nil {
  21801. return v, errors.New("OldIndex requires an ID field in the mutation")
  21802. }
  21803. oldValue, err := m.oldValue(ctx)
  21804. if err != nil {
  21805. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  21806. }
  21807. return oldValue.Index, nil
  21808. }
  21809. // AddIndex adds i to the "index" field.
  21810. func (m *TutorialMutation) AddIndex(i int) {
  21811. if m.addindex != nil {
  21812. *m.addindex += i
  21813. } else {
  21814. m.addindex = &i
  21815. }
  21816. }
  21817. // AddedIndex returns the value that was added to the "index" field in this mutation.
  21818. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  21819. v := m.addindex
  21820. if v == nil {
  21821. return
  21822. }
  21823. return *v, true
  21824. }
  21825. // ResetIndex resets all changes to the "index" field.
  21826. func (m *TutorialMutation) ResetIndex() {
  21827. m.index = nil
  21828. m.addindex = nil
  21829. }
  21830. // SetTitle sets the "title" field.
  21831. func (m *TutorialMutation) SetTitle(s string) {
  21832. m.title = &s
  21833. }
  21834. // Title returns the value of the "title" field in the mutation.
  21835. func (m *TutorialMutation) Title() (r string, exists bool) {
  21836. v := m.title
  21837. if v == nil {
  21838. return
  21839. }
  21840. return *v, true
  21841. }
  21842. // OldTitle returns the old "title" field's value of the Tutorial entity.
  21843. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21845. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  21846. if !m.op.Is(OpUpdateOne) {
  21847. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  21848. }
  21849. if m.id == nil || m.oldValue == nil {
  21850. return v, errors.New("OldTitle requires an ID field in the mutation")
  21851. }
  21852. oldValue, err := m.oldValue(ctx)
  21853. if err != nil {
  21854. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  21855. }
  21856. return oldValue.Title, nil
  21857. }
  21858. // ResetTitle resets all changes to the "title" field.
  21859. func (m *TutorialMutation) ResetTitle() {
  21860. m.title = nil
  21861. }
  21862. // SetContent sets the "content" field.
  21863. func (m *TutorialMutation) SetContent(s string) {
  21864. m.content = &s
  21865. }
  21866. // Content returns the value of the "content" field in the mutation.
  21867. func (m *TutorialMutation) Content() (r string, exists bool) {
  21868. v := m.content
  21869. if v == nil {
  21870. return
  21871. }
  21872. return *v, true
  21873. }
  21874. // OldContent returns the old "content" field's value of the Tutorial entity.
  21875. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21877. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  21878. if !m.op.Is(OpUpdateOne) {
  21879. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  21880. }
  21881. if m.id == nil || m.oldValue == nil {
  21882. return v, errors.New("OldContent requires an ID field in the mutation")
  21883. }
  21884. oldValue, err := m.oldValue(ctx)
  21885. if err != nil {
  21886. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  21887. }
  21888. return oldValue.Content, nil
  21889. }
  21890. // ResetContent resets all changes to the "content" field.
  21891. func (m *TutorialMutation) ResetContent() {
  21892. m.content = nil
  21893. }
  21894. // SetOrganizationID sets the "organization_id" field.
  21895. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  21896. m.organization_id = &u
  21897. m.addorganization_id = nil
  21898. }
  21899. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21900. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  21901. v := m.organization_id
  21902. if v == nil {
  21903. return
  21904. }
  21905. return *v, true
  21906. }
  21907. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  21908. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21910. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21911. if !m.op.Is(OpUpdateOne) {
  21912. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21913. }
  21914. if m.id == nil || m.oldValue == nil {
  21915. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21916. }
  21917. oldValue, err := m.oldValue(ctx)
  21918. if err != nil {
  21919. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21920. }
  21921. return oldValue.OrganizationID, nil
  21922. }
  21923. // AddOrganizationID adds u to the "organization_id" field.
  21924. func (m *TutorialMutation) AddOrganizationID(u int64) {
  21925. if m.addorganization_id != nil {
  21926. *m.addorganization_id += u
  21927. } else {
  21928. m.addorganization_id = &u
  21929. }
  21930. }
  21931. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21932. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  21933. v := m.addorganization_id
  21934. if v == nil {
  21935. return
  21936. }
  21937. return *v, true
  21938. }
  21939. // ResetOrganizationID resets all changes to the "organization_id" field.
  21940. func (m *TutorialMutation) ResetOrganizationID() {
  21941. m.organization_id = nil
  21942. m.addorganization_id = nil
  21943. }
  21944. // ClearEmployee clears the "employee" edge to the Employee entity.
  21945. func (m *TutorialMutation) ClearEmployee() {
  21946. m.clearedemployee = true
  21947. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  21948. }
  21949. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  21950. func (m *TutorialMutation) EmployeeCleared() bool {
  21951. return m.clearedemployee
  21952. }
  21953. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  21954. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21955. // EmployeeID instead. It exists only for internal usage by the builders.
  21956. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  21957. if id := m.employee; id != nil {
  21958. ids = append(ids, *id)
  21959. }
  21960. return
  21961. }
  21962. // ResetEmployee resets all changes to the "employee" edge.
  21963. func (m *TutorialMutation) ResetEmployee() {
  21964. m.employee = nil
  21965. m.clearedemployee = false
  21966. }
  21967. // Where appends a list predicates to the TutorialMutation builder.
  21968. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  21969. m.predicates = append(m.predicates, ps...)
  21970. }
  21971. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  21972. // users can use type-assertion to append predicates that do not depend on any generated package.
  21973. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  21974. p := make([]predicate.Tutorial, len(ps))
  21975. for i := range ps {
  21976. p[i] = ps[i]
  21977. }
  21978. m.Where(p...)
  21979. }
  21980. // Op returns the operation name.
  21981. func (m *TutorialMutation) Op() Op {
  21982. return m.op
  21983. }
  21984. // SetOp allows setting the mutation operation.
  21985. func (m *TutorialMutation) SetOp(op Op) {
  21986. m.op = op
  21987. }
  21988. // Type returns the node type of this mutation (Tutorial).
  21989. func (m *TutorialMutation) Type() string {
  21990. return m.typ
  21991. }
  21992. // Fields returns all fields that were changed during this mutation. Note that in
  21993. // order to get all numeric fields that were incremented/decremented, call
  21994. // AddedFields().
  21995. func (m *TutorialMutation) Fields() []string {
  21996. fields := make([]string, 0, 8)
  21997. if m.created_at != nil {
  21998. fields = append(fields, tutorial.FieldCreatedAt)
  21999. }
  22000. if m.updated_at != nil {
  22001. fields = append(fields, tutorial.FieldUpdatedAt)
  22002. }
  22003. if m.deleted_at != nil {
  22004. fields = append(fields, tutorial.FieldDeletedAt)
  22005. }
  22006. if m.employee != nil {
  22007. fields = append(fields, tutorial.FieldEmployeeID)
  22008. }
  22009. if m.index != nil {
  22010. fields = append(fields, tutorial.FieldIndex)
  22011. }
  22012. if m.title != nil {
  22013. fields = append(fields, tutorial.FieldTitle)
  22014. }
  22015. if m.content != nil {
  22016. fields = append(fields, tutorial.FieldContent)
  22017. }
  22018. if m.organization_id != nil {
  22019. fields = append(fields, tutorial.FieldOrganizationID)
  22020. }
  22021. return fields
  22022. }
  22023. // Field returns the value of a field with the given name. The second boolean
  22024. // return value indicates that this field was not set, or was not defined in the
  22025. // schema.
  22026. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  22027. switch name {
  22028. case tutorial.FieldCreatedAt:
  22029. return m.CreatedAt()
  22030. case tutorial.FieldUpdatedAt:
  22031. return m.UpdatedAt()
  22032. case tutorial.FieldDeletedAt:
  22033. return m.DeletedAt()
  22034. case tutorial.FieldEmployeeID:
  22035. return m.EmployeeID()
  22036. case tutorial.FieldIndex:
  22037. return m.Index()
  22038. case tutorial.FieldTitle:
  22039. return m.Title()
  22040. case tutorial.FieldContent:
  22041. return m.Content()
  22042. case tutorial.FieldOrganizationID:
  22043. return m.OrganizationID()
  22044. }
  22045. return nil, false
  22046. }
  22047. // OldField returns the old value of the field from the database. An error is
  22048. // returned if the mutation operation is not UpdateOne, or the query to the
  22049. // database failed.
  22050. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22051. switch name {
  22052. case tutorial.FieldCreatedAt:
  22053. return m.OldCreatedAt(ctx)
  22054. case tutorial.FieldUpdatedAt:
  22055. return m.OldUpdatedAt(ctx)
  22056. case tutorial.FieldDeletedAt:
  22057. return m.OldDeletedAt(ctx)
  22058. case tutorial.FieldEmployeeID:
  22059. return m.OldEmployeeID(ctx)
  22060. case tutorial.FieldIndex:
  22061. return m.OldIndex(ctx)
  22062. case tutorial.FieldTitle:
  22063. return m.OldTitle(ctx)
  22064. case tutorial.FieldContent:
  22065. return m.OldContent(ctx)
  22066. case tutorial.FieldOrganizationID:
  22067. return m.OldOrganizationID(ctx)
  22068. }
  22069. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  22070. }
  22071. // SetField sets the value of a field with the given name. It returns an error if
  22072. // the field is not defined in the schema, or if the type mismatched the field
  22073. // type.
  22074. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  22075. switch name {
  22076. case tutorial.FieldCreatedAt:
  22077. v, ok := value.(time.Time)
  22078. if !ok {
  22079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22080. }
  22081. m.SetCreatedAt(v)
  22082. return nil
  22083. case tutorial.FieldUpdatedAt:
  22084. v, ok := value.(time.Time)
  22085. if !ok {
  22086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22087. }
  22088. m.SetUpdatedAt(v)
  22089. return nil
  22090. case tutorial.FieldDeletedAt:
  22091. v, ok := value.(time.Time)
  22092. if !ok {
  22093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22094. }
  22095. m.SetDeletedAt(v)
  22096. return nil
  22097. case tutorial.FieldEmployeeID:
  22098. v, ok := value.(uint64)
  22099. if !ok {
  22100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22101. }
  22102. m.SetEmployeeID(v)
  22103. return nil
  22104. case tutorial.FieldIndex:
  22105. v, ok := value.(int)
  22106. if !ok {
  22107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22108. }
  22109. m.SetIndex(v)
  22110. return nil
  22111. case tutorial.FieldTitle:
  22112. v, ok := value.(string)
  22113. if !ok {
  22114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22115. }
  22116. m.SetTitle(v)
  22117. return nil
  22118. case tutorial.FieldContent:
  22119. v, ok := value.(string)
  22120. if !ok {
  22121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22122. }
  22123. m.SetContent(v)
  22124. return nil
  22125. case tutorial.FieldOrganizationID:
  22126. v, ok := value.(uint64)
  22127. if !ok {
  22128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22129. }
  22130. m.SetOrganizationID(v)
  22131. return nil
  22132. }
  22133. return fmt.Errorf("unknown Tutorial field %s", name)
  22134. }
  22135. // AddedFields returns all numeric fields that were incremented/decremented during
  22136. // this mutation.
  22137. func (m *TutorialMutation) AddedFields() []string {
  22138. var fields []string
  22139. if m.addindex != nil {
  22140. fields = append(fields, tutorial.FieldIndex)
  22141. }
  22142. if m.addorganization_id != nil {
  22143. fields = append(fields, tutorial.FieldOrganizationID)
  22144. }
  22145. return fields
  22146. }
  22147. // AddedField returns the numeric value that was incremented/decremented on a field
  22148. // with the given name. The second boolean return value indicates that this field
  22149. // was not set, or was not defined in the schema.
  22150. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  22151. switch name {
  22152. case tutorial.FieldIndex:
  22153. return m.AddedIndex()
  22154. case tutorial.FieldOrganizationID:
  22155. return m.AddedOrganizationID()
  22156. }
  22157. return nil, false
  22158. }
  22159. // AddField adds the value to the field with the given name. It returns an error if
  22160. // the field is not defined in the schema, or if the type mismatched the field
  22161. // type.
  22162. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  22163. switch name {
  22164. case tutorial.FieldIndex:
  22165. v, ok := value.(int)
  22166. if !ok {
  22167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22168. }
  22169. m.AddIndex(v)
  22170. return nil
  22171. case tutorial.FieldOrganizationID:
  22172. v, ok := value.(int64)
  22173. if !ok {
  22174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22175. }
  22176. m.AddOrganizationID(v)
  22177. return nil
  22178. }
  22179. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  22180. }
  22181. // ClearedFields returns all nullable fields that were cleared during this
  22182. // mutation.
  22183. func (m *TutorialMutation) ClearedFields() []string {
  22184. var fields []string
  22185. if m.FieldCleared(tutorial.FieldDeletedAt) {
  22186. fields = append(fields, tutorial.FieldDeletedAt)
  22187. }
  22188. return fields
  22189. }
  22190. // FieldCleared returns a boolean indicating if a field with the given name was
  22191. // cleared in this mutation.
  22192. func (m *TutorialMutation) FieldCleared(name string) bool {
  22193. _, ok := m.clearedFields[name]
  22194. return ok
  22195. }
  22196. // ClearField clears the value of the field with the given name. It returns an
  22197. // error if the field is not defined in the schema.
  22198. func (m *TutorialMutation) ClearField(name string) error {
  22199. switch name {
  22200. case tutorial.FieldDeletedAt:
  22201. m.ClearDeletedAt()
  22202. return nil
  22203. }
  22204. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  22205. }
  22206. // ResetField resets all changes in the mutation for the field with the given name.
  22207. // It returns an error if the field is not defined in the schema.
  22208. func (m *TutorialMutation) ResetField(name string) error {
  22209. switch name {
  22210. case tutorial.FieldCreatedAt:
  22211. m.ResetCreatedAt()
  22212. return nil
  22213. case tutorial.FieldUpdatedAt:
  22214. m.ResetUpdatedAt()
  22215. return nil
  22216. case tutorial.FieldDeletedAt:
  22217. m.ResetDeletedAt()
  22218. return nil
  22219. case tutorial.FieldEmployeeID:
  22220. m.ResetEmployeeID()
  22221. return nil
  22222. case tutorial.FieldIndex:
  22223. m.ResetIndex()
  22224. return nil
  22225. case tutorial.FieldTitle:
  22226. m.ResetTitle()
  22227. return nil
  22228. case tutorial.FieldContent:
  22229. m.ResetContent()
  22230. return nil
  22231. case tutorial.FieldOrganizationID:
  22232. m.ResetOrganizationID()
  22233. return nil
  22234. }
  22235. return fmt.Errorf("unknown Tutorial field %s", name)
  22236. }
  22237. // AddedEdges returns all edge names that were set/added in this mutation.
  22238. func (m *TutorialMutation) AddedEdges() []string {
  22239. edges := make([]string, 0, 1)
  22240. if m.employee != nil {
  22241. edges = append(edges, tutorial.EdgeEmployee)
  22242. }
  22243. return edges
  22244. }
  22245. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22246. // name in this mutation.
  22247. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  22248. switch name {
  22249. case tutorial.EdgeEmployee:
  22250. if id := m.employee; id != nil {
  22251. return []ent.Value{*id}
  22252. }
  22253. }
  22254. return nil
  22255. }
  22256. // RemovedEdges returns all edge names that were removed in this mutation.
  22257. func (m *TutorialMutation) RemovedEdges() []string {
  22258. edges := make([]string, 0, 1)
  22259. return edges
  22260. }
  22261. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22262. // the given name in this mutation.
  22263. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  22264. return nil
  22265. }
  22266. // ClearedEdges returns all edge names that were cleared in this mutation.
  22267. func (m *TutorialMutation) ClearedEdges() []string {
  22268. edges := make([]string, 0, 1)
  22269. if m.clearedemployee {
  22270. edges = append(edges, tutorial.EdgeEmployee)
  22271. }
  22272. return edges
  22273. }
  22274. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22275. // was cleared in this mutation.
  22276. func (m *TutorialMutation) EdgeCleared(name string) bool {
  22277. switch name {
  22278. case tutorial.EdgeEmployee:
  22279. return m.clearedemployee
  22280. }
  22281. return false
  22282. }
  22283. // ClearEdge clears the value of the edge with the given name. It returns an error
  22284. // if that edge is not defined in the schema.
  22285. func (m *TutorialMutation) ClearEdge(name string) error {
  22286. switch name {
  22287. case tutorial.EdgeEmployee:
  22288. m.ClearEmployee()
  22289. return nil
  22290. }
  22291. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  22292. }
  22293. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22294. // It returns an error if the edge is not defined in the schema.
  22295. func (m *TutorialMutation) ResetEdge(name string) error {
  22296. switch name {
  22297. case tutorial.EdgeEmployee:
  22298. m.ResetEmployee()
  22299. return nil
  22300. }
  22301. return fmt.Errorf("unknown Tutorial edge %s", name)
  22302. }
  22303. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  22304. type UsageDetailMutation struct {
  22305. config
  22306. op Op
  22307. typ string
  22308. id *uint64
  22309. created_at *time.Time
  22310. updated_at *time.Time
  22311. status *uint8
  22312. addstatus *int8
  22313. _type *int
  22314. add_type *int
  22315. bot_id *string
  22316. receiver_id *string
  22317. app *int
  22318. addapp *int
  22319. session_id *uint64
  22320. addsession_id *int64
  22321. request *string
  22322. response *string
  22323. total_tokens *uint64
  22324. addtotal_tokens *int64
  22325. prompt_tokens *uint64
  22326. addprompt_tokens *int64
  22327. completion_tokens *uint64
  22328. addcompletion_tokens *int64
  22329. organization_id *uint64
  22330. addorganization_id *int64
  22331. clearedFields map[string]struct{}
  22332. done bool
  22333. oldValue func(context.Context) (*UsageDetail, error)
  22334. predicates []predicate.UsageDetail
  22335. }
  22336. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  22337. // usagedetailOption allows management of the mutation configuration using functional options.
  22338. type usagedetailOption func(*UsageDetailMutation)
  22339. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  22340. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  22341. m := &UsageDetailMutation{
  22342. config: c,
  22343. op: op,
  22344. typ: TypeUsageDetail,
  22345. clearedFields: make(map[string]struct{}),
  22346. }
  22347. for _, opt := range opts {
  22348. opt(m)
  22349. }
  22350. return m
  22351. }
  22352. // withUsageDetailID sets the ID field of the mutation.
  22353. func withUsageDetailID(id uint64) usagedetailOption {
  22354. return func(m *UsageDetailMutation) {
  22355. var (
  22356. err error
  22357. once sync.Once
  22358. value *UsageDetail
  22359. )
  22360. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  22361. once.Do(func() {
  22362. if m.done {
  22363. err = errors.New("querying old values post mutation is not allowed")
  22364. } else {
  22365. value, err = m.Client().UsageDetail.Get(ctx, id)
  22366. }
  22367. })
  22368. return value, err
  22369. }
  22370. m.id = &id
  22371. }
  22372. }
  22373. // withUsageDetail sets the old UsageDetail of the mutation.
  22374. func withUsageDetail(node *UsageDetail) usagedetailOption {
  22375. return func(m *UsageDetailMutation) {
  22376. m.oldValue = func(context.Context) (*UsageDetail, error) {
  22377. return node, nil
  22378. }
  22379. m.id = &node.ID
  22380. }
  22381. }
  22382. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22383. // executed in a transaction (ent.Tx), a transactional client is returned.
  22384. func (m UsageDetailMutation) Client() *Client {
  22385. client := &Client{config: m.config}
  22386. client.init()
  22387. return client
  22388. }
  22389. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22390. // it returns an error otherwise.
  22391. func (m UsageDetailMutation) Tx() (*Tx, error) {
  22392. if _, ok := m.driver.(*txDriver); !ok {
  22393. return nil, errors.New("ent: mutation is not running in a transaction")
  22394. }
  22395. tx := &Tx{config: m.config}
  22396. tx.init()
  22397. return tx, nil
  22398. }
  22399. // SetID sets the value of the id field. Note that this
  22400. // operation is only accepted on creation of UsageDetail entities.
  22401. func (m *UsageDetailMutation) SetID(id uint64) {
  22402. m.id = &id
  22403. }
  22404. // ID returns the ID value in the mutation. Note that the ID is only available
  22405. // if it was provided to the builder or after it was returned from the database.
  22406. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  22407. if m.id == nil {
  22408. return
  22409. }
  22410. return *m.id, true
  22411. }
  22412. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22413. // That means, if the mutation is applied within a transaction with an isolation level such
  22414. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22415. // or updated by the mutation.
  22416. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  22417. switch {
  22418. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22419. id, exists := m.ID()
  22420. if exists {
  22421. return []uint64{id}, nil
  22422. }
  22423. fallthrough
  22424. case m.op.Is(OpUpdate | OpDelete):
  22425. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  22426. default:
  22427. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22428. }
  22429. }
  22430. // SetCreatedAt sets the "created_at" field.
  22431. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  22432. m.created_at = &t
  22433. }
  22434. // CreatedAt returns the value of the "created_at" field in the mutation.
  22435. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  22436. v := m.created_at
  22437. if v == nil {
  22438. return
  22439. }
  22440. return *v, true
  22441. }
  22442. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  22443. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22445. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22446. if !m.op.Is(OpUpdateOne) {
  22447. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22448. }
  22449. if m.id == nil || m.oldValue == nil {
  22450. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22451. }
  22452. oldValue, err := m.oldValue(ctx)
  22453. if err != nil {
  22454. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22455. }
  22456. return oldValue.CreatedAt, nil
  22457. }
  22458. // ResetCreatedAt resets all changes to the "created_at" field.
  22459. func (m *UsageDetailMutation) ResetCreatedAt() {
  22460. m.created_at = nil
  22461. }
  22462. // SetUpdatedAt sets the "updated_at" field.
  22463. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  22464. m.updated_at = &t
  22465. }
  22466. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22467. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  22468. v := m.updated_at
  22469. if v == nil {
  22470. return
  22471. }
  22472. return *v, true
  22473. }
  22474. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  22475. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22477. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22478. if !m.op.Is(OpUpdateOne) {
  22479. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22480. }
  22481. if m.id == nil || m.oldValue == nil {
  22482. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22483. }
  22484. oldValue, err := m.oldValue(ctx)
  22485. if err != nil {
  22486. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22487. }
  22488. return oldValue.UpdatedAt, nil
  22489. }
  22490. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22491. func (m *UsageDetailMutation) ResetUpdatedAt() {
  22492. m.updated_at = nil
  22493. }
  22494. // SetStatus sets the "status" field.
  22495. func (m *UsageDetailMutation) SetStatus(u uint8) {
  22496. m.status = &u
  22497. m.addstatus = nil
  22498. }
  22499. // Status returns the value of the "status" field in the mutation.
  22500. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  22501. v := m.status
  22502. if v == nil {
  22503. return
  22504. }
  22505. return *v, true
  22506. }
  22507. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  22508. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22510. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22511. if !m.op.Is(OpUpdateOne) {
  22512. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22513. }
  22514. if m.id == nil || m.oldValue == nil {
  22515. return v, errors.New("OldStatus requires an ID field in the mutation")
  22516. }
  22517. oldValue, err := m.oldValue(ctx)
  22518. if err != nil {
  22519. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22520. }
  22521. return oldValue.Status, nil
  22522. }
  22523. // AddStatus adds u to the "status" field.
  22524. func (m *UsageDetailMutation) AddStatus(u int8) {
  22525. if m.addstatus != nil {
  22526. *m.addstatus += u
  22527. } else {
  22528. m.addstatus = &u
  22529. }
  22530. }
  22531. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22532. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  22533. v := m.addstatus
  22534. if v == nil {
  22535. return
  22536. }
  22537. return *v, true
  22538. }
  22539. // ClearStatus clears the value of the "status" field.
  22540. func (m *UsageDetailMutation) ClearStatus() {
  22541. m.status = nil
  22542. m.addstatus = nil
  22543. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  22544. }
  22545. // StatusCleared returns if the "status" field was cleared in this mutation.
  22546. func (m *UsageDetailMutation) StatusCleared() bool {
  22547. _, ok := m.clearedFields[usagedetail.FieldStatus]
  22548. return ok
  22549. }
  22550. // ResetStatus resets all changes to the "status" field.
  22551. func (m *UsageDetailMutation) ResetStatus() {
  22552. m.status = nil
  22553. m.addstatus = nil
  22554. delete(m.clearedFields, usagedetail.FieldStatus)
  22555. }
  22556. // SetType sets the "type" field.
  22557. func (m *UsageDetailMutation) SetType(i int) {
  22558. m._type = &i
  22559. m.add_type = nil
  22560. }
  22561. // GetType returns the value of the "type" field in the mutation.
  22562. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  22563. v := m._type
  22564. if v == nil {
  22565. return
  22566. }
  22567. return *v, true
  22568. }
  22569. // OldType returns the old "type" field's value of the UsageDetail entity.
  22570. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22572. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  22573. if !m.op.Is(OpUpdateOne) {
  22574. return v, errors.New("OldType is only allowed on UpdateOne operations")
  22575. }
  22576. if m.id == nil || m.oldValue == nil {
  22577. return v, errors.New("OldType requires an ID field in the mutation")
  22578. }
  22579. oldValue, err := m.oldValue(ctx)
  22580. if err != nil {
  22581. return v, fmt.Errorf("querying old value for OldType: %w", err)
  22582. }
  22583. return oldValue.Type, nil
  22584. }
  22585. // AddType adds i to the "type" field.
  22586. func (m *UsageDetailMutation) AddType(i int) {
  22587. if m.add_type != nil {
  22588. *m.add_type += i
  22589. } else {
  22590. m.add_type = &i
  22591. }
  22592. }
  22593. // AddedType returns the value that was added to the "type" field in this mutation.
  22594. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  22595. v := m.add_type
  22596. if v == nil {
  22597. return
  22598. }
  22599. return *v, true
  22600. }
  22601. // ClearType clears the value of the "type" field.
  22602. func (m *UsageDetailMutation) ClearType() {
  22603. m._type = nil
  22604. m.add_type = nil
  22605. m.clearedFields[usagedetail.FieldType] = struct{}{}
  22606. }
  22607. // TypeCleared returns if the "type" field was cleared in this mutation.
  22608. func (m *UsageDetailMutation) TypeCleared() bool {
  22609. _, ok := m.clearedFields[usagedetail.FieldType]
  22610. return ok
  22611. }
  22612. // ResetType resets all changes to the "type" field.
  22613. func (m *UsageDetailMutation) ResetType() {
  22614. m._type = nil
  22615. m.add_type = nil
  22616. delete(m.clearedFields, usagedetail.FieldType)
  22617. }
  22618. // SetBotID sets the "bot_id" field.
  22619. func (m *UsageDetailMutation) SetBotID(s string) {
  22620. m.bot_id = &s
  22621. }
  22622. // BotID returns the value of the "bot_id" field in the mutation.
  22623. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  22624. v := m.bot_id
  22625. if v == nil {
  22626. return
  22627. }
  22628. return *v, true
  22629. }
  22630. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  22631. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22633. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  22634. if !m.op.Is(OpUpdateOne) {
  22635. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  22636. }
  22637. if m.id == nil || m.oldValue == nil {
  22638. return v, errors.New("OldBotID requires an ID field in the mutation")
  22639. }
  22640. oldValue, err := m.oldValue(ctx)
  22641. if err != nil {
  22642. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  22643. }
  22644. return oldValue.BotID, nil
  22645. }
  22646. // ResetBotID resets all changes to the "bot_id" field.
  22647. func (m *UsageDetailMutation) ResetBotID() {
  22648. m.bot_id = nil
  22649. }
  22650. // SetReceiverID sets the "receiver_id" field.
  22651. func (m *UsageDetailMutation) SetReceiverID(s string) {
  22652. m.receiver_id = &s
  22653. }
  22654. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  22655. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  22656. v := m.receiver_id
  22657. if v == nil {
  22658. return
  22659. }
  22660. return *v, true
  22661. }
  22662. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  22663. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22665. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  22666. if !m.op.Is(OpUpdateOne) {
  22667. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  22668. }
  22669. if m.id == nil || m.oldValue == nil {
  22670. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  22671. }
  22672. oldValue, err := m.oldValue(ctx)
  22673. if err != nil {
  22674. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  22675. }
  22676. return oldValue.ReceiverID, nil
  22677. }
  22678. // ResetReceiverID resets all changes to the "receiver_id" field.
  22679. func (m *UsageDetailMutation) ResetReceiverID() {
  22680. m.receiver_id = nil
  22681. }
  22682. // SetApp sets the "app" field.
  22683. func (m *UsageDetailMutation) SetApp(i int) {
  22684. m.app = &i
  22685. m.addapp = nil
  22686. }
  22687. // App returns the value of the "app" field in the mutation.
  22688. func (m *UsageDetailMutation) App() (r int, exists bool) {
  22689. v := m.app
  22690. if v == nil {
  22691. return
  22692. }
  22693. return *v, true
  22694. }
  22695. // OldApp returns the old "app" field's value of the UsageDetail entity.
  22696. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22698. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  22699. if !m.op.Is(OpUpdateOne) {
  22700. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  22701. }
  22702. if m.id == nil || m.oldValue == nil {
  22703. return v, errors.New("OldApp requires an ID field in the mutation")
  22704. }
  22705. oldValue, err := m.oldValue(ctx)
  22706. if err != nil {
  22707. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  22708. }
  22709. return oldValue.App, nil
  22710. }
  22711. // AddApp adds i to the "app" field.
  22712. func (m *UsageDetailMutation) AddApp(i int) {
  22713. if m.addapp != nil {
  22714. *m.addapp += i
  22715. } else {
  22716. m.addapp = &i
  22717. }
  22718. }
  22719. // AddedApp returns the value that was added to the "app" field in this mutation.
  22720. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  22721. v := m.addapp
  22722. if v == nil {
  22723. return
  22724. }
  22725. return *v, true
  22726. }
  22727. // ClearApp clears the value of the "app" field.
  22728. func (m *UsageDetailMutation) ClearApp() {
  22729. m.app = nil
  22730. m.addapp = nil
  22731. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  22732. }
  22733. // AppCleared returns if the "app" field was cleared in this mutation.
  22734. func (m *UsageDetailMutation) AppCleared() bool {
  22735. _, ok := m.clearedFields[usagedetail.FieldApp]
  22736. return ok
  22737. }
  22738. // ResetApp resets all changes to the "app" field.
  22739. func (m *UsageDetailMutation) ResetApp() {
  22740. m.app = nil
  22741. m.addapp = nil
  22742. delete(m.clearedFields, usagedetail.FieldApp)
  22743. }
  22744. // SetSessionID sets the "session_id" field.
  22745. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  22746. m.session_id = &u
  22747. m.addsession_id = nil
  22748. }
  22749. // SessionID returns the value of the "session_id" field in the mutation.
  22750. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  22751. v := m.session_id
  22752. if v == nil {
  22753. return
  22754. }
  22755. return *v, true
  22756. }
  22757. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  22758. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22760. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  22761. if !m.op.Is(OpUpdateOne) {
  22762. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  22763. }
  22764. if m.id == nil || m.oldValue == nil {
  22765. return v, errors.New("OldSessionID requires an ID field in the mutation")
  22766. }
  22767. oldValue, err := m.oldValue(ctx)
  22768. if err != nil {
  22769. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  22770. }
  22771. return oldValue.SessionID, nil
  22772. }
  22773. // AddSessionID adds u to the "session_id" field.
  22774. func (m *UsageDetailMutation) AddSessionID(u int64) {
  22775. if m.addsession_id != nil {
  22776. *m.addsession_id += u
  22777. } else {
  22778. m.addsession_id = &u
  22779. }
  22780. }
  22781. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  22782. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  22783. v := m.addsession_id
  22784. if v == nil {
  22785. return
  22786. }
  22787. return *v, true
  22788. }
  22789. // ClearSessionID clears the value of the "session_id" field.
  22790. func (m *UsageDetailMutation) ClearSessionID() {
  22791. m.session_id = nil
  22792. m.addsession_id = nil
  22793. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  22794. }
  22795. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  22796. func (m *UsageDetailMutation) SessionIDCleared() bool {
  22797. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  22798. return ok
  22799. }
  22800. // ResetSessionID resets all changes to the "session_id" field.
  22801. func (m *UsageDetailMutation) ResetSessionID() {
  22802. m.session_id = nil
  22803. m.addsession_id = nil
  22804. delete(m.clearedFields, usagedetail.FieldSessionID)
  22805. }
  22806. // SetRequest sets the "request" field.
  22807. func (m *UsageDetailMutation) SetRequest(s string) {
  22808. m.request = &s
  22809. }
  22810. // Request returns the value of the "request" field in the mutation.
  22811. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  22812. v := m.request
  22813. if v == nil {
  22814. return
  22815. }
  22816. return *v, true
  22817. }
  22818. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  22819. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22821. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  22822. if !m.op.Is(OpUpdateOne) {
  22823. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  22824. }
  22825. if m.id == nil || m.oldValue == nil {
  22826. return v, errors.New("OldRequest requires an ID field in the mutation")
  22827. }
  22828. oldValue, err := m.oldValue(ctx)
  22829. if err != nil {
  22830. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  22831. }
  22832. return oldValue.Request, nil
  22833. }
  22834. // ResetRequest resets all changes to the "request" field.
  22835. func (m *UsageDetailMutation) ResetRequest() {
  22836. m.request = nil
  22837. }
  22838. // SetResponse sets the "response" field.
  22839. func (m *UsageDetailMutation) SetResponse(s string) {
  22840. m.response = &s
  22841. }
  22842. // Response returns the value of the "response" field in the mutation.
  22843. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  22844. v := m.response
  22845. if v == nil {
  22846. return
  22847. }
  22848. return *v, true
  22849. }
  22850. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  22851. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22853. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  22854. if !m.op.Is(OpUpdateOne) {
  22855. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  22856. }
  22857. if m.id == nil || m.oldValue == nil {
  22858. return v, errors.New("OldResponse requires an ID field in the mutation")
  22859. }
  22860. oldValue, err := m.oldValue(ctx)
  22861. if err != nil {
  22862. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  22863. }
  22864. return oldValue.Response, nil
  22865. }
  22866. // ResetResponse resets all changes to the "response" field.
  22867. func (m *UsageDetailMutation) ResetResponse() {
  22868. m.response = nil
  22869. }
  22870. // SetTotalTokens sets the "total_tokens" field.
  22871. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  22872. m.total_tokens = &u
  22873. m.addtotal_tokens = nil
  22874. }
  22875. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  22876. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  22877. v := m.total_tokens
  22878. if v == nil {
  22879. return
  22880. }
  22881. return *v, true
  22882. }
  22883. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  22884. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22886. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  22887. if !m.op.Is(OpUpdateOne) {
  22888. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  22889. }
  22890. if m.id == nil || m.oldValue == nil {
  22891. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  22892. }
  22893. oldValue, err := m.oldValue(ctx)
  22894. if err != nil {
  22895. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  22896. }
  22897. return oldValue.TotalTokens, nil
  22898. }
  22899. // AddTotalTokens adds u to the "total_tokens" field.
  22900. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  22901. if m.addtotal_tokens != nil {
  22902. *m.addtotal_tokens += u
  22903. } else {
  22904. m.addtotal_tokens = &u
  22905. }
  22906. }
  22907. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  22908. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  22909. v := m.addtotal_tokens
  22910. if v == nil {
  22911. return
  22912. }
  22913. return *v, true
  22914. }
  22915. // ClearTotalTokens clears the value of the "total_tokens" field.
  22916. func (m *UsageDetailMutation) ClearTotalTokens() {
  22917. m.total_tokens = nil
  22918. m.addtotal_tokens = nil
  22919. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  22920. }
  22921. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  22922. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  22923. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  22924. return ok
  22925. }
  22926. // ResetTotalTokens resets all changes to the "total_tokens" field.
  22927. func (m *UsageDetailMutation) ResetTotalTokens() {
  22928. m.total_tokens = nil
  22929. m.addtotal_tokens = nil
  22930. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  22931. }
  22932. // SetPromptTokens sets the "prompt_tokens" field.
  22933. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  22934. m.prompt_tokens = &u
  22935. m.addprompt_tokens = nil
  22936. }
  22937. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  22938. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  22939. v := m.prompt_tokens
  22940. if v == nil {
  22941. return
  22942. }
  22943. return *v, true
  22944. }
  22945. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  22946. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22948. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  22949. if !m.op.Is(OpUpdateOne) {
  22950. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  22951. }
  22952. if m.id == nil || m.oldValue == nil {
  22953. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  22954. }
  22955. oldValue, err := m.oldValue(ctx)
  22956. if err != nil {
  22957. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  22958. }
  22959. return oldValue.PromptTokens, nil
  22960. }
  22961. // AddPromptTokens adds u to the "prompt_tokens" field.
  22962. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  22963. if m.addprompt_tokens != nil {
  22964. *m.addprompt_tokens += u
  22965. } else {
  22966. m.addprompt_tokens = &u
  22967. }
  22968. }
  22969. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  22970. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  22971. v := m.addprompt_tokens
  22972. if v == nil {
  22973. return
  22974. }
  22975. return *v, true
  22976. }
  22977. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  22978. func (m *UsageDetailMutation) ClearPromptTokens() {
  22979. m.prompt_tokens = nil
  22980. m.addprompt_tokens = nil
  22981. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  22982. }
  22983. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  22984. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  22985. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  22986. return ok
  22987. }
  22988. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  22989. func (m *UsageDetailMutation) ResetPromptTokens() {
  22990. m.prompt_tokens = nil
  22991. m.addprompt_tokens = nil
  22992. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  22993. }
  22994. // SetCompletionTokens sets the "completion_tokens" field.
  22995. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  22996. m.completion_tokens = &u
  22997. m.addcompletion_tokens = nil
  22998. }
  22999. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  23000. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  23001. v := m.completion_tokens
  23002. if v == nil {
  23003. return
  23004. }
  23005. return *v, true
  23006. }
  23007. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  23008. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23010. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  23011. if !m.op.Is(OpUpdateOne) {
  23012. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  23013. }
  23014. if m.id == nil || m.oldValue == nil {
  23015. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  23016. }
  23017. oldValue, err := m.oldValue(ctx)
  23018. if err != nil {
  23019. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  23020. }
  23021. return oldValue.CompletionTokens, nil
  23022. }
  23023. // AddCompletionTokens adds u to the "completion_tokens" field.
  23024. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  23025. if m.addcompletion_tokens != nil {
  23026. *m.addcompletion_tokens += u
  23027. } else {
  23028. m.addcompletion_tokens = &u
  23029. }
  23030. }
  23031. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  23032. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  23033. v := m.addcompletion_tokens
  23034. if v == nil {
  23035. return
  23036. }
  23037. return *v, true
  23038. }
  23039. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  23040. func (m *UsageDetailMutation) ClearCompletionTokens() {
  23041. m.completion_tokens = nil
  23042. m.addcompletion_tokens = nil
  23043. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  23044. }
  23045. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  23046. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  23047. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  23048. return ok
  23049. }
  23050. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  23051. func (m *UsageDetailMutation) ResetCompletionTokens() {
  23052. m.completion_tokens = nil
  23053. m.addcompletion_tokens = nil
  23054. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  23055. }
  23056. // SetOrganizationID sets the "organization_id" field.
  23057. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  23058. m.organization_id = &u
  23059. m.addorganization_id = nil
  23060. }
  23061. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23062. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  23063. v := m.organization_id
  23064. if v == nil {
  23065. return
  23066. }
  23067. return *v, true
  23068. }
  23069. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  23070. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23072. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23073. if !m.op.Is(OpUpdateOne) {
  23074. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23075. }
  23076. if m.id == nil || m.oldValue == nil {
  23077. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23078. }
  23079. oldValue, err := m.oldValue(ctx)
  23080. if err != nil {
  23081. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23082. }
  23083. return oldValue.OrganizationID, nil
  23084. }
  23085. // AddOrganizationID adds u to the "organization_id" field.
  23086. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  23087. if m.addorganization_id != nil {
  23088. *m.addorganization_id += u
  23089. } else {
  23090. m.addorganization_id = &u
  23091. }
  23092. }
  23093. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23094. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  23095. v := m.addorganization_id
  23096. if v == nil {
  23097. return
  23098. }
  23099. return *v, true
  23100. }
  23101. // ClearOrganizationID clears the value of the "organization_id" field.
  23102. func (m *UsageDetailMutation) ClearOrganizationID() {
  23103. m.organization_id = nil
  23104. m.addorganization_id = nil
  23105. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  23106. }
  23107. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23108. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  23109. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  23110. return ok
  23111. }
  23112. // ResetOrganizationID resets all changes to the "organization_id" field.
  23113. func (m *UsageDetailMutation) ResetOrganizationID() {
  23114. m.organization_id = nil
  23115. m.addorganization_id = nil
  23116. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  23117. }
  23118. // Where appends a list predicates to the UsageDetailMutation builder.
  23119. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  23120. m.predicates = append(m.predicates, ps...)
  23121. }
  23122. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  23123. // users can use type-assertion to append predicates that do not depend on any generated package.
  23124. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  23125. p := make([]predicate.UsageDetail, len(ps))
  23126. for i := range ps {
  23127. p[i] = ps[i]
  23128. }
  23129. m.Where(p...)
  23130. }
  23131. // Op returns the operation name.
  23132. func (m *UsageDetailMutation) Op() Op {
  23133. return m.op
  23134. }
  23135. // SetOp allows setting the mutation operation.
  23136. func (m *UsageDetailMutation) SetOp(op Op) {
  23137. m.op = op
  23138. }
  23139. // Type returns the node type of this mutation (UsageDetail).
  23140. func (m *UsageDetailMutation) Type() string {
  23141. return m.typ
  23142. }
  23143. // Fields returns all fields that were changed during this mutation. Note that in
  23144. // order to get all numeric fields that were incremented/decremented, call
  23145. // AddedFields().
  23146. func (m *UsageDetailMutation) Fields() []string {
  23147. fields := make([]string, 0, 14)
  23148. if m.created_at != nil {
  23149. fields = append(fields, usagedetail.FieldCreatedAt)
  23150. }
  23151. if m.updated_at != nil {
  23152. fields = append(fields, usagedetail.FieldUpdatedAt)
  23153. }
  23154. if m.status != nil {
  23155. fields = append(fields, usagedetail.FieldStatus)
  23156. }
  23157. if m._type != nil {
  23158. fields = append(fields, usagedetail.FieldType)
  23159. }
  23160. if m.bot_id != nil {
  23161. fields = append(fields, usagedetail.FieldBotID)
  23162. }
  23163. if m.receiver_id != nil {
  23164. fields = append(fields, usagedetail.FieldReceiverID)
  23165. }
  23166. if m.app != nil {
  23167. fields = append(fields, usagedetail.FieldApp)
  23168. }
  23169. if m.session_id != nil {
  23170. fields = append(fields, usagedetail.FieldSessionID)
  23171. }
  23172. if m.request != nil {
  23173. fields = append(fields, usagedetail.FieldRequest)
  23174. }
  23175. if m.response != nil {
  23176. fields = append(fields, usagedetail.FieldResponse)
  23177. }
  23178. if m.total_tokens != nil {
  23179. fields = append(fields, usagedetail.FieldTotalTokens)
  23180. }
  23181. if m.prompt_tokens != nil {
  23182. fields = append(fields, usagedetail.FieldPromptTokens)
  23183. }
  23184. if m.completion_tokens != nil {
  23185. fields = append(fields, usagedetail.FieldCompletionTokens)
  23186. }
  23187. if m.organization_id != nil {
  23188. fields = append(fields, usagedetail.FieldOrganizationID)
  23189. }
  23190. return fields
  23191. }
  23192. // Field returns the value of a field with the given name. The second boolean
  23193. // return value indicates that this field was not set, or was not defined in the
  23194. // schema.
  23195. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  23196. switch name {
  23197. case usagedetail.FieldCreatedAt:
  23198. return m.CreatedAt()
  23199. case usagedetail.FieldUpdatedAt:
  23200. return m.UpdatedAt()
  23201. case usagedetail.FieldStatus:
  23202. return m.Status()
  23203. case usagedetail.FieldType:
  23204. return m.GetType()
  23205. case usagedetail.FieldBotID:
  23206. return m.BotID()
  23207. case usagedetail.FieldReceiverID:
  23208. return m.ReceiverID()
  23209. case usagedetail.FieldApp:
  23210. return m.App()
  23211. case usagedetail.FieldSessionID:
  23212. return m.SessionID()
  23213. case usagedetail.FieldRequest:
  23214. return m.Request()
  23215. case usagedetail.FieldResponse:
  23216. return m.Response()
  23217. case usagedetail.FieldTotalTokens:
  23218. return m.TotalTokens()
  23219. case usagedetail.FieldPromptTokens:
  23220. return m.PromptTokens()
  23221. case usagedetail.FieldCompletionTokens:
  23222. return m.CompletionTokens()
  23223. case usagedetail.FieldOrganizationID:
  23224. return m.OrganizationID()
  23225. }
  23226. return nil, false
  23227. }
  23228. // OldField returns the old value of the field from the database. An error is
  23229. // returned if the mutation operation is not UpdateOne, or the query to the
  23230. // database failed.
  23231. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23232. switch name {
  23233. case usagedetail.FieldCreatedAt:
  23234. return m.OldCreatedAt(ctx)
  23235. case usagedetail.FieldUpdatedAt:
  23236. return m.OldUpdatedAt(ctx)
  23237. case usagedetail.FieldStatus:
  23238. return m.OldStatus(ctx)
  23239. case usagedetail.FieldType:
  23240. return m.OldType(ctx)
  23241. case usagedetail.FieldBotID:
  23242. return m.OldBotID(ctx)
  23243. case usagedetail.FieldReceiverID:
  23244. return m.OldReceiverID(ctx)
  23245. case usagedetail.FieldApp:
  23246. return m.OldApp(ctx)
  23247. case usagedetail.FieldSessionID:
  23248. return m.OldSessionID(ctx)
  23249. case usagedetail.FieldRequest:
  23250. return m.OldRequest(ctx)
  23251. case usagedetail.FieldResponse:
  23252. return m.OldResponse(ctx)
  23253. case usagedetail.FieldTotalTokens:
  23254. return m.OldTotalTokens(ctx)
  23255. case usagedetail.FieldPromptTokens:
  23256. return m.OldPromptTokens(ctx)
  23257. case usagedetail.FieldCompletionTokens:
  23258. return m.OldCompletionTokens(ctx)
  23259. case usagedetail.FieldOrganizationID:
  23260. return m.OldOrganizationID(ctx)
  23261. }
  23262. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  23263. }
  23264. // SetField sets the value of a field with the given name. It returns an error if
  23265. // the field is not defined in the schema, or if the type mismatched the field
  23266. // type.
  23267. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  23268. switch name {
  23269. case usagedetail.FieldCreatedAt:
  23270. v, ok := value.(time.Time)
  23271. if !ok {
  23272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23273. }
  23274. m.SetCreatedAt(v)
  23275. return nil
  23276. case usagedetail.FieldUpdatedAt:
  23277. v, ok := value.(time.Time)
  23278. if !ok {
  23279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23280. }
  23281. m.SetUpdatedAt(v)
  23282. return nil
  23283. case usagedetail.FieldStatus:
  23284. v, ok := value.(uint8)
  23285. if !ok {
  23286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23287. }
  23288. m.SetStatus(v)
  23289. return nil
  23290. case usagedetail.FieldType:
  23291. v, ok := value.(int)
  23292. if !ok {
  23293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23294. }
  23295. m.SetType(v)
  23296. return nil
  23297. case usagedetail.FieldBotID:
  23298. v, ok := value.(string)
  23299. if !ok {
  23300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23301. }
  23302. m.SetBotID(v)
  23303. return nil
  23304. case usagedetail.FieldReceiverID:
  23305. v, ok := value.(string)
  23306. if !ok {
  23307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23308. }
  23309. m.SetReceiverID(v)
  23310. return nil
  23311. case usagedetail.FieldApp:
  23312. v, ok := value.(int)
  23313. if !ok {
  23314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23315. }
  23316. m.SetApp(v)
  23317. return nil
  23318. case usagedetail.FieldSessionID:
  23319. v, ok := value.(uint64)
  23320. if !ok {
  23321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23322. }
  23323. m.SetSessionID(v)
  23324. return nil
  23325. case usagedetail.FieldRequest:
  23326. v, ok := value.(string)
  23327. if !ok {
  23328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23329. }
  23330. m.SetRequest(v)
  23331. return nil
  23332. case usagedetail.FieldResponse:
  23333. v, ok := value.(string)
  23334. if !ok {
  23335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23336. }
  23337. m.SetResponse(v)
  23338. return nil
  23339. case usagedetail.FieldTotalTokens:
  23340. v, ok := value.(uint64)
  23341. if !ok {
  23342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23343. }
  23344. m.SetTotalTokens(v)
  23345. return nil
  23346. case usagedetail.FieldPromptTokens:
  23347. v, ok := value.(uint64)
  23348. if !ok {
  23349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23350. }
  23351. m.SetPromptTokens(v)
  23352. return nil
  23353. case usagedetail.FieldCompletionTokens:
  23354. v, ok := value.(uint64)
  23355. if !ok {
  23356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23357. }
  23358. m.SetCompletionTokens(v)
  23359. return nil
  23360. case usagedetail.FieldOrganizationID:
  23361. v, ok := value.(uint64)
  23362. if !ok {
  23363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23364. }
  23365. m.SetOrganizationID(v)
  23366. return nil
  23367. }
  23368. return fmt.Errorf("unknown UsageDetail field %s", name)
  23369. }
  23370. // AddedFields returns all numeric fields that were incremented/decremented during
  23371. // this mutation.
  23372. func (m *UsageDetailMutation) AddedFields() []string {
  23373. var fields []string
  23374. if m.addstatus != nil {
  23375. fields = append(fields, usagedetail.FieldStatus)
  23376. }
  23377. if m.add_type != nil {
  23378. fields = append(fields, usagedetail.FieldType)
  23379. }
  23380. if m.addapp != nil {
  23381. fields = append(fields, usagedetail.FieldApp)
  23382. }
  23383. if m.addsession_id != nil {
  23384. fields = append(fields, usagedetail.FieldSessionID)
  23385. }
  23386. if m.addtotal_tokens != nil {
  23387. fields = append(fields, usagedetail.FieldTotalTokens)
  23388. }
  23389. if m.addprompt_tokens != nil {
  23390. fields = append(fields, usagedetail.FieldPromptTokens)
  23391. }
  23392. if m.addcompletion_tokens != nil {
  23393. fields = append(fields, usagedetail.FieldCompletionTokens)
  23394. }
  23395. if m.addorganization_id != nil {
  23396. fields = append(fields, usagedetail.FieldOrganizationID)
  23397. }
  23398. return fields
  23399. }
  23400. // AddedField returns the numeric value that was incremented/decremented on a field
  23401. // with the given name. The second boolean return value indicates that this field
  23402. // was not set, or was not defined in the schema.
  23403. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  23404. switch name {
  23405. case usagedetail.FieldStatus:
  23406. return m.AddedStatus()
  23407. case usagedetail.FieldType:
  23408. return m.AddedType()
  23409. case usagedetail.FieldApp:
  23410. return m.AddedApp()
  23411. case usagedetail.FieldSessionID:
  23412. return m.AddedSessionID()
  23413. case usagedetail.FieldTotalTokens:
  23414. return m.AddedTotalTokens()
  23415. case usagedetail.FieldPromptTokens:
  23416. return m.AddedPromptTokens()
  23417. case usagedetail.FieldCompletionTokens:
  23418. return m.AddedCompletionTokens()
  23419. case usagedetail.FieldOrganizationID:
  23420. return m.AddedOrganizationID()
  23421. }
  23422. return nil, false
  23423. }
  23424. // AddField adds the value to the field with the given name. It returns an error if
  23425. // the field is not defined in the schema, or if the type mismatched the field
  23426. // type.
  23427. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  23428. switch name {
  23429. case usagedetail.FieldStatus:
  23430. v, ok := value.(int8)
  23431. if !ok {
  23432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23433. }
  23434. m.AddStatus(v)
  23435. return nil
  23436. case usagedetail.FieldType:
  23437. v, ok := value.(int)
  23438. if !ok {
  23439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23440. }
  23441. m.AddType(v)
  23442. return nil
  23443. case usagedetail.FieldApp:
  23444. v, ok := value.(int)
  23445. if !ok {
  23446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23447. }
  23448. m.AddApp(v)
  23449. return nil
  23450. case usagedetail.FieldSessionID:
  23451. v, ok := value.(int64)
  23452. if !ok {
  23453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23454. }
  23455. m.AddSessionID(v)
  23456. return nil
  23457. case usagedetail.FieldTotalTokens:
  23458. v, ok := value.(int64)
  23459. if !ok {
  23460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23461. }
  23462. m.AddTotalTokens(v)
  23463. return nil
  23464. case usagedetail.FieldPromptTokens:
  23465. v, ok := value.(int64)
  23466. if !ok {
  23467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23468. }
  23469. m.AddPromptTokens(v)
  23470. return nil
  23471. case usagedetail.FieldCompletionTokens:
  23472. v, ok := value.(int64)
  23473. if !ok {
  23474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23475. }
  23476. m.AddCompletionTokens(v)
  23477. return nil
  23478. case usagedetail.FieldOrganizationID:
  23479. v, ok := value.(int64)
  23480. if !ok {
  23481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23482. }
  23483. m.AddOrganizationID(v)
  23484. return nil
  23485. }
  23486. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  23487. }
  23488. // ClearedFields returns all nullable fields that were cleared during this
  23489. // mutation.
  23490. func (m *UsageDetailMutation) ClearedFields() []string {
  23491. var fields []string
  23492. if m.FieldCleared(usagedetail.FieldStatus) {
  23493. fields = append(fields, usagedetail.FieldStatus)
  23494. }
  23495. if m.FieldCleared(usagedetail.FieldType) {
  23496. fields = append(fields, usagedetail.FieldType)
  23497. }
  23498. if m.FieldCleared(usagedetail.FieldApp) {
  23499. fields = append(fields, usagedetail.FieldApp)
  23500. }
  23501. if m.FieldCleared(usagedetail.FieldSessionID) {
  23502. fields = append(fields, usagedetail.FieldSessionID)
  23503. }
  23504. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  23505. fields = append(fields, usagedetail.FieldTotalTokens)
  23506. }
  23507. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  23508. fields = append(fields, usagedetail.FieldPromptTokens)
  23509. }
  23510. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  23511. fields = append(fields, usagedetail.FieldCompletionTokens)
  23512. }
  23513. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  23514. fields = append(fields, usagedetail.FieldOrganizationID)
  23515. }
  23516. return fields
  23517. }
  23518. // FieldCleared returns a boolean indicating if a field with the given name was
  23519. // cleared in this mutation.
  23520. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  23521. _, ok := m.clearedFields[name]
  23522. return ok
  23523. }
  23524. // ClearField clears the value of the field with the given name. It returns an
  23525. // error if the field is not defined in the schema.
  23526. func (m *UsageDetailMutation) ClearField(name string) error {
  23527. switch name {
  23528. case usagedetail.FieldStatus:
  23529. m.ClearStatus()
  23530. return nil
  23531. case usagedetail.FieldType:
  23532. m.ClearType()
  23533. return nil
  23534. case usagedetail.FieldApp:
  23535. m.ClearApp()
  23536. return nil
  23537. case usagedetail.FieldSessionID:
  23538. m.ClearSessionID()
  23539. return nil
  23540. case usagedetail.FieldTotalTokens:
  23541. m.ClearTotalTokens()
  23542. return nil
  23543. case usagedetail.FieldPromptTokens:
  23544. m.ClearPromptTokens()
  23545. return nil
  23546. case usagedetail.FieldCompletionTokens:
  23547. m.ClearCompletionTokens()
  23548. return nil
  23549. case usagedetail.FieldOrganizationID:
  23550. m.ClearOrganizationID()
  23551. return nil
  23552. }
  23553. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  23554. }
  23555. // ResetField resets all changes in the mutation for the field with the given name.
  23556. // It returns an error if the field is not defined in the schema.
  23557. func (m *UsageDetailMutation) ResetField(name string) error {
  23558. switch name {
  23559. case usagedetail.FieldCreatedAt:
  23560. m.ResetCreatedAt()
  23561. return nil
  23562. case usagedetail.FieldUpdatedAt:
  23563. m.ResetUpdatedAt()
  23564. return nil
  23565. case usagedetail.FieldStatus:
  23566. m.ResetStatus()
  23567. return nil
  23568. case usagedetail.FieldType:
  23569. m.ResetType()
  23570. return nil
  23571. case usagedetail.FieldBotID:
  23572. m.ResetBotID()
  23573. return nil
  23574. case usagedetail.FieldReceiverID:
  23575. m.ResetReceiverID()
  23576. return nil
  23577. case usagedetail.FieldApp:
  23578. m.ResetApp()
  23579. return nil
  23580. case usagedetail.FieldSessionID:
  23581. m.ResetSessionID()
  23582. return nil
  23583. case usagedetail.FieldRequest:
  23584. m.ResetRequest()
  23585. return nil
  23586. case usagedetail.FieldResponse:
  23587. m.ResetResponse()
  23588. return nil
  23589. case usagedetail.FieldTotalTokens:
  23590. m.ResetTotalTokens()
  23591. return nil
  23592. case usagedetail.FieldPromptTokens:
  23593. m.ResetPromptTokens()
  23594. return nil
  23595. case usagedetail.FieldCompletionTokens:
  23596. m.ResetCompletionTokens()
  23597. return nil
  23598. case usagedetail.FieldOrganizationID:
  23599. m.ResetOrganizationID()
  23600. return nil
  23601. }
  23602. return fmt.Errorf("unknown UsageDetail field %s", name)
  23603. }
  23604. // AddedEdges returns all edge names that were set/added in this mutation.
  23605. func (m *UsageDetailMutation) AddedEdges() []string {
  23606. edges := make([]string, 0, 0)
  23607. return edges
  23608. }
  23609. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23610. // name in this mutation.
  23611. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  23612. return nil
  23613. }
  23614. // RemovedEdges returns all edge names that were removed in this mutation.
  23615. func (m *UsageDetailMutation) RemovedEdges() []string {
  23616. edges := make([]string, 0, 0)
  23617. return edges
  23618. }
  23619. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23620. // the given name in this mutation.
  23621. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  23622. return nil
  23623. }
  23624. // ClearedEdges returns all edge names that were cleared in this mutation.
  23625. func (m *UsageDetailMutation) ClearedEdges() []string {
  23626. edges := make([]string, 0, 0)
  23627. return edges
  23628. }
  23629. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23630. // was cleared in this mutation.
  23631. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  23632. return false
  23633. }
  23634. // ClearEdge clears the value of the edge with the given name. It returns an error
  23635. // if that edge is not defined in the schema.
  23636. func (m *UsageDetailMutation) ClearEdge(name string) error {
  23637. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  23638. }
  23639. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23640. // It returns an error if the edge is not defined in the schema.
  23641. func (m *UsageDetailMutation) ResetEdge(name string) error {
  23642. return fmt.Errorf("unknown UsageDetail edge %s", name)
  23643. }
  23644. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  23645. type UsageTotalMutation struct {
  23646. config
  23647. op Op
  23648. typ string
  23649. id *uint64
  23650. created_at *time.Time
  23651. updated_at *time.Time
  23652. status *uint8
  23653. addstatus *int8
  23654. _type *int
  23655. add_type *int
  23656. bot_id *string
  23657. total_tokens *uint64
  23658. addtotal_tokens *int64
  23659. start_index *uint64
  23660. addstart_index *int64
  23661. end_index *uint64
  23662. addend_index *int64
  23663. organization_id *uint64
  23664. addorganization_id *int64
  23665. clearedFields map[string]struct{}
  23666. done bool
  23667. oldValue func(context.Context) (*UsageTotal, error)
  23668. predicates []predicate.UsageTotal
  23669. }
  23670. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  23671. // usagetotalOption allows management of the mutation configuration using functional options.
  23672. type usagetotalOption func(*UsageTotalMutation)
  23673. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  23674. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  23675. m := &UsageTotalMutation{
  23676. config: c,
  23677. op: op,
  23678. typ: TypeUsageTotal,
  23679. clearedFields: make(map[string]struct{}),
  23680. }
  23681. for _, opt := range opts {
  23682. opt(m)
  23683. }
  23684. return m
  23685. }
  23686. // withUsageTotalID sets the ID field of the mutation.
  23687. func withUsageTotalID(id uint64) usagetotalOption {
  23688. return func(m *UsageTotalMutation) {
  23689. var (
  23690. err error
  23691. once sync.Once
  23692. value *UsageTotal
  23693. )
  23694. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  23695. once.Do(func() {
  23696. if m.done {
  23697. err = errors.New("querying old values post mutation is not allowed")
  23698. } else {
  23699. value, err = m.Client().UsageTotal.Get(ctx, id)
  23700. }
  23701. })
  23702. return value, err
  23703. }
  23704. m.id = &id
  23705. }
  23706. }
  23707. // withUsageTotal sets the old UsageTotal of the mutation.
  23708. func withUsageTotal(node *UsageTotal) usagetotalOption {
  23709. return func(m *UsageTotalMutation) {
  23710. m.oldValue = func(context.Context) (*UsageTotal, error) {
  23711. return node, nil
  23712. }
  23713. m.id = &node.ID
  23714. }
  23715. }
  23716. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23717. // executed in a transaction (ent.Tx), a transactional client is returned.
  23718. func (m UsageTotalMutation) Client() *Client {
  23719. client := &Client{config: m.config}
  23720. client.init()
  23721. return client
  23722. }
  23723. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23724. // it returns an error otherwise.
  23725. func (m UsageTotalMutation) Tx() (*Tx, error) {
  23726. if _, ok := m.driver.(*txDriver); !ok {
  23727. return nil, errors.New("ent: mutation is not running in a transaction")
  23728. }
  23729. tx := &Tx{config: m.config}
  23730. tx.init()
  23731. return tx, nil
  23732. }
  23733. // SetID sets the value of the id field. Note that this
  23734. // operation is only accepted on creation of UsageTotal entities.
  23735. func (m *UsageTotalMutation) SetID(id uint64) {
  23736. m.id = &id
  23737. }
  23738. // ID returns the ID value in the mutation. Note that the ID is only available
  23739. // if it was provided to the builder or after it was returned from the database.
  23740. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  23741. if m.id == nil {
  23742. return
  23743. }
  23744. return *m.id, true
  23745. }
  23746. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23747. // That means, if the mutation is applied within a transaction with an isolation level such
  23748. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23749. // or updated by the mutation.
  23750. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  23751. switch {
  23752. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23753. id, exists := m.ID()
  23754. if exists {
  23755. return []uint64{id}, nil
  23756. }
  23757. fallthrough
  23758. case m.op.Is(OpUpdate | OpDelete):
  23759. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  23760. default:
  23761. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23762. }
  23763. }
  23764. // SetCreatedAt sets the "created_at" field.
  23765. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  23766. m.created_at = &t
  23767. }
  23768. // CreatedAt returns the value of the "created_at" field in the mutation.
  23769. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  23770. v := m.created_at
  23771. if v == nil {
  23772. return
  23773. }
  23774. return *v, true
  23775. }
  23776. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  23777. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  23778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23779. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23780. if !m.op.Is(OpUpdateOne) {
  23781. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23782. }
  23783. if m.id == nil || m.oldValue == nil {
  23784. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23785. }
  23786. oldValue, err := m.oldValue(ctx)
  23787. if err != nil {
  23788. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23789. }
  23790. return oldValue.CreatedAt, nil
  23791. }
  23792. // ResetCreatedAt resets all changes to the "created_at" field.
  23793. func (m *UsageTotalMutation) ResetCreatedAt() {
  23794. m.created_at = nil
  23795. }
  23796. // SetUpdatedAt sets the "updated_at" field.
  23797. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  23798. m.updated_at = &t
  23799. }
  23800. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23801. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  23802. v := m.updated_at
  23803. if v == nil {
  23804. return
  23805. }
  23806. return *v, true
  23807. }
  23808. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  23809. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  23810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23811. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23812. if !m.op.Is(OpUpdateOne) {
  23813. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23814. }
  23815. if m.id == nil || m.oldValue == nil {
  23816. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23817. }
  23818. oldValue, err := m.oldValue(ctx)
  23819. if err != nil {
  23820. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23821. }
  23822. return oldValue.UpdatedAt, nil
  23823. }
  23824. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23825. func (m *UsageTotalMutation) ResetUpdatedAt() {
  23826. m.updated_at = nil
  23827. }
  23828. // SetStatus sets the "status" field.
  23829. func (m *UsageTotalMutation) SetStatus(u uint8) {
  23830. m.status = &u
  23831. m.addstatus = nil
  23832. }
  23833. // Status returns the value of the "status" field in the mutation.
  23834. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  23835. v := m.status
  23836. if v == nil {
  23837. return
  23838. }
  23839. return *v, true
  23840. }
  23841. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  23842. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  23843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23844. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23845. if !m.op.Is(OpUpdateOne) {
  23846. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23847. }
  23848. if m.id == nil || m.oldValue == nil {
  23849. return v, errors.New("OldStatus requires an ID field in the mutation")
  23850. }
  23851. oldValue, err := m.oldValue(ctx)
  23852. if err != nil {
  23853. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23854. }
  23855. return oldValue.Status, nil
  23856. }
  23857. // AddStatus adds u to the "status" field.
  23858. func (m *UsageTotalMutation) AddStatus(u int8) {
  23859. if m.addstatus != nil {
  23860. *m.addstatus += u
  23861. } else {
  23862. m.addstatus = &u
  23863. }
  23864. }
  23865. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23866. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  23867. v := m.addstatus
  23868. if v == nil {
  23869. return
  23870. }
  23871. return *v, true
  23872. }
  23873. // ClearStatus clears the value of the "status" field.
  23874. func (m *UsageTotalMutation) ClearStatus() {
  23875. m.status = nil
  23876. m.addstatus = nil
  23877. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  23878. }
  23879. // StatusCleared returns if the "status" field was cleared in this mutation.
  23880. func (m *UsageTotalMutation) StatusCleared() bool {
  23881. _, ok := m.clearedFields[usagetotal.FieldStatus]
  23882. return ok
  23883. }
  23884. // ResetStatus resets all changes to the "status" field.
  23885. func (m *UsageTotalMutation) ResetStatus() {
  23886. m.status = nil
  23887. m.addstatus = nil
  23888. delete(m.clearedFields, usagetotal.FieldStatus)
  23889. }
  23890. // SetType sets the "type" field.
  23891. func (m *UsageTotalMutation) SetType(i int) {
  23892. m._type = &i
  23893. m.add_type = nil
  23894. }
  23895. // GetType returns the value of the "type" field in the mutation.
  23896. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  23897. v := m._type
  23898. if v == nil {
  23899. return
  23900. }
  23901. return *v, true
  23902. }
  23903. // OldType returns the old "type" field's value of the UsageTotal entity.
  23904. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  23905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23906. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  23907. if !m.op.Is(OpUpdateOne) {
  23908. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23909. }
  23910. if m.id == nil || m.oldValue == nil {
  23911. return v, errors.New("OldType requires an ID field in the mutation")
  23912. }
  23913. oldValue, err := m.oldValue(ctx)
  23914. if err != nil {
  23915. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23916. }
  23917. return oldValue.Type, nil
  23918. }
  23919. // AddType adds i to the "type" field.
  23920. func (m *UsageTotalMutation) AddType(i int) {
  23921. if m.add_type != nil {
  23922. *m.add_type += i
  23923. } else {
  23924. m.add_type = &i
  23925. }
  23926. }
  23927. // AddedType returns the value that was added to the "type" field in this mutation.
  23928. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  23929. v := m.add_type
  23930. if v == nil {
  23931. return
  23932. }
  23933. return *v, true
  23934. }
  23935. // ClearType clears the value of the "type" field.
  23936. func (m *UsageTotalMutation) ClearType() {
  23937. m._type = nil
  23938. m.add_type = nil
  23939. m.clearedFields[usagetotal.FieldType] = struct{}{}
  23940. }
  23941. // TypeCleared returns if the "type" field was cleared in this mutation.
  23942. func (m *UsageTotalMutation) TypeCleared() bool {
  23943. _, ok := m.clearedFields[usagetotal.FieldType]
  23944. return ok
  23945. }
  23946. // ResetType resets all changes to the "type" field.
  23947. func (m *UsageTotalMutation) ResetType() {
  23948. m._type = nil
  23949. m.add_type = nil
  23950. delete(m.clearedFields, usagetotal.FieldType)
  23951. }
  23952. // SetBotID sets the "bot_id" field.
  23953. func (m *UsageTotalMutation) SetBotID(s string) {
  23954. m.bot_id = &s
  23955. }
  23956. // BotID returns the value of the "bot_id" field in the mutation.
  23957. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  23958. v := m.bot_id
  23959. if v == nil {
  23960. return
  23961. }
  23962. return *v, true
  23963. }
  23964. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  23965. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  23966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23967. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  23968. if !m.op.Is(OpUpdateOne) {
  23969. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  23970. }
  23971. if m.id == nil || m.oldValue == nil {
  23972. return v, errors.New("OldBotID requires an ID field in the mutation")
  23973. }
  23974. oldValue, err := m.oldValue(ctx)
  23975. if err != nil {
  23976. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  23977. }
  23978. return oldValue.BotID, nil
  23979. }
  23980. // ResetBotID resets all changes to the "bot_id" field.
  23981. func (m *UsageTotalMutation) ResetBotID() {
  23982. m.bot_id = nil
  23983. }
  23984. // SetTotalTokens sets the "total_tokens" field.
  23985. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  23986. m.total_tokens = &u
  23987. m.addtotal_tokens = nil
  23988. }
  23989. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  23990. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  23991. v := m.total_tokens
  23992. if v == nil {
  23993. return
  23994. }
  23995. return *v, true
  23996. }
  23997. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  23998. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  23999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24000. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  24001. if !m.op.Is(OpUpdateOne) {
  24002. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  24003. }
  24004. if m.id == nil || m.oldValue == nil {
  24005. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  24006. }
  24007. oldValue, err := m.oldValue(ctx)
  24008. if err != nil {
  24009. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  24010. }
  24011. return oldValue.TotalTokens, nil
  24012. }
  24013. // AddTotalTokens adds u to the "total_tokens" field.
  24014. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  24015. if m.addtotal_tokens != nil {
  24016. *m.addtotal_tokens += u
  24017. } else {
  24018. m.addtotal_tokens = &u
  24019. }
  24020. }
  24021. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  24022. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  24023. v := m.addtotal_tokens
  24024. if v == nil {
  24025. return
  24026. }
  24027. return *v, true
  24028. }
  24029. // ClearTotalTokens clears the value of the "total_tokens" field.
  24030. func (m *UsageTotalMutation) ClearTotalTokens() {
  24031. m.total_tokens = nil
  24032. m.addtotal_tokens = nil
  24033. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  24034. }
  24035. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  24036. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  24037. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  24038. return ok
  24039. }
  24040. // ResetTotalTokens resets all changes to the "total_tokens" field.
  24041. func (m *UsageTotalMutation) ResetTotalTokens() {
  24042. m.total_tokens = nil
  24043. m.addtotal_tokens = nil
  24044. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  24045. }
  24046. // SetStartIndex sets the "start_index" field.
  24047. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  24048. m.start_index = &u
  24049. m.addstart_index = nil
  24050. }
  24051. // StartIndex returns the value of the "start_index" field in the mutation.
  24052. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  24053. v := m.start_index
  24054. if v == nil {
  24055. return
  24056. }
  24057. return *v, true
  24058. }
  24059. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  24060. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24062. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  24063. if !m.op.Is(OpUpdateOne) {
  24064. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  24065. }
  24066. if m.id == nil || m.oldValue == nil {
  24067. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  24068. }
  24069. oldValue, err := m.oldValue(ctx)
  24070. if err != nil {
  24071. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  24072. }
  24073. return oldValue.StartIndex, nil
  24074. }
  24075. // AddStartIndex adds u to the "start_index" field.
  24076. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  24077. if m.addstart_index != nil {
  24078. *m.addstart_index += u
  24079. } else {
  24080. m.addstart_index = &u
  24081. }
  24082. }
  24083. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  24084. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  24085. v := m.addstart_index
  24086. if v == nil {
  24087. return
  24088. }
  24089. return *v, true
  24090. }
  24091. // ClearStartIndex clears the value of the "start_index" field.
  24092. func (m *UsageTotalMutation) ClearStartIndex() {
  24093. m.start_index = nil
  24094. m.addstart_index = nil
  24095. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  24096. }
  24097. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  24098. func (m *UsageTotalMutation) StartIndexCleared() bool {
  24099. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  24100. return ok
  24101. }
  24102. // ResetStartIndex resets all changes to the "start_index" field.
  24103. func (m *UsageTotalMutation) ResetStartIndex() {
  24104. m.start_index = nil
  24105. m.addstart_index = nil
  24106. delete(m.clearedFields, usagetotal.FieldStartIndex)
  24107. }
  24108. // SetEndIndex sets the "end_index" field.
  24109. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  24110. m.end_index = &u
  24111. m.addend_index = nil
  24112. }
  24113. // EndIndex returns the value of the "end_index" field in the mutation.
  24114. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  24115. v := m.end_index
  24116. if v == nil {
  24117. return
  24118. }
  24119. return *v, true
  24120. }
  24121. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  24122. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24124. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  24125. if !m.op.Is(OpUpdateOne) {
  24126. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  24127. }
  24128. if m.id == nil || m.oldValue == nil {
  24129. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  24130. }
  24131. oldValue, err := m.oldValue(ctx)
  24132. if err != nil {
  24133. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  24134. }
  24135. return oldValue.EndIndex, nil
  24136. }
  24137. // AddEndIndex adds u to the "end_index" field.
  24138. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  24139. if m.addend_index != nil {
  24140. *m.addend_index += u
  24141. } else {
  24142. m.addend_index = &u
  24143. }
  24144. }
  24145. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  24146. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  24147. v := m.addend_index
  24148. if v == nil {
  24149. return
  24150. }
  24151. return *v, true
  24152. }
  24153. // ClearEndIndex clears the value of the "end_index" field.
  24154. func (m *UsageTotalMutation) ClearEndIndex() {
  24155. m.end_index = nil
  24156. m.addend_index = nil
  24157. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  24158. }
  24159. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  24160. func (m *UsageTotalMutation) EndIndexCleared() bool {
  24161. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  24162. return ok
  24163. }
  24164. // ResetEndIndex resets all changes to the "end_index" field.
  24165. func (m *UsageTotalMutation) ResetEndIndex() {
  24166. m.end_index = nil
  24167. m.addend_index = nil
  24168. delete(m.clearedFields, usagetotal.FieldEndIndex)
  24169. }
  24170. // SetOrganizationID sets the "organization_id" field.
  24171. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  24172. m.organization_id = &u
  24173. m.addorganization_id = nil
  24174. }
  24175. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24176. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  24177. v := m.organization_id
  24178. if v == nil {
  24179. return
  24180. }
  24181. return *v, true
  24182. }
  24183. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  24184. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24186. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24187. if !m.op.Is(OpUpdateOne) {
  24188. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24189. }
  24190. if m.id == nil || m.oldValue == nil {
  24191. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24192. }
  24193. oldValue, err := m.oldValue(ctx)
  24194. if err != nil {
  24195. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24196. }
  24197. return oldValue.OrganizationID, nil
  24198. }
  24199. // AddOrganizationID adds u to the "organization_id" field.
  24200. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  24201. if m.addorganization_id != nil {
  24202. *m.addorganization_id += u
  24203. } else {
  24204. m.addorganization_id = &u
  24205. }
  24206. }
  24207. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24208. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  24209. v := m.addorganization_id
  24210. if v == nil {
  24211. return
  24212. }
  24213. return *v, true
  24214. }
  24215. // ClearOrganizationID clears the value of the "organization_id" field.
  24216. func (m *UsageTotalMutation) ClearOrganizationID() {
  24217. m.organization_id = nil
  24218. m.addorganization_id = nil
  24219. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  24220. }
  24221. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24222. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  24223. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  24224. return ok
  24225. }
  24226. // ResetOrganizationID resets all changes to the "organization_id" field.
  24227. func (m *UsageTotalMutation) ResetOrganizationID() {
  24228. m.organization_id = nil
  24229. m.addorganization_id = nil
  24230. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  24231. }
  24232. // Where appends a list predicates to the UsageTotalMutation builder.
  24233. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  24234. m.predicates = append(m.predicates, ps...)
  24235. }
  24236. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  24237. // users can use type-assertion to append predicates that do not depend on any generated package.
  24238. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  24239. p := make([]predicate.UsageTotal, len(ps))
  24240. for i := range ps {
  24241. p[i] = ps[i]
  24242. }
  24243. m.Where(p...)
  24244. }
  24245. // Op returns the operation name.
  24246. func (m *UsageTotalMutation) Op() Op {
  24247. return m.op
  24248. }
  24249. // SetOp allows setting the mutation operation.
  24250. func (m *UsageTotalMutation) SetOp(op Op) {
  24251. m.op = op
  24252. }
  24253. // Type returns the node type of this mutation (UsageTotal).
  24254. func (m *UsageTotalMutation) Type() string {
  24255. return m.typ
  24256. }
  24257. // Fields returns all fields that were changed during this mutation. Note that in
  24258. // order to get all numeric fields that were incremented/decremented, call
  24259. // AddedFields().
  24260. func (m *UsageTotalMutation) Fields() []string {
  24261. fields := make([]string, 0, 9)
  24262. if m.created_at != nil {
  24263. fields = append(fields, usagetotal.FieldCreatedAt)
  24264. }
  24265. if m.updated_at != nil {
  24266. fields = append(fields, usagetotal.FieldUpdatedAt)
  24267. }
  24268. if m.status != nil {
  24269. fields = append(fields, usagetotal.FieldStatus)
  24270. }
  24271. if m._type != nil {
  24272. fields = append(fields, usagetotal.FieldType)
  24273. }
  24274. if m.bot_id != nil {
  24275. fields = append(fields, usagetotal.FieldBotID)
  24276. }
  24277. if m.total_tokens != nil {
  24278. fields = append(fields, usagetotal.FieldTotalTokens)
  24279. }
  24280. if m.start_index != nil {
  24281. fields = append(fields, usagetotal.FieldStartIndex)
  24282. }
  24283. if m.end_index != nil {
  24284. fields = append(fields, usagetotal.FieldEndIndex)
  24285. }
  24286. if m.organization_id != nil {
  24287. fields = append(fields, usagetotal.FieldOrganizationID)
  24288. }
  24289. return fields
  24290. }
  24291. // Field returns the value of a field with the given name. The second boolean
  24292. // return value indicates that this field was not set, or was not defined in the
  24293. // schema.
  24294. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  24295. switch name {
  24296. case usagetotal.FieldCreatedAt:
  24297. return m.CreatedAt()
  24298. case usagetotal.FieldUpdatedAt:
  24299. return m.UpdatedAt()
  24300. case usagetotal.FieldStatus:
  24301. return m.Status()
  24302. case usagetotal.FieldType:
  24303. return m.GetType()
  24304. case usagetotal.FieldBotID:
  24305. return m.BotID()
  24306. case usagetotal.FieldTotalTokens:
  24307. return m.TotalTokens()
  24308. case usagetotal.FieldStartIndex:
  24309. return m.StartIndex()
  24310. case usagetotal.FieldEndIndex:
  24311. return m.EndIndex()
  24312. case usagetotal.FieldOrganizationID:
  24313. return m.OrganizationID()
  24314. }
  24315. return nil, false
  24316. }
  24317. // OldField returns the old value of the field from the database. An error is
  24318. // returned if the mutation operation is not UpdateOne, or the query to the
  24319. // database failed.
  24320. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24321. switch name {
  24322. case usagetotal.FieldCreatedAt:
  24323. return m.OldCreatedAt(ctx)
  24324. case usagetotal.FieldUpdatedAt:
  24325. return m.OldUpdatedAt(ctx)
  24326. case usagetotal.FieldStatus:
  24327. return m.OldStatus(ctx)
  24328. case usagetotal.FieldType:
  24329. return m.OldType(ctx)
  24330. case usagetotal.FieldBotID:
  24331. return m.OldBotID(ctx)
  24332. case usagetotal.FieldTotalTokens:
  24333. return m.OldTotalTokens(ctx)
  24334. case usagetotal.FieldStartIndex:
  24335. return m.OldStartIndex(ctx)
  24336. case usagetotal.FieldEndIndex:
  24337. return m.OldEndIndex(ctx)
  24338. case usagetotal.FieldOrganizationID:
  24339. return m.OldOrganizationID(ctx)
  24340. }
  24341. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  24342. }
  24343. // SetField sets the value of a field with the given name. It returns an error if
  24344. // the field is not defined in the schema, or if the type mismatched the field
  24345. // type.
  24346. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  24347. switch name {
  24348. case usagetotal.FieldCreatedAt:
  24349. v, ok := value.(time.Time)
  24350. if !ok {
  24351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24352. }
  24353. m.SetCreatedAt(v)
  24354. return nil
  24355. case usagetotal.FieldUpdatedAt:
  24356. v, ok := value.(time.Time)
  24357. if !ok {
  24358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24359. }
  24360. m.SetUpdatedAt(v)
  24361. return nil
  24362. case usagetotal.FieldStatus:
  24363. v, ok := value.(uint8)
  24364. if !ok {
  24365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24366. }
  24367. m.SetStatus(v)
  24368. return nil
  24369. case usagetotal.FieldType:
  24370. v, ok := value.(int)
  24371. if !ok {
  24372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24373. }
  24374. m.SetType(v)
  24375. return nil
  24376. case usagetotal.FieldBotID:
  24377. v, ok := value.(string)
  24378. if !ok {
  24379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24380. }
  24381. m.SetBotID(v)
  24382. return nil
  24383. case usagetotal.FieldTotalTokens:
  24384. v, ok := value.(uint64)
  24385. if !ok {
  24386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24387. }
  24388. m.SetTotalTokens(v)
  24389. return nil
  24390. case usagetotal.FieldStartIndex:
  24391. v, ok := value.(uint64)
  24392. if !ok {
  24393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24394. }
  24395. m.SetStartIndex(v)
  24396. return nil
  24397. case usagetotal.FieldEndIndex:
  24398. v, ok := value.(uint64)
  24399. if !ok {
  24400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24401. }
  24402. m.SetEndIndex(v)
  24403. return nil
  24404. case usagetotal.FieldOrganizationID:
  24405. v, ok := value.(uint64)
  24406. if !ok {
  24407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24408. }
  24409. m.SetOrganizationID(v)
  24410. return nil
  24411. }
  24412. return fmt.Errorf("unknown UsageTotal field %s", name)
  24413. }
  24414. // AddedFields returns all numeric fields that were incremented/decremented during
  24415. // this mutation.
  24416. func (m *UsageTotalMutation) AddedFields() []string {
  24417. var fields []string
  24418. if m.addstatus != nil {
  24419. fields = append(fields, usagetotal.FieldStatus)
  24420. }
  24421. if m.add_type != nil {
  24422. fields = append(fields, usagetotal.FieldType)
  24423. }
  24424. if m.addtotal_tokens != nil {
  24425. fields = append(fields, usagetotal.FieldTotalTokens)
  24426. }
  24427. if m.addstart_index != nil {
  24428. fields = append(fields, usagetotal.FieldStartIndex)
  24429. }
  24430. if m.addend_index != nil {
  24431. fields = append(fields, usagetotal.FieldEndIndex)
  24432. }
  24433. if m.addorganization_id != nil {
  24434. fields = append(fields, usagetotal.FieldOrganizationID)
  24435. }
  24436. return fields
  24437. }
  24438. // AddedField returns the numeric value that was incremented/decremented on a field
  24439. // with the given name. The second boolean return value indicates that this field
  24440. // was not set, or was not defined in the schema.
  24441. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  24442. switch name {
  24443. case usagetotal.FieldStatus:
  24444. return m.AddedStatus()
  24445. case usagetotal.FieldType:
  24446. return m.AddedType()
  24447. case usagetotal.FieldTotalTokens:
  24448. return m.AddedTotalTokens()
  24449. case usagetotal.FieldStartIndex:
  24450. return m.AddedStartIndex()
  24451. case usagetotal.FieldEndIndex:
  24452. return m.AddedEndIndex()
  24453. case usagetotal.FieldOrganizationID:
  24454. return m.AddedOrganizationID()
  24455. }
  24456. return nil, false
  24457. }
  24458. // AddField adds the value to the field with the given name. It returns an error if
  24459. // the field is not defined in the schema, or if the type mismatched the field
  24460. // type.
  24461. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  24462. switch name {
  24463. case usagetotal.FieldStatus:
  24464. v, ok := value.(int8)
  24465. if !ok {
  24466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24467. }
  24468. m.AddStatus(v)
  24469. return nil
  24470. case usagetotal.FieldType:
  24471. v, ok := value.(int)
  24472. if !ok {
  24473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24474. }
  24475. m.AddType(v)
  24476. return nil
  24477. case usagetotal.FieldTotalTokens:
  24478. v, ok := value.(int64)
  24479. if !ok {
  24480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24481. }
  24482. m.AddTotalTokens(v)
  24483. return nil
  24484. case usagetotal.FieldStartIndex:
  24485. v, ok := value.(int64)
  24486. if !ok {
  24487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24488. }
  24489. m.AddStartIndex(v)
  24490. return nil
  24491. case usagetotal.FieldEndIndex:
  24492. v, ok := value.(int64)
  24493. if !ok {
  24494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24495. }
  24496. m.AddEndIndex(v)
  24497. return nil
  24498. case usagetotal.FieldOrganizationID:
  24499. v, ok := value.(int64)
  24500. if !ok {
  24501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24502. }
  24503. m.AddOrganizationID(v)
  24504. return nil
  24505. }
  24506. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  24507. }
  24508. // ClearedFields returns all nullable fields that were cleared during this
  24509. // mutation.
  24510. func (m *UsageTotalMutation) ClearedFields() []string {
  24511. var fields []string
  24512. if m.FieldCleared(usagetotal.FieldStatus) {
  24513. fields = append(fields, usagetotal.FieldStatus)
  24514. }
  24515. if m.FieldCleared(usagetotal.FieldType) {
  24516. fields = append(fields, usagetotal.FieldType)
  24517. }
  24518. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  24519. fields = append(fields, usagetotal.FieldTotalTokens)
  24520. }
  24521. if m.FieldCleared(usagetotal.FieldStartIndex) {
  24522. fields = append(fields, usagetotal.FieldStartIndex)
  24523. }
  24524. if m.FieldCleared(usagetotal.FieldEndIndex) {
  24525. fields = append(fields, usagetotal.FieldEndIndex)
  24526. }
  24527. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  24528. fields = append(fields, usagetotal.FieldOrganizationID)
  24529. }
  24530. return fields
  24531. }
  24532. // FieldCleared returns a boolean indicating if a field with the given name was
  24533. // cleared in this mutation.
  24534. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  24535. _, ok := m.clearedFields[name]
  24536. return ok
  24537. }
  24538. // ClearField clears the value of the field with the given name. It returns an
  24539. // error if the field is not defined in the schema.
  24540. func (m *UsageTotalMutation) ClearField(name string) error {
  24541. switch name {
  24542. case usagetotal.FieldStatus:
  24543. m.ClearStatus()
  24544. return nil
  24545. case usagetotal.FieldType:
  24546. m.ClearType()
  24547. return nil
  24548. case usagetotal.FieldTotalTokens:
  24549. m.ClearTotalTokens()
  24550. return nil
  24551. case usagetotal.FieldStartIndex:
  24552. m.ClearStartIndex()
  24553. return nil
  24554. case usagetotal.FieldEndIndex:
  24555. m.ClearEndIndex()
  24556. return nil
  24557. case usagetotal.FieldOrganizationID:
  24558. m.ClearOrganizationID()
  24559. return nil
  24560. }
  24561. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  24562. }
  24563. // ResetField resets all changes in the mutation for the field with the given name.
  24564. // It returns an error if the field is not defined in the schema.
  24565. func (m *UsageTotalMutation) ResetField(name string) error {
  24566. switch name {
  24567. case usagetotal.FieldCreatedAt:
  24568. m.ResetCreatedAt()
  24569. return nil
  24570. case usagetotal.FieldUpdatedAt:
  24571. m.ResetUpdatedAt()
  24572. return nil
  24573. case usagetotal.FieldStatus:
  24574. m.ResetStatus()
  24575. return nil
  24576. case usagetotal.FieldType:
  24577. m.ResetType()
  24578. return nil
  24579. case usagetotal.FieldBotID:
  24580. m.ResetBotID()
  24581. return nil
  24582. case usagetotal.FieldTotalTokens:
  24583. m.ResetTotalTokens()
  24584. return nil
  24585. case usagetotal.FieldStartIndex:
  24586. m.ResetStartIndex()
  24587. return nil
  24588. case usagetotal.FieldEndIndex:
  24589. m.ResetEndIndex()
  24590. return nil
  24591. case usagetotal.FieldOrganizationID:
  24592. m.ResetOrganizationID()
  24593. return nil
  24594. }
  24595. return fmt.Errorf("unknown UsageTotal field %s", name)
  24596. }
  24597. // AddedEdges returns all edge names that were set/added in this mutation.
  24598. func (m *UsageTotalMutation) AddedEdges() []string {
  24599. edges := make([]string, 0, 0)
  24600. return edges
  24601. }
  24602. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24603. // name in this mutation.
  24604. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  24605. return nil
  24606. }
  24607. // RemovedEdges returns all edge names that were removed in this mutation.
  24608. func (m *UsageTotalMutation) RemovedEdges() []string {
  24609. edges := make([]string, 0, 0)
  24610. return edges
  24611. }
  24612. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24613. // the given name in this mutation.
  24614. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  24615. return nil
  24616. }
  24617. // ClearedEdges returns all edge names that were cleared in this mutation.
  24618. func (m *UsageTotalMutation) ClearedEdges() []string {
  24619. edges := make([]string, 0, 0)
  24620. return edges
  24621. }
  24622. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24623. // was cleared in this mutation.
  24624. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  24625. return false
  24626. }
  24627. // ClearEdge clears the value of the edge with the given name. It returns an error
  24628. // if that edge is not defined in the schema.
  24629. func (m *UsageTotalMutation) ClearEdge(name string) error {
  24630. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  24631. }
  24632. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24633. // It returns an error if the edge is not defined in the schema.
  24634. func (m *UsageTotalMutation) ResetEdge(name string) error {
  24635. return fmt.Errorf("unknown UsageTotal edge %s", name)
  24636. }
  24637. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  24638. type WorkExperienceMutation struct {
  24639. config
  24640. op Op
  24641. typ string
  24642. id *uint64
  24643. created_at *time.Time
  24644. updated_at *time.Time
  24645. deleted_at *time.Time
  24646. start_date *time.Time
  24647. end_date *time.Time
  24648. company *string
  24649. experience *string
  24650. organization_id *uint64
  24651. addorganization_id *int64
  24652. clearedFields map[string]struct{}
  24653. employee *uint64
  24654. clearedemployee bool
  24655. done bool
  24656. oldValue func(context.Context) (*WorkExperience, error)
  24657. predicates []predicate.WorkExperience
  24658. }
  24659. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  24660. // workexperienceOption allows management of the mutation configuration using functional options.
  24661. type workexperienceOption func(*WorkExperienceMutation)
  24662. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  24663. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  24664. m := &WorkExperienceMutation{
  24665. config: c,
  24666. op: op,
  24667. typ: TypeWorkExperience,
  24668. clearedFields: make(map[string]struct{}),
  24669. }
  24670. for _, opt := range opts {
  24671. opt(m)
  24672. }
  24673. return m
  24674. }
  24675. // withWorkExperienceID sets the ID field of the mutation.
  24676. func withWorkExperienceID(id uint64) workexperienceOption {
  24677. return func(m *WorkExperienceMutation) {
  24678. var (
  24679. err error
  24680. once sync.Once
  24681. value *WorkExperience
  24682. )
  24683. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  24684. once.Do(func() {
  24685. if m.done {
  24686. err = errors.New("querying old values post mutation is not allowed")
  24687. } else {
  24688. value, err = m.Client().WorkExperience.Get(ctx, id)
  24689. }
  24690. })
  24691. return value, err
  24692. }
  24693. m.id = &id
  24694. }
  24695. }
  24696. // withWorkExperience sets the old WorkExperience of the mutation.
  24697. func withWorkExperience(node *WorkExperience) workexperienceOption {
  24698. return func(m *WorkExperienceMutation) {
  24699. m.oldValue = func(context.Context) (*WorkExperience, error) {
  24700. return node, nil
  24701. }
  24702. m.id = &node.ID
  24703. }
  24704. }
  24705. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24706. // executed in a transaction (ent.Tx), a transactional client is returned.
  24707. func (m WorkExperienceMutation) Client() *Client {
  24708. client := &Client{config: m.config}
  24709. client.init()
  24710. return client
  24711. }
  24712. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24713. // it returns an error otherwise.
  24714. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  24715. if _, ok := m.driver.(*txDriver); !ok {
  24716. return nil, errors.New("ent: mutation is not running in a transaction")
  24717. }
  24718. tx := &Tx{config: m.config}
  24719. tx.init()
  24720. return tx, nil
  24721. }
  24722. // SetID sets the value of the id field. Note that this
  24723. // operation is only accepted on creation of WorkExperience entities.
  24724. func (m *WorkExperienceMutation) SetID(id uint64) {
  24725. m.id = &id
  24726. }
  24727. // ID returns the ID value in the mutation. Note that the ID is only available
  24728. // if it was provided to the builder or after it was returned from the database.
  24729. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  24730. if m.id == nil {
  24731. return
  24732. }
  24733. return *m.id, true
  24734. }
  24735. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24736. // That means, if the mutation is applied within a transaction with an isolation level such
  24737. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24738. // or updated by the mutation.
  24739. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  24740. switch {
  24741. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24742. id, exists := m.ID()
  24743. if exists {
  24744. return []uint64{id}, nil
  24745. }
  24746. fallthrough
  24747. case m.op.Is(OpUpdate | OpDelete):
  24748. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  24749. default:
  24750. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24751. }
  24752. }
  24753. // SetCreatedAt sets the "created_at" field.
  24754. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  24755. m.created_at = &t
  24756. }
  24757. // CreatedAt returns the value of the "created_at" field in the mutation.
  24758. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  24759. v := m.created_at
  24760. if v == nil {
  24761. return
  24762. }
  24763. return *v, true
  24764. }
  24765. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  24766. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  24767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24768. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24769. if !m.op.Is(OpUpdateOne) {
  24770. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24771. }
  24772. if m.id == nil || m.oldValue == nil {
  24773. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24774. }
  24775. oldValue, err := m.oldValue(ctx)
  24776. if err != nil {
  24777. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24778. }
  24779. return oldValue.CreatedAt, nil
  24780. }
  24781. // ResetCreatedAt resets all changes to the "created_at" field.
  24782. func (m *WorkExperienceMutation) ResetCreatedAt() {
  24783. m.created_at = nil
  24784. }
  24785. // SetUpdatedAt sets the "updated_at" field.
  24786. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  24787. m.updated_at = &t
  24788. }
  24789. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24790. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  24791. v := m.updated_at
  24792. if v == nil {
  24793. return
  24794. }
  24795. return *v, true
  24796. }
  24797. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  24798. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  24799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24800. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24801. if !m.op.Is(OpUpdateOne) {
  24802. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24803. }
  24804. if m.id == nil || m.oldValue == nil {
  24805. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24806. }
  24807. oldValue, err := m.oldValue(ctx)
  24808. if err != nil {
  24809. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24810. }
  24811. return oldValue.UpdatedAt, nil
  24812. }
  24813. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24814. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  24815. m.updated_at = nil
  24816. }
  24817. // SetDeletedAt sets the "deleted_at" field.
  24818. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  24819. m.deleted_at = &t
  24820. }
  24821. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24822. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  24823. v := m.deleted_at
  24824. if v == nil {
  24825. return
  24826. }
  24827. return *v, true
  24828. }
  24829. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  24830. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  24831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24832. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24833. if !m.op.Is(OpUpdateOne) {
  24834. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24835. }
  24836. if m.id == nil || m.oldValue == nil {
  24837. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24838. }
  24839. oldValue, err := m.oldValue(ctx)
  24840. if err != nil {
  24841. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24842. }
  24843. return oldValue.DeletedAt, nil
  24844. }
  24845. // ClearDeletedAt clears the value of the "deleted_at" field.
  24846. func (m *WorkExperienceMutation) ClearDeletedAt() {
  24847. m.deleted_at = nil
  24848. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  24849. }
  24850. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24851. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  24852. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  24853. return ok
  24854. }
  24855. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24856. func (m *WorkExperienceMutation) ResetDeletedAt() {
  24857. m.deleted_at = nil
  24858. delete(m.clearedFields, workexperience.FieldDeletedAt)
  24859. }
  24860. // SetEmployeeID sets the "employee_id" field.
  24861. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  24862. m.employee = &u
  24863. }
  24864. // EmployeeID returns the value of the "employee_id" field in the mutation.
  24865. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  24866. v := m.employee
  24867. if v == nil {
  24868. return
  24869. }
  24870. return *v, true
  24871. }
  24872. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  24873. // If the WorkExperience 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 *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  24876. if !m.op.Is(OpUpdateOne) {
  24877. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  24878. }
  24879. if m.id == nil || m.oldValue == nil {
  24880. return v, errors.New("OldEmployeeID 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 OldEmployeeID: %w", err)
  24885. }
  24886. return oldValue.EmployeeID, nil
  24887. }
  24888. // ResetEmployeeID resets all changes to the "employee_id" field.
  24889. func (m *WorkExperienceMutation) ResetEmployeeID() {
  24890. m.employee = nil
  24891. }
  24892. // SetStartDate sets the "start_date" field.
  24893. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  24894. m.start_date = &t
  24895. }
  24896. // StartDate returns the value of the "start_date" field in the mutation.
  24897. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  24898. v := m.start_date
  24899. if v == nil {
  24900. return
  24901. }
  24902. return *v, true
  24903. }
  24904. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  24905. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  24906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24907. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  24908. if !m.op.Is(OpUpdateOne) {
  24909. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  24910. }
  24911. if m.id == nil || m.oldValue == nil {
  24912. return v, errors.New("OldStartDate requires an ID field in the mutation")
  24913. }
  24914. oldValue, err := m.oldValue(ctx)
  24915. if err != nil {
  24916. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  24917. }
  24918. return oldValue.StartDate, nil
  24919. }
  24920. // ResetStartDate resets all changes to the "start_date" field.
  24921. func (m *WorkExperienceMutation) ResetStartDate() {
  24922. m.start_date = nil
  24923. }
  24924. // SetEndDate sets the "end_date" field.
  24925. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  24926. m.end_date = &t
  24927. }
  24928. // EndDate returns the value of the "end_date" field in the mutation.
  24929. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  24930. v := m.end_date
  24931. if v == nil {
  24932. return
  24933. }
  24934. return *v, true
  24935. }
  24936. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  24937. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  24938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24939. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  24940. if !m.op.Is(OpUpdateOne) {
  24941. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  24942. }
  24943. if m.id == nil || m.oldValue == nil {
  24944. return v, errors.New("OldEndDate requires an ID field in the mutation")
  24945. }
  24946. oldValue, err := m.oldValue(ctx)
  24947. if err != nil {
  24948. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  24949. }
  24950. return oldValue.EndDate, nil
  24951. }
  24952. // ResetEndDate resets all changes to the "end_date" field.
  24953. func (m *WorkExperienceMutation) ResetEndDate() {
  24954. m.end_date = nil
  24955. }
  24956. // SetCompany sets the "company" field.
  24957. func (m *WorkExperienceMutation) SetCompany(s string) {
  24958. m.company = &s
  24959. }
  24960. // Company returns the value of the "company" field in the mutation.
  24961. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  24962. v := m.company
  24963. if v == nil {
  24964. return
  24965. }
  24966. return *v, true
  24967. }
  24968. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  24969. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  24970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24971. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  24972. if !m.op.Is(OpUpdateOne) {
  24973. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  24974. }
  24975. if m.id == nil || m.oldValue == nil {
  24976. return v, errors.New("OldCompany requires an ID field in the mutation")
  24977. }
  24978. oldValue, err := m.oldValue(ctx)
  24979. if err != nil {
  24980. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  24981. }
  24982. return oldValue.Company, nil
  24983. }
  24984. // ResetCompany resets all changes to the "company" field.
  24985. func (m *WorkExperienceMutation) ResetCompany() {
  24986. m.company = nil
  24987. }
  24988. // SetExperience sets the "experience" field.
  24989. func (m *WorkExperienceMutation) SetExperience(s string) {
  24990. m.experience = &s
  24991. }
  24992. // Experience returns the value of the "experience" field in the mutation.
  24993. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  24994. v := m.experience
  24995. if v == nil {
  24996. return
  24997. }
  24998. return *v, true
  24999. }
  25000. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  25001. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25003. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  25004. if !m.op.Is(OpUpdateOne) {
  25005. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  25006. }
  25007. if m.id == nil || m.oldValue == nil {
  25008. return v, errors.New("OldExperience requires an ID field in the mutation")
  25009. }
  25010. oldValue, err := m.oldValue(ctx)
  25011. if err != nil {
  25012. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  25013. }
  25014. return oldValue.Experience, nil
  25015. }
  25016. // ResetExperience resets all changes to the "experience" field.
  25017. func (m *WorkExperienceMutation) ResetExperience() {
  25018. m.experience = nil
  25019. }
  25020. // SetOrganizationID sets the "organization_id" field.
  25021. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  25022. m.organization_id = &u
  25023. m.addorganization_id = nil
  25024. }
  25025. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25026. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  25027. v := m.organization_id
  25028. if v == nil {
  25029. return
  25030. }
  25031. return *v, true
  25032. }
  25033. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  25034. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25036. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25037. if !m.op.Is(OpUpdateOne) {
  25038. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25039. }
  25040. if m.id == nil || m.oldValue == nil {
  25041. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25042. }
  25043. oldValue, err := m.oldValue(ctx)
  25044. if err != nil {
  25045. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25046. }
  25047. return oldValue.OrganizationID, nil
  25048. }
  25049. // AddOrganizationID adds u to the "organization_id" field.
  25050. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  25051. if m.addorganization_id != nil {
  25052. *m.addorganization_id += u
  25053. } else {
  25054. m.addorganization_id = &u
  25055. }
  25056. }
  25057. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25058. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  25059. v := m.addorganization_id
  25060. if v == nil {
  25061. return
  25062. }
  25063. return *v, true
  25064. }
  25065. // ResetOrganizationID resets all changes to the "organization_id" field.
  25066. func (m *WorkExperienceMutation) ResetOrganizationID() {
  25067. m.organization_id = nil
  25068. m.addorganization_id = nil
  25069. }
  25070. // ClearEmployee clears the "employee" edge to the Employee entity.
  25071. func (m *WorkExperienceMutation) ClearEmployee() {
  25072. m.clearedemployee = true
  25073. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  25074. }
  25075. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  25076. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  25077. return m.clearedemployee
  25078. }
  25079. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  25080. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25081. // EmployeeID instead. It exists only for internal usage by the builders.
  25082. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  25083. if id := m.employee; id != nil {
  25084. ids = append(ids, *id)
  25085. }
  25086. return
  25087. }
  25088. // ResetEmployee resets all changes to the "employee" edge.
  25089. func (m *WorkExperienceMutation) ResetEmployee() {
  25090. m.employee = nil
  25091. m.clearedemployee = false
  25092. }
  25093. // Where appends a list predicates to the WorkExperienceMutation builder.
  25094. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  25095. m.predicates = append(m.predicates, ps...)
  25096. }
  25097. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  25098. // users can use type-assertion to append predicates that do not depend on any generated package.
  25099. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  25100. p := make([]predicate.WorkExperience, len(ps))
  25101. for i := range ps {
  25102. p[i] = ps[i]
  25103. }
  25104. m.Where(p...)
  25105. }
  25106. // Op returns the operation name.
  25107. func (m *WorkExperienceMutation) Op() Op {
  25108. return m.op
  25109. }
  25110. // SetOp allows setting the mutation operation.
  25111. func (m *WorkExperienceMutation) SetOp(op Op) {
  25112. m.op = op
  25113. }
  25114. // Type returns the node type of this mutation (WorkExperience).
  25115. func (m *WorkExperienceMutation) Type() string {
  25116. return m.typ
  25117. }
  25118. // Fields returns all fields that were changed during this mutation. Note that in
  25119. // order to get all numeric fields that were incremented/decremented, call
  25120. // AddedFields().
  25121. func (m *WorkExperienceMutation) Fields() []string {
  25122. fields := make([]string, 0, 9)
  25123. if m.created_at != nil {
  25124. fields = append(fields, workexperience.FieldCreatedAt)
  25125. }
  25126. if m.updated_at != nil {
  25127. fields = append(fields, workexperience.FieldUpdatedAt)
  25128. }
  25129. if m.deleted_at != nil {
  25130. fields = append(fields, workexperience.FieldDeletedAt)
  25131. }
  25132. if m.employee != nil {
  25133. fields = append(fields, workexperience.FieldEmployeeID)
  25134. }
  25135. if m.start_date != nil {
  25136. fields = append(fields, workexperience.FieldStartDate)
  25137. }
  25138. if m.end_date != nil {
  25139. fields = append(fields, workexperience.FieldEndDate)
  25140. }
  25141. if m.company != nil {
  25142. fields = append(fields, workexperience.FieldCompany)
  25143. }
  25144. if m.experience != nil {
  25145. fields = append(fields, workexperience.FieldExperience)
  25146. }
  25147. if m.organization_id != nil {
  25148. fields = append(fields, workexperience.FieldOrganizationID)
  25149. }
  25150. return fields
  25151. }
  25152. // Field returns the value of a field with the given name. The second boolean
  25153. // return value indicates that this field was not set, or was not defined in the
  25154. // schema.
  25155. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  25156. switch name {
  25157. case workexperience.FieldCreatedAt:
  25158. return m.CreatedAt()
  25159. case workexperience.FieldUpdatedAt:
  25160. return m.UpdatedAt()
  25161. case workexperience.FieldDeletedAt:
  25162. return m.DeletedAt()
  25163. case workexperience.FieldEmployeeID:
  25164. return m.EmployeeID()
  25165. case workexperience.FieldStartDate:
  25166. return m.StartDate()
  25167. case workexperience.FieldEndDate:
  25168. return m.EndDate()
  25169. case workexperience.FieldCompany:
  25170. return m.Company()
  25171. case workexperience.FieldExperience:
  25172. return m.Experience()
  25173. case workexperience.FieldOrganizationID:
  25174. return m.OrganizationID()
  25175. }
  25176. return nil, false
  25177. }
  25178. // OldField returns the old value of the field from the database. An error is
  25179. // returned if the mutation operation is not UpdateOne, or the query to the
  25180. // database failed.
  25181. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25182. switch name {
  25183. case workexperience.FieldCreatedAt:
  25184. return m.OldCreatedAt(ctx)
  25185. case workexperience.FieldUpdatedAt:
  25186. return m.OldUpdatedAt(ctx)
  25187. case workexperience.FieldDeletedAt:
  25188. return m.OldDeletedAt(ctx)
  25189. case workexperience.FieldEmployeeID:
  25190. return m.OldEmployeeID(ctx)
  25191. case workexperience.FieldStartDate:
  25192. return m.OldStartDate(ctx)
  25193. case workexperience.FieldEndDate:
  25194. return m.OldEndDate(ctx)
  25195. case workexperience.FieldCompany:
  25196. return m.OldCompany(ctx)
  25197. case workexperience.FieldExperience:
  25198. return m.OldExperience(ctx)
  25199. case workexperience.FieldOrganizationID:
  25200. return m.OldOrganizationID(ctx)
  25201. }
  25202. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  25203. }
  25204. // SetField sets the value of a field with the given name. It returns an error if
  25205. // the field is not defined in the schema, or if the type mismatched the field
  25206. // type.
  25207. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  25208. switch name {
  25209. case workexperience.FieldCreatedAt:
  25210. v, ok := value.(time.Time)
  25211. if !ok {
  25212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25213. }
  25214. m.SetCreatedAt(v)
  25215. return nil
  25216. case workexperience.FieldUpdatedAt:
  25217. v, ok := value.(time.Time)
  25218. if !ok {
  25219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25220. }
  25221. m.SetUpdatedAt(v)
  25222. return nil
  25223. case workexperience.FieldDeletedAt:
  25224. v, ok := value.(time.Time)
  25225. if !ok {
  25226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25227. }
  25228. m.SetDeletedAt(v)
  25229. return nil
  25230. case workexperience.FieldEmployeeID:
  25231. v, ok := value.(uint64)
  25232. if !ok {
  25233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25234. }
  25235. m.SetEmployeeID(v)
  25236. return nil
  25237. case workexperience.FieldStartDate:
  25238. v, ok := value.(time.Time)
  25239. if !ok {
  25240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25241. }
  25242. m.SetStartDate(v)
  25243. return nil
  25244. case workexperience.FieldEndDate:
  25245. v, ok := value.(time.Time)
  25246. if !ok {
  25247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25248. }
  25249. m.SetEndDate(v)
  25250. return nil
  25251. case workexperience.FieldCompany:
  25252. v, ok := value.(string)
  25253. if !ok {
  25254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25255. }
  25256. m.SetCompany(v)
  25257. return nil
  25258. case workexperience.FieldExperience:
  25259. v, ok := value.(string)
  25260. if !ok {
  25261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25262. }
  25263. m.SetExperience(v)
  25264. return nil
  25265. case workexperience.FieldOrganizationID:
  25266. v, ok := value.(uint64)
  25267. if !ok {
  25268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25269. }
  25270. m.SetOrganizationID(v)
  25271. return nil
  25272. }
  25273. return fmt.Errorf("unknown WorkExperience field %s", name)
  25274. }
  25275. // AddedFields returns all numeric fields that were incremented/decremented during
  25276. // this mutation.
  25277. func (m *WorkExperienceMutation) AddedFields() []string {
  25278. var fields []string
  25279. if m.addorganization_id != nil {
  25280. fields = append(fields, workexperience.FieldOrganizationID)
  25281. }
  25282. return fields
  25283. }
  25284. // AddedField returns the numeric value that was incremented/decremented on a field
  25285. // with the given name. The second boolean return value indicates that this field
  25286. // was not set, or was not defined in the schema.
  25287. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  25288. switch name {
  25289. case workexperience.FieldOrganizationID:
  25290. return m.AddedOrganizationID()
  25291. }
  25292. return nil, false
  25293. }
  25294. // AddField adds the value to the field with the given name. It returns an error if
  25295. // the field is not defined in the schema, or if the type mismatched the field
  25296. // type.
  25297. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  25298. switch name {
  25299. case workexperience.FieldOrganizationID:
  25300. v, ok := value.(int64)
  25301. if !ok {
  25302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25303. }
  25304. m.AddOrganizationID(v)
  25305. return nil
  25306. }
  25307. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  25308. }
  25309. // ClearedFields returns all nullable fields that were cleared during this
  25310. // mutation.
  25311. func (m *WorkExperienceMutation) ClearedFields() []string {
  25312. var fields []string
  25313. if m.FieldCleared(workexperience.FieldDeletedAt) {
  25314. fields = append(fields, workexperience.FieldDeletedAt)
  25315. }
  25316. return fields
  25317. }
  25318. // FieldCleared returns a boolean indicating if a field with the given name was
  25319. // cleared in this mutation.
  25320. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  25321. _, ok := m.clearedFields[name]
  25322. return ok
  25323. }
  25324. // ClearField clears the value of the field with the given name. It returns an
  25325. // error if the field is not defined in the schema.
  25326. func (m *WorkExperienceMutation) ClearField(name string) error {
  25327. switch name {
  25328. case workexperience.FieldDeletedAt:
  25329. m.ClearDeletedAt()
  25330. return nil
  25331. }
  25332. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  25333. }
  25334. // ResetField resets all changes in the mutation for the field with the given name.
  25335. // It returns an error if the field is not defined in the schema.
  25336. func (m *WorkExperienceMutation) ResetField(name string) error {
  25337. switch name {
  25338. case workexperience.FieldCreatedAt:
  25339. m.ResetCreatedAt()
  25340. return nil
  25341. case workexperience.FieldUpdatedAt:
  25342. m.ResetUpdatedAt()
  25343. return nil
  25344. case workexperience.FieldDeletedAt:
  25345. m.ResetDeletedAt()
  25346. return nil
  25347. case workexperience.FieldEmployeeID:
  25348. m.ResetEmployeeID()
  25349. return nil
  25350. case workexperience.FieldStartDate:
  25351. m.ResetStartDate()
  25352. return nil
  25353. case workexperience.FieldEndDate:
  25354. m.ResetEndDate()
  25355. return nil
  25356. case workexperience.FieldCompany:
  25357. m.ResetCompany()
  25358. return nil
  25359. case workexperience.FieldExperience:
  25360. m.ResetExperience()
  25361. return nil
  25362. case workexperience.FieldOrganizationID:
  25363. m.ResetOrganizationID()
  25364. return nil
  25365. }
  25366. return fmt.Errorf("unknown WorkExperience field %s", name)
  25367. }
  25368. // AddedEdges returns all edge names that were set/added in this mutation.
  25369. func (m *WorkExperienceMutation) AddedEdges() []string {
  25370. edges := make([]string, 0, 1)
  25371. if m.employee != nil {
  25372. edges = append(edges, workexperience.EdgeEmployee)
  25373. }
  25374. return edges
  25375. }
  25376. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25377. // name in this mutation.
  25378. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  25379. switch name {
  25380. case workexperience.EdgeEmployee:
  25381. if id := m.employee; id != nil {
  25382. return []ent.Value{*id}
  25383. }
  25384. }
  25385. return nil
  25386. }
  25387. // RemovedEdges returns all edge names that were removed in this mutation.
  25388. func (m *WorkExperienceMutation) RemovedEdges() []string {
  25389. edges := make([]string, 0, 1)
  25390. return edges
  25391. }
  25392. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25393. // the given name in this mutation.
  25394. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  25395. return nil
  25396. }
  25397. // ClearedEdges returns all edge names that were cleared in this mutation.
  25398. func (m *WorkExperienceMutation) ClearedEdges() []string {
  25399. edges := make([]string, 0, 1)
  25400. if m.clearedemployee {
  25401. edges = append(edges, workexperience.EdgeEmployee)
  25402. }
  25403. return edges
  25404. }
  25405. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25406. // was cleared in this mutation.
  25407. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  25408. switch name {
  25409. case workexperience.EdgeEmployee:
  25410. return m.clearedemployee
  25411. }
  25412. return false
  25413. }
  25414. // ClearEdge clears the value of the edge with the given name. It returns an error
  25415. // if that edge is not defined in the schema.
  25416. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  25417. switch name {
  25418. case workexperience.EdgeEmployee:
  25419. m.ClearEmployee()
  25420. return nil
  25421. }
  25422. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  25423. }
  25424. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25425. // It returns an error if the edge is not defined in the schema.
  25426. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  25427. switch name {
  25428. case workexperience.EdgeEmployee:
  25429. m.ResetEmployee()
  25430. return nil
  25431. }
  25432. return fmt.Errorf("unknown WorkExperience edge %s", name)
  25433. }
  25434. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  25435. type WxMutation struct {
  25436. config
  25437. op Op
  25438. typ string
  25439. id *uint64
  25440. created_at *time.Time
  25441. updated_at *time.Time
  25442. status *uint8
  25443. addstatus *int8
  25444. deleted_at *time.Time
  25445. port *string
  25446. process_id *string
  25447. callback *string
  25448. wxid *string
  25449. account *string
  25450. nickname *string
  25451. tel *string
  25452. head_big *string
  25453. organization_id *uint64
  25454. addorganization_id *int64
  25455. api_base *string
  25456. api_key *string
  25457. allow_list *[]string
  25458. appendallow_list []string
  25459. group_allow_list *[]string
  25460. appendgroup_allow_list []string
  25461. block_list *[]string
  25462. appendblock_list []string
  25463. group_block_list *[]string
  25464. appendgroup_block_list []string
  25465. clearedFields map[string]struct{}
  25466. server *uint64
  25467. clearedserver bool
  25468. agent *uint64
  25469. clearedagent bool
  25470. done bool
  25471. oldValue func(context.Context) (*Wx, error)
  25472. predicates []predicate.Wx
  25473. }
  25474. var _ ent.Mutation = (*WxMutation)(nil)
  25475. // wxOption allows management of the mutation configuration using functional options.
  25476. type wxOption func(*WxMutation)
  25477. // newWxMutation creates new mutation for the Wx entity.
  25478. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  25479. m := &WxMutation{
  25480. config: c,
  25481. op: op,
  25482. typ: TypeWx,
  25483. clearedFields: make(map[string]struct{}),
  25484. }
  25485. for _, opt := range opts {
  25486. opt(m)
  25487. }
  25488. return m
  25489. }
  25490. // withWxID sets the ID field of the mutation.
  25491. func withWxID(id uint64) wxOption {
  25492. return func(m *WxMutation) {
  25493. var (
  25494. err error
  25495. once sync.Once
  25496. value *Wx
  25497. )
  25498. m.oldValue = func(ctx context.Context) (*Wx, error) {
  25499. once.Do(func() {
  25500. if m.done {
  25501. err = errors.New("querying old values post mutation is not allowed")
  25502. } else {
  25503. value, err = m.Client().Wx.Get(ctx, id)
  25504. }
  25505. })
  25506. return value, err
  25507. }
  25508. m.id = &id
  25509. }
  25510. }
  25511. // withWx sets the old Wx of the mutation.
  25512. func withWx(node *Wx) wxOption {
  25513. return func(m *WxMutation) {
  25514. m.oldValue = func(context.Context) (*Wx, error) {
  25515. return node, nil
  25516. }
  25517. m.id = &node.ID
  25518. }
  25519. }
  25520. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25521. // executed in a transaction (ent.Tx), a transactional client is returned.
  25522. func (m WxMutation) Client() *Client {
  25523. client := &Client{config: m.config}
  25524. client.init()
  25525. return client
  25526. }
  25527. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25528. // it returns an error otherwise.
  25529. func (m WxMutation) Tx() (*Tx, error) {
  25530. if _, ok := m.driver.(*txDriver); !ok {
  25531. return nil, errors.New("ent: mutation is not running in a transaction")
  25532. }
  25533. tx := &Tx{config: m.config}
  25534. tx.init()
  25535. return tx, nil
  25536. }
  25537. // SetID sets the value of the id field. Note that this
  25538. // operation is only accepted on creation of Wx entities.
  25539. func (m *WxMutation) SetID(id uint64) {
  25540. m.id = &id
  25541. }
  25542. // ID returns the ID value in the mutation. Note that the ID is only available
  25543. // if it was provided to the builder or after it was returned from the database.
  25544. func (m *WxMutation) ID() (id uint64, exists bool) {
  25545. if m.id == nil {
  25546. return
  25547. }
  25548. return *m.id, true
  25549. }
  25550. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25551. // That means, if the mutation is applied within a transaction with an isolation level such
  25552. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25553. // or updated by the mutation.
  25554. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  25555. switch {
  25556. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25557. id, exists := m.ID()
  25558. if exists {
  25559. return []uint64{id}, nil
  25560. }
  25561. fallthrough
  25562. case m.op.Is(OpUpdate | OpDelete):
  25563. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  25564. default:
  25565. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25566. }
  25567. }
  25568. // SetCreatedAt sets the "created_at" field.
  25569. func (m *WxMutation) SetCreatedAt(t time.Time) {
  25570. m.created_at = &t
  25571. }
  25572. // CreatedAt returns the value of the "created_at" field in the mutation.
  25573. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  25574. v := m.created_at
  25575. if v == nil {
  25576. return
  25577. }
  25578. return *v, true
  25579. }
  25580. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  25581. // If the Wx 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 *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25584. if !m.op.Is(OpUpdateOne) {
  25585. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25586. }
  25587. if m.id == nil || m.oldValue == nil {
  25588. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  25593. }
  25594. return oldValue.CreatedAt, nil
  25595. }
  25596. // ResetCreatedAt resets all changes to the "created_at" field.
  25597. func (m *WxMutation) ResetCreatedAt() {
  25598. m.created_at = nil
  25599. }
  25600. // SetUpdatedAt sets the "updated_at" field.
  25601. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  25602. m.updated_at = &t
  25603. }
  25604. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25605. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  25606. v := m.updated_at
  25607. if v == nil {
  25608. return
  25609. }
  25610. return *v, true
  25611. }
  25612. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  25613. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  25614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25615. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25616. if !m.op.Is(OpUpdateOne) {
  25617. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25618. }
  25619. if m.id == nil || m.oldValue == nil {
  25620. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25621. }
  25622. oldValue, err := m.oldValue(ctx)
  25623. if err != nil {
  25624. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25625. }
  25626. return oldValue.UpdatedAt, nil
  25627. }
  25628. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25629. func (m *WxMutation) ResetUpdatedAt() {
  25630. m.updated_at = nil
  25631. }
  25632. // SetStatus sets the "status" field.
  25633. func (m *WxMutation) SetStatus(u uint8) {
  25634. m.status = &u
  25635. m.addstatus = nil
  25636. }
  25637. // Status returns the value of the "status" field in the mutation.
  25638. func (m *WxMutation) Status() (r uint8, exists bool) {
  25639. v := m.status
  25640. if v == nil {
  25641. return
  25642. }
  25643. return *v, true
  25644. }
  25645. // OldStatus returns the old "status" field's value of the Wx entity.
  25646. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  25647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25648. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25649. if !m.op.Is(OpUpdateOne) {
  25650. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25651. }
  25652. if m.id == nil || m.oldValue == nil {
  25653. return v, errors.New("OldStatus requires an ID field in the mutation")
  25654. }
  25655. oldValue, err := m.oldValue(ctx)
  25656. if err != nil {
  25657. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25658. }
  25659. return oldValue.Status, nil
  25660. }
  25661. // AddStatus adds u to the "status" field.
  25662. func (m *WxMutation) AddStatus(u int8) {
  25663. if m.addstatus != nil {
  25664. *m.addstatus += u
  25665. } else {
  25666. m.addstatus = &u
  25667. }
  25668. }
  25669. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25670. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  25671. v := m.addstatus
  25672. if v == nil {
  25673. return
  25674. }
  25675. return *v, true
  25676. }
  25677. // ClearStatus clears the value of the "status" field.
  25678. func (m *WxMutation) ClearStatus() {
  25679. m.status = nil
  25680. m.addstatus = nil
  25681. m.clearedFields[wx.FieldStatus] = struct{}{}
  25682. }
  25683. // StatusCleared returns if the "status" field was cleared in this mutation.
  25684. func (m *WxMutation) StatusCleared() bool {
  25685. _, ok := m.clearedFields[wx.FieldStatus]
  25686. return ok
  25687. }
  25688. // ResetStatus resets all changes to the "status" field.
  25689. func (m *WxMutation) ResetStatus() {
  25690. m.status = nil
  25691. m.addstatus = nil
  25692. delete(m.clearedFields, wx.FieldStatus)
  25693. }
  25694. // SetDeletedAt sets the "deleted_at" field.
  25695. func (m *WxMutation) SetDeletedAt(t time.Time) {
  25696. m.deleted_at = &t
  25697. }
  25698. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25699. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  25700. v := m.deleted_at
  25701. if v == nil {
  25702. return
  25703. }
  25704. return *v, true
  25705. }
  25706. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  25707. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  25708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25709. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25710. if !m.op.Is(OpUpdateOne) {
  25711. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25712. }
  25713. if m.id == nil || m.oldValue == nil {
  25714. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25715. }
  25716. oldValue, err := m.oldValue(ctx)
  25717. if err != nil {
  25718. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25719. }
  25720. return oldValue.DeletedAt, nil
  25721. }
  25722. // ClearDeletedAt clears the value of the "deleted_at" field.
  25723. func (m *WxMutation) ClearDeletedAt() {
  25724. m.deleted_at = nil
  25725. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  25726. }
  25727. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25728. func (m *WxMutation) DeletedAtCleared() bool {
  25729. _, ok := m.clearedFields[wx.FieldDeletedAt]
  25730. return ok
  25731. }
  25732. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25733. func (m *WxMutation) ResetDeletedAt() {
  25734. m.deleted_at = nil
  25735. delete(m.clearedFields, wx.FieldDeletedAt)
  25736. }
  25737. // SetServerID sets the "server_id" field.
  25738. func (m *WxMutation) SetServerID(u uint64) {
  25739. m.server = &u
  25740. }
  25741. // ServerID returns the value of the "server_id" field in the mutation.
  25742. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  25743. v := m.server
  25744. if v == nil {
  25745. return
  25746. }
  25747. return *v, true
  25748. }
  25749. // OldServerID returns the old "server_id" field's value of the Wx entity.
  25750. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  25751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25752. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  25753. if !m.op.Is(OpUpdateOne) {
  25754. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  25755. }
  25756. if m.id == nil || m.oldValue == nil {
  25757. return v, errors.New("OldServerID requires an ID field in the mutation")
  25758. }
  25759. oldValue, err := m.oldValue(ctx)
  25760. if err != nil {
  25761. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  25762. }
  25763. return oldValue.ServerID, nil
  25764. }
  25765. // ClearServerID clears the value of the "server_id" field.
  25766. func (m *WxMutation) ClearServerID() {
  25767. m.server = nil
  25768. m.clearedFields[wx.FieldServerID] = struct{}{}
  25769. }
  25770. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  25771. func (m *WxMutation) ServerIDCleared() bool {
  25772. _, ok := m.clearedFields[wx.FieldServerID]
  25773. return ok
  25774. }
  25775. // ResetServerID resets all changes to the "server_id" field.
  25776. func (m *WxMutation) ResetServerID() {
  25777. m.server = nil
  25778. delete(m.clearedFields, wx.FieldServerID)
  25779. }
  25780. // SetPort sets the "port" field.
  25781. func (m *WxMutation) SetPort(s string) {
  25782. m.port = &s
  25783. }
  25784. // Port returns the value of the "port" field in the mutation.
  25785. func (m *WxMutation) Port() (r string, exists bool) {
  25786. v := m.port
  25787. if v == nil {
  25788. return
  25789. }
  25790. return *v, true
  25791. }
  25792. // OldPort returns the old "port" field's value of the Wx entity.
  25793. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  25794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25795. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  25796. if !m.op.Is(OpUpdateOne) {
  25797. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  25798. }
  25799. if m.id == nil || m.oldValue == nil {
  25800. return v, errors.New("OldPort requires an ID field in the mutation")
  25801. }
  25802. oldValue, err := m.oldValue(ctx)
  25803. if err != nil {
  25804. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  25805. }
  25806. return oldValue.Port, nil
  25807. }
  25808. // ResetPort resets all changes to the "port" field.
  25809. func (m *WxMutation) ResetPort() {
  25810. m.port = nil
  25811. }
  25812. // SetProcessID sets the "process_id" field.
  25813. func (m *WxMutation) SetProcessID(s string) {
  25814. m.process_id = &s
  25815. }
  25816. // ProcessID returns the value of the "process_id" field in the mutation.
  25817. func (m *WxMutation) ProcessID() (r string, exists bool) {
  25818. v := m.process_id
  25819. if v == nil {
  25820. return
  25821. }
  25822. return *v, true
  25823. }
  25824. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  25825. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  25826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25827. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  25828. if !m.op.Is(OpUpdateOne) {
  25829. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  25830. }
  25831. if m.id == nil || m.oldValue == nil {
  25832. return v, errors.New("OldProcessID requires an ID field in the mutation")
  25833. }
  25834. oldValue, err := m.oldValue(ctx)
  25835. if err != nil {
  25836. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  25837. }
  25838. return oldValue.ProcessID, nil
  25839. }
  25840. // ResetProcessID resets all changes to the "process_id" field.
  25841. func (m *WxMutation) ResetProcessID() {
  25842. m.process_id = nil
  25843. }
  25844. // SetCallback sets the "callback" field.
  25845. func (m *WxMutation) SetCallback(s string) {
  25846. m.callback = &s
  25847. }
  25848. // Callback returns the value of the "callback" field in the mutation.
  25849. func (m *WxMutation) Callback() (r string, exists bool) {
  25850. v := m.callback
  25851. if v == nil {
  25852. return
  25853. }
  25854. return *v, true
  25855. }
  25856. // OldCallback returns the old "callback" field's value of the Wx entity.
  25857. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  25858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25859. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  25860. if !m.op.Is(OpUpdateOne) {
  25861. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  25862. }
  25863. if m.id == nil || m.oldValue == nil {
  25864. return v, errors.New("OldCallback requires an ID field in the mutation")
  25865. }
  25866. oldValue, err := m.oldValue(ctx)
  25867. if err != nil {
  25868. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  25869. }
  25870. return oldValue.Callback, nil
  25871. }
  25872. // ResetCallback resets all changes to the "callback" field.
  25873. func (m *WxMutation) ResetCallback() {
  25874. m.callback = nil
  25875. }
  25876. // SetWxid sets the "wxid" field.
  25877. func (m *WxMutation) SetWxid(s string) {
  25878. m.wxid = &s
  25879. }
  25880. // Wxid returns the value of the "wxid" field in the mutation.
  25881. func (m *WxMutation) Wxid() (r string, exists bool) {
  25882. v := m.wxid
  25883. if v == nil {
  25884. return
  25885. }
  25886. return *v, true
  25887. }
  25888. // OldWxid returns the old "wxid" field's value of the Wx entity.
  25889. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  25890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25891. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  25892. if !m.op.Is(OpUpdateOne) {
  25893. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  25894. }
  25895. if m.id == nil || m.oldValue == nil {
  25896. return v, errors.New("OldWxid requires an ID field in the mutation")
  25897. }
  25898. oldValue, err := m.oldValue(ctx)
  25899. if err != nil {
  25900. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  25901. }
  25902. return oldValue.Wxid, nil
  25903. }
  25904. // ResetWxid resets all changes to the "wxid" field.
  25905. func (m *WxMutation) ResetWxid() {
  25906. m.wxid = nil
  25907. }
  25908. // SetAccount sets the "account" field.
  25909. func (m *WxMutation) SetAccount(s string) {
  25910. m.account = &s
  25911. }
  25912. // Account returns the value of the "account" field in the mutation.
  25913. func (m *WxMutation) Account() (r string, exists bool) {
  25914. v := m.account
  25915. if v == nil {
  25916. return
  25917. }
  25918. return *v, true
  25919. }
  25920. // OldAccount returns the old "account" field's value of the Wx entity.
  25921. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  25922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25923. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  25924. if !m.op.Is(OpUpdateOne) {
  25925. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  25926. }
  25927. if m.id == nil || m.oldValue == nil {
  25928. return v, errors.New("OldAccount requires an ID field in the mutation")
  25929. }
  25930. oldValue, err := m.oldValue(ctx)
  25931. if err != nil {
  25932. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  25933. }
  25934. return oldValue.Account, nil
  25935. }
  25936. // ResetAccount resets all changes to the "account" field.
  25937. func (m *WxMutation) ResetAccount() {
  25938. m.account = nil
  25939. }
  25940. // SetNickname sets the "nickname" field.
  25941. func (m *WxMutation) SetNickname(s string) {
  25942. m.nickname = &s
  25943. }
  25944. // Nickname returns the value of the "nickname" field in the mutation.
  25945. func (m *WxMutation) Nickname() (r string, exists bool) {
  25946. v := m.nickname
  25947. if v == nil {
  25948. return
  25949. }
  25950. return *v, true
  25951. }
  25952. // OldNickname returns the old "nickname" field's value of the Wx entity.
  25953. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  25954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25955. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  25956. if !m.op.Is(OpUpdateOne) {
  25957. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  25958. }
  25959. if m.id == nil || m.oldValue == nil {
  25960. return v, errors.New("OldNickname requires an ID field in the mutation")
  25961. }
  25962. oldValue, err := m.oldValue(ctx)
  25963. if err != nil {
  25964. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  25965. }
  25966. return oldValue.Nickname, nil
  25967. }
  25968. // ResetNickname resets all changes to the "nickname" field.
  25969. func (m *WxMutation) ResetNickname() {
  25970. m.nickname = nil
  25971. }
  25972. // SetTel sets the "tel" field.
  25973. func (m *WxMutation) SetTel(s string) {
  25974. m.tel = &s
  25975. }
  25976. // Tel returns the value of the "tel" field in the mutation.
  25977. func (m *WxMutation) Tel() (r string, exists bool) {
  25978. v := m.tel
  25979. if v == nil {
  25980. return
  25981. }
  25982. return *v, true
  25983. }
  25984. // OldTel returns the old "tel" field's value of the Wx entity.
  25985. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  25986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25987. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  25988. if !m.op.Is(OpUpdateOne) {
  25989. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  25990. }
  25991. if m.id == nil || m.oldValue == nil {
  25992. return v, errors.New("OldTel requires an ID field in the mutation")
  25993. }
  25994. oldValue, err := m.oldValue(ctx)
  25995. if err != nil {
  25996. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  25997. }
  25998. return oldValue.Tel, nil
  25999. }
  26000. // ResetTel resets all changes to the "tel" field.
  26001. func (m *WxMutation) ResetTel() {
  26002. m.tel = nil
  26003. }
  26004. // SetHeadBig sets the "head_big" field.
  26005. func (m *WxMutation) SetHeadBig(s string) {
  26006. m.head_big = &s
  26007. }
  26008. // HeadBig returns the value of the "head_big" field in the mutation.
  26009. func (m *WxMutation) HeadBig() (r string, exists bool) {
  26010. v := m.head_big
  26011. if v == nil {
  26012. return
  26013. }
  26014. return *v, true
  26015. }
  26016. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  26017. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  26018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26019. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  26020. if !m.op.Is(OpUpdateOne) {
  26021. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  26022. }
  26023. if m.id == nil || m.oldValue == nil {
  26024. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  26025. }
  26026. oldValue, err := m.oldValue(ctx)
  26027. if err != nil {
  26028. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  26029. }
  26030. return oldValue.HeadBig, nil
  26031. }
  26032. // ResetHeadBig resets all changes to the "head_big" field.
  26033. func (m *WxMutation) ResetHeadBig() {
  26034. m.head_big = nil
  26035. }
  26036. // SetOrganizationID sets the "organization_id" field.
  26037. func (m *WxMutation) SetOrganizationID(u uint64) {
  26038. m.organization_id = &u
  26039. m.addorganization_id = nil
  26040. }
  26041. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26042. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  26043. v := m.organization_id
  26044. if v == nil {
  26045. return
  26046. }
  26047. return *v, true
  26048. }
  26049. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  26050. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  26051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26052. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26053. if !m.op.Is(OpUpdateOne) {
  26054. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26055. }
  26056. if m.id == nil || m.oldValue == nil {
  26057. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26058. }
  26059. oldValue, err := m.oldValue(ctx)
  26060. if err != nil {
  26061. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26062. }
  26063. return oldValue.OrganizationID, nil
  26064. }
  26065. // AddOrganizationID adds u to the "organization_id" field.
  26066. func (m *WxMutation) AddOrganizationID(u int64) {
  26067. if m.addorganization_id != nil {
  26068. *m.addorganization_id += u
  26069. } else {
  26070. m.addorganization_id = &u
  26071. }
  26072. }
  26073. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26074. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  26075. v := m.addorganization_id
  26076. if v == nil {
  26077. return
  26078. }
  26079. return *v, true
  26080. }
  26081. // ClearOrganizationID clears the value of the "organization_id" field.
  26082. func (m *WxMutation) ClearOrganizationID() {
  26083. m.organization_id = nil
  26084. m.addorganization_id = nil
  26085. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  26086. }
  26087. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  26088. func (m *WxMutation) OrganizationIDCleared() bool {
  26089. _, ok := m.clearedFields[wx.FieldOrganizationID]
  26090. return ok
  26091. }
  26092. // ResetOrganizationID resets all changes to the "organization_id" field.
  26093. func (m *WxMutation) ResetOrganizationID() {
  26094. m.organization_id = nil
  26095. m.addorganization_id = nil
  26096. delete(m.clearedFields, wx.FieldOrganizationID)
  26097. }
  26098. // SetAgentID sets the "agent_id" field.
  26099. func (m *WxMutation) SetAgentID(u uint64) {
  26100. m.agent = &u
  26101. }
  26102. // AgentID returns the value of the "agent_id" field in the mutation.
  26103. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  26104. v := m.agent
  26105. if v == nil {
  26106. return
  26107. }
  26108. return *v, true
  26109. }
  26110. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  26111. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  26112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26113. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  26114. if !m.op.Is(OpUpdateOne) {
  26115. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  26116. }
  26117. if m.id == nil || m.oldValue == nil {
  26118. return v, errors.New("OldAgentID requires an ID field in the mutation")
  26119. }
  26120. oldValue, err := m.oldValue(ctx)
  26121. if err != nil {
  26122. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  26123. }
  26124. return oldValue.AgentID, nil
  26125. }
  26126. // ResetAgentID resets all changes to the "agent_id" field.
  26127. func (m *WxMutation) ResetAgentID() {
  26128. m.agent = nil
  26129. }
  26130. // SetAPIBase sets the "api_base" field.
  26131. func (m *WxMutation) SetAPIBase(s string) {
  26132. m.api_base = &s
  26133. }
  26134. // APIBase returns the value of the "api_base" field in the mutation.
  26135. func (m *WxMutation) APIBase() (r string, exists bool) {
  26136. v := m.api_base
  26137. if v == nil {
  26138. return
  26139. }
  26140. return *v, true
  26141. }
  26142. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  26143. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  26144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26145. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  26146. if !m.op.Is(OpUpdateOne) {
  26147. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  26148. }
  26149. if m.id == nil || m.oldValue == nil {
  26150. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  26151. }
  26152. oldValue, err := m.oldValue(ctx)
  26153. if err != nil {
  26154. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  26155. }
  26156. return oldValue.APIBase, nil
  26157. }
  26158. // ClearAPIBase clears the value of the "api_base" field.
  26159. func (m *WxMutation) ClearAPIBase() {
  26160. m.api_base = nil
  26161. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  26162. }
  26163. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  26164. func (m *WxMutation) APIBaseCleared() bool {
  26165. _, ok := m.clearedFields[wx.FieldAPIBase]
  26166. return ok
  26167. }
  26168. // ResetAPIBase resets all changes to the "api_base" field.
  26169. func (m *WxMutation) ResetAPIBase() {
  26170. m.api_base = nil
  26171. delete(m.clearedFields, wx.FieldAPIBase)
  26172. }
  26173. // SetAPIKey sets the "api_key" field.
  26174. func (m *WxMutation) SetAPIKey(s string) {
  26175. m.api_key = &s
  26176. }
  26177. // APIKey returns the value of the "api_key" field in the mutation.
  26178. func (m *WxMutation) APIKey() (r string, exists bool) {
  26179. v := m.api_key
  26180. if v == nil {
  26181. return
  26182. }
  26183. return *v, true
  26184. }
  26185. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  26186. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  26187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26188. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  26189. if !m.op.Is(OpUpdateOne) {
  26190. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  26191. }
  26192. if m.id == nil || m.oldValue == nil {
  26193. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  26194. }
  26195. oldValue, err := m.oldValue(ctx)
  26196. if err != nil {
  26197. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  26198. }
  26199. return oldValue.APIKey, nil
  26200. }
  26201. // ClearAPIKey clears the value of the "api_key" field.
  26202. func (m *WxMutation) ClearAPIKey() {
  26203. m.api_key = nil
  26204. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  26205. }
  26206. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  26207. func (m *WxMutation) APIKeyCleared() bool {
  26208. _, ok := m.clearedFields[wx.FieldAPIKey]
  26209. return ok
  26210. }
  26211. // ResetAPIKey resets all changes to the "api_key" field.
  26212. func (m *WxMutation) ResetAPIKey() {
  26213. m.api_key = nil
  26214. delete(m.clearedFields, wx.FieldAPIKey)
  26215. }
  26216. // SetAllowList sets the "allow_list" field.
  26217. func (m *WxMutation) SetAllowList(s []string) {
  26218. m.allow_list = &s
  26219. m.appendallow_list = nil
  26220. }
  26221. // AllowList returns the value of the "allow_list" field in the mutation.
  26222. func (m *WxMutation) AllowList() (r []string, exists bool) {
  26223. v := m.allow_list
  26224. if v == nil {
  26225. return
  26226. }
  26227. return *v, true
  26228. }
  26229. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  26230. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  26231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26232. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  26233. if !m.op.Is(OpUpdateOne) {
  26234. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  26235. }
  26236. if m.id == nil || m.oldValue == nil {
  26237. return v, errors.New("OldAllowList requires an ID field in the mutation")
  26238. }
  26239. oldValue, err := m.oldValue(ctx)
  26240. if err != nil {
  26241. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  26242. }
  26243. return oldValue.AllowList, nil
  26244. }
  26245. // AppendAllowList adds s to the "allow_list" field.
  26246. func (m *WxMutation) AppendAllowList(s []string) {
  26247. m.appendallow_list = append(m.appendallow_list, s...)
  26248. }
  26249. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  26250. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  26251. if len(m.appendallow_list) == 0 {
  26252. return nil, false
  26253. }
  26254. return m.appendallow_list, true
  26255. }
  26256. // ResetAllowList resets all changes to the "allow_list" field.
  26257. func (m *WxMutation) ResetAllowList() {
  26258. m.allow_list = nil
  26259. m.appendallow_list = nil
  26260. }
  26261. // SetGroupAllowList sets the "group_allow_list" field.
  26262. func (m *WxMutation) SetGroupAllowList(s []string) {
  26263. m.group_allow_list = &s
  26264. m.appendgroup_allow_list = nil
  26265. }
  26266. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  26267. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  26268. v := m.group_allow_list
  26269. if v == nil {
  26270. return
  26271. }
  26272. return *v, true
  26273. }
  26274. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  26275. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  26276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26277. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  26278. if !m.op.Is(OpUpdateOne) {
  26279. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  26280. }
  26281. if m.id == nil || m.oldValue == nil {
  26282. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  26283. }
  26284. oldValue, err := m.oldValue(ctx)
  26285. if err != nil {
  26286. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  26287. }
  26288. return oldValue.GroupAllowList, nil
  26289. }
  26290. // AppendGroupAllowList adds s to the "group_allow_list" field.
  26291. func (m *WxMutation) AppendGroupAllowList(s []string) {
  26292. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  26293. }
  26294. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  26295. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  26296. if len(m.appendgroup_allow_list) == 0 {
  26297. return nil, false
  26298. }
  26299. return m.appendgroup_allow_list, true
  26300. }
  26301. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  26302. func (m *WxMutation) ResetGroupAllowList() {
  26303. m.group_allow_list = nil
  26304. m.appendgroup_allow_list = nil
  26305. }
  26306. // SetBlockList sets the "block_list" field.
  26307. func (m *WxMutation) SetBlockList(s []string) {
  26308. m.block_list = &s
  26309. m.appendblock_list = nil
  26310. }
  26311. // BlockList returns the value of the "block_list" field in the mutation.
  26312. func (m *WxMutation) BlockList() (r []string, exists bool) {
  26313. v := m.block_list
  26314. if v == nil {
  26315. return
  26316. }
  26317. return *v, true
  26318. }
  26319. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  26320. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  26321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26322. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  26323. if !m.op.Is(OpUpdateOne) {
  26324. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  26325. }
  26326. if m.id == nil || m.oldValue == nil {
  26327. return v, errors.New("OldBlockList requires an ID field in the mutation")
  26328. }
  26329. oldValue, err := m.oldValue(ctx)
  26330. if err != nil {
  26331. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  26332. }
  26333. return oldValue.BlockList, nil
  26334. }
  26335. // AppendBlockList adds s to the "block_list" field.
  26336. func (m *WxMutation) AppendBlockList(s []string) {
  26337. m.appendblock_list = append(m.appendblock_list, s...)
  26338. }
  26339. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  26340. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  26341. if len(m.appendblock_list) == 0 {
  26342. return nil, false
  26343. }
  26344. return m.appendblock_list, true
  26345. }
  26346. // ResetBlockList resets all changes to the "block_list" field.
  26347. func (m *WxMutation) ResetBlockList() {
  26348. m.block_list = nil
  26349. m.appendblock_list = nil
  26350. }
  26351. // SetGroupBlockList sets the "group_block_list" field.
  26352. func (m *WxMutation) SetGroupBlockList(s []string) {
  26353. m.group_block_list = &s
  26354. m.appendgroup_block_list = nil
  26355. }
  26356. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  26357. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  26358. v := m.group_block_list
  26359. if v == nil {
  26360. return
  26361. }
  26362. return *v, true
  26363. }
  26364. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  26365. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  26366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26367. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  26368. if !m.op.Is(OpUpdateOne) {
  26369. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  26370. }
  26371. if m.id == nil || m.oldValue == nil {
  26372. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  26373. }
  26374. oldValue, err := m.oldValue(ctx)
  26375. if err != nil {
  26376. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  26377. }
  26378. return oldValue.GroupBlockList, nil
  26379. }
  26380. // AppendGroupBlockList adds s to the "group_block_list" field.
  26381. func (m *WxMutation) AppendGroupBlockList(s []string) {
  26382. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  26383. }
  26384. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  26385. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  26386. if len(m.appendgroup_block_list) == 0 {
  26387. return nil, false
  26388. }
  26389. return m.appendgroup_block_list, true
  26390. }
  26391. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  26392. func (m *WxMutation) ResetGroupBlockList() {
  26393. m.group_block_list = nil
  26394. m.appendgroup_block_list = nil
  26395. }
  26396. // ClearServer clears the "server" edge to the Server entity.
  26397. func (m *WxMutation) ClearServer() {
  26398. m.clearedserver = true
  26399. m.clearedFields[wx.FieldServerID] = struct{}{}
  26400. }
  26401. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  26402. func (m *WxMutation) ServerCleared() bool {
  26403. return m.ServerIDCleared() || m.clearedserver
  26404. }
  26405. // ServerIDs returns the "server" edge IDs in the mutation.
  26406. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26407. // ServerID instead. It exists only for internal usage by the builders.
  26408. func (m *WxMutation) ServerIDs() (ids []uint64) {
  26409. if id := m.server; id != nil {
  26410. ids = append(ids, *id)
  26411. }
  26412. return
  26413. }
  26414. // ResetServer resets all changes to the "server" edge.
  26415. func (m *WxMutation) ResetServer() {
  26416. m.server = nil
  26417. m.clearedserver = false
  26418. }
  26419. // ClearAgent clears the "agent" edge to the Agent entity.
  26420. func (m *WxMutation) ClearAgent() {
  26421. m.clearedagent = true
  26422. m.clearedFields[wx.FieldAgentID] = struct{}{}
  26423. }
  26424. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  26425. func (m *WxMutation) AgentCleared() bool {
  26426. return m.clearedagent
  26427. }
  26428. // AgentIDs returns the "agent" edge IDs in the mutation.
  26429. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26430. // AgentID instead. It exists only for internal usage by the builders.
  26431. func (m *WxMutation) AgentIDs() (ids []uint64) {
  26432. if id := m.agent; id != nil {
  26433. ids = append(ids, *id)
  26434. }
  26435. return
  26436. }
  26437. // ResetAgent resets all changes to the "agent" edge.
  26438. func (m *WxMutation) ResetAgent() {
  26439. m.agent = nil
  26440. m.clearedagent = false
  26441. }
  26442. // Where appends a list predicates to the WxMutation builder.
  26443. func (m *WxMutation) Where(ps ...predicate.Wx) {
  26444. m.predicates = append(m.predicates, ps...)
  26445. }
  26446. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  26447. // users can use type-assertion to append predicates that do not depend on any generated package.
  26448. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  26449. p := make([]predicate.Wx, len(ps))
  26450. for i := range ps {
  26451. p[i] = ps[i]
  26452. }
  26453. m.Where(p...)
  26454. }
  26455. // Op returns the operation name.
  26456. func (m *WxMutation) Op() Op {
  26457. return m.op
  26458. }
  26459. // SetOp allows setting the mutation operation.
  26460. func (m *WxMutation) SetOp(op Op) {
  26461. m.op = op
  26462. }
  26463. // Type returns the node type of this mutation (Wx).
  26464. func (m *WxMutation) Type() string {
  26465. return m.typ
  26466. }
  26467. // Fields returns all fields that were changed during this mutation. Note that in
  26468. // order to get all numeric fields that were incremented/decremented, call
  26469. // AddedFields().
  26470. func (m *WxMutation) Fields() []string {
  26471. fields := make([]string, 0, 21)
  26472. if m.created_at != nil {
  26473. fields = append(fields, wx.FieldCreatedAt)
  26474. }
  26475. if m.updated_at != nil {
  26476. fields = append(fields, wx.FieldUpdatedAt)
  26477. }
  26478. if m.status != nil {
  26479. fields = append(fields, wx.FieldStatus)
  26480. }
  26481. if m.deleted_at != nil {
  26482. fields = append(fields, wx.FieldDeletedAt)
  26483. }
  26484. if m.server != nil {
  26485. fields = append(fields, wx.FieldServerID)
  26486. }
  26487. if m.port != nil {
  26488. fields = append(fields, wx.FieldPort)
  26489. }
  26490. if m.process_id != nil {
  26491. fields = append(fields, wx.FieldProcessID)
  26492. }
  26493. if m.callback != nil {
  26494. fields = append(fields, wx.FieldCallback)
  26495. }
  26496. if m.wxid != nil {
  26497. fields = append(fields, wx.FieldWxid)
  26498. }
  26499. if m.account != nil {
  26500. fields = append(fields, wx.FieldAccount)
  26501. }
  26502. if m.nickname != nil {
  26503. fields = append(fields, wx.FieldNickname)
  26504. }
  26505. if m.tel != nil {
  26506. fields = append(fields, wx.FieldTel)
  26507. }
  26508. if m.head_big != nil {
  26509. fields = append(fields, wx.FieldHeadBig)
  26510. }
  26511. if m.organization_id != nil {
  26512. fields = append(fields, wx.FieldOrganizationID)
  26513. }
  26514. if m.agent != nil {
  26515. fields = append(fields, wx.FieldAgentID)
  26516. }
  26517. if m.api_base != nil {
  26518. fields = append(fields, wx.FieldAPIBase)
  26519. }
  26520. if m.api_key != nil {
  26521. fields = append(fields, wx.FieldAPIKey)
  26522. }
  26523. if m.allow_list != nil {
  26524. fields = append(fields, wx.FieldAllowList)
  26525. }
  26526. if m.group_allow_list != nil {
  26527. fields = append(fields, wx.FieldGroupAllowList)
  26528. }
  26529. if m.block_list != nil {
  26530. fields = append(fields, wx.FieldBlockList)
  26531. }
  26532. if m.group_block_list != nil {
  26533. fields = append(fields, wx.FieldGroupBlockList)
  26534. }
  26535. return fields
  26536. }
  26537. // Field returns the value of a field with the given name. The second boolean
  26538. // return value indicates that this field was not set, or was not defined in the
  26539. // schema.
  26540. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  26541. switch name {
  26542. case wx.FieldCreatedAt:
  26543. return m.CreatedAt()
  26544. case wx.FieldUpdatedAt:
  26545. return m.UpdatedAt()
  26546. case wx.FieldStatus:
  26547. return m.Status()
  26548. case wx.FieldDeletedAt:
  26549. return m.DeletedAt()
  26550. case wx.FieldServerID:
  26551. return m.ServerID()
  26552. case wx.FieldPort:
  26553. return m.Port()
  26554. case wx.FieldProcessID:
  26555. return m.ProcessID()
  26556. case wx.FieldCallback:
  26557. return m.Callback()
  26558. case wx.FieldWxid:
  26559. return m.Wxid()
  26560. case wx.FieldAccount:
  26561. return m.Account()
  26562. case wx.FieldNickname:
  26563. return m.Nickname()
  26564. case wx.FieldTel:
  26565. return m.Tel()
  26566. case wx.FieldHeadBig:
  26567. return m.HeadBig()
  26568. case wx.FieldOrganizationID:
  26569. return m.OrganizationID()
  26570. case wx.FieldAgentID:
  26571. return m.AgentID()
  26572. case wx.FieldAPIBase:
  26573. return m.APIBase()
  26574. case wx.FieldAPIKey:
  26575. return m.APIKey()
  26576. case wx.FieldAllowList:
  26577. return m.AllowList()
  26578. case wx.FieldGroupAllowList:
  26579. return m.GroupAllowList()
  26580. case wx.FieldBlockList:
  26581. return m.BlockList()
  26582. case wx.FieldGroupBlockList:
  26583. return m.GroupBlockList()
  26584. }
  26585. return nil, false
  26586. }
  26587. // OldField returns the old value of the field from the database. An error is
  26588. // returned if the mutation operation is not UpdateOne, or the query to the
  26589. // database failed.
  26590. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26591. switch name {
  26592. case wx.FieldCreatedAt:
  26593. return m.OldCreatedAt(ctx)
  26594. case wx.FieldUpdatedAt:
  26595. return m.OldUpdatedAt(ctx)
  26596. case wx.FieldStatus:
  26597. return m.OldStatus(ctx)
  26598. case wx.FieldDeletedAt:
  26599. return m.OldDeletedAt(ctx)
  26600. case wx.FieldServerID:
  26601. return m.OldServerID(ctx)
  26602. case wx.FieldPort:
  26603. return m.OldPort(ctx)
  26604. case wx.FieldProcessID:
  26605. return m.OldProcessID(ctx)
  26606. case wx.FieldCallback:
  26607. return m.OldCallback(ctx)
  26608. case wx.FieldWxid:
  26609. return m.OldWxid(ctx)
  26610. case wx.FieldAccount:
  26611. return m.OldAccount(ctx)
  26612. case wx.FieldNickname:
  26613. return m.OldNickname(ctx)
  26614. case wx.FieldTel:
  26615. return m.OldTel(ctx)
  26616. case wx.FieldHeadBig:
  26617. return m.OldHeadBig(ctx)
  26618. case wx.FieldOrganizationID:
  26619. return m.OldOrganizationID(ctx)
  26620. case wx.FieldAgentID:
  26621. return m.OldAgentID(ctx)
  26622. case wx.FieldAPIBase:
  26623. return m.OldAPIBase(ctx)
  26624. case wx.FieldAPIKey:
  26625. return m.OldAPIKey(ctx)
  26626. case wx.FieldAllowList:
  26627. return m.OldAllowList(ctx)
  26628. case wx.FieldGroupAllowList:
  26629. return m.OldGroupAllowList(ctx)
  26630. case wx.FieldBlockList:
  26631. return m.OldBlockList(ctx)
  26632. case wx.FieldGroupBlockList:
  26633. return m.OldGroupBlockList(ctx)
  26634. }
  26635. return nil, fmt.Errorf("unknown Wx field %s", name)
  26636. }
  26637. // SetField sets the value of a field with the given name. It returns an error if
  26638. // the field is not defined in the schema, or if the type mismatched the field
  26639. // type.
  26640. func (m *WxMutation) SetField(name string, value ent.Value) error {
  26641. switch name {
  26642. case wx.FieldCreatedAt:
  26643. v, ok := value.(time.Time)
  26644. if !ok {
  26645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26646. }
  26647. m.SetCreatedAt(v)
  26648. return nil
  26649. case wx.FieldUpdatedAt:
  26650. v, ok := value.(time.Time)
  26651. if !ok {
  26652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26653. }
  26654. m.SetUpdatedAt(v)
  26655. return nil
  26656. case wx.FieldStatus:
  26657. v, ok := value.(uint8)
  26658. if !ok {
  26659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26660. }
  26661. m.SetStatus(v)
  26662. return nil
  26663. case wx.FieldDeletedAt:
  26664. v, ok := value.(time.Time)
  26665. if !ok {
  26666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26667. }
  26668. m.SetDeletedAt(v)
  26669. return nil
  26670. case wx.FieldServerID:
  26671. v, ok := value.(uint64)
  26672. if !ok {
  26673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26674. }
  26675. m.SetServerID(v)
  26676. return nil
  26677. case wx.FieldPort:
  26678. v, ok := value.(string)
  26679. if !ok {
  26680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26681. }
  26682. m.SetPort(v)
  26683. return nil
  26684. case wx.FieldProcessID:
  26685. v, ok := value.(string)
  26686. if !ok {
  26687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26688. }
  26689. m.SetProcessID(v)
  26690. return nil
  26691. case wx.FieldCallback:
  26692. v, ok := value.(string)
  26693. if !ok {
  26694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26695. }
  26696. m.SetCallback(v)
  26697. return nil
  26698. case wx.FieldWxid:
  26699. v, ok := value.(string)
  26700. if !ok {
  26701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26702. }
  26703. m.SetWxid(v)
  26704. return nil
  26705. case wx.FieldAccount:
  26706. v, ok := value.(string)
  26707. if !ok {
  26708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26709. }
  26710. m.SetAccount(v)
  26711. return nil
  26712. case wx.FieldNickname:
  26713. v, ok := value.(string)
  26714. if !ok {
  26715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26716. }
  26717. m.SetNickname(v)
  26718. return nil
  26719. case wx.FieldTel:
  26720. v, ok := value.(string)
  26721. if !ok {
  26722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26723. }
  26724. m.SetTel(v)
  26725. return nil
  26726. case wx.FieldHeadBig:
  26727. v, ok := value.(string)
  26728. if !ok {
  26729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26730. }
  26731. m.SetHeadBig(v)
  26732. return nil
  26733. case wx.FieldOrganizationID:
  26734. v, ok := value.(uint64)
  26735. if !ok {
  26736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26737. }
  26738. m.SetOrganizationID(v)
  26739. return nil
  26740. case wx.FieldAgentID:
  26741. v, ok := value.(uint64)
  26742. if !ok {
  26743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26744. }
  26745. m.SetAgentID(v)
  26746. return nil
  26747. case wx.FieldAPIBase:
  26748. v, ok := value.(string)
  26749. if !ok {
  26750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26751. }
  26752. m.SetAPIBase(v)
  26753. return nil
  26754. case wx.FieldAPIKey:
  26755. v, ok := value.(string)
  26756. if !ok {
  26757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26758. }
  26759. m.SetAPIKey(v)
  26760. return nil
  26761. case wx.FieldAllowList:
  26762. v, ok := value.([]string)
  26763. if !ok {
  26764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26765. }
  26766. m.SetAllowList(v)
  26767. return nil
  26768. case wx.FieldGroupAllowList:
  26769. v, ok := value.([]string)
  26770. if !ok {
  26771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26772. }
  26773. m.SetGroupAllowList(v)
  26774. return nil
  26775. case wx.FieldBlockList:
  26776. v, ok := value.([]string)
  26777. if !ok {
  26778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26779. }
  26780. m.SetBlockList(v)
  26781. return nil
  26782. case wx.FieldGroupBlockList:
  26783. v, ok := value.([]string)
  26784. if !ok {
  26785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26786. }
  26787. m.SetGroupBlockList(v)
  26788. return nil
  26789. }
  26790. return fmt.Errorf("unknown Wx field %s", name)
  26791. }
  26792. // AddedFields returns all numeric fields that were incremented/decremented during
  26793. // this mutation.
  26794. func (m *WxMutation) AddedFields() []string {
  26795. var fields []string
  26796. if m.addstatus != nil {
  26797. fields = append(fields, wx.FieldStatus)
  26798. }
  26799. if m.addorganization_id != nil {
  26800. fields = append(fields, wx.FieldOrganizationID)
  26801. }
  26802. return fields
  26803. }
  26804. // AddedField returns the numeric value that was incremented/decremented on a field
  26805. // with the given name. The second boolean return value indicates that this field
  26806. // was not set, or was not defined in the schema.
  26807. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  26808. switch name {
  26809. case wx.FieldStatus:
  26810. return m.AddedStatus()
  26811. case wx.FieldOrganizationID:
  26812. return m.AddedOrganizationID()
  26813. }
  26814. return nil, false
  26815. }
  26816. // AddField adds the value to the field with the given name. It returns an error if
  26817. // the field is not defined in the schema, or if the type mismatched the field
  26818. // type.
  26819. func (m *WxMutation) AddField(name string, value ent.Value) error {
  26820. switch name {
  26821. case wx.FieldStatus:
  26822. v, ok := value.(int8)
  26823. if !ok {
  26824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26825. }
  26826. m.AddStatus(v)
  26827. return nil
  26828. case wx.FieldOrganizationID:
  26829. v, ok := value.(int64)
  26830. if !ok {
  26831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26832. }
  26833. m.AddOrganizationID(v)
  26834. return nil
  26835. }
  26836. return fmt.Errorf("unknown Wx numeric field %s", name)
  26837. }
  26838. // ClearedFields returns all nullable fields that were cleared during this
  26839. // mutation.
  26840. func (m *WxMutation) ClearedFields() []string {
  26841. var fields []string
  26842. if m.FieldCleared(wx.FieldStatus) {
  26843. fields = append(fields, wx.FieldStatus)
  26844. }
  26845. if m.FieldCleared(wx.FieldDeletedAt) {
  26846. fields = append(fields, wx.FieldDeletedAt)
  26847. }
  26848. if m.FieldCleared(wx.FieldServerID) {
  26849. fields = append(fields, wx.FieldServerID)
  26850. }
  26851. if m.FieldCleared(wx.FieldOrganizationID) {
  26852. fields = append(fields, wx.FieldOrganizationID)
  26853. }
  26854. if m.FieldCleared(wx.FieldAPIBase) {
  26855. fields = append(fields, wx.FieldAPIBase)
  26856. }
  26857. if m.FieldCleared(wx.FieldAPIKey) {
  26858. fields = append(fields, wx.FieldAPIKey)
  26859. }
  26860. return fields
  26861. }
  26862. // FieldCleared returns a boolean indicating if a field with the given name was
  26863. // cleared in this mutation.
  26864. func (m *WxMutation) FieldCleared(name string) bool {
  26865. _, ok := m.clearedFields[name]
  26866. return ok
  26867. }
  26868. // ClearField clears the value of the field with the given name. It returns an
  26869. // error if the field is not defined in the schema.
  26870. func (m *WxMutation) ClearField(name string) error {
  26871. switch name {
  26872. case wx.FieldStatus:
  26873. m.ClearStatus()
  26874. return nil
  26875. case wx.FieldDeletedAt:
  26876. m.ClearDeletedAt()
  26877. return nil
  26878. case wx.FieldServerID:
  26879. m.ClearServerID()
  26880. return nil
  26881. case wx.FieldOrganizationID:
  26882. m.ClearOrganizationID()
  26883. return nil
  26884. case wx.FieldAPIBase:
  26885. m.ClearAPIBase()
  26886. return nil
  26887. case wx.FieldAPIKey:
  26888. m.ClearAPIKey()
  26889. return nil
  26890. }
  26891. return fmt.Errorf("unknown Wx nullable field %s", name)
  26892. }
  26893. // ResetField resets all changes in the mutation for the field with the given name.
  26894. // It returns an error if the field is not defined in the schema.
  26895. func (m *WxMutation) ResetField(name string) error {
  26896. switch name {
  26897. case wx.FieldCreatedAt:
  26898. m.ResetCreatedAt()
  26899. return nil
  26900. case wx.FieldUpdatedAt:
  26901. m.ResetUpdatedAt()
  26902. return nil
  26903. case wx.FieldStatus:
  26904. m.ResetStatus()
  26905. return nil
  26906. case wx.FieldDeletedAt:
  26907. m.ResetDeletedAt()
  26908. return nil
  26909. case wx.FieldServerID:
  26910. m.ResetServerID()
  26911. return nil
  26912. case wx.FieldPort:
  26913. m.ResetPort()
  26914. return nil
  26915. case wx.FieldProcessID:
  26916. m.ResetProcessID()
  26917. return nil
  26918. case wx.FieldCallback:
  26919. m.ResetCallback()
  26920. return nil
  26921. case wx.FieldWxid:
  26922. m.ResetWxid()
  26923. return nil
  26924. case wx.FieldAccount:
  26925. m.ResetAccount()
  26926. return nil
  26927. case wx.FieldNickname:
  26928. m.ResetNickname()
  26929. return nil
  26930. case wx.FieldTel:
  26931. m.ResetTel()
  26932. return nil
  26933. case wx.FieldHeadBig:
  26934. m.ResetHeadBig()
  26935. return nil
  26936. case wx.FieldOrganizationID:
  26937. m.ResetOrganizationID()
  26938. return nil
  26939. case wx.FieldAgentID:
  26940. m.ResetAgentID()
  26941. return nil
  26942. case wx.FieldAPIBase:
  26943. m.ResetAPIBase()
  26944. return nil
  26945. case wx.FieldAPIKey:
  26946. m.ResetAPIKey()
  26947. return nil
  26948. case wx.FieldAllowList:
  26949. m.ResetAllowList()
  26950. return nil
  26951. case wx.FieldGroupAllowList:
  26952. m.ResetGroupAllowList()
  26953. return nil
  26954. case wx.FieldBlockList:
  26955. m.ResetBlockList()
  26956. return nil
  26957. case wx.FieldGroupBlockList:
  26958. m.ResetGroupBlockList()
  26959. return nil
  26960. }
  26961. return fmt.Errorf("unknown Wx field %s", name)
  26962. }
  26963. // AddedEdges returns all edge names that were set/added in this mutation.
  26964. func (m *WxMutation) AddedEdges() []string {
  26965. edges := make([]string, 0, 2)
  26966. if m.server != nil {
  26967. edges = append(edges, wx.EdgeServer)
  26968. }
  26969. if m.agent != nil {
  26970. edges = append(edges, wx.EdgeAgent)
  26971. }
  26972. return edges
  26973. }
  26974. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26975. // name in this mutation.
  26976. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  26977. switch name {
  26978. case wx.EdgeServer:
  26979. if id := m.server; id != nil {
  26980. return []ent.Value{*id}
  26981. }
  26982. case wx.EdgeAgent:
  26983. if id := m.agent; id != nil {
  26984. return []ent.Value{*id}
  26985. }
  26986. }
  26987. return nil
  26988. }
  26989. // RemovedEdges returns all edge names that were removed in this mutation.
  26990. func (m *WxMutation) RemovedEdges() []string {
  26991. edges := make([]string, 0, 2)
  26992. return edges
  26993. }
  26994. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26995. // the given name in this mutation.
  26996. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  26997. return nil
  26998. }
  26999. // ClearedEdges returns all edge names that were cleared in this mutation.
  27000. func (m *WxMutation) ClearedEdges() []string {
  27001. edges := make([]string, 0, 2)
  27002. if m.clearedserver {
  27003. edges = append(edges, wx.EdgeServer)
  27004. }
  27005. if m.clearedagent {
  27006. edges = append(edges, wx.EdgeAgent)
  27007. }
  27008. return edges
  27009. }
  27010. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27011. // was cleared in this mutation.
  27012. func (m *WxMutation) EdgeCleared(name string) bool {
  27013. switch name {
  27014. case wx.EdgeServer:
  27015. return m.clearedserver
  27016. case wx.EdgeAgent:
  27017. return m.clearedagent
  27018. }
  27019. return false
  27020. }
  27021. // ClearEdge clears the value of the edge with the given name. It returns an error
  27022. // if that edge is not defined in the schema.
  27023. func (m *WxMutation) ClearEdge(name string) error {
  27024. switch name {
  27025. case wx.EdgeServer:
  27026. m.ClearServer()
  27027. return nil
  27028. case wx.EdgeAgent:
  27029. m.ClearAgent()
  27030. return nil
  27031. }
  27032. return fmt.Errorf("unknown Wx unique edge %s", name)
  27033. }
  27034. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27035. // It returns an error if the edge is not defined in the schema.
  27036. func (m *WxMutation) ResetEdge(name string) error {
  27037. switch name {
  27038. case wx.EdgeServer:
  27039. m.ResetServer()
  27040. return nil
  27041. case wx.EdgeAgent:
  27042. m.ResetAgent()
  27043. return nil
  27044. }
  27045. return fmt.Errorf("unknown Wx edge %s", name)
  27046. }
  27047. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  27048. type WxCardMutation struct {
  27049. config
  27050. op Op
  27051. typ string
  27052. id *uint64
  27053. created_at *time.Time
  27054. updated_at *time.Time
  27055. deleted_at *time.Time
  27056. user_id *uint64
  27057. adduser_id *int64
  27058. wx_user_id *uint64
  27059. addwx_user_id *int64
  27060. avatar *string
  27061. logo *string
  27062. name *string
  27063. company *string
  27064. address *string
  27065. phone *string
  27066. official_account *string
  27067. wechat_account *string
  27068. email *string
  27069. api_base *string
  27070. api_key *string
  27071. ai_info *string
  27072. intro *string
  27073. clearedFields map[string]struct{}
  27074. done bool
  27075. oldValue func(context.Context) (*WxCard, error)
  27076. predicates []predicate.WxCard
  27077. }
  27078. var _ ent.Mutation = (*WxCardMutation)(nil)
  27079. // wxcardOption allows management of the mutation configuration using functional options.
  27080. type wxcardOption func(*WxCardMutation)
  27081. // newWxCardMutation creates new mutation for the WxCard entity.
  27082. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  27083. m := &WxCardMutation{
  27084. config: c,
  27085. op: op,
  27086. typ: TypeWxCard,
  27087. clearedFields: make(map[string]struct{}),
  27088. }
  27089. for _, opt := range opts {
  27090. opt(m)
  27091. }
  27092. return m
  27093. }
  27094. // withWxCardID sets the ID field of the mutation.
  27095. func withWxCardID(id uint64) wxcardOption {
  27096. return func(m *WxCardMutation) {
  27097. var (
  27098. err error
  27099. once sync.Once
  27100. value *WxCard
  27101. )
  27102. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  27103. once.Do(func() {
  27104. if m.done {
  27105. err = errors.New("querying old values post mutation is not allowed")
  27106. } else {
  27107. value, err = m.Client().WxCard.Get(ctx, id)
  27108. }
  27109. })
  27110. return value, err
  27111. }
  27112. m.id = &id
  27113. }
  27114. }
  27115. // withWxCard sets the old WxCard of the mutation.
  27116. func withWxCard(node *WxCard) wxcardOption {
  27117. return func(m *WxCardMutation) {
  27118. m.oldValue = func(context.Context) (*WxCard, error) {
  27119. return node, nil
  27120. }
  27121. m.id = &node.ID
  27122. }
  27123. }
  27124. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27125. // executed in a transaction (ent.Tx), a transactional client is returned.
  27126. func (m WxCardMutation) Client() *Client {
  27127. client := &Client{config: m.config}
  27128. client.init()
  27129. return client
  27130. }
  27131. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27132. // it returns an error otherwise.
  27133. func (m WxCardMutation) Tx() (*Tx, error) {
  27134. if _, ok := m.driver.(*txDriver); !ok {
  27135. return nil, errors.New("ent: mutation is not running in a transaction")
  27136. }
  27137. tx := &Tx{config: m.config}
  27138. tx.init()
  27139. return tx, nil
  27140. }
  27141. // SetID sets the value of the id field. Note that this
  27142. // operation is only accepted on creation of WxCard entities.
  27143. func (m *WxCardMutation) SetID(id uint64) {
  27144. m.id = &id
  27145. }
  27146. // ID returns the ID value in the mutation. Note that the ID is only available
  27147. // if it was provided to the builder or after it was returned from the database.
  27148. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  27149. if m.id == nil {
  27150. return
  27151. }
  27152. return *m.id, true
  27153. }
  27154. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27155. // That means, if the mutation is applied within a transaction with an isolation level such
  27156. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27157. // or updated by the mutation.
  27158. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  27159. switch {
  27160. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27161. id, exists := m.ID()
  27162. if exists {
  27163. return []uint64{id}, nil
  27164. }
  27165. fallthrough
  27166. case m.op.Is(OpUpdate | OpDelete):
  27167. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  27168. default:
  27169. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27170. }
  27171. }
  27172. // SetCreatedAt sets the "created_at" field.
  27173. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  27174. m.created_at = &t
  27175. }
  27176. // CreatedAt returns the value of the "created_at" field in the mutation.
  27177. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  27178. v := m.created_at
  27179. if v == nil {
  27180. return
  27181. }
  27182. return *v, true
  27183. }
  27184. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  27185. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27187. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27188. if !m.op.Is(OpUpdateOne) {
  27189. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27190. }
  27191. if m.id == nil || m.oldValue == nil {
  27192. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27193. }
  27194. oldValue, err := m.oldValue(ctx)
  27195. if err != nil {
  27196. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27197. }
  27198. return oldValue.CreatedAt, nil
  27199. }
  27200. // ResetCreatedAt resets all changes to the "created_at" field.
  27201. func (m *WxCardMutation) ResetCreatedAt() {
  27202. m.created_at = nil
  27203. }
  27204. // SetUpdatedAt sets the "updated_at" field.
  27205. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  27206. m.updated_at = &t
  27207. }
  27208. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27209. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  27210. v := m.updated_at
  27211. if v == nil {
  27212. return
  27213. }
  27214. return *v, true
  27215. }
  27216. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  27217. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27219. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27220. if !m.op.Is(OpUpdateOne) {
  27221. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27222. }
  27223. if m.id == nil || m.oldValue == nil {
  27224. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27225. }
  27226. oldValue, err := m.oldValue(ctx)
  27227. if err != nil {
  27228. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27229. }
  27230. return oldValue.UpdatedAt, nil
  27231. }
  27232. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27233. func (m *WxCardMutation) ResetUpdatedAt() {
  27234. m.updated_at = nil
  27235. }
  27236. // SetDeletedAt sets the "deleted_at" field.
  27237. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  27238. m.deleted_at = &t
  27239. }
  27240. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27241. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  27242. v := m.deleted_at
  27243. if v == nil {
  27244. return
  27245. }
  27246. return *v, true
  27247. }
  27248. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  27249. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27251. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27252. if !m.op.Is(OpUpdateOne) {
  27253. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27254. }
  27255. if m.id == nil || m.oldValue == nil {
  27256. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27257. }
  27258. oldValue, err := m.oldValue(ctx)
  27259. if err != nil {
  27260. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27261. }
  27262. return oldValue.DeletedAt, nil
  27263. }
  27264. // ClearDeletedAt clears the value of the "deleted_at" field.
  27265. func (m *WxCardMutation) ClearDeletedAt() {
  27266. m.deleted_at = nil
  27267. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  27268. }
  27269. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27270. func (m *WxCardMutation) DeletedAtCleared() bool {
  27271. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  27272. return ok
  27273. }
  27274. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27275. func (m *WxCardMutation) ResetDeletedAt() {
  27276. m.deleted_at = nil
  27277. delete(m.clearedFields, wxcard.FieldDeletedAt)
  27278. }
  27279. // SetUserID sets the "user_id" field.
  27280. func (m *WxCardMutation) SetUserID(u uint64) {
  27281. m.user_id = &u
  27282. m.adduser_id = nil
  27283. }
  27284. // UserID returns the value of the "user_id" field in the mutation.
  27285. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  27286. v := m.user_id
  27287. if v == nil {
  27288. return
  27289. }
  27290. return *v, true
  27291. }
  27292. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  27293. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27295. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  27296. if !m.op.Is(OpUpdateOne) {
  27297. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  27298. }
  27299. if m.id == nil || m.oldValue == nil {
  27300. return v, errors.New("OldUserID requires an ID field in the mutation")
  27301. }
  27302. oldValue, err := m.oldValue(ctx)
  27303. if err != nil {
  27304. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  27305. }
  27306. return oldValue.UserID, nil
  27307. }
  27308. // AddUserID adds u to the "user_id" field.
  27309. func (m *WxCardMutation) AddUserID(u int64) {
  27310. if m.adduser_id != nil {
  27311. *m.adduser_id += u
  27312. } else {
  27313. m.adduser_id = &u
  27314. }
  27315. }
  27316. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  27317. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  27318. v := m.adduser_id
  27319. if v == nil {
  27320. return
  27321. }
  27322. return *v, true
  27323. }
  27324. // ClearUserID clears the value of the "user_id" field.
  27325. func (m *WxCardMutation) ClearUserID() {
  27326. m.user_id = nil
  27327. m.adduser_id = nil
  27328. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  27329. }
  27330. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  27331. func (m *WxCardMutation) UserIDCleared() bool {
  27332. _, ok := m.clearedFields[wxcard.FieldUserID]
  27333. return ok
  27334. }
  27335. // ResetUserID resets all changes to the "user_id" field.
  27336. func (m *WxCardMutation) ResetUserID() {
  27337. m.user_id = nil
  27338. m.adduser_id = nil
  27339. delete(m.clearedFields, wxcard.FieldUserID)
  27340. }
  27341. // SetWxUserID sets the "wx_user_id" field.
  27342. func (m *WxCardMutation) SetWxUserID(u uint64) {
  27343. m.wx_user_id = &u
  27344. m.addwx_user_id = nil
  27345. }
  27346. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  27347. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  27348. v := m.wx_user_id
  27349. if v == nil {
  27350. return
  27351. }
  27352. return *v, true
  27353. }
  27354. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  27355. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27357. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  27358. if !m.op.Is(OpUpdateOne) {
  27359. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  27360. }
  27361. if m.id == nil || m.oldValue == nil {
  27362. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  27363. }
  27364. oldValue, err := m.oldValue(ctx)
  27365. if err != nil {
  27366. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  27367. }
  27368. return oldValue.WxUserID, nil
  27369. }
  27370. // AddWxUserID adds u to the "wx_user_id" field.
  27371. func (m *WxCardMutation) AddWxUserID(u int64) {
  27372. if m.addwx_user_id != nil {
  27373. *m.addwx_user_id += u
  27374. } else {
  27375. m.addwx_user_id = &u
  27376. }
  27377. }
  27378. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  27379. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  27380. v := m.addwx_user_id
  27381. if v == nil {
  27382. return
  27383. }
  27384. return *v, true
  27385. }
  27386. // ClearWxUserID clears the value of the "wx_user_id" field.
  27387. func (m *WxCardMutation) ClearWxUserID() {
  27388. m.wx_user_id = nil
  27389. m.addwx_user_id = nil
  27390. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  27391. }
  27392. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  27393. func (m *WxCardMutation) WxUserIDCleared() bool {
  27394. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  27395. return ok
  27396. }
  27397. // ResetWxUserID resets all changes to the "wx_user_id" field.
  27398. func (m *WxCardMutation) ResetWxUserID() {
  27399. m.wx_user_id = nil
  27400. m.addwx_user_id = nil
  27401. delete(m.clearedFields, wxcard.FieldWxUserID)
  27402. }
  27403. // SetAvatar sets the "avatar" field.
  27404. func (m *WxCardMutation) SetAvatar(s string) {
  27405. m.avatar = &s
  27406. }
  27407. // Avatar returns the value of the "avatar" field in the mutation.
  27408. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  27409. v := m.avatar
  27410. if v == nil {
  27411. return
  27412. }
  27413. return *v, true
  27414. }
  27415. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  27416. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27418. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  27419. if !m.op.Is(OpUpdateOne) {
  27420. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  27421. }
  27422. if m.id == nil || m.oldValue == nil {
  27423. return v, errors.New("OldAvatar requires an ID field in the mutation")
  27424. }
  27425. oldValue, err := m.oldValue(ctx)
  27426. if err != nil {
  27427. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  27428. }
  27429. return oldValue.Avatar, nil
  27430. }
  27431. // ResetAvatar resets all changes to the "avatar" field.
  27432. func (m *WxCardMutation) ResetAvatar() {
  27433. m.avatar = nil
  27434. }
  27435. // SetLogo sets the "logo" field.
  27436. func (m *WxCardMutation) SetLogo(s string) {
  27437. m.logo = &s
  27438. }
  27439. // Logo returns the value of the "logo" field in the mutation.
  27440. func (m *WxCardMutation) Logo() (r string, exists bool) {
  27441. v := m.logo
  27442. if v == nil {
  27443. return
  27444. }
  27445. return *v, true
  27446. }
  27447. // OldLogo returns the old "logo" field's value of the WxCard entity.
  27448. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27450. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  27451. if !m.op.Is(OpUpdateOne) {
  27452. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  27453. }
  27454. if m.id == nil || m.oldValue == nil {
  27455. return v, errors.New("OldLogo requires an ID field in the mutation")
  27456. }
  27457. oldValue, err := m.oldValue(ctx)
  27458. if err != nil {
  27459. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  27460. }
  27461. return oldValue.Logo, nil
  27462. }
  27463. // ResetLogo resets all changes to the "logo" field.
  27464. func (m *WxCardMutation) ResetLogo() {
  27465. m.logo = nil
  27466. }
  27467. // SetName sets the "name" field.
  27468. func (m *WxCardMutation) SetName(s string) {
  27469. m.name = &s
  27470. }
  27471. // Name returns the value of the "name" field in the mutation.
  27472. func (m *WxCardMutation) Name() (r string, exists bool) {
  27473. v := m.name
  27474. if v == nil {
  27475. return
  27476. }
  27477. return *v, true
  27478. }
  27479. // OldName returns the old "name" field's value of the WxCard entity.
  27480. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27482. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  27483. if !m.op.Is(OpUpdateOne) {
  27484. return v, errors.New("OldName is only allowed on UpdateOne operations")
  27485. }
  27486. if m.id == nil || m.oldValue == nil {
  27487. return v, errors.New("OldName requires an ID field in the mutation")
  27488. }
  27489. oldValue, err := m.oldValue(ctx)
  27490. if err != nil {
  27491. return v, fmt.Errorf("querying old value for OldName: %w", err)
  27492. }
  27493. return oldValue.Name, nil
  27494. }
  27495. // ResetName resets all changes to the "name" field.
  27496. func (m *WxCardMutation) ResetName() {
  27497. m.name = nil
  27498. }
  27499. // SetCompany sets the "company" field.
  27500. func (m *WxCardMutation) SetCompany(s string) {
  27501. m.company = &s
  27502. }
  27503. // Company returns the value of the "company" field in the mutation.
  27504. func (m *WxCardMutation) Company() (r string, exists bool) {
  27505. v := m.company
  27506. if v == nil {
  27507. return
  27508. }
  27509. return *v, true
  27510. }
  27511. // OldCompany returns the old "company" field's value of the WxCard entity.
  27512. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27514. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  27515. if !m.op.Is(OpUpdateOne) {
  27516. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  27517. }
  27518. if m.id == nil || m.oldValue == nil {
  27519. return v, errors.New("OldCompany requires an ID field in the mutation")
  27520. }
  27521. oldValue, err := m.oldValue(ctx)
  27522. if err != nil {
  27523. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  27524. }
  27525. return oldValue.Company, nil
  27526. }
  27527. // ResetCompany resets all changes to the "company" field.
  27528. func (m *WxCardMutation) ResetCompany() {
  27529. m.company = nil
  27530. }
  27531. // SetAddress sets the "address" field.
  27532. func (m *WxCardMutation) SetAddress(s string) {
  27533. m.address = &s
  27534. }
  27535. // Address returns the value of the "address" field in the mutation.
  27536. func (m *WxCardMutation) Address() (r string, exists bool) {
  27537. v := m.address
  27538. if v == nil {
  27539. return
  27540. }
  27541. return *v, true
  27542. }
  27543. // OldAddress returns the old "address" field's value of the WxCard entity.
  27544. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27546. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  27547. if !m.op.Is(OpUpdateOne) {
  27548. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  27549. }
  27550. if m.id == nil || m.oldValue == nil {
  27551. return v, errors.New("OldAddress requires an ID field in the mutation")
  27552. }
  27553. oldValue, err := m.oldValue(ctx)
  27554. if err != nil {
  27555. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  27556. }
  27557. return oldValue.Address, nil
  27558. }
  27559. // ResetAddress resets all changes to the "address" field.
  27560. func (m *WxCardMutation) ResetAddress() {
  27561. m.address = nil
  27562. }
  27563. // SetPhone sets the "phone" field.
  27564. func (m *WxCardMutation) SetPhone(s string) {
  27565. m.phone = &s
  27566. }
  27567. // Phone returns the value of the "phone" field in the mutation.
  27568. func (m *WxCardMutation) Phone() (r string, exists bool) {
  27569. v := m.phone
  27570. if v == nil {
  27571. return
  27572. }
  27573. return *v, true
  27574. }
  27575. // OldPhone returns the old "phone" field's value of the WxCard entity.
  27576. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27578. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  27579. if !m.op.Is(OpUpdateOne) {
  27580. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  27581. }
  27582. if m.id == nil || m.oldValue == nil {
  27583. return v, errors.New("OldPhone requires an ID field in the mutation")
  27584. }
  27585. oldValue, err := m.oldValue(ctx)
  27586. if err != nil {
  27587. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  27588. }
  27589. return oldValue.Phone, nil
  27590. }
  27591. // ResetPhone resets all changes to the "phone" field.
  27592. func (m *WxCardMutation) ResetPhone() {
  27593. m.phone = nil
  27594. }
  27595. // SetOfficialAccount sets the "official_account" field.
  27596. func (m *WxCardMutation) SetOfficialAccount(s string) {
  27597. m.official_account = &s
  27598. }
  27599. // OfficialAccount returns the value of the "official_account" field in the mutation.
  27600. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  27601. v := m.official_account
  27602. if v == nil {
  27603. return
  27604. }
  27605. return *v, true
  27606. }
  27607. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  27608. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27610. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  27611. if !m.op.Is(OpUpdateOne) {
  27612. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  27613. }
  27614. if m.id == nil || m.oldValue == nil {
  27615. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  27616. }
  27617. oldValue, err := m.oldValue(ctx)
  27618. if err != nil {
  27619. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  27620. }
  27621. return oldValue.OfficialAccount, nil
  27622. }
  27623. // ResetOfficialAccount resets all changes to the "official_account" field.
  27624. func (m *WxCardMutation) ResetOfficialAccount() {
  27625. m.official_account = nil
  27626. }
  27627. // SetWechatAccount sets the "wechat_account" field.
  27628. func (m *WxCardMutation) SetWechatAccount(s string) {
  27629. m.wechat_account = &s
  27630. }
  27631. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  27632. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  27633. v := m.wechat_account
  27634. if v == nil {
  27635. return
  27636. }
  27637. return *v, true
  27638. }
  27639. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  27640. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27642. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  27643. if !m.op.Is(OpUpdateOne) {
  27644. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  27645. }
  27646. if m.id == nil || m.oldValue == nil {
  27647. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  27648. }
  27649. oldValue, err := m.oldValue(ctx)
  27650. if err != nil {
  27651. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  27652. }
  27653. return oldValue.WechatAccount, nil
  27654. }
  27655. // ResetWechatAccount resets all changes to the "wechat_account" field.
  27656. func (m *WxCardMutation) ResetWechatAccount() {
  27657. m.wechat_account = nil
  27658. }
  27659. // SetEmail sets the "email" field.
  27660. func (m *WxCardMutation) SetEmail(s string) {
  27661. m.email = &s
  27662. }
  27663. // Email returns the value of the "email" field in the mutation.
  27664. func (m *WxCardMutation) Email() (r string, exists bool) {
  27665. v := m.email
  27666. if v == nil {
  27667. return
  27668. }
  27669. return *v, true
  27670. }
  27671. // OldEmail returns the old "email" field's value of the WxCard entity.
  27672. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27674. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  27675. if !m.op.Is(OpUpdateOne) {
  27676. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  27677. }
  27678. if m.id == nil || m.oldValue == nil {
  27679. return v, errors.New("OldEmail requires an ID field in the mutation")
  27680. }
  27681. oldValue, err := m.oldValue(ctx)
  27682. if err != nil {
  27683. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  27684. }
  27685. return oldValue.Email, nil
  27686. }
  27687. // ClearEmail clears the value of the "email" field.
  27688. func (m *WxCardMutation) ClearEmail() {
  27689. m.email = nil
  27690. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  27691. }
  27692. // EmailCleared returns if the "email" field was cleared in this mutation.
  27693. func (m *WxCardMutation) EmailCleared() bool {
  27694. _, ok := m.clearedFields[wxcard.FieldEmail]
  27695. return ok
  27696. }
  27697. // ResetEmail resets all changes to the "email" field.
  27698. func (m *WxCardMutation) ResetEmail() {
  27699. m.email = nil
  27700. delete(m.clearedFields, wxcard.FieldEmail)
  27701. }
  27702. // SetAPIBase sets the "api_base" field.
  27703. func (m *WxCardMutation) SetAPIBase(s string) {
  27704. m.api_base = &s
  27705. }
  27706. // APIBase returns the value of the "api_base" field in the mutation.
  27707. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  27708. v := m.api_base
  27709. if v == nil {
  27710. return
  27711. }
  27712. return *v, true
  27713. }
  27714. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  27715. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27717. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  27718. if !m.op.Is(OpUpdateOne) {
  27719. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  27720. }
  27721. if m.id == nil || m.oldValue == nil {
  27722. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  27723. }
  27724. oldValue, err := m.oldValue(ctx)
  27725. if err != nil {
  27726. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  27727. }
  27728. return oldValue.APIBase, nil
  27729. }
  27730. // ClearAPIBase clears the value of the "api_base" field.
  27731. func (m *WxCardMutation) ClearAPIBase() {
  27732. m.api_base = nil
  27733. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  27734. }
  27735. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  27736. func (m *WxCardMutation) APIBaseCleared() bool {
  27737. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  27738. return ok
  27739. }
  27740. // ResetAPIBase resets all changes to the "api_base" field.
  27741. func (m *WxCardMutation) ResetAPIBase() {
  27742. m.api_base = nil
  27743. delete(m.clearedFields, wxcard.FieldAPIBase)
  27744. }
  27745. // SetAPIKey sets the "api_key" field.
  27746. func (m *WxCardMutation) SetAPIKey(s string) {
  27747. m.api_key = &s
  27748. }
  27749. // APIKey returns the value of the "api_key" field in the mutation.
  27750. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  27751. v := m.api_key
  27752. if v == nil {
  27753. return
  27754. }
  27755. return *v, true
  27756. }
  27757. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  27758. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27760. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  27761. if !m.op.Is(OpUpdateOne) {
  27762. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  27763. }
  27764. if m.id == nil || m.oldValue == nil {
  27765. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  27766. }
  27767. oldValue, err := m.oldValue(ctx)
  27768. if err != nil {
  27769. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  27770. }
  27771. return oldValue.APIKey, nil
  27772. }
  27773. // ClearAPIKey clears the value of the "api_key" field.
  27774. func (m *WxCardMutation) ClearAPIKey() {
  27775. m.api_key = nil
  27776. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  27777. }
  27778. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  27779. func (m *WxCardMutation) APIKeyCleared() bool {
  27780. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  27781. return ok
  27782. }
  27783. // ResetAPIKey resets all changes to the "api_key" field.
  27784. func (m *WxCardMutation) ResetAPIKey() {
  27785. m.api_key = nil
  27786. delete(m.clearedFields, wxcard.FieldAPIKey)
  27787. }
  27788. // SetAiInfo sets the "ai_info" field.
  27789. func (m *WxCardMutation) SetAiInfo(s string) {
  27790. m.ai_info = &s
  27791. }
  27792. // AiInfo returns the value of the "ai_info" field in the mutation.
  27793. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  27794. v := m.ai_info
  27795. if v == nil {
  27796. return
  27797. }
  27798. return *v, true
  27799. }
  27800. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  27801. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27803. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  27804. if !m.op.Is(OpUpdateOne) {
  27805. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  27806. }
  27807. if m.id == nil || m.oldValue == nil {
  27808. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  27809. }
  27810. oldValue, err := m.oldValue(ctx)
  27811. if err != nil {
  27812. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  27813. }
  27814. return oldValue.AiInfo, nil
  27815. }
  27816. // ClearAiInfo clears the value of the "ai_info" field.
  27817. func (m *WxCardMutation) ClearAiInfo() {
  27818. m.ai_info = nil
  27819. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  27820. }
  27821. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  27822. func (m *WxCardMutation) AiInfoCleared() bool {
  27823. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  27824. return ok
  27825. }
  27826. // ResetAiInfo resets all changes to the "ai_info" field.
  27827. func (m *WxCardMutation) ResetAiInfo() {
  27828. m.ai_info = nil
  27829. delete(m.clearedFields, wxcard.FieldAiInfo)
  27830. }
  27831. // SetIntro sets the "intro" field.
  27832. func (m *WxCardMutation) SetIntro(s string) {
  27833. m.intro = &s
  27834. }
  27835. // Intro returns the value of the "intro" field in the mutation.
  27836. func (m *WxCardMutation) Intro() (r string, exists bool) {
  27837. v := m.intro
  27838. if v == nil {
  27839. return
  27840. }
  27841. return *v, true
  27842. }
  27843. // OldIntro returns the old "intro" field's value of the WxCard entity.
  27844. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  27845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27846. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  27847. if !m.op.Is(OpUpdateOne) {
  27848. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  27849. }
  27850. if m.id == nil || m.oldValue == nil {
  27851. return v, errors.New("OldIntro requires an ID field in the mutation")
  27852. }
  27853. oldValue, err := m.oldValue(ctx)
  27854. if err != nil {
  27855. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  27856. }
  27857. return oldValue.Intro, nil
  27858. }
  27859. // ClearIntro clears the value of the "intro" field.
  27860. func (m *WxCardMutation) ClearIntro() {
  27861. m.intro = nil
  27862. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  27863. }
  27864. // IntroCleared returns if the "intro" field was cleared in this mutation.
  27865. func (m *WxCardMutation) IntroCleared() bool {
  27866. _, ok := m.clearedFields[wxcard.FieldIntro]
  27867. return ok
  27868. }
  27869. // ResetIntro resets all changes to the "intro" field.
  27870. func (m *WxCardMutation) ResetIntro() {
  27871. m.intro = nil
  27872. delete(m.clearedFields, wxcard.FieldIntro)
  27873. }
  27874. // Where appends a list predicates to the WxCardMutation builder.
  27875. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  27876. m.predicates = append(m.predicates, ps...)
  27877. }
  27878. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  27879. // users can use type-assertion to append predicates that do not depend on any generated package.
  27880. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  27881. p := make([]predicate.WxCard, len(ps))
  27882. for i := range ps {
  27883. p[i] = ps[i]
  27884. }
  27885. m.Where(p...)
  27886. }
  27887. // Op returns the operation name.
  27888. func (m *WxCardMutation) Op() Op {
  27889. return m.op
  27890. }
  27891. // SetOp allows setting the mutation operation.
  27892. func (m *WxCardMutation) SetOp(op Op) {
  27893. m.op = op
  27894. }
  27895. // Type returns the node type of this mutation (WxCard).
  27896. func (m *WxCardMutation) Type() string {
  27897. return m.typ
  27898. }
  27899. // Fields returns all fields that were changed during this mutation. Note that in
  27900. // order to get all numeric fields that were incremented/decremented, call
  27901. // AddedFields().
  27902. func (m *WxCardMutation) Fields() []string {
  27903. fields := make([]string, 0, 18)
  27904. if m.created_at != nil {
  27905. fields = append(fields, wxcard.FieldCreatedAt)
  27906. }
  27907. if m.updated_at != nil {
  27908. fields = append(fields, wxcard.FieldUpdatedAt)
  27909. }
  27910. if m.deleted_at != nil {
  27911. fields = append(fields, wxcard.FieldDeletedAt)
  27912. }
  27913. if m.user_id != nil {
  27914. fields = append(fields, wxcard.FieldUserID)
  27915. }
  27916. if m.wx_user_id != nil {
  27917. fields = append(fields, wxcard.FieldWxUserID)
  27918. }
  27919. if m.avatar != nil {
  27920. fields = append(fields, wxcard.FieldAvatar)
  27921. }
  27922. if m.logo != nil {
  27923. fields = append(fields, wxcard.FieldLogo)
  27924. }
  27925. if m.name != nil {
  27926. fields = append(fields, wxcard.FieldName)
  27927. }
  27928. if m.company != nil {
  27929. fields = append(fields, wxcard.FieldCompany)
  27930. }
  27931. if m.address != nil {
  27932. fields = append(fields, wxcard.FieldAddress)
  27933. }
  27934. if m.phone != nil {
  27935. fields = append(fields, wxcard.FieldPhone)
  27936. }
  27937. if m.official_account != nil {
  27938. fields = append(fields, wxcard.FieldOfficialAccount)
  27939. }
  27940. if m.wechat_account != nil {
  27941. fields = append(fields, wxcard.FieldWechatAccount)
  27942. }
  27943. if m.email != nil {
  27944. fields = append(fields, wxcard.FieldEmail)
  27945. }
  27946. if m.api_base != nil {
  27947. fields = append(fields, wxcard.FieldAPIBase)
  27948. }
  27949. if m.api_key != nil {
  27950. fields = append(fields, wxcard.FieldAPIKey)
  27951. }
  27952. if m.ai_info != nil {
  27953. fields = append(fields, wxcard.FieldAiInfo)
  27954. }
  27955. if m.intro != nil {
  27956. fields = append(fields, wxcard.FieldIntro)
  27957. }
  27958. return fields
  27959. }
  27960. // Field returns the value of a field with the given name. The second boolean
  27961. // return value indicates that this field was not set, or was not defined in the
  27962. // schema.
  27963. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  27964. switch name {
  27965. case wxcard.FieldCreatedAt:
  27966. return m.CreatedAt()
  27967. case wxcard.FieldUpdatedAt:
  27968. return m.UpdatedAt()
  27969. case wxcard.FieldDeletedAt:
  27970. return m.DeletedAt()
  27971. case wxcard.FieldUserID:
  27972. return m.UserID()
  27973. case wxcard.FieldWxUserID:
  27974. return m.WxUserID()
  27975. case wxcard.FieldAvatar:
  27976. return m.Avatar()
  27977. case wxcard.FieldLogo:
  27978. return m.Logo()
  27979. case wxcard.FieldName:
  27980. return m.Name()
  27981. case wxcard.FieldCompany:
  27982. return m.Company()
  27983. case wxcard.FieldAddress:
  27984. return m.Address()
  27985. case wxcard.FieldPhone:
  27986. return m.Phone()
  27987. case wxcard.FieldOfficialAccount:
  27988. return m.OfficialAccount()
  27989. case wxcard.FieldWechatAccount:
  27990. return m.WechatAccount()
  27991. case wxcard.FieldEmail:
  27992. return m.Email()
  27993. case wxcard.FieldAPIBase:
  27994. return m.APIBase()
  27995. case wxcard.FieldAPIKey:
  27996. return m.APIKey()
  27997. case wxcard.FieldAiInfo:
  27998. return m.AiInfo()
  27999. case wxcard.FieldIntro:
  28000. return m.Intro()
  28001. }
  28002. return nil, false
  28003. }
  28004. // OldField returns the old value of the field from the database. An error is
  28005. // returned if the mutation operation is not UpdateOne, or the query to the
  28006. // database failed.
  28007. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28008. switch name {
  28009. case wxcard.FieldCreatedAt:
  28010. return m.OldCreatedAt(ctx)
  28011. case wxcard.FieldUpdatedAt:
  28012. return m.OldUpdatedAt(ctx)
  28013. case wxcard.FieldDeletedAt:
  28014. return m.OldDeletedAt(ctx)
  28015. case wxcard.FieldUserID:
  28016. return m.OldUserID(ctx)
  28017. case wxcard.FieldWxUserID:
  28018. return m.OldWxUserID(ctx)
  28019. case wxcard.FieldAvatar:
  28020. return m.OldAvatar(ctx)
  28021. case wxcard.FieldLogo:
  28022. return m.OldLogo(ctx)
  28023. case wxcard.FieldName:
  28024. return m.OldName(ctx)
  28025. case wxcard.FieldCompany:
  28026. return m.OldCompany(ctx)
  28027. case wxcard.FieldAddress:
  28028. return m.OldAddress(ctx)
  28029. case wxcard.FieldPhone:
  28030. return m.OldPhone(ctx)
  28031. case wxcard.FieldOfficialAccount:
  28032. return m.OldOfficialAccount(ctx)
  28033. case wxcard.FieldWechatAccount:
  28034. return m.OldWechatAccount(ctx)
  28035. case wxcard.FieldEmail:
  28036. return m.OldEmail(ctx)
  28037. case wxcard.FieldAPIBase:
  28038. return m.OldAPIBase(ctx)
  28039. case wxcard.FieldAPIKey:
  28040. return m.OldAPIKey(ctx)
  28041. case wxcard.FieldAiInfo:
  28042. return m.OldAiInfo(ctx)
  28043. case wxcard.FieldIntro:
  28044. return m.OldIntro(ctx)
  28045. }
  28046. return nil, fmt.Errorf("unknown WxCard field %s", name)
  28047. }
  28048. // SetField sets the value of a field with the given name. It returns an error if
  28049. // the field is not defined in the schema, or if the type mismatched the field
  28050. // type.
  28051. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  28052. switch name {
  28053. case wxcard.FieldCreatedAt:
  28054. v, ok := value.(time.Time)
  28055. if !ok {
  28056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28057. }
  28058. m.SetCreatedAt(v)
  28059. return nil
  28060. case wxcard.FieldUpdatedAt:
  28061. v, ok := value.(time.Time)
  28062. if !ok {
  28063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28064. }
  28065. m.SetUpdatedAt(v)
  28066. return nil
  28067. case wxcard.FieldDeletedAt:
  28068. v, ok := value.(time.Time)
  28069. if !ok {
  28070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28071. }
  28072. m.SetDeletedAt(v)
  28073. return nil
  28074. case wxcard.FieldUserID:
  28075. v, ok := value.(uint64)
  28076. if !ok {
  28077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28078. }
  28079. m.SetUserID(v)
  28080. return nil
  28081. case wxcard.FieldWxUserID:
  28082. v, ok := value.(uint64)
  28083. if !ok {
  28084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28085. }
  28086. m.SetWxUserID(v)
  28087. return nil
  28088. case wxcard.FieldAvatar:
  28089. v, ok := value.(string)
  28090. if !ok {
  28091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28092. }
  28093. m.SetAvatar(v)
  28094. return nil
  28095. case wxcard.FieldLogo:
  28096. v, ok := value.(string)
  28097. if !ok {
  28098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28099. }
  28100. m.SetLogo(v)
  28101. return nil
  28102. case wxcard.FieldName:
  28103. v, ok := value.(string)
  28104. if !ok {
  28105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28106. }
  28107. m.SetName(v)
  28108. return nil
  28109. case wxcard.FieldCompany:
  28110. v, ok := value.(string)
  28111. if !ok {
  28112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28113. }
  28114. m.SetCompany(v)
  28115. return nil
  28116. case wxcard.FieldAddress:
  28117. v, ok := value.(string)
  28118. if !ok {
  28119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28120. }
  28121. m.SetAddress(v)
  28122. return nil
  28123. case wxcard.FieldPhone:
  28124. v, ok := value.(string)
  28125. if !ok {
  28126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28127. }
  28128. m.SetPhone(v)
  28129. return nil
  28130. case wxcard.FieldOfficialAccount:
  28131. v, ok := value.(string)
  28132. if !ok {
  28133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28134. }
  28135. m.SetOfficialAccount(v)
  28136. return nil
  28137. case wxcard.FieldWechatAccount:
  28138. v, ok := value.(string)
  28139. if !ok {
  28140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28141. }
  28142. m.SetWechatAccount(v)
  28143. return nil
  28144. case wxcard.FieldEmail:
  28145. v, ok := value.(string)
  28146. if !ok {
  28147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28148. }
  28149. m.SetEmail(v)
  28150. return nil
  28151. case wxcard.FieldAPIBase:
  28152. v, ok := value.(string)
  28153. if !ok {
  28154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28155. }
  28156. m.SetAPIBase(v)
  28157. return nil
  28158. case wxcard.FieldAPIKey:
  28159. v, ok := value.(string)
  28160. if !ok {
  28161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28162. }
  28163. m.SetAPIKey(v)
  28164. return nil
  28165. case wxcard.FieldAiInfo:
  28166. v, ok := value.(string)
  28167. if !ok {
  28168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28169. }
  28170. m.SetAiInfo(v)
  28171. return nil
  28172. case wxcard.FieldIntro:
  28173. v, ok := value.(string)
  28174. if !ok {
  28175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28176. }
  28177. m.SetIntro(v)
  28178. return nil
  28179. }
  28180. return fmt.Errorf("unknown WxCard field %s", name)
  28181. }
  28182. // AddedFields returns all numeric fields that were incremented/decremented during
  28183. // this mutation.
  28184. func (m *WxCardMutation) AddedFields() []string {
  28185. var fields []string
  28186. if m.adduser_id != nil {
  28187. fields = append(fields, wxcard.FieldUserID)
  28188. }
  28189. if m.addwx_user_id != nil {
  28190. fields = append(fields, wxcard.FieldWxUserID)
  28191. }
  28192. return fields
  28193. }
  28194. // AddedField returns the numeric value that was incremented/decremented on a field
  28195. // with the given name. The second boolean return value indicates that this field
  28196. // was not set, or was not defined in the schema.
  28197. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  28198. switch name {
  28199. case wxcard.FieldUserID:
  28200. return m.AddedUserID()
  28201. case wxcard.FieldWxUserID:
  28202. return m.AddedWxUserID()
  28203. }
  28204. return nil, false
  28205. }
  28206. // AddField adds the value to the field with the given name. It returns an error if
  28207. // the field is not defined in the schema, or if the type mismatched the field
  28208. // type.
  28209. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  28210. switch name {
  28211. case wxcard.FieldUserID:
  28212. v, ok := value.(int64)
  28213. if !ok {
  28214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28215. }
  28216. m.AddUserID(v)
  28217. return nil
  28218. case wxcard.FieldWxUserID:
  28219. v, ok := value.(int64)
  28220. if !ok {
  28221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28222. }
  28223. m.AddWxUserID(v)
  28224. return nil
  28225. }
  28226. return fmt.Errorf("unknown WxCard numeric field %s", name)
  28227. }
  28228. // ClearedFields returns all nullable fields that were cleared during this
  28229. // mutation.
  28230. func (m *WxCardMutation) ClearedFields() []string {
  28231. var fields []string
  28232. if m.FieldCleared(wxcard.FieldDeletedAt) {
  28233. fields = append(fields, wxcard.FieldDeletedAt)
  28234. }
  28235. if m.FieldCleared(wxcard.FieldUserID) {
  28236. fields = append(fields, wxcard.FieldUserID)
  28237. }
  28238. if m.FieldCleared(wxcard.FieldWxUserID) {
  28239. fields = append(fields, wxcard.FieldWxUserID)
  28240. }
  28241. if m.FieldCleared(wxcard.FieldEmail) {
  28242. fields = append(fields, wxcard.FieldEmail)
  28243. }
  28244. if m.FieldCleared(wxcard.FieldAPIBase) {
  28245. fields = append(fields, wxcard.FieldAPIBase)
  28246. }
  28247. if m.FieldCleared(wxcard.FieldAPIKey) {
  28248. fields = append(fields, wxcard.FieldAPIKey)
  28249. }
  28250. if m.FieldCleared(wxcard.FieldAiInfo) {
  28251. fields = append(fields, wxcard.FieldAiInfo)
  28252. }
  28253. if m.FieldCleared(wxcard.FieldIntro) {
  28254. fields = append(fields, wxcard.FieldIntro)
  28255. }
  28256. return fields
  28257. }
  28258. // FieldCleared returns a boolean indicating if a field with the given name was
  28259. // cleared in this mutation.
  28260. func (m *WxCardMutation) FieldCleared(name string) bool {
  28261. _, ok := m.clearedFields[name]
  28262. return ok
  28263. }
  28264. // ClearField clears the value of the field with the given name. It returns an
  28265. // error if the field is not defined in the schema.
  28266. func (m *WxCardMutation) ClearField(name string) error {
  28267. switch name {
  28268. case wxcard.FieldDeletedAt:
  28269. m.ClearDeletedAt()
  28270. return nil
  28271. case wxcard.FieldUserID:
  28272. m.ClearUserID()
  28273. return nil
  28274. case wxcard.FieldWxUserID:
  28275. m.ClearWxUserID()
  28276. return nil
  28277. case wxcard.FieldEmail:
  28278. m.ClearEmail()
  28279. return nil
  28280. case wxcard.FieldAPIBase:
  28281. m.ClearAPIBase()
  28282. return nil
  28283. case wxcard.FieldAPIKey:
  28284. m.ClearAPIKey()
  28285. return nil
  28286. case wxcard.FieldAiInfo:
  28287. m.ClearAiInfo()
  28288. return nil
  28289. case wxcard.FieldIntro:
  28290. m.ClearIntro()
  28291. return nil
  28292. }
  28293. return fmt.Errorf("unknown WxCard nullable field %s", name)
  28294. }
  28295. // ResetField resets all changes in the mutation for the field with the given name.
  28296. // It returns an error if the field is not defined in the schema.
  28297. func (m *WxCardMutation) ResetField(name string) error {
  28298. switch name {
  28299. case wxcard.FieldCreatedAt:
  28300. m.ResetCreatedAt()
  28301. return nil
  28302. case wxcard.FieldUpdatedAt:
  28303. m.ResetUpdatedAt()
  28304. return nil
  28305. case wxcard.FieldDeletedAt:
  28306. m.ResetDeletedAt()
  28307. return nil
  28308. case wxcard.FieldUserID:
  28309. m.ResetUserID()
  28310. return nil
  28311. case wxcard.FieldWxUserID:
  28312. m.ResetWxUserID()
  28313. return nil
  28314. case wxcard.FieldAvatar:
  28315. m.ResetAvatar()
  28316. return nil
  28317. case wxcard.FieldLogo:
  28318. m.ResetLogo()
  28319. return nil
  28320. case wxcard.FieldName:
  28321. m.ResetName()
  28322. return nil
  28323. case wxcard.FieldCompany:
  28324. m.ResetCompany()
  28325. return nil
  28326. case wxcard.FieldAddress:
  28327. m.ResetAddress()
  28328. return nil
  28329. case wxcard.FieldPhone:
  28330. m.ResetPhone()
  28331. return nil
  28332. case wxcard.FieldOfficialAccount:
  28333. m.ResetOfficialAccount()
  28334. return nil
  28335. case wxcard.FieldWechatAccount:
  28336. m.ResetWechatAccount()
  28337. return nil
  28338. case wxcard.FieldEmail:
  28339. m.ResetEmail()
  28340. return nil
  28341. case wxcard.FieldAPIBase:
  28342. m.ResetAPIBase()
  28343. return nil
  28344. case wxcard.FieldAPIKey:
  28345. m.ResetAPIKey()
  28346. return nil
  28347. case wxcard.FieldAiInfo:
  28348. m.ResetAiInfo()
  28349. return nil
  28350. case wxcard.FieldIntro:
  28351. m.ResetIntro()
  28352. return nil
  28353. }
  28354. return fmt.Errorf("unknown WxCard field %s", name)
  28355. }
  28356. // AddedEdges returns all edge names that were set/added in this mutation.
  28357. func (m *WxCardMutation) AddedEdges() []string {
  28358. edges := make([]string, 0, 0)
  28359. return edges
  28360. }
  28361. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28362. // name in this mutation.
  28363. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  28364. return nil
  28365. }
  28366. // RemovedEdges returns all edge names that were removed in this mutation.
  28367. func (m *WxCardMutation) RemovedEdges() []string {
  28368. edges := make([]string, 0, 0)
  28369. return edges
  28370. }
  28371. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28372. // the given name in this mutation.
  28373. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  28374. return nil
  28375. }
  28376. // ClearedEdges returns all edge names that were cleared in this mutation.
  28377. func (m *WxCardMutation) ClearedEdges() []string {
  28378. edges := make([]string, 0, 0)
  28379. return edges
  28380. }
  28381. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28382. // was cleared in this mutation.
  28383. func (m *WxCardMutation) EdgeCleared(name string) bool {
  28384. return false
  28385. }
  28386. // ClearEdge clears the value of the edge with the given name. It returns an error
  28387. // if that edge is not defined in the schema.
  28388. func (m *WxCardMutation) ClearEdge(name string) error {
  28389. return fmt.Errorf("unknown WxCard unique edge %s", name)
  28390. }
  28391. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28392. // It returns an error if the edge is not defined in the schema.
  28393. func (m *WxCardMutation) ResetEdge(name string) error {
  28394. return fmt.Errorf("unknown WxCard edge %s", name)
  28395. }
  28396. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  28397. type WxCardUserMutation struct {
  28398. config
  28399. op Op
  28400. typ string
  28401. id *uint64
  28402. created_at *time.Time
  28403. updated_at *time.Time
  28404. deleted_at *time.Time
  28405. wxid *string
  28406. account *string
  28407. avatar *string
  28408. nickname *string
  28409. remark *string
  28410. phone *string
  28411. open_id *string
  28412. union_id *string
  28413. session_key *string
  28414. is_vip *int
  28415. addis_vip *int
  28416. clearedFields map[string]struct{}
  28417. done bool
  28418. oldValue func(context.Context) (*WxCardUser, error)
  28419. predicates []predicate.WxCardUser
  28420. }
  28421. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  28422. // wxcarduserOption allows management of the mutation configuration using functional options.
  28423. type wxcarduserOption func(*WxCardUserMutation)
  28424. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  28425. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  28426. m := &WxCardUserMutation{
  28427. config: c,
  28428. op: op,
  28429. typ: TypeWxCardUser,
  28430. clearedFields: make(map[string]struct{}),
  28431. }
  28432. for _, opt := range opts {
  28433. opt(m)
  28434. }
  28435. return m
  28436. }
  28437. // withWxCardUserID sets the ID field of the mutation.
  28438. func withWxCardUserID(id uint64) wxcarduserOption {
  28439. return func(m *WxCardUserMutation) {
  28440. var (
  28441. err error
  28442. once sync.Once
  28443. value *WxCardUser
  28444. )
  28445. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  28446. once.Do(func() {
  28447. if m.done {
  28448. err = errors.New("querying old values post mutation is not allowed")
  28449. } else {
  28450. value, err = m.Client().WxCardUser.Get(ctx, id)
  28451. }
  28452. })
  28453. return value, err
  28454. }
  28455. m.id = &id
  28456. }
  28457. }
  28458. // withWxCardUser sets the old WxCardUser of the mutation.
  28459. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  28460. return func(m *WxCardUserMutation) {
  28461. m.oldValue = func(context.Context) (*WxCardUser, error) {
  28462. return node, nil
  28463. }
  28464. m.id = &node.ID
  28465. }
  28466. }
  28467. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28468. // executed in a transaction (ent.Tx), a transactional client is returned.
  28469. func (m WxCardUserMutation) Client() *Client {
  28470. client := &Client{config: m.config}
  28471. client.init()
  28472. return client
  28473. }
  28474. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28475. // it returns an error otherwise.
  28476. func (m WxCardUserMutation) Tx() (*Tx, error) {
  28477. if _, ok := m.driver.(*txDriver); !ok {
  28478. return nil, errors.New("ent: mutation is not running in a transaction")
  28479. }
  28480. tx := &Tx{config: m.config}
  28481. tx.init()
  28482. return tx, nil
  28483. }
  28484. // SetID sets the value of the id field. Note that this
  28485. // operation is only accepted on creation of WxCardUser entities.
  28486. func (m *WxCardUserMutation) SetID(id uint64) {
  28487. m.id = &id
  28488. }
  28489. // ID returns the ID value in the mutation. Note that the ID is only available
  28490. // if it was provided to the builder or after it was returned from the database.
  28491. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  28492. if m.id == nil {
  28493. return
  28494. }
  28495. return *m.id, true
  28496. }
  28497. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28498. // That means, if the mutation is applied within a transaction with an isolation level such
  28499. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28500. // or updated by the mutation.
  28501. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  28502. switch {
  28503. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28504. id, exists := m.ID()
  28505. if exists {
  28506. return []uint64{id}, nil
  28507. }
  28508. fallthrough
  28509. case m.op.Is(OpUpdate | OpDelete):
  28510. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  28511. default:
  28512. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28513. }
  28514. }
  28515. // SetCreatedAt sets the "created_at" field.
  28516. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  28517. m.created_at = &t
  28518. }
  28519. // CreatedAt returns the value of the "created_at" field in the mutation.
  28520. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  28521. v := m.created_at
  28522. if v == nil {
  28523. return
  28524. }
  28525. return *v, true
  28526. }
  28527. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  28528. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  28529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28530. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28531. if !m.op.Is(OpUpdateOne) {
  28532. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28533. }
  28534. if m.id == nil || m.oldValue == nil {
  28535. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28536. }
  28537. oldValue, err := m.oldValue(ctx)
  28538. if err != nil {
  28539. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28540. }
  28541. return oldValue.CreatedAt, nil
  28542. }
  28543. // ResetCreatedAt resets all changes to the "created_at" field.
  28544. func (m *WxCardUserMutation) ResetCreatedAt() {
  28545. m.created_at = nil
  28546. }
  28547. // SetUpdatedAt sets the "updated_at" field.
  28548. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  28549. m.updated_at = &t
  28550. }
  28551. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28552. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  28553. v := m.updated_at
  28554. if v == nil {
  28555. return
  28556. }
  28557. return *v, true
  28558. }
  28559. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  28560. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  28561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28562. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28563. if !m.op.Is(OpUpdateOne) {
  28564. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28565. }
  28566. if m.id == nil || m.oldValue == nil {
  28567. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28568. }
  28569. oldValue, err := m.oldValue(ctx)
  28570. if err != nil {
  28571. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28572. }
  28573. return oldValue.UpdatedAt, nil
  28574. }
  28575. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28576. func (m *WxCardUserMutation) ResetUpdatedAt() {
  28577. m.updated_at = nil
  28578. }
  28579. // SetDeletedAt sets the "deleted_at" field.
  28580. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  28581. m.deleted_at = &t
  28582. }
  28583. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28584. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  28585. v := m.deleted_at
  28586. if v == nil {
  28587. return
  28588. }
  28589. return *v, true
  28590. }
  28591. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  28592. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  28593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28594. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28595. if !m.op.Is(OpUpdateOne) {
  28596. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28597. }
  28598. if m.id == nil || m.oldValue == nil {
  28599. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28600. }
  28601. oldValue, err := m.oldValue(ctx)
  28602. if err != nil {
  28603. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28604. }
  28605. return oldValue.DeletedAt, nil
  28606. }
  28607. // ClearDeletedAt clears the value of the "deleted_at" field.
  28608. func (m *WxCardUserMutation) ClearDeletedAt() {
  28609. m.deleted_at = nil
  28610. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  28611. }
  28612. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28613. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  28614. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  28615. return ok
  28616. }
  28617. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28618. func (m *WxCardUserMutation) ResetDeletedAt() {
  28619. m.deleted_at = nil
  28620. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  28621. }
  28622. // SetWxid sets the "wxid" field.
  28623. func (m *WxCardUserMutation) SetWxid(s string) {
  28624. m.wxid = &s
  28625. }
  28626. // Wxid returns the value of the "wxid" field in the mutation.
  28627. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  28628. v := m.wxid
  28629. if v == nil {
  28630. return
  28631. }
  28632. return *v, true
  28633. }
  28634. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  28635. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  28636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28637. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  28638. if !m.op.Is(OpUpdateOne) {
  28639. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  28640. }
  28641. if m.id == nil || m.oldValue == nil {
  28642. return v, errors.New("OldWxid requires an ID field in the mutation")
  28643. }
  28644. oldValue, err := m.oldValue(ctx)
  28645. if err != nil {
  28646. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  28647. }
  28648. return oldValue.Wxid, nil
  28649. }
  28650. // ResetWxid resets all changes to the "wxid" field.
  28651. func (m *WxCardUserMutation) ResetWxid() {
  28652. m.wxid = nil
  28653. }
  28654. // SetAccount sets the "account" field.
  28655. func (m *WxCardUserMutation) SetAccount(s string) {
  28656. m.account = &s
  28657. }
  28658. // Account returns the value of the "account" field in the mutation.
  28659. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  28660. v := m.account
  28661. if v == nil {
  28662. return
  28663. }
  28664. return *v, true
  28665. }
  28666. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  28667. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  28668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28669. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  28670. if !m.op.Is(OpUpdateOne) {
  28671. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  28672. }
  28673. if m.id == nil || m.oldValue == nil {
  28674. return v, errors.New("OldAccount requires an ID field in the mutation")
  28675. }
  28676. oldValue, err := m.oldValue(ctx)
  28677. if err != nil {
  28678. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  28679. }
  28680. return oldValue.Account, nil
  28681. }
  28682. // ResetAccount resets all changes to the "account" field.
  28683. func (m *WxCardUserMutation) ResetAccount() {
  28684. m.account = nil
  28685. }
  28686. // SetAvatar sets the "avatar" field.
  28687. func (m *WxCardUserMutation) SetAvatar(s string) {
  28688. m.avatar = &s
  28689. }
  28690. // Avatar returns the value of the "avatar" field in the mutation.
  28691. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  28692. v := m.avatar
  28693. if v == nil {
  28694. return
  28695. }
  28696. return *v, true
  28697. }
  28698. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  28699. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  28700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28701. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  28702. if !m.op.Is(OpUpdateOne) {
  28703. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  28704. }
  28705. if m.id == nil || m.oldValue == nil {
  28706. return v, errors.New("OldAvatar requires an ID field in the mutation")
  28707. }
  28708. oldValue, err := m.oldValue(ctx)
  28709. if err != nil {
  28710. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  28711. }
  28712. return oldValue.Avatar, nil
  28713. }
  28714. // ResetAvatar resets all changes to the "avatar" field.
  28715. func (m *WxCardUserMutation) ResetAvatar() {
  28716. m.avatar = nil
  28717. }
  28718. // SetNickname sets the "nickname" field.
  28719. func (m *WxCardUserMutation) SetNickname(s string) {
  28720. m.nickname = &s
  28721. }
  28722. // Nickname returns the value of the "nickname" field in the mutation.
  28723. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  28724. v := m.nickname
  28725. if v == nil {
  28726. return
  28727. }
  28728. return *v, true
  28729. }
  28730. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  28731. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  28732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28733. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  28734. if !m.op.Is(OpUpdateOne) {
  28735. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  28736. }
  28737. if m.id == nil || m.oldValue == nil {
  28738. return v, errors.New("OldNickname requires an ID field in the mutation")
  28739. }
  28740. oldValue, err := m.oldValue(ctx)
  28741. if err != nil {
  28742. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  28743. }
  28744. return oldValue.Nickname, nil
  28745. }
  28746. // ResetNickname resets all changes to the "nickname" field.
  28747. func (m *WxCardUserMutation) ResetNickname() {
  28748. m.nickname = nil
  28749. }
  28750. // SetRemark sets the "remark" field.
  28751. func (m *WxCardUserMutation) SetRemark(s string) {
  28752. m.remark = &s
  28753. }
  28754. // Remark returns the value of the "remark" field in the mutation.
  28755. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  28756. v := m.remark
  28757. if v == nil {
  28758. return
  28759. }
  28760. return *v, true
  28761. }
  28762. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  28763. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  28764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28765. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  28766. if !m.op.Is(OpUpdateOne) {
  28767. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  28768. }
  28769. if m.id == nil || m.oldValue == nil {
  28770. return v, errors.New("OldRemark requires an ID field in the mutation")
  28771. }
  28772. oldValue, err := m.oldValue(ctx)
  28773. if err != nil {
  28774. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  28775. }
  28776. return oldValue.Remark, nil
  28777. }
  28778. // ResetRemark resets all changes to the "remark" field.
  28779. func (m *WxCardUserMutation) ResetRemark() {
  28780. m.remark = nil
  28781. }
  28782. // SetPhone sets the "phone" field.
  28783. func (m *WxCardUserMutation) SetPhone(s string) {
  28784. m.phone = &s
  28785. }
  28786. // Phone returns the value of the "phone" field in the mutation.
  28787. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  28788. v := m.phone
  28789. if v == nil {
  28790. return
  28791. }
  28792. return *v, true
  28793. }
  28794. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  28795. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  28796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28797. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  28798. if !m.op.Is(OpUpdateOne) {
  28799. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  28800. }
  28801. if m.id == nil || m.oldValue == nil {
  28802. return v, errors.New("OldPhone requires an ID field in the mutation")
  28803. }
  28804. oldValue, err := m.oldValue(ctx)
  28805. if err != nil {
  28806. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  28807. }
  28808. return oldValue.Phone, nil
  28809. }
  28810. // ResetPhone resets all changes to the "phone" field.
  28811. func (m *WxCardUserMutation) ResetPhone() {
  28812. m.phone = nil
  28813. }
  28814. // SetOpenID sets the "open_id" field.
  28815. func (m *WxCardUserMutation) SetOpenID(s string) {
  28816. m.open_id = &s
  28817. }
  28818. // OpenID returns the value of the "open_id" field in the mutation.
  28819. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  28820. v := m.open_id
  28821. if v == nil {
  28822. return
  28823. }
  28824. return *v, true
  28825. }
  28826. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  28827. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  28828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28829. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  28830. if !m.op.Is(OpUpdateOne) {
  28831. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  28832. }
  28833. if m.id == nil || m.oldValue == nil {
  28834. return v, errors.New("OldOpenID requires an ID field in the mutation")
  28835. }
  28836. oldValue, err := m.oldValue(ctx)
  28837. if err != nil {
  28838. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  28839. }
  28840. return oldValue.OpenID, nil
  28841. }
  28842. // ResetOpenID resets all changes to the "open_id" field.
  28843. func (m *WxCardUserMutation) ResetOpenID() {
  28844. m.open_id = nil
  28845. }
  28846. // SetUnionID sets the "union_id" field.
  28847. func (m *WxCardUserMutation) SetUnionID(s string) {
  28848. m.union_id = &s
  28849. }
  28850. // UnionID returns the value of the "union_id" field in the mutation.
  28851. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  28852. v := m.union_id
  28853. if v == nil {
  28854. return
  28855. }
  28856. return *v, true
  28857. }
  28858. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  28859. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  28860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28861. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  28862. if !m.op.Is(OpUpdateOne) {
  28863. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  28864. }
  28865. if m.id == nil || m.oldValue == nil {
  28866. return v, errors.New("OldUnionID requires an ID field in the mutation")
  28867. }
  28868. oldValue, err := m.oldValue(ctx)
  28869. if err != nil {
  28870. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  28871. }
  28872. return oldValue.UnionID, nil
  28873. }
  28874. // ResetUnionID resets all changes to the "union_id" field.
  28875. func (m *WxCardUserMutation) ResetUnionID() {
  28876. m.union_id = nil
  28877. }
  28878. // SetSessionKey sets the "session_key" field.
  28879. func (m *WxCardUserMutation) SetSessionKey(s string) {
  28880. m.session_key = &s
  28881. }
  28882. // SessionKey returns the value of the "session_key" field in the mutation.
  28883. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  28884. v := m.session_key
  28885. if v == nil {
  28886. return
  28887. }
  28888. return *v, true
  28889. }
  28890. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  28891. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  28892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28893. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  28894. if !m.op.Is(OpUpdateOne) {
  28895. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  28896. }
  28897. if m.id == nil || m.oldValue == nil {
  28898. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  28899. }
  28900. oldValue, err := m.oldValue(ctx)
  28901. if err != nil {
  28902. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  28903. }
  28904. return oldValue.SessionKey, nil
  28905. }
  28906. // ResetSessionKey resets all changes to the "session_key" field.
  28907. func (m *WxCardUserMutation) ResetSessionKey() {
  28908. m.session_key = nil
  28909. }
  28910. // SetIsVip sets the "is_vip" field.
  28911. func (m *WxCardUserMutation) SetIsVip(i int) {
  28912. m.is_vip = &i
  28913. m.addis_vip = nil
  28914. }
  28915. // IsVip returns the value of the "is_vip" field in the mutation.
  28916. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  28917. v := m.is_vip
  28918. if v == nil {
  28919. return
  28920. }
  28921. return *v, true
  28922. }
  28923. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  28924. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  28925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28926. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  28927. if !m.op.Is(OpUpdateOne) {
  28928. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  28929. }
  28930. if m.id == nil || m.oldValue == nil {
  28931. return v, errors.New("OldIsVip requires an ID field in the mutation")
  28932. }
  28933. oldValue, err := m.oldValue(ctx)
  28934. if err != nil {
  28935. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  28936. }
  28937. return oldValue.IsVip, nil
  28938. }
  28939. // AddIsVip adds i to the "is_vip" field.
  28940. func (m *WxCardUserMutation) AddIsVip(i int) {
  28941. if m.addis_vip != nil {
  28942. *m.addis_vip += i
  28943. } else {
  28944. m.addis_vip = &i
  28945. }
  28946. }
  28947. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  28948. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  28949. v := m.addis_vip
  28950. if v == nil {
  28951. return
  28952. }
  28953. return *v, true
  28954. }
  28955. // ResetIsVip resets all changes to the "is_vip" field.
  28956. func (m *WxCardUserMutation) ResetIsVip() {
  28957. m.is_vip = nil
  28958. m.addis_vip = nil
  28959. }
  28960. // Where appends a list predicates to the WxCardUserMutation builder.
  28961. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  28962. m.predicates = append(m.predicates, ps...)
  28963. }
  28964. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  28965. // users can use type-assertion to append predicates that do not depend on any generated package.
  28966. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  28967. p := make([]predicate.WxCardUser, len(ps))
  28968. for i := range ps {
  28969. p[i] = ps[i]
  28970. }
  28971. m.Where(p...)
  28972. }
  28973. // Op returns the operation name.
  28974. func (m *WxCardUserMutation) Op() Op {
  28975. return m.op
  28976. }
  28977. // SetOp allows setting the mutation operation.
  28978. func (m *WxCardUserMutation) SetOp(op Op) {
  28979. m.op = op
  28980. }
  28981. // Type returns the node type of this mutation (WxCardUser).
  28982. func (m *WxCardUserMutation) Type() string {
  28983. return m.typ
  28984. }
  28985. // Fields returns all fields that were changed during this mutation. Note that in
  28986. // order to get all numeric fields that were incremented/decremented, call
  28987. // AddedFields().
  28988. func (m *WxCardUserMutation) Fields() []string {
  28989. fields := make([]string, 0, 13)
  28990. if m.created_at != nil {
  28991. fields = append(fields, wxcarduser.FieldCreatedAt)
  28992. }
  28993. if m.updated_at != nil {
  28994. fields = append(fields, wxcarduser.FieldUpdatedAt)
  28995. }
  28996. if m.deleted_at != nil {
  28997. fields = append(fields, wxcarduser.FieldDeletedAt)
  28998. }
  28999. if m.wxid != nil {
  29000. fields = append(fields, wxcarduser.FieldWxid)
  29001. }
  29002. if m.account != nil {
  29003. fields = append(fields, wxcarduser.FieldAccount)
  29004. }
  29005. if m.avatar != nil {
  29006. fields = append(fields, wxcarduser.FieldAvatar)
  29007. }
  29008. if m.nickname != nil {
  29009. fields = append(fields, wxcarduser.FieldNickname)
  29010. }
  29011. if m.remark != nil {
  29012. fields = append(fields, wxcarduser.FieldRemark)
  29013. }
  29014. if m.phone != nil {
  29015. fields = append(fields, wxcarduser.FieldPhone)
  29016. }
  29017. if m.open_id != nil {
  29018. fields = append(fields, wxcarduser.FieldOpenID)
  29019. }
  29020. if m.union_id != nil {
  29021. fields = append(fields, wxcarduser.FieldUnionID)
  29022. }
  29023. if m.session_key != nil {
  29024. fields = append(fields, wxcarduser.FieldSessionKey)
  29025. }
  29026. if m.is_vip != nil {
  29027. fields = append(fields, wxcarduser.FieldIsVip)
  29028. }
  29029. return fields
  29030. }
  29031. // Field returns the value of a field with the given name. The second boolean
  29032. // return value indicates that this field was not set, or was not defined in the
  29033. // schema.
  29034. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  29035. switch name {
  29036. case wxcarduser.FieldCreatedAt:
  29037. return m.CreatedAt()
  29038. case wxcarduser.FieldUpdatedAt:
  29039. return m.UpdatedAt()
  29040. case wxcarduser.FieldDeletedAt:
  29041. return m.DeletedAt()
  29042. case wxcarduser.FieldWxid:
  29043. return m.Wxid()
  29044. case wxcarduser.FieldAccount:
  29045. return m.Account()
  29046. case wxcarduser.FieldAvatar:
  29047. return m.Avatar()
  29048. case wxcarduser.FieldNickname:
  29049. return m.Nickname()
  29050. case wxcarduser.FieldRemark:
  29051. return m.Remark()
  29052. case wxcarduser.FieldPhone:
  29053. return m.Phone()
  29054. case wxcarduser.FieldOpenID:
  29055. return m.OpenID()
  29056. case wxcarduser.FieldUnionID:
  29057. return m.UnionID()
  29058. case wxcarduser.FieldSessionKey:
  29059. return m.SessionKey()
  29060. case wxcarduser.FieldIsVip:
  29061. return m.IsVip()
  29062. }
  29063. return nil, false
  29064. }
  29065. // OldField returns the old value of the field from the database. An error is
  29066. // returned if the mutation operation is not UpdateOne, or the query to the
  29067. // database failed.
  29068. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29069. switch name {
  29070. case wxcarduser.FieldCreatedAt:
  29071. return m.OldCreatedAt(ctx)
  29072. case wxcarduser.FieldUpdatedAt:
  29073. return m.OldUpdatedAt(ctx)
  29074. case wxcarduser.FieldDeletedAt:
  29075. return m.OldDeletedAt(ctx)
  29076. case wxcarduser.FieldWxid:
  29077. return m.OldWxid(ctx)
  29078. case wxcarduser.FieldAccount:
  29079. return m.OldAccount(ctx)
  29080. case wxcarduser.FieldAvatar:
  29081. return m.OldAvatar(ctx)
  29082. case wxcarduser.FieldNickname:
  29083. return m.OldNickname(ctx)
  29084. case wxcarduser.FieldRemark:
  29085. return m.OldRemark(ctx)
  29086. case wxcarduser.FieldPhone:
  29087. return m.OldPhone(ctx)
  29088. case wxcarduser.FieldOpenID:
  29089. return m.OldOpenID(ctx)
  29090. case wxcarduser.FieldUnionID:
  29091. return m.OldUnionID(ctx)
  29092. case wxcarduser.FieldSessionKey:
  29093. return m.OldSessionKey(ctx)
  29094. case wxcarduser.FieldIsVip:
  29095. return m.OldIsVip(ctx)
  29096. }
  29097. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  29098. }
  29099. // SetField sets the value of a field with the given name. It returns an error if
  29100. // the field is not defined in the schema, or if the type mismatched the field
  29101. // type.
  29102. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  29103. switch name {
  29104. case wxcarduser.FieldCreatedAt:
  29105. v, ok := value.(time.Time)
  29106. if !ok {
  29107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29108. }
  29109. m.SetCreatedAt(v)
  29110. return nil
  29111. case wxcarduser.FieldUpdatedAt:
  29112. v, ok := value.(time.Time)
  29113. if !ok {
  29114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29115. }
  29116. m.SetUpdatedAt(v)
  29117. return nil
  29118. case wxcarduser.FieldDeletedAt:
  29119. v, ok := value.(time.Time)
  29120. if !ok {
  29121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29122. }
  29123. m.SetDeletedAt(v)
  29124. return nil
  29125. case wxcarduser.FieldWxid:
  29126. v, ok := value.(string)
  29127. if !ok {
  29128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29129. }
  29130. m.SetWxid(v)
  29131. return nil
  29132. case wxcarduser.FieldAccount:
  29133. v, ok := value.(string)
  29134. if !ok {
  29135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29136. }
  29137. m.SetAccount(v)
  29138. return nil
  29139. case wxcarduser.FieldAvatar:
  29140. v, ok := value.(string)
  29141. if !ok {
  29142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29143. }
  29144. m.SetAvatar(v)
  29145. return nil
  29146. case wxcarduser.FieldNickname:
  29147. v, ok := value.(string)
  29148. if !ok {
  29149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29150. }
  29151. m.SetNickname(v)
  29152. return nil
  29153. case wxcarduser.FieldRemark:
  29154. v, ok := value.(string)
  29155. if !ok {
  29156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29157. }
  29158. m.SetRemark(v)
  29159. return nil
  29160. case wxcarduser.FieldPhone:
  29161. v, ok := value.(string)
  29162. if !ok {
  29163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29164. }
  29165. m.SetPhone(v)
  29166. return nil
  29167. case wxcarduser.FieldOpenID:
  29168. v, ok := value.(string)
  29169. if !ok {
  29170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29171. }
  29172. m.SetOpenID(v)
  29173. return nil
  29174. case wxcarduser.FieldUnionID:
  29175. v, ok := value.(string)
  29176. if !ok {
  29177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29178. }
  29179. m.SetUnionID(v)
  29180. return nil
  29181. case wxcarduser.FieldSessionKey:
  29182. v, ok := value.(string)
  29183. if !ok {
  29184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29185. }
  29186. m.SetSessionKey(v)
  29187. return nil
  29188. case wxcarduser.FieldIsVip:
  29189. v, ok := value.(int)
  29190. if !ok {
  29191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29192. }
  29193. m.SetIsVip(v)
  29194. return nil
  29195. }
  29196. return fmt.Errorf("unknown WxCardUser field %s", name)
  29197. }
  29198. // AddedFields returns all numeric fields that were incremented/decremented during
  29199. // this mutation.
  29200. func (m *WxCardUserMutation) AddedFields() []string {
  29201. var fields []string
  29202. if m.addis_vip != nil {
  29203. fields = append(fields, wxcarduser.FieldIsVip)
  29204. }
  29205. return fields
  29206. }
  29207. // AddedField returns the numeric value that was incremented/decremented on a field
  29208. // with the given name. The second boolean return value indicates that this field
  29209. // was not set, or was not defined in the schema.
  29210. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  29211. switch name {
  29212. case wxcarduser.FieldIsVip:
  29213. return m.AddedIsVip()
  29214. }
  29215. return nil, false
  29216. }
  29217. // AddField adds the value to the field with the given name. It returns an error if
  29218. // the field is not defined in the schema, or if the type mismatched the field
  29219. // type.
  29220. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  29221. switch name {
  29222. case wxcarduser.FieldIsVip:
  29223. v, ok := value.(int)
  29224. if !ok {
  29225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29226. }
  29227. m.AddIsVip(v)
  29228. return nil
  29229. }
  29230. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  29231. }
  29232. // ClearedFields returns all nullable fields that were cleared during this
  29233. // mutation.
  29234. func (m *WxCardUserMutation) ClearedFields() []string {
  29235. var fields []string
  29236. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  29237. fields = append(fields, wxcarduser.FieldDeletedAt)
  29238. }
  29239. return fields
  29240. }
  29241. // FieldCleared returns a boolean indicating if a field with the given name was
  29242. // cleared in this mutation.
  29243. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  29244. _, ok := m.clearedFields[name]
  29245. return ok
  29246. }
  29247. // ClearField clears the value of the field with the given name. It returns an
  29248. // error if the field is not defined in the schema.
  29249. func (m *WxCardUserMutation) ClearField(name string) error {
  29250. switch name {
  29251. case wxcarduser.FieldDeletedAt:
  29252. m.ClearDeletedAt()
  29253. return nil
  29254. }
  29255. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  29256. }
  29257. // ResetField resets all changes in the mutation for the field with the given name.
  29258. // It returns an error if the field is not defined in the schema.
  29259. func (m *WxCardUserMutation) ResetField(name string) error {
  29260. switch name {
  29261. case wxcarduser.FieldCreatedAt:
  29262. m.ResetCreatedAt()
  29263. return nil
  29264. case wxcarduser.FieldUpdatedAt:
  29265. m.ResetUpdatedAt()
  29266. return nil
  29267. case wxcarduser.FieldDeletedAt:
  29268. m.ResetDeletedAt()
  29269. return nil
  29270. case wxcarduser.FieldWxid:
  29271. m.ResetWxid()
  29272. return nil
  29273. case wxcarduser.FieldAccount:
  29274. m.ResetAccount()
  29275. return nil
  29276. case wxcarduser.FieldAvatar:
  29277. m.ResetAvatar()
  29278. return nil
  29279. case wxcarduser.FieldNickname:
  29280. m.ResetNickname()
  29281. return nil
  29282. case wxcarduser.FieldRemark:
  29283. m.ResetRemark()
  29284. return nil
  29285. case wxcarduser.FieldPhone:
  29286. m.ResetPhone()
  29287. return nil
  29288. case wxcarduser.FieldOpenID:
  29289. m.ResetOpenID()
  29290. return nil
  29291. case wxcarduser.FieldUnionID:
  29292. m.ResetUnionID()
  29293. return nil
  29294. case wxcarduser.FieldSessionKey:
  29295. m.ResetSessionKey()
  29296. return nil
  29297. case wxcarduser.FieldIsVip:
  29298. m.ResetIsVip()
  29299. return nil
  29300. }
  29301. return fmt.Errorf("unknown WxCardUser field %s", name)
  29302. }
  29303. // AddedEdges returns all edge names that were set/added in this mutation.
  29304. func (m *WxCardUserMutation) AddedEdges() []string {
  29305. edges := make([]string, 0, 0)
  29306. return edges
  29307. }
  29308. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29309. // name in this mutation.
  29310. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  29311. return nil
  29312. }
  29313. // RemovedEdges returns all edge names that were removed in this mutation.
  29314. func (m *WxCardUserMutation) RemovedEdges() []string {
  29315. edges := make([]string, 0, 0)
  29316. return edges
  29317. }
  29318. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29319. // the given name in this mutation.
  29320. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  29321. return nil
  29322. }
  29323. // ClearedEdges returns all edge names that were cleared in this mutation.
  29324. func (m *WxCardUserMutation) ClearedEdges() []string {
  29325. edges := make([]string, 0, 0)
  29326. return edges
  29327. }
  29328. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29329. // was cleared in this mutation.
  29330. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  29331. return false
  29332. }
  29333. // ClearEdge clears the value of the edge with the given name. It returns an error
  29334. // if that edge is not defined in the schema.
  29335. func (m *WxCardUserMutation) ClearEdge(name string) error {
  29336. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  29337. }
  29338. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29339. // It returns an error if the edge is not defined in the schema.
  29340. func (m *WxCardUserMutation) ResetEdge(name string) error {
  29341. return fmt.Errorf("unknown WxCardUser edge %s", name)
  29342. }
  29343. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  29344. type WxCardVisitMutation struct {
  29345. config
  29346. op Op
  29347. typ string
  29348. id *uint64
  29349. created_at *time.Time
  29350. updated_at *time.Time
  29351. deleted_at *time.Time
  29352. user_id *uint64
  29353. adduser_id *int64
  29354. bot_id *uint64
  29355. addbot_id *int64
  29356. bot_type *uint8
  29357. addbot_type *int8
  29358. clearedFields map[string]struct{}
  29359. done bool
  29360. oldValue func(context.Context) (*WxCardVisit, error)
  29361. predicates []predicate.WxCardVisit
  29362. }
  29363. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  29364. // wxcardvisitOption allows management of the mutation configuration using functional options.
  29365. type wxcardvisitOption func(*WxCardVisitMutation)
  29366. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  29367. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  29368. m := &WxCardVisitMutation{
  29369. config: c,
  29370. op: op,
  29371. typ: TypeWxCardVisit,
  29372. clearedFields: make(map[string]struct{}),
  29373. }
  29374. for _, opt := range opts {
  29375. opt(m)
  29376. }
  29377. return m
  29378. }
  29379. // withWxCardVisitID sets the ID field of the mutation.
  29380. func withWxCardVisitID(id uint64) wxcardvisitOption {
  29381. return func(m *WxCardVisitMutation) {
  29382. var (
  29383. err error
  29384. once sync.Once
  29385. value *WxCardVisit
  29386. )
  29387. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  29388. once.Do(func() {
  29389. if m.done {
  29390. err = errors.New("querying old values post mutation is not allowed")
  29391. } else {
  29392. value, err = m.Client().WxCardVisit.Get(ctx, id)
  29393. }
  29394. })
  29395. return value, err
  29396. }
  29397. m.id = &id
  29398. }
  29399. }
  29400. // withWxCardVisit sets the old WxCardVisit of the mutation.
  29401. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  29402. return func(m *WxCardVisitMutation) {
  29403. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  29404. return node, nil
  29405. }
  29406. m.id = &node.ID
  29407. }
  29408. }
  29409. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29410. // executed in a transaction (ent.Tx), a transactional client is returned.
  29411. func (m WxCardVisitMutation) Client() *Client {
  29412. client := &Client{config: m.config}
  29413. client.init()
  29414. return client
  29415. }
  29416. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29417. // it returns an error otherwise.
  29418. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  29419. if _, ok := m.driver.(*txDriver); !ok {
  29420. return nil, errors.New("ent: mutation is not running in a transaction")
  29421. }
  29422. tx := &Tx{config: m.config}
  29423. tx.init()
  29424. return tx, nil
  29425. }
  29426. // SetID sets the value of the id field. Note that this
  29427. // operation is only accepted on creation of WxCardVisit entities.
  29428. func (m *WxCardVisitMutation) SetID(id uint64) {
  29429. m.id = &id
  29430. }
  29431. // ID returns the ID value in the mutation. Note that the ID is only available
  29432. // if it was provided to the builder or after it was returned from the database.
  29433. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  29434. if m.id == nil {
  29435. return
  29436. }
  29437. return *m.id, true
  29438. }
  29439. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29440. // That means, if the mutation is applied within a transaction with an isolation level such
  29441. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29442. // or updated by the mutation.
  29443. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  29444. switch {
  29445. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29446. id, exists := m.ID()
  29447. if exists {
  29448. return []uint64{id}, nil
  29449. }
  29450. fallthrough
  29451. case m.op.Is(OpUpdate | OpDelete):
  29452. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  29453. default:
  29454. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29455. }
  29456. }
  29457. // SetCreatedAt sets the "created_at" field.
  29458. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  29459. m.created_at = &t
  29460. }
  29461. // CreatedAt returns the value of the "created_at" field in the mutation.
  29462. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  29463. v := m.created_at
  29464. if v == nil {
  29465. return
  29466. }
  29467. return *v, true
  29468. }
  29469. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  29470. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  29471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29472. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29473. if !m.op.Is(OpUpdateOne) {
  29474. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29475. }
  29476. if m.id == nil || m.oldValue == nil {
  29477. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29478. }
  29479. oldValue, err := m.oldValue(ctx)
  29480. if err != nil {
  29481. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29482. }
  29483. return oldValue.CreatedAt, nil
  29484. }
  29485. // ResetCreatedAt resets all changes to the "created_at" field.
  29486. func (m *WxCardVisitMutation) ResetCreatedAt() {
  29487. m.created_at = nil
  29488. }
  29489. // SetUpdatedAt sets the "updated_at" field.
  29490. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  29491. m.updated_at = &t
  29492. }
  29493. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29494. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  29495. v := m.updated_at
  29496. if v == nil {
  29497. return
  29498. }
  29499. return *v, true
  29500. }
  29501. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  29502. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  29503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29504. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29505. if !m.op.Is(OpUpdateOne) {
  29506. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29507. }
  29508. if m.id == nil || m.oldValue == nil {
  29509. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29510. }
  29511. oldValue, err := m.oldValue(ctx)
  29512. if err != nil {
  29513. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29514. }
  29515. return oldValue.UpdatedAt, nil
  29516. }
  29517. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29518. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  29519. m.updated_at = nil
  29520. }
  29521. // SetDeletedAt sets the "deleted_at" field.
  29522. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  29523. m.deleted_at = &t
  29524. }
  29525. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29526. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  29527. v := m.deleted_at
  29528. if v == nil {
  29529. return
  29530. }
  29531. return *v, true
  29532. }
  29533. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  29534. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  29535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29536. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29537. if !m.op.Is(OpUpdateOne) {
  29538. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29539. }
  29540. if m.id == nil || m.oldValue == nil {
  29541. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29542. }
  29543. oldValue, err := m.oldValue(ctx)
  29544. if err != nil {
  29545. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29546. }
  29547. return oldValue.DeletedAt, nil
  29548. }
  29549. // ClearDeletedAt clears the value of the "deleted_at" field.
  29550. func (m *WxCardVisitMutation) ClearDeletedAt() {
  29551. m.deleted_at = nil
  29552. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  29553. }
  29554. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29555. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  29556. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  29557. return ok
  29558. }
  29559. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29560. func (m *WxCardVisitMutation) ResetDeletedAt() {
  29561. m.deleted_at = nil
  29562. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  29563. }
  29564. // SetUserID sets the "user_id" field.
  29565. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  29566. m.user_id = &u
  29567. m.adduser_id = nil
  29568. }
  29569. // UserID returns the value of the "user_id" field in the mutation.
  29570. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  29571. v := m.user_id
  29572. if v == nil {
  29573. return
  29574. }
  29575. return *v, true
  29576. }
  29577. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  29578. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  29579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29580. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  29581. if !m.op.Is(OpUpdateOne) {
  29582. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  29583. }
  29584. if m.id == nil || m.oldValue == nil {
  29585. return v, errors.New("OldUserID requires an ID field in the mutation")
  29586. }
  29587. oldValue, err := m.oldValue(ctx)
  29588. if err != nil {
  29589. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  29590. }
  29591. return oldValue.UserID, nil
  29592. }
  29593. // AddUserID adds u to the "user_id" field.
  29594. func (m *WxCardVisitMutation) AddUserID(u int64) {
  29595. if m.adduser_id != nil {
  29596. *m.adduser_id += u
  29597. } else {
  29598. m.adduser_id = &u
  29599. }
  29600. }
  29601. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  29602. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  29603. v := m.adduser_id
  29604. if v == nil {
  29605. return
  29606. }
  29607. return *v, true
  29608. }
  29609. // ClearUserID clears the value of the "user_id" field.
  29610. func (m *WxCardVisitMutation) ClearUserID() {
  29611. m.user_id = nil
  29612. m.adduser_id = nil
  29613. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  29614. }
  29615. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  29616. func (m *WxCardVisitMutation) UserIDCleared() bool {
  29617. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  29618. return ok
  29619. }
  29620. // ResetUserID resets all changes to the "user_id" field.
  29621. func (m *WxCardVisitMutation) ResetUserID() {
  29622. m.user_id = nil
  29623. m.adduser_id = nil
  29624. delete(m.clearedFields, wxcardvisit.FieldUserID)
  29625. }
  29626. // SetBotID sets the "bot_id" field.
  29627. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  29628. m.bot_id = &u
  29629. m.addbot_id = nil
  29630. }
  29631. // BotID returns the value of the "bot_id" field in the mutation.
  29632. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  29633. v := m.bot_id
  29634. if v == nil {
  29635. return
  29636. }
  29637. return *v, true
  29638. }
  29639. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  29640. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  29641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29642. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  29643. if !m.op.Is(OpUpdateOne) {
  29644. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29645. }
  29646. if m.id == nil || m.oldValue == nil {
  29647. return v, errors.New("OldBotID requires an ID field in the mutation")
  29648. }
  29649. oldValue, err := m.oldValue(ctx)
  29650. if err != nil {
  29651. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29652. }
  29653. return oldValue.BotID, nil
  29654. }
  29655. // AddBotID adds u to the "bot_id" field.
  29656. func (m *WxCardVisitMutation) AddBotID(u int64) {
  29657. if m.addbot_id != nil {
  29658. *m.addbot_id += u
  29659. } else {
  29660. m.addbot_id = &u
  29661. }
  29662. }
  29663. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  29664. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  29665. v := m.addbot_id
  29666. if v == nil {
  29667. return
  29668. }
  29669. return *v, true
  29670. }
  29671. // ResetBotID resets all changes to the "bot_id" field.
  29672. func (m *WxCardVisitMutation) ResetBotID() {
  29673. m.bot_id = nil
  29674. m.addbot_id = nil
  29675. }
  29676. // SetBotType sets the "bot_type" field.
  29677. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  29678. m.bot_type = &u
  29679. m.addbot_type = nil
  29680. }
  29681. // BotType returns the value of the "bot_type" field in the mutation.
  29682. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  29683. v := m.bot_type
  29684. if v == nil {
  29685. return
  29686. }
  29687. return *v, true
  29688. }
  29689. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  29690. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  29691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29692. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  29693. if !m.op.Is(OpUpdateOne) {
  29694. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  29695. }
  29696. if m.id == nil || m.oldValue == nil {
  29697. return v, errors.New("OldBotType requires an ID field in the mutation")
  29698. }
  29699. oldValue, err := m.oldValue(ctx)
  29700. if err != nil {
  29701. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  29702. }
  29703. return oldValue.BotType, nil
  29704. }
  29705. // AddBotType adds u to the "bot_type" field.
  29706. func (m *WxCardVisitMutation) AddBotType(u int8) {
  29707. if m.addbot_type != nil {
  29708. *m.addbot_type += u
  29709. } else {
  29710. m.addbot_type = &u
  29711. }
  29712. }
  29713. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  29714. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  29715. v := m.addbot_type
  29716. if v == nil {
  29717. return
  29718. }
  29719. return *v, true
  29720. }
  29721. // ResetBotType resets all changes to the "bot_type" field.
  29722. func (m *WxCardVisitMutation) ResetBotType() {
  29723. m.bot_type = nil
  29724. m.addbot_type = nil
  29725. }
  29726. // Where appends a list predicates to the WxCardVisitMutation builder.
  29727. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  29728. m.predicates = append(m.predicates, ps...)
  29729. }
  29730. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  29731. // users can use type-assertion to append predicates that do not depend on any generated package.
  29732. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  29733. p := make([]predicate.WxCardVisit, len(ps))
  29734. for i := range ps {
  29735. p[i] = ps[i]
  29736. }
  29737. m.Where(p...)
  29738. }
  29739. // Op returns the operation name.
  29740. func (m *WxCardVisitMutation) Op() Op {
  29741. return m.op
  29742. }
  29743. // SetOp allows setting the mutation operation.
  29744. func (m *WxCardVisitMutation) SetOp(op Op) {
  29745. m.op = op
  29746. }
  29747. // Type returns the node type of this mutation (WxCardVisit).
  29748. func (m *WxCardVisitMutation) Type() string {
  29749. return m.typ
  29750. }
  29751. // Fields returns all fields that were changed during this mutation. Note that in
  29752. // order to get all numeric fields that were incremented/decremented, call
  29753. // AddedFields().
  29754. func (m *WxCardVisitMutation) Fields() []string {
  29755. fields := make([]string, 0, 6)
  29756. if m.created_at != nil {
  29757. fields = append(fields, wxcardvisit.FieldCreatedAt)
  29758. }
  29759. if m.updated_at != nil {
  29760. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  29761. }
  29762. if m.deleted_at != nil {
  29763. fields = append(fields, wxcardvisit.FieldDeletedAt)
  29764. }
  29765. if m.user_id != nil {
  29766. fields = append(fields, wxcardvisit.FieldUserID)
  29767. }
  29768. if m.bot_id != nil {
  29769. fields = append(fields, wxcardvisit.FieldBotID)
  29770. }
  29771. if m.bot_type != nil {
  29772. fields = append(fields, wxcardvisit.FieldBotType)
  29773. }
  29774. return fields
  29775. }
  29776. // Field returns the value of a field with the given name. The second boolean
  29777. // return value indicates that this field was not set, or was not defined in the
  29778. // schema.
  29779. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  29780. switch name {
  29781. case wxcardvisit.FieldCreatedAt:
  29782. return m.CreatedAt()
  29783. case wxcardvisit.FieldUpdatedAt:
  29784. return m.UpdatedAt()
  29785. case wxcardvisit.FieldDeletedAt:
  29786. return m.DeletedAt()
  29787. case wxcardvisit.FieldUserID:
  29788. return m.UserID()
  29789. case wxcardvisit.FieldBotID:
  29790. return m.BotID()
  29791. case wxcardvisit.FieldBotType:
  29792. return m.BotType()
  29793. }
  29794. return nil, false
  29795. }
  29796. // OldField returns the old value of the field from the database. An error is
  29797. // returned if the mutation operation is not UpdateOne, or the query to the
  29798. // database failed.
  29799. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29800. switch name {
  29801. case wxcardvisit.FieldCreatedAt:
  29802. return m.OldCreatedAt(ctx)
  29803. case wxcardvisit.FieldUpdatedAt:
  29804. return m.OldUpdatedAt(ctx)
  29805. case wxcardvisit.FieldDeletedAt:
  29806. return m.OldDeletedAt(ctx)
  29807. case wxcardvisit.FieldUserID:
  29808. return m.OldUserID(ctx)
  29809. case wxcardvisit.FieldBotID:
  29810. return m.OldBotID(ctx)
  29811. case wxcardvisit.FieldBotType:
  29812. return m.OldBotType(ctx)
  29813. }
  29814. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  29815. }
  29816. // SetField sets the value of a field with the given name. It returns an error if
  29817. // the field is not defined in the schema, or if the type mismatched the field
  29818. // type.
  29819. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  29820. switch name {
  29821. case wxcardvisit.FieldCreatedAt:
  29822. v, ok := value.(time.Time)
  29823. if !ok {
  29824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29825. }
  29826. m.SetCreatedAt(v)
  29827. return nil
  29828. case wxcardvisit.FieldUpdatedAt:
  29829. v, ok := value.(time.Time)
  29830. if !ok {
  29831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29832. }
  29833. m.SetUpdatedAt(v)
  29834. return nil
  29835. case wxcardvisit.FieldDeletedAt:
  29836. v, ok := value.(time.Time)
  29837. if !ok {
  29838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29839. }
  29840. m.SetDeletedAt(v)
  29841. return nil
  29842. case wxcardvisit.FieldUserID:
  29843. v, ok := value.(uint64)
  29844. if !ok {
  29845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29846. }
  29847. m.SetUserID(v)
  29848. return nil
  29849. case wxcardvisit.FieldBotID:
  29850. v, ok := value.(uint64)
  29851. if !ok {
  29852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29853. }
  29854. m.SetBotID(v)
  29855. return nil
  29856. case wxcardvisit.FieldBotType:
  29857. v, ok := value.(uint8)
  29858. if !ok {
  29859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29860. }
  29861. m.SetBotType(v)
  29862. return nil
  29863. }
  29864. return fmt.Errorf("unknown WxCardVisit field %s", name)
  29865. }
  29866. // AddedFields returns all numeric fields that were incremented/decremented during
  29867. // this mutation.
  29868. func (m *WxCardVisitMutation) AddedFields() []string {
  29869. var fields []string
  29870. if m.adduser_id != nil {
  29871. fields = append(fields, wxcardvisit.FieldUserID)
  29872. }
  29873. if m.addbot_id != nil {
  29874. fields = append(fields, wxcardvisit.FieldBotID)
  29875. }
  29876. if m.addbot_type != nil {
  29877. fields = append(fields, wxcardvisit.FieldBotType)
  29878. }
  29879. return fields
  29880. }
  29881. // AddedField returns the numeric value that was incremented/decremented on a field
  29882. // with the given name. The second boolean return value indicates that this field
  29883. // was not set, or was not defined in the schema.
  29884. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  29885. switch name {
  29886. case wxcardvisit.FieldUserID:
  29887. return m.AddedUserID()
  29888. case wxcardvisit.FieldBotID:
  29889. return m.AddedBotID()
  29890. case wxcardvisit.FieldBotType:
  29891. return m.AddedBotType()
  29892. }
  29893. return nil, false
  29894. }
  29895. // AddField adds the value to the field with the given name. It returns an error if
  29896. // the field is not defined in the schema, or if the type mismatched the field
  29897. // type.
  29898. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  29899. switch name {
  29900. case wxcardvisit.FieldUserID:
  29901. v, ok := value.(int64)
  29902. if !ok {
  29903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29904. }
  29905. m.AddUserID(v)
  29906. return nil
  29907. case wxcardvisit.FieldBotID:
  29908. v, ok := value.(int64)
  29909. if !ok {
  29910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29911. }
  29912. m.AddBotID(v)
  29913. return nil
  29914. case wxcardvisit.FieldBotType:
  29915. v, ok := value.(int8)
  29916. if !ok {
  29917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29918. }
  29919. m.AddBotType(v)
  29920. return nil
  29921. }
  29922. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  29923. }
  29924. // ClearedFields returns all nullable fields that were cleared during this
  29925. // mutation.
  29926. func (m *WxCardVisitMutation) ClearedFields() []string {
  29927. var fields []string
  29928. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  29929. fields = append(fields, wxcardvisit.FieldDeletedAt)
  29930. }
  29931. if m.FieldCleared(wxcardvisit.FieldUserID) {
  29932. fields = append(fields, wxcardvisit.FieldUserID)
  29933. }
  29934. return fields
  29935. }
  29936. // FieldCleared returns a boolean indicating if a field with the given name was
  29937. // cleared in this mutation.
  29938. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  29939. _, ok := m.clearedFields[name]
  29940. return ok
  29941. }
  29942. // ClearField clears the value of the field with the given name. It returns an
  29943. // error if the field is not defined in the schema.
  29944. func (m *WxCardVisitMutation) ClearField(name string) error {
  29945. switch name {
  29946. case wxcardvisit.FieldDeletedAt:
  29947. m.ClearDeletedAt()
  29948. return nil
  29949. case wxcardvisit.FieldUserID:
  29950. m.ClearUserID()
  29951. return nil
  29952. }
  29953. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  29954. }
  29955. // ResetField resets all changes in the mutation for the field with the given name.
  29956. // It returns an error if the field is not defined in the schema.
  29957. func (m *WxCardVisitMutation) ResetField(name string) error {
  29958. switch name {
  29959. case wxcardvisit.FieldCreatedAt:
  29960. m.ResetCreatedAt()
  29961. return nil
  29962. case wxcardvisit.FieldUpdatedAt:
  29963. m.ResetUpdatedAt()
  29964. return nil
  29965. case wxcardvisit.FieldDeletedAt:
  29966. m.ResetDeletedAt()
  29967. return nil
  29968. case wxcardvisit.FieldUserID:
  29969. m.ResetUserID()
  29970. return nil
  29971. case wxcardvisit.FieldBotID:
  29972. m.ResetBotID()
  29973. return nil
  29974. case wxcardvisit.FieldBotType:
  29975. m.ResetBotType()
  29976. return nil
  29977. }
  29978. return fmt.Errorf("unknown WxCardVisit field %s", name)
  29979. }
  29980. // AddedEdges returns all edge names that were set/added in this mutation.
  29981. func (m *WxCardVisitMutation) AddedEdges() []string {
  29982. edges := make([]string, 0, 0)
  29983. return edges
  29984. }
  29985. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29986. // name in this mutation.
  29987. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  29988. return nil
  29989. }
  29990. // RemovedEdges returns all edge names that were removed in this mutation.
  29991. func (m *WxCardVisitMutation) RemovedEdges() []string {
  29992. edges := make([]string, 0, 0)
  29993. return edges
  29994. }
  29995. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29996. // the given name in this mutation.
  29997. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  29998. return nil
  29999. }
  30000. // ClearedEdges returns all edge names that were cleared in this mutation.
  30001. func (m *WxCardVisitMutation) ClearedEdges() []string {
  30002. edges := make([]string, 0, 0)
  30003. return edges
  30004. }
  30005. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30006. // was cleared in this mutation.
  30007. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  30008. return false
  30009. }
  30010. // ClearEdge clears the value of the edge with the given name. It returns an error
  30011. // if that edge is not defined in the schema.
  30012. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  30013. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  30014. }
  30015. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30016. // It returns an error if the edge is not defined in the schema.
  30017. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  30018. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  30019. }